lcx_ecdsa.h | Developers

lcx_ecdsa.h

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.

Warning
It 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.
Returns
Length 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.
Returns
Error 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.
Returns
1 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.
Returns
1 if the signature is verified, 0 otherwise.

Back to the files list


Did you find this page helpful?


How would you improve this page for developers?



Getting Started
Theme Features
Customization

Nano Apps