lcx_eddsa.h | Developers

lcx_eddsa.h

Back to the files list

EDDSA (Edwards Curve Digital Signature Algorithm) More...

Functions

cx_err_t cx_eddsa_sign_no_throw (const cx_ecfp_private_key_t *pvkey, cx_md_t hashID, const uint8_t *hash, size_t hash_len, uint8_t *sig, size_t sig_len)
 Signs a message digest. More...
static int cx_eddsa_sign (const cx_ecfp_private_key_t *pvkey, int mode, cx_md_t hashID, const unsigned char *hash, unsigned int hash_len, const unsigned char *ctx, unsigned int ctx_len, unsigned char *sig, unsigned int sig_len, unsigned int *info)
 Signs a message digest. More...
bool cx_eddsa_verify_no_throw (const cx_ecfp_public_key_t *pukey, cx_md_t hashID, const uint8_t *hash, size_t hash_len, const uint8_t *sig, size_t sig_len)
 Verifies a signature. More...
static int cx_eddsa_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 *ctx, unsigned int ctx_len, const unsigned char *sig, unsigned int sig_len)
 Verifies a signature. More...
void cx_encode_coord (uint8_t *coord, int len, int sign)
 Encodes the curve point coordinates. More...
int cx_decode_coord (uint8_t *coord, int len)
 Decodes the curve point coordinates. More...

Detailed Description

EDDSA (Edwards Curve Digital Signature Algorithm)

EDDSA is a digital signature scheme relying on Edwards curves, especially Ed25519 and Ed448. Refer to RFC8032 for more details.

Function Documentation

cx_decode_coord()

int cx_decode_coord ( uint8_t *  coord,
int  len 
)

Decodes the curve point coordinates.

Parameters
[in,out]coordA pointer to the point encoded coordinates.
[in]lenLength of the encoded coordinates.
Returns
Sign of the x-coordinate.

cx_eddsa_sign()

static int cx_eddsa_sign ( const cx_ecfp_private_key_t pvkey,
int  mode,
cx_md_t  hashID,
const unsigned char *  hash,
unsigned int  hash_len,
const unsigned char *  ctx,
unsigned int  ctx_len,
unsigned char *  sig,
unsigned int  sig_len,
unsigned int *  info 
)

Signs a message digest.

The signature is done according to the EDDSA specification RFC8032 . This function throws an exception if the computation doesn't succeed.

Warning
It is recommended to use cx_eddsa_sign_no_throw rather than this function.
Parameters
[in]pvkeyPrivate key. This shall be initialized with cx_ecfp_init_private_key_no_throw.
[in]modeMode. This parameter is not used.
[in]hashIDMessage digest agorithm identifier. Algorithms supported:
  • SHA512
  • SHA3
  • Keccak
[in]hashPointer to the message digest.
[in]hash_lenLength of the digest.
[in]ctxPointer to the context. This parameter is not used.
[in]ctx_lenLength of ctx. This parameter is not used.
[out]sigBuffer where to store the signature.
[in]sig_lenLength of the signature.
[in]infoAdditional information. This parameter is not used.
Returns
Length of the signature.
Exceptions
CX_EC_INVALID_CURVE
CX_INVALID_PARAMETER
INVALID_PARAMETER
CX_NOT_UNLOCKED
CX_INVALID_PARAMETER_SIZE
CX_MEMORY_FULL
CX_NOT_LOCKED
CX_INVALID_PARAMETER_SIZE
CX_EC_INVALID_POINT
CX_EC_INFINITE_POINT
CX_INTERNAL_ERROR
CX_INVALID_PARAMETER_VALUE

cx_eddsa_sign_no_throw()

cx_err_t cx_eddsa_sign_no_throw ( const cx_ecfp_private_key_t pvkey,
cx_md_t  hashID,
const uint8_t *  hash,
size_t  hash_len,
uint8_t *  sig,
size_t  sig_len 
)

Signs a message digest.

The signature is done according to the EDDSA specification RFC8032 .

Parameters
[in]pvkeyPrivate key. This shall be initialized with cx_ecfp_init_private_key_no_throw.
[in]hashIDMessage digest agorithm identifier. Algorithms supported:
  • SHA512
  • SHA3
  • Keccak
[in]hashPointer to the message digest.
[in]hash_lenLength of the digest.
[out]sigBuffer where to store the signature.
[in]sig_lenLength of the signature.
Returns
Error code:
  • CX_OK on success
  • CX_EC_INVALID_CURVE
  • CX_INVALID_PARAMETER
  • INVALID_PARAMETER
  • CX_NOT_UNLOCKED
  • CX_INVALID_PARAMETER_SIZE
  • CX_MEMORY_FULL
  • CX_NOT_LOCKED
  • CX_INVALID_PARAMETER_SIZE
  • CX_EC_INVALID_POINT
  • CX_EC_INFINITE_POINT
  • CX_INTERNAL_ERROR
  • CX_INVALID_PARAMETER_VALUE

cx_eddsa_verify()

static int cx_eddsa_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 *  ctx,
unsigned int  ctx_len,
const unsigned char *  sig,
unsigned int  sig_len 
)

Verifies a signature.

The verification is done according to the specification RFC8032 . This function throws an exception if the computation doesn't succeed.

Parameters
[in]pukeyPublic key. THis shall be initialized with cx_ecfp_init_public_key_no_throw.
[in]modeMode. This parameter is not used.
[in]hashIDMessage digest agorithm identifier. Algorithms supported:
  • SHA512
  • SHA3
  • Keccak
[in]hashPointer to the message digest.
[in]hash_lenLength of the digest.
[in]ctxPointer to the context. This parameter is not used.
[in]ctx_lenLength of the context. This parameter is not used.
[out]sigPointer to the signature.
[in]sig_lenLength of the signature.
Returns
1 if the signature is verified, otherwise 0.

cx_eddsa_verify_no_throw()

bool cx_eddsa_verify_no_throw ( const cx_ecfp_public_key_t pukey,
cx_md_t  hashID,
const uint8_t *  hash,
size_t  hash_len,
const uint8_t *  sig,
size_t  sig_len 
)

Verifies a signature.

The verification is done according to the specification RFC8032 .

Parameters
[in]pukeyPublic key. This shall be initialized with cx_ecfp_init_public_key_no_throw.
[in]hashIDMessage digest agorithm identifier. Algorithms supported:
  • SHA512
  • SHA3
  • Keccak
[in]hashPointer to the message digest.
[in]hash_lenLength of the digest.
[out]sigPointer to the signature.
[in]sig_lenLength of the signature.
Returns
1 if the signature is verified, otherwise 0.

cx_encode_coord()

void cx_encode_coord ( uint8_t *  coord,
int  len,
int  sign 
)

Encodes the curve point coordinates.

Parameters
[in,out]coordA pointer to the point coordinates in the form x|y.
[in]lenLength of the coordinates.
[in]signSign of the x-coordinate.

Back to the files list


Did you find this page helpful?


How would you improve this page for developers?



Getting Started
Theme Features
Customization

Embedded Apps