Provides ECDH related functionality through nrf_crypto. More...
Macros |
|
| #define | NRF_CRYPTO_ECDH_SHARED_SECRET_INSTANCE_CREATE (name, type) |
|
Macro to create an instance of a ECDH shared secret with a given name.
More...
|
|
| #define | NRF_CRYPTO_ECDH_SHARED_SECRET_CREATE_FROM_ARRAY (name, type, input) |
|
Macro to create an instance of a ECDH shared secret with a given name, type and input.
More...
|
|
| #define | NRF_CRYPTO_BLE_ECDH_CURVE_INFO |
|
Macro to express curve information for Bluetooth LE Secure Connection (LESC)
More...
|
|
Functions |
|
| uint32_t | nrf_crypto_ecdh_shared_secret_size_get ( nrf_ecc_curve_type_t curve_type, uint32_t *p_size) |
|
Function to get the shared secret size given curve type.
More...
|
|
| uint32_t | nrf_crypto_ecdh_shared_secret_allocate ( nrf_crypto_curve_info_t curve_type, nrf_value_length_t *p_shared_secret, nrf_value_length_t const *p_raw_shared_secret) |
|
Function to allocate dynamic memory for ECDH shared secret.
More...
|
|
| uint32_t | nrf_crypto_ecdh_shared_secret_free ( nrf_value_length_t *p_shared_secret) |
|
Function to free allocated memory for ECDH shared secret.
More...
|
|
| uint32_t | nrf_crypto_ecdh_shared_secret_compute ( nrf_crypto_curve_info_t curve_info, nrf_value_length_t const *p_private_key, nrf_value_length_t const *p_public_key, nrf_value_length_t *p_shared_secret) |
|
Function for computing a shared secret from a key pair.
More...
|
|
Detailed Description
Provides ECDH related functionality through nrf_crypto.
Macro Definition Documentation
| #define NRF_CRYPTO_BLE_ECDH_CURVE_INFO |
Macro to express curve information for Bluetooth LE Secure Connection (LESC)
| #define NRF_CRYPTO_ECDH_SHARED_SECRET_CREATE_FROM_ARRAY | ( | name, | |
| type, | |||
| input | |||
| ) |
Macro to create an instance of a ECDH shared secret with a given name, type and input.
If the input is not of the correct size a static assert will be occur compile-time.
- Note
- This creates the value length structure used for nrf_crypto APIs and a buffer to hold the shared secret without using dynamically allocated memory.
- Parameters
-
[in] name Name of the variable to hold an ECDH shared secret. [in] type Either SECP160R1, SECP192R1, SECP224R1, SECP256R1, SECP384R1, SECP521R1, SECP192K1, SECP224K1, or SECP256K1. [in] input Input must be an array of correct size according to the curve type.
| #define NRF_CRYPTO_ECDH_SHARED_SECRET_INSTANCE_CREATE | ( | name, | |
| type | |||
| ) |
Macro to create an instance of a ECDH shared secret with a given name.
- Note
- This creates the value length structure used for nrf_crypto APIs and a buffer to hold the shared secret without using dynamically allocated memory.
- Parameters
-
[in] name Name of the variable to hold an ECDH shared secret. [in] type Either SECP160R1, SECP192R1, SECP224R1, SECP256R1, SECP384R1, SECP521R1, SECP192K1, SECP224K1, or SECP256K1.
Function Documentation
| uint32_t nrf_crypto_ecdh_shared_secret_allocate | ( | nrf_crypto_curve_info_t | curve_type , |
| nrf_value_length_t * | p_shared_secret , | ||
| nrf_value_length_t const * | p_raw_shared_secret | ||
| ) |
Function to allocate dynamic memory for ECDH shared secret.
- Parameters
-
[in] curve_type Elliptic curve to use. [in,out] p_shared_secret Pointer to structure to hold a shared secret. [in] p_raw_shared_secret Pointer to structure holding a raw representation of a shared secret. If this is not NULL, the value will be copied to the allocated memory.
- Return values
-
NRF_SUCCESS Memory for the public key was successfully allocated. NRF_ERROR_NULL If any of the parameters was NULL. Any other error code reported by the memory manager.
| uint32_t nrf_crypto_ecdh_shared_secret_compute | ( | nrf_crypto_curve_info_t | curve_info , |
| nrf_value_length_t const * | p_private_key , | ||
| nrf_value_length_t const * | p_public_key , | ||
| nrf_value_length_t * | p_shared_secret | ||
| ) |
Function for computing a shared secret from a key pair.
- Note
- Length of allocated buffers for private key, public key and shared secret is taken as input.
- Parameters
-
[in] curve_info Elliptic curve to use, and requested endianness of p_shared_secret.[in] p_private_key Pointer to structure holding private key. [in] p_public_key Pointer to structure holding public key. [in,out] p_shared_secret Pointer to structure to hold the calculated shared secret. After the call the length variable will be updated to the actual length of the shared secret data
- Return values
-
NRF_SUCCESS If the shared secret was computed successfully. NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was uninitialized. NRF_ERROR_NULL If the provided key, hash or signature parameters was NULL. NRF_ERROR_NOT_SUPPORTED If the selected elliptic curve is not supported. NRF_ERROR_INVALID_ADDR If any of the provided pointers are invalid. NRF_ERROR_INVALID_DATA If any of the keys or result data is deemed invalid by the nrf_crypto backend. NRF_ERROR_INVALID_LENGTH If the length of allocated data for keys or result is incorrect. NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend.
| uint32_t nrf_crypto_ecdh_shared_secret_free | ( | nrf_value_length_t * | p_shared_secret | ) |
Function to free allocated memory for ECDH shared secret.
- Parameters
-
[in] p_shared_secret
- Return values
-
NRF_SUCCESS Memory for the ECDH shared secret was successfully freed. Any other error code reported by the memory manager.
| uint32_t nrf_crypto_ecdh_shared_secret_size_get | ( | nrf_ecc_curve_type_t | curve_type , |
| uint32_t * | p_size | ||
| ) |
Function to get the shared secret size given curve type.
- Parameters
-
[in] curve_type Elliptic curve to use. [in,out] p_size Pointer to variable to hold size of shared secret.
- Return values
-
NRF_SUCCESS Shared secret size was calculated. NRF_ERROR_NOT_SUPPORTED Selected curve was not supported.