lcx_ecdsa.h Previous Back to the files list ECDSA (Elliptic Curve Digital Signature Algorithm). More... Macros #define cx_ecdsa_init_public_key cx_ecfp_init_public_key_no_throw #define cx_ecdsa_init_private_key cx_ecfp_init_private_key_no_throw Functions cx_err_t cx_ecdsa_sign_no_throw (const cx_ecfp_private_key_t *pvkey, uint32_t mode, cx_md_t hashID, const uint8_t *hash, size_t hash_len, uint8_t *sig, size_t *sig_len, uint32_t *info) Signs a message digest according to ECDSA specification. More... static int cx_ecdsa_sign (const cx_ecfp_private_key_t *pvkey, int mode, cx_md_t hashID, const unsigned char *hash, unsigned int hash_len, unsigned char *sig, unsigned int sig_len, unsigned int *info) Signs a message digest according to ECDSA specification. More... bool cx_ecdsa_verify_no_throw (const cx_ecfp_public_key_t *pukey, const uint8_t *hash, size_t hash_len, const uint8_t *sig, size_t sig_len) Verifies an ECDSA signature according to ECDSA specification. More... static bool cx_ecdsa_verify (const cx_ecfp_public_key_t *pukey, int mode, cx_md_t hashID, const unsigned char *hash, unsigned int hash_len, const unsigned char *sig, unsigned int sig_len) Verifies an ECDSA signature according to ECDSA specification. More... Detailed Description ECDSA (Elliptic Curve Digital Signature Algorithm). ECDSA is a standard digital signature scheme relying on elliptic curves. It provides data integrity and verifiable authenticity. Refer to RFC6979 for more details. Macro Definition Documentation cx_ecdsa_init_private_key #define cx_ecdsa_init_private_key cx_ecfp_init_private_key_no_throw cx_ecdsa_init_public_key #define cx_ecdsa_init_public_key cx_ecfp_init_public_key_no_throw Function Documentation cx_ecdsa_sign() static int cx_ecdsa_sign ( const cx_ecfp_private_key_t * pvkey, int mode, cx_md_t hashID, const unsigned char * hash, unsigned int hash_len, unsigned char * sig, unsigned int sig_len, unsigned int * info ) Signs a message digest according to ECDSA specification. This function throws an exception if the signature doesn't succeed. WarningIt is recommended to use cx_ecdsa_sign_no_throw rather than this function. Parameters [in]pvkeyPrivate key. Shall be initialized with cx_ecfp_init_private_key_no_throw. [in]modeCrypto mode flags. Supported flags: CX_RND_TRNG CX_RND_RFC6979 [in]hashIDMessage digest algorithm identifer. This parameter is mandatory with the flag CX_RND_RFC6979. [in]hashDigest of the message to be signed. The length of hash must be shorter than the group order size. Otherwise it is truncated. [in]hash_lenLength of the digest in octets. [out]sigBuffer where to store the signature. The signature is encoded in TLV: 30 || L || 02 || Lr || r || 02 || Ls || s [in]sig_lenLength of the buffer in octets. [out]infoSet with CX_ECCINFO_PARITY_ODD if the y-coordinate is odd when computing [k].G. ReturnsLength of the signature. Exceptions CX_EC_INVALID_CURVE CX_INVALID_PARAMETER CX_INTERNAL_ERROR CX_NOT_UNLOCKED CX_INVALID_PARAMETER_SIZE CX_MEMORY_FULL CX_NOT_LOCKED CX_EC_INVALID_POINT CX_EC_INFINITE_POINT CX_INVALID_PARAMETER_VALUE cx_ecdsa_sign_no_throw() cx_err_t cx_ecdsa_sign_no_throw ( const cx_ecfp_private_key_t * pvkey, uint32_t mode, cx_md_t hashID, const uint8_t * hash, size_t hash_len, uint8_t * sig, size_t * sig_len, uint32_t * info ) Signs a message digest according to ECDSA specification. Parameters [in]pvkeyPrivate key. Shall be initialized with cx_ecfp_init_private_key_no_throw. [in]modeCrypto mode flags. Supported flags: CX_RND_TRNG CX_RND_RFC6979 [in]hashIDMessage digest algorithm identifer. This parameter is mandatory with the flag CX_RND_RFC6979. [in]hashDigest of the message to be signed. The length of hash must be shorter than the group order size. Otherwise it is truncated. [in]hash_lenLength of the digest in octets. [out]sigBuffer where to store the signature. The signature is encoded in TLV: 30 || L || 02 || Lr || r || 02 || Ls || s [in]sig_lenLength of the buffer in octets. [out]infoSet with CX_ECCINFO_PARITY_ODD if the y-coordinate is odd when computing [k].G. ReturnsError code: CX_OK on success CX_EC_INVALID_CURVE CX_INVALID_PARAMETER CX_INTERNAL_ERROR CX_NOT_UNLOCKED CX_INVALID_PARAMETER_SIZE CX_MEMORY_FULL CX_NOT_LOCKED CX_EC_INVALID_POINT CX_EC_INFINITE_POINT CX_INVALID_PARAMETER_VALUE cx_ecdsa_verify() static bool cx_ecdsa_verify ( const cx_ecfp_public_key_t * pukey, int mode, cx_md_t hashID, const unsigned char * hash, unsigned int hash_len, const unsigned char * sig, unsigned int sig_len ) Verifies an ECDSA signature according to ECDSA specification. Parameters [in]pukeyPublic key initialized with cx_ecfp_init_public_key_no_throw. [in]modeECDSA mode. This parameter is not used. [in]hashIDMessage digest algorithm identifer. This parameter is not used. [in]hashDigest of the message to be verified. The length of hash must be smaller than the group order size. Otherwise it is truncated. [in]hash_lenLength of the digest in octets. [in]sigPointer to the signature encoded in TLV: 30 || L || 02 || Lr || r || 02 || Ls || s [in]sig_lenLength of the signature in octets. Returns1 if the signature is verified, 0 otherwise. cx_ecdsa_verify_no_throw() bool cx_ecdsa_verify_no_throw ( const cx_ecfp_public_key_t * pukey, const uint8_t * hash, size_t hash_len, const uint8_t * sig, size_t sig_len ) Verifies an ECDSA signature according to ECDSA specification. Parameters [in]pukeyPublic key initialized with cx_ecfp_init_public_key_no_throw. [in]hashDigest of the message to be verified. The length of hash must be smaller than the group order size. Otherwise it is truncated. [in]hash_lenLength of the digest in octets. [in]sigPointer to the signature encoded in TLV: 30 || L || 02 || Lr || r || 02 || Ls || s [in]sig_lenLength of the signature in octets. Returns1 if the signature is verified, 0 otherwise. Previous Back to the files list Did you find this page helpful? How would you improve this page for developers? I am a developer. Contributors will be chosen randomly to receive rewards. Check this box to send your email and participate. Ledger collects your email address to send you rewards for your contribution to improve the Developer Portal documentation. Learn more about how we manage your data and your rights. By providing your email address, you consent that Ledger may contact you for rewards delivery purposes. If you are part of the randomly selected contributors, we will send you an email to ask for your physical address and if necessary, ask you for additional information on the suggestion you made. Your information will only be available to Ledger and will be retained for no longer than 90 days. It may be transferred to non-European countries that ensure an adequate level of protection or under the standard contractual clauses adopted by the EU Commission. Please note that you may withdraw your consent at any time, access your data and request their rectification or deletion. You may also request the limitation of the processing of your data. To exercise your rights or for any question on the processing of your data, please contact LEDGER’s Data Protection Officer here. If nevertheless you believe LEDGER did not adequately address your concerns and mishandled your data, you may lodge a complaint with the personal data protection authority of your country.