nRF5 SDK v17.0.2
Modules | Macros | Functions
Elliptic Curve Cryptography interface

Elliptic Curve Cryptography interface. More...

Modules

 Elliptic Curve Cryptography Library configuration
 

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]rngUse 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_skPrivate key. Pointer must be aligned to a 4-byte boundary.
[out]p_le_pkPublic key. Pointer must be aligned to a 4-byte boundary.
Return values
NRF_SUCCESSKey pair successfuly created.
NRF_ERROR_NULLNULL pointer provided.
NRF_ERROR_INVALID_ADDRUnaligned pointer provided.
NRF_ERROR_INTERNALInternal 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_skPrivate key. Pointer must be aligned to a 4-byte boundary.
[out]p_le_pkPublic key. Pointer must be aligned to a 4-byte boundary.
Return values
NRF_SUCCESSPublic key successfuly created.
NRF_ERROR_NULLNULL pointer provided.
NRF_ERROR_INVALID_ADDRUnaligned pointer provided.
NRF_ERROR_INTERNALInternal 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_skPrivate key. Pointer must be aligned to a 4-byte boundary.
[in]p_le_pkPublic key. Pointer must be aligned to a 4-byte boundary.
[out]p_le_ssShared secret. Pointer must be aligned to a 4-byte boundary.
Return values
NRF_SUCCESSShared secret successfuly created.
NRF_ERROR_NULLNULL pointer provided.
NRF_ERROR_INVALID_ADDRUnaligned pointer provided.
NRF_ERROR_INTERNALInternal 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_skPrivate key. Pointer must be aligned to a 4-byte boundary.
[in]p_le_hashHash. Pointer must be aligned to a 4-byte boundary.
[in]hlenHash length in bytes.
[out]p_le_sigSignature. Pointer must be aligned to a 4-byte boundary.
Return values
NRF_SUCCESSSignature successfuly created.
NRF_ERROR_NULLNULL pointer provided.
NRF_ERROR_INVALID_ADDRUnaligned pointer provided.
NRF_ERROR_INTERNALInternal 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_pkPublic key. Pointer must be aligned to a 4-byte boundary.
[in]p_le_hashHash. Pointer must be aligned to a 4-byte boundary.
[in]hlenHash length in bytes.
[in]p_le_sigSignature. Pointer must be aligned to a 4-byte boundary.
Return values
NRF_SUCCESSSignature verified.
NRF_ERROR_INVALID_DATASignature failed verification.
NRF_ERROR_NULLNULL pointer provided.
NRF_ERROR_INVALID_ADDRUnaligned pointer provided.
NRF_ERROR_INTERNALInternal error during signature verification.

Documentation feedback | Developer Zone | Subscribe | Updated