Provides cryptographic hash related functionality through nrf_crypto. More...
Macros |
|
| #define | NRF_CRYPTO_HASH_SIZE (type) STRING_CONCATENATE (NRF_CRYPTO_HASH_SIZE_, type) |
|
Internal macro to get the size of a given hash type.
More...
|
|
| #define | NRF_CRYPTO_HASH_CONTEXT_CREATE (name, type) |
|
Macro to create an instance of a hash context by a given name and type.
More...
|
|
| #define | NRF_CRYPTO_HASH_CREATE (name, type) |
|
Macro to create an instance of a hash by a given name and type.
More...
|
|
| #define | NRF_CRYPTO_HASH_CREATE_FROM_ARRAY (name, type, input) |
|
Macro to create an instance of a hash by a given name and type and input buffer.
More...
|
|
Functions |
|
| uint32_t | nrf_crypto_hash_size_get ( nrf_hash_type_t hash_type, uint32_t *p_hash_size) |
|
Function to get the size of a given hash type.
More...
|
|
| uint32_t | nrf_crypto_hash_context_allocate ( nrf_crypto_hash_info_t hash_info, nrf_value_length_t *p_hash_context) |
|
Function to dynamically allocate memory to hold a hash context used when calculating hash as a non-integrated step.
More...
|
|
| uint32_t | nrf_crypto_hash_context_free ( nrf_value_length_t *p_hash_context) |
|
Function to free dynamically allocated memory for hash context used when calculating hash as a non-integrated step.
More...
|
|
| uint32_t | nrf_crypto_hash_allocate ( nrf_crypto_hash_info_t hash_info, nrf_value_length_t *p_hash, nrf_value_length_t const *p_raw_hash) |
|
Function to dynamically allocate memory to hold a hash value.
More...
|
|
| uint32_t | nrf_crypto_hash_free ( nrf_value_length_t *p_hash) |
|
Function to free dynamically allocated memory for a hash value.
More...
|
|
| uint32_t | nrf_crypto_hash_init ( nrf_crypto_hash_info_t hash_info, nrf_value_length_t *p_hash_context) |
|
Function for computing a hash from arbitrary data.
More...
|
|
| uint32_t | nrf_crypto_hash_update ( nrf_value_length_t *p_hash_context, uint8_t const *p_data, uint32_t len) |
|
Function for computing a hash or a digest from arbitrary data.
More...
|
|
| uint32_t | nrf_crypto_hash_finalize ( nrf_crypto_hash_info_t hash_info, nrf_value_length_t *p_hash_context, nrf_value_length_t *p_hash) |
|
Function for computing a hash from arbitrary data.
More...
|
|
| uint32_t | nrf_crypto_hash_compute ( nrf_crypto_hash_info_t hash_info, uint8_t const *p_data, uint32_t len, nrf_value_length_t *p_hash) |
|
Function for computing a hash from arbitrary data in a single integrated step.
More...
|
|
Detailed Description
Provides cryptographic hash related functionality through nrf_crypto.
Macro Definition Documentation
| #define NRF_CRYPTO_HASH_CONTEXT_CREATE | ( | name, | |
| type | |||
| ) |
Macro to create an instance of a hash context by a given name and type.
- Note
- This creates the value length structure and a backing buffer without using dynamically allocated memory.
| #define NRF_CRYPTO_HASH_CREATE | ( | name, | |
| type | |||
| ) |
Macro to create an instance of a hash by a given name and type.
- Parameters
-
[in] name Name of the hash instance. [in] type Either MD5, SHA0, SHA1, SHA224, SHA256, SHA384 or SHA512.
- Note
- This creates the value length structure and a backing buffer without using dynamically allocated memory.
| #define NRF_CRYPTO_HASH_CREATE_FROM_ARRAY | ( | name, | |
| type, | |||
| input | |||
| ) |
Macro to create an instance of a hash by a given name and type and input buffer.
If the input is not of the correct size a static assert will be occur compile-time.
- Parameters
-
[in] name Name of the hash instance. [in] type Either MD5, SHA0, SHA1, SHA224, SHA256, SHA384 or SHA512. [in] input Array used as input buffer.
- Note
- This creates the value length structure and a backing buffer without using dynamically allocated memory.
| #define NRF_CRYPTO_HASH_SIZE | ( | type | ) | STRING_CONCATENATE (NRF_CRYPTO_HASH_SIZE_, type) |
Internal macro to get the size of a given hash type.
- Parameters
-
[in] type Either MD5, SHA0, SHA1, SHA224, SHA256, SHA384 or SHA512
Function Documentation
| uint32_t nrf_crypto_hash_allocate | ( | nrf_crypto_hash_info_t | hash_info , |
| nrf_value_length_t * | p_hash , | ||
| nrf_value_length_t const * | p_raw_hash | ||
| ) |
Function to dynamically allocate memory to hold a hash value.
- Parameters
-
[in] hash_info Structure holding info about hash algorithm to use and endianness for the computed hash. [in,out] p_hash Pointer to value-length structure to hold allocated space. [in] p_raw_hash Pointer to value length structure to hold raw representation of hash.
- Return values
-
NRF_SUCCESS Space was successfully alloacted.
| uint32_t nrf_crypto_hash_compute | ( | nrf_crypto_hash_info_t | hash_info , |
| uint8_t const * | p_data , | ||
| uint32_t | len , | ||
| nrf_value_length_t * | p_hash | ||
| ) |
Function for computing a hash from arbitrary data in a single integrated step.
- Parameters
-
[in] hash_info Structure holding info about hash algorithm to use and endianness for the computed hash. [in] p_data Pointer to data to be hashed. [in] len Length of the data to be hashed. [in,out] p_hash Pointer to structure holding the calculated hash.
- Return values
-
NRF_SUCCESS If the hash was computed successfully. NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was uninitialized. NRF_ERROR_NOT_SUPPORTED If the selected hash algorithm is not supported. NRF_ERROR_INVALID_ADDR If any of the provided pointers are invalid. NRF_ERROR_INVALID_LENGTH If the hash is bigger than the size of the provided buffer or the size of the hash context is invalid. NRF_ERROR_INVALID_DATA If the hash context was deemed invalid by the nrf_crypto backend. NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend.
| uint32_t nrf_crypto_hash_context_allocate | ( | nrf_crypto_hash_info_t | hash_info , |
| nrf_value_length_t * | p_hash_context | ||
| ) |
Function to dynamically allocate memory to hold a hash context used when calculating hash as a non-integrated step.
- Parameters
-
[in] hash_info Hashing algorithm to create context for [in,out] p_hash_context Pointer to value-length structure to hold allocated space.
- Return values
-
NRF_SUCCESS Space was successfully allocated.
| uint32_t nrf_crypto_hash_context_free | ( | nrf_value_length_t * | p_hash_context | ) |
Function to free dynamically allocated memory for hash context used when calculating hash as a non-integrated step.
- Note
- The length value of the value length structure will be set to zero when the memory is freed. There is no impact of running this function on already deallocated memory.
- Parameters
-
[in,out] p_hash_context Pointer a to value-length structure that holds the allocated space to be freed.
- Return values
-
NRF_SUCCESS Space was successfully freed.
| uint32_t nrf_crypto_hash_finalize | ( | nrf_crypto_hash_info_t | hash_info , |
| nrf_value_length_t * | p_hash_context , | ||
| nrf_value_length_t * | p_hash | ||
| ) |
Function for computing a hash from arbitrary data.
- Note
- The context object is assumed to be an opaque type defined by the nrf_crypto backend. See NRF_CRYPTO_HASH_CONTEXT_SIZE for the relevant nrf_crypto backend.
- Parameters
-
[in] hash_info Structure holding info about hash algorithm to use. [in,out] p_hash_context Pointer to structure holding context information for the hash computation. [in,out] p_hash Pointer to structure holding the calculated hash.
- Return values
-
NRF_SUCCESS If the hash was computed successfully. NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was uninitialized. NRF_ERROR_NULL If the any of the parameters was NULL. NRF_ERROR_NOT_SUPPORTED If the selected hash algorithm is not supported. NRF_ERROR_INVALID_ADDR If any of the provided pointers are invalid. NRF_ERROR_INVALID_LENGTH If the hash is bigger than the size of the provided buffer or the size of the hash context is invalid. NRF_ERROR_INVALID_DATA If the hash context was deemed invalid by the nrf_crypto backend. NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend.
| uint32_t nrf_crypto_hash_free | ( | nrf_value_length_t * | p_hash | ) |
Function to free dynamically allocated memory for a hash value.
- Note
- The length value of the value length structure will be set to zero when the memory is freed. There is no impact of running this function on already deallocated memory.
- Parameters
-
[in,out] p_hash Pointer to a value-length structure that holds the allocated space to be freed.
- Return values
-
NRF_SUCCESS Space was successfully freed.
| uint32_t nrf_crypto_hash_init | ( | nrf_crypto_hash_info_t | hash_info , |
| nrf_value_length_t * | p_hash_context | ||
| ) |
Function for computing a hash from arbitrary data.
- Note
- The context object is assumed to be an opaque type defined by the nrf_crypto backend. See NRF_CRYPTO_HASH_CONTEXT_SIZE for the relevant nrf_crypto backend.
- Parameters
-
[in] hash_info Structure holding info about hash algorithm to use and endianness for the computed hash. [in,out] p_hash_context Pointer to structure holding context information for the hash computation.
- Return values
-
NRF_SUCCESS If the hash initialization was successful. NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was uninitialized. NRF_ERROR_NULL If the hash context parameter was NULL. NRF_ERROR_NOT_SUPPORTED If the selected hash algorithm is not supported. NRF_ERROR_INVALID_ADDR If any of the provided pointers are invalid. NRF_ERROR_INVALID_LENGTH If the hash is bigger than the size of the provided buffer. NRF_ERROR_INVALID_DATA If the hash context was deemed invalid by the nrf_crypto backend. NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend.
| uint32_t nrf_crypto_hash_size_get | ( | nrf_hash_type_t | hash_type , |
| uint32_t * | p_hash_size | ||
| ) |
Function to get the size of a given hash type.
- Parameters
-
[in] hash_type Type of hash. [in,out] p_hash_size Pointer to variable to hold the hash size. Must not be NULL.
- Return values
-
NRF_SUCCESS Hash function found. NRF_ERROR_NULL p_hash_size was NULL. NRF_ERROR_NOT_SUPPORTED Requested hash type isn't supported.
| uint32_t nrf_crypto_hash_update | ( | nrf_value_length_t * | p_hash_context , |
| uint8_t const * | p_data , | ||
| uint32_t | len | ||
| ) |
Function for computing a hash or a digest from arbitrary data.
- Note
- The context object is assumed to be an opaque type defined by the nrf_crypto backend. See NRF_CRYPTO_HASH_CONTEXT_SIZE for the relevant nrf_crypto backend.
- Parameters
-
[in,out] p_hash_context Pointer to structure holding context information for the hash computation. [in] p_data Pointer to data to be hashed. [in] len Length of the data to be hashed.
- Return values
-
NRF_SUCCESS If the hash was computed successfully. NRF_ERROR_NULL If the hash context parameter was NULL. NRF_ERROR_INVALID_STATE If the function was called when nrf_crypto was uninitialized. NRF_ERROR_NOT_SUPPORTED If the selected hash algorithm is not supported. NRF_ERROR_INVALID_ADDR If any of the provided pointers are invalid. NRF_ERROR_INVALID_LENGTH If the size of the hash context is invalid. NRF_ERROR_INVALID_DATA If the hash context was deemed invalid by the nrf_crypto backend. NRF_ERROR_INTERNAL If an internal error occured in the nrf_crypto backend.