Elliptic Curve Cryptography interface

nRF5 SDK v12.2.0

Elliptic Curve Cryptography interface. More...

Macros

#define ECC_P256_SK_LEN 32
#define ECC_P256_PK_LEN 64

Functions

void ecc_init (bool rng)
Initialize the ECC module. More...
ret_code_t ecc_p256_keypair_gen (uint8_t *p_le_sk, uint8_t *p_le_pk)
Create a public/private key pair. More...
ret_code_t ecc_p256_public_key_compute (uint8_t const *p_le_sk, uint8_t *p_le_pk)
Create a public key from a provided private key. More...
ret_code_t ecc_p256_shared_secret_compute (uint8_t const *p_le_sk, uint8_t const *p_le_pk, uint8_t *p_le_ss)
Create a shared secret from a provided public/private key pair. More...
ret_code_t ecc_p256_sign (uint8_t const *p_le_sk, uint8_t const *p_le_hash, uint32_t hlen, uint8_t *p_le_sig)
Sign a hash or digest using a private key. More...
ret_code_t ecc_p256_verify (uint8_t const *p_le_pk, uint8_t const *p_le_hash, uint32_t hlen, uint8_t const *p_le_sig)
Verify a signature using a public key. More...

Detailed Description

Elliptic Curve Cryptography interface.

Function Documentation

void ecc_init ( bool rng )

Initialize the ECC module.

Parameters
[in] rng Use a random number generator.
ret_code_t ecc_p256_keypair_gen ( uint8_t * p_le_sk ,
uint8_t * p_le_pk
)

Create a public/private key pair.

Parameters
[out] p_le_sk Private key. Pointer must be aligned to a 4-byte boundary.
[out] p_le_pk Public key. Pointer must be aligned to a 4-byte boundary.
Return values
NRF_SUCCESS Key pair successfuly created.
NRF_ERROR_NULL NULL pointer provided.
NRF_ERROR_INVALID_ADDR Unaligned pointer provided.
NRF_ERROR_INTERNAL Internal error during key generation.
ret_code_t ecc_p256_public_key_compute ( uint8_t const * p_le_sk ,
uint8_t * p_le_pk
)

Create a public key from a provided private key.

Parameters
[in] p_le_sk Private key. Pointer must be aligned to a 4-byte boundary.
[out] p_le_pk Public key. Pointer must be aligned to a 4-byte boundary.
Return values
NRF_SUCCESS Public key successfuly created.
NRF_ERROR_NULL NULL pointer provided.
NRF_ERROR_INVALID_ADDR Unaligned pointer provided.
NRF_ERROR_INTERNAL Internal error during key generation.
ret_code_t ecc_p256_shared_secret_compute ( uint8_t const * p_le_sk ,
uint8_t const * p_le_pk ,
uint8_t * p_le_ss
)

Create a shared secret from a provided public/private key pair.

Parameters
[in] p_le_sk Private key. Pointer must be aligned to a 4-byte boundary.
[in] p_le_pk Public key. Pointer must be aligned to a 4-byte boundary.
[out] p_le_ss Shared secret. Pointer must be aligned to a 4-byte boundary.
Return values
NRF_SUCCESS Shared secret successfuly created.
NRF_ERROR_NULL NULL pointer provided.
NRF_ERROR_INVALID_ADDR Unaligned pointer provided.
NRF_ERROR_INTERNAL Internal error during key generation.
ret_code_t ecc_p256_sign ( uint8_t const * p_le_sk ,
uint8_t const * p_le_hash ,
uint32_t hlen ,
uint8_t * p_le_sig
)

Sign a hash or digest using a private key.

Parameters
[in] p_le_sk Private key. Pointer must be aligned to a 4-byte boundary.
[in] p_le_hash Hash. Pointer must be aligned to a 4-byte boundary.
[in] hlen Hash length in bytes.
[out] p_le_sig Signature. Pointer must be aligned to a 4-byte boundary.
Return values
NRF_SUCCESS Signature successfuly created.
NRF_ERROR_NULL NULL pointer provided.
NRF_ERROR_INVALID_ADDR Unaligned pointer provided.
NRF_ERROR_INTERNAL Internal error during signature generation.
ret_code_t ecc_p256_verify ( uint8_t const * p_le_pk ,
uint8_t const * p_le_hash ,
uint32_t hlen ,
uint8_t const * p_le_sig
)

Verify a signature using a public key.

Parameters
[in] p_le_pk Public key. Pointer must be aligned to a 4-byte boundary.
[in] p_le_hash Hash. Pointer must be aligned to a 4-byte boundary.
[in] hlen Hash length in bytes.
[in] p_le_sig Signature. Pointer must be aligned to a 4-byte boundary.
Return values
NRF_SUCCESS Signature verified.
NRF_ERROR_INVALID_DATA Signature failed verification.
NRF_ERROR_NULL NULL pointer provided.
NRF_ERROR_INVALID_ADDR Unaligned pointer provided.
NRF_ERROR_INTERNAL Internal error during signature verification.