Provides elliptic curve cryptography API for public and private key management. More...
Data Structures |
|
| struct | nrf_crypto_ecc_curve_info_s |
|
Structure holding information on a specific curve.
More...
|
|
| union | nrf_crypto_ecc_key_pair_generate_context_t |
|
Union holding a context for a key pair generation.
More...
|
|
| union | nrf_crypto_ecc_public_key_calculate_context_t |
|
Union holding a context for a public key calculation.
More...
|
|
| union | nrf_crypto_ecc_private_key_t |
|
Union holding representation of a private key for any curve type.
More...
|
|
| union | nrf_crypto_ecc_public_key_t |
|
Union holding representation of a public key for any curve type.
More...
|
|
Macros |
|
| #define | NRF_CRYPTO_ECC_RAW_PRIVATE_KEY_MAX_SIZE NRF_CRYPTO_BACKEND_ECC_RAW_PRIVATE_KEY_MAX_SIZE |
|
Maximum size of a raw private key for all enabled curves.
|
|
| #define | NRF_CRYPTO_ECC_RAW_PUBLIC_KEY_MAX_SIZE NRF_CRYPTO_BACKEND_ECC_RAW_PUBLIC_KEY_MAX_SIZE |
|
Maximum size of a raw public key for all enabled curves.
|
|
Typedefs |
|
|
typedef struct
nrf_crypto_ecc_curve_info_s |
nrf_crypto_ecc_curve_info_t |
|
Structure holding information on a specific curve.
More...
|
|
| typedef uint8_t | nrf_crypto_ecc_raw_private_key_t [NRF_CRYPTO_BACKEND_ECC_RAW_PRIVATE_KEY_MAX_SIZE] |
|
Type big enough to hold a raw private key for any the enabled curves.
|
|
| typedef uint8_t | nrf_crypto_ecc_raw_public_key_t [NRF_CRYPTO_BACKEND_ECC_RAW_PUBLIC_KEY_MAX_SIZE] |
|
Type big enough to hold a raw public key for any the enabled curves.
|
|
Functions |
|
| ret_code_t | nrf_crypto_ecc_key_pair_generate ( nrf_crypto_ecc_key_pair_generate_context_t *p_context, nrf_crypto_ecc_curve_info_t const *p_curve_info, nrf_crypto_ecc_private_key_t *p_private_key, nrf_crypto_ecc_public_key_t *p_public_key) |
|
Generate a new pair of a public key and a private key.
More...
|
|
| ret_code_t | nrf_crypto_ecc_public_key_calculate ( nrf_crypto_ecc_public_key_calculate_context_t *p_context, nrf_crypto_ecc_private_key_t const *p_private_key, nrf_crypto_ecc_public_key_t *p_public_key) |
|
Calculate public key associated with provided private key.
More...
|
|
| ret_code_t | nrf_crypto_ecc_private_key_from_raw ( nrf_crypto_ecc_curve_info_t const *p_curve_info, nrf_crypto_ecc_private_key_t *p_private_key, uint8_t const *p_raw_data, size_t raw_data_size) |
|
Create a private key from a raw data.
More...
|
|
| ret_code_t | nrf_crypto_ecc_private_key_to_raw ( nrf_crypto_ecc_private_key_t const *p_private_key, uint8_t *p_raw_data, size_t *p_raw_data_size) |
|
Convert a private key to a raw data.
More...
|
|
| ret_code_t | nrf_crypto_ecc_public_key_from_raw ( nrf_crypto_ecc_curve_info_t const *p_curve_info, nrf_crypto_ecc_public_key_t *p_public_key, uint8_t const *p_raw_data, size_t raw_data_size) |
|
Create a public key from a raw data.
More...
|
|
| ret_code_t | nrf_crypto_ecc_public_key_to_raw ( nrf_crypto_ecc_public_key_t const *p_public_key, uint8_t *p_raw_data, size_t *p_raw_data_size) |
|
Convert a public key to a raw data.
More...
|
|
| ret_code_t | nrf_crypto_ecc_private_key_free ( nrf_crypto_ecc_private_key_t *p_private_key) |
|
Release resources taken by a private key.
More...
|
|
| ret_code_t | nrf_crypto_ecc_public_key_free ( nrf_crypto_ecc_public_key_t *p_public_key) |
|
Release resources taken by a public key.
More...
|
|
| ret_code_t | nrf_crypto_ecc_curve_info_get (void const *p_key, nrf_crypto_ecc_curve_info_t const **pp_curve_info) |
|
Gets curve information structure from provided key (private or public).
More...
|
|
| ret_code_t | nrf_crypto_ecc_byte_order_invert ( nrf_crypto_ecc_curve_info_t const *p_curve_info, uint8_t const *p_raw_input, uint8_t *p_raw_output, size_t raw_data_size) |
|
Inverts byte order of a big integers contained in a raw data.
More...
|
|
Detailed Description
Provides elliptic curve cryptography API for public and private key management.
Typedef Documentation
| typedef struct nrf_crypto_ecc_curve_info_s nrf_crypto_ecc_curve_info_t |
Structure holding information on a specific curve.
- Note
- This structure cannot be used to create a new variable. Only the variables defined by this library can be used, e.g. g_nrf_crypto_ecc_secp256r1_curve_info .
Enumeration Type Documentation
Defines type of ECC curve.
Function Documentation
| ret_code_t nrf_crypto_ecc_byte_order_invert | ( | nrf_crypto_ecc_curve_info_t const * | p_curve_info , |
| uint8_t const * | p_raw_input , | ||
| uint8_t * | p_raw_output , | ||
| size_t | raw_data_size | ||
| ) |
Inverts byte order of a big integers contained in a raw data.
All the ECC API accepts only data with big endian integers, so this function have to be used if little endian is required. If input is in little endian byte order it will be converted to big endian. If input is in big endian byte order it will be converted to little endian. It works for ECC raw private key, raw public key, signature and shared secret. If raw data contains two big integers (e.g. R, S, or X, Y) each integer is inverted separately. If
p_curve_info
is NULL then all bytes in buffer will be inverted regardless what is the content of the buffer.
- Parameters
-
[in] p_curve_info Pointer to information on selected curve. Use only global variables defined by nrf_crypto, e.g. g_nrf_crypto_ecc_secp256r1_curve_info . [in] p_raw_input Pointer to buffer holding source data. [out] p_raw_output Pointer to buffer that will be filled with inverted byte order. This parameter can be the same as p_raw_input, otherwise the buffers cannot overlap.[in] raw_data_size Size of input and output buffer.
| ret_code_t nrf_crypto_ecc_curve_info_get | ( | void const * | p_key , |
| nrf_crypto_ecc_curve_info_t const ** | pp_curve_info | ||
| ) |
Gets curve information structure from provided key (private or public).
- Parameters
-
[in] p_key Pointer to structure holding private or public key. [out] pp_curve_info Pointer to location where put retrieved pointer to curve information structure.
| ret_code_t nrf_crypto_ecc_key_pair_generate | ( | nrf_crypto_ecc_key_pair_generate_context_t * | p_context , |
| nrf_crypto_ecc_curve_info_t const * | p_curve_info , | ||
| nrf_crypto_ecc_private_key_t * | p_private_key , | ||
| nrf_crypto_ecc_public_key_t * | p_public_key | ||
| ) |
Generate a new pair of a public key and a private key.
Generated keys have to deallocated using nrf_crypto_ecc_private_key_free and nrf_crypto_ecc_public_key_free .
- Parameters
-
[in] p_context Pointer to temporary structure holding context information. If it is NULL, necessary data will be allocated with NRF_CRYPTO_ALLOC and freed at the end of the function. [in] p_curve_info Pointer to information on selected curve. Use only global variables defined by nrf_crypto, e.g. g_nrf_crypto_ecc_secp256r1_curve_info . [out] p_private_key Pointer to structure where newly generated private key will be put. [out] p_public_key Pointer to structure where newly generated public key will be put.
| ret_code_t nrf_crypto_ecc_private_key_free | ( | nrf_crypto_ecc_private_key_t * | p_private_key | ) |
Release resources taken by a private key.
- Parameters
-
[in] p_private_key Pointer to structure holding private key to release.
| ret_code_t nrf_crypto_ecc_private_key_from_raw | ( | nrf_crypto_ecc_curve_info_t const * | p_curve_info , |
| nrf_crypto_ecc_private_key_t * | p_private_key , | ||
| uint8_t const * | p_raw_data , | ||
| size_t | raw_data_size | ||
| ) |
Create a private key from a raw data.
Generated private key has to be deallocated using nrf_crypto_ecc_private_key_free .
- Parameters
-
[in] p_curve_info Pointer to information on selected curve. Use only global variables defined by nrf_crypto, e.g. g_nrf_crypto_ecc_secp256r1_curve_info . [out] p_private_key Pointer to structure where newly converted private key will be put. [in] p_raw_data Pointer to buffer containing a big endian raw data. [in] raw_data_size Number of bytes of a raw data. Correct size for selected curve can be found in p_curve_infoand it is also defined by the preprocessor definitions, e.g. NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE .
| ret_code_t nrf_crypto_ecc_private_key_to_raw | ( | nrf_crypto_ecc_private_key_t const * | p_private_key , |
| uint8_t * | p_raw_data , | ||
| size_t * | p_raw_data_size | ||
| ) |
Convert a private key to a raw data.
- Parameters
-
[in] p_private_key Pointer to structure holding private key that will be convert. [out] p_raw_data Pointer to buffer containing a big endian raw data. [in,out] p_raw_data_size Maximum number of bytes that p_raw_databuffer can hold on input and the actual number of bytes used by the raw data on output. Actual size for selected curve can be found in nrf_crypto_ecc_curve_info_t and it is also defined by the preprocessor definitions, e.g. NRF_CRYPTO_ECC_SECP256R1_RAW_PRIVATE_KEY_SIZE .
| ret_code_t nrf_crypto_ecc_public_key_calculate | ( | nrf_crypto_ecc_public_key_calculate_context_t * | p_context , |
| nrf_crypto_ecc_private_key_t const * | p_private_key , | ||
| nrf_crypto_ecc_public_key_t * | p_public_key | ||
| ) |
Calculate public key associated with provided private key.
Calculated public key has to be deallocated using nrf_crypto_ecc_public_key_free .
- Parameters
-
[in] p_context Pointer to temporary structure holding context information. If it is NULL, necessary data will be allocated with NRF_CRYPTO_ALLOC and freed at the end of the function. [in] p_private_key Pointer to structure holding a private key that will be used for computation. [out] p_public_key Pointer to structure where newly generated public key will be put.
| ret_code_t nrf_crypto_ecc_public_key_free | ( | nrf_crypto_ecc_public_key_t * | p_public_key | ) |
Release resources taken by a public key.
- Parameters
-
[in] p_public_key Pointer to structure holding public key to release.
| ret_code_t nrf_crypto_ecc_public_key_from_raw | ( | nrf_crypto_ecc_curve_info_t const * | p_curve_info , |
| nrf_crypto_ecc_public_key_t * | p_public_key , | ||
| uint8_t const * | p_raw_data , | ||
| size_t | raw_data_size | ||
| ) |
Create a public key from a raw data.
Generated public key has to be deallocated using nrf_crypto_ecc_public_key_free .
- Parameters
-
[in] p_curve_info Pointer to information on selected curve. Use only global variables defined by nrf_crypto, e.g. g_nrf_crypto_ecc_secp256r1_curve_info . [out] p_public_key Pointer to structure where newly converted public key will be put. [in] p_raw_data Pointer to buffer containing a big endian raw data. [in] raw_data_size Number of bytes of a raw data. Correct size for selected curve can be found in p_curve_infoand it is also defined by the preprocessor definitions, e.g. NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE .
| ret_code_t nrf_crypto_ecc_public_key_to_raw | ( | nrf_crypto_ecc_public_key_t const * | p_public_key , |
| uint8_t * | p_raw_data , | ||
| size_t * | p_raw_data_size | ||
| ) |
Convert a public key to a raw data.
- Parameters
-
[in] p_public_key Pointer to structure holding public key that will be convert. [out] p_raw_data Pointer to buffer containing a big endian raw data. [in,out] p_raw_data_size Maximum number of bytes that p_raw_databuffer can hold on input and the actual number of bytes used by the raw data on output. Actual size for selected curve can be found in nrf_crypto_ecc_curve_info_t and it is also defined by the preprocessor definitions, e.g. NRF_CRYPTO_ECC_SECP256R1_RAW_PUBLIC_KEY_SIZE .