Provides cryptographic hash related functionality through nrf_crypto.
More...
|
ret_code_t | nrf_crypto_hash_init (nrf_crypto_hash_context_t *const p_context, nrf_crypto_hash_info_t const *p_info) |
| Function for initializing the context structure required to compute a hash digest from arbitrary input data. More...
|
|
ret_code_t | nrf_crypto_hash_update (nrf_crypto_hash_context_t *const p_context, uint8_t const *p_data, size_t data_size) |
| Function for updating the hash calculation with partial arbitrary data. More...
|
|
ret_code_t | nrf_crypto_hash_finalize (nrf_crypto_hash_context_t *const p_context, uint8_t *p_digest, size_t *const p_digest_size) |
| Function for finalizing computation of a hash digest from arbitrary data. More...
|
|
ret_code_t | nrf_crypto_hash_calculate (nrf_crypto_hash_context_t *const p_context, nrf_crypto_hash_info_t const *p_info, uint8_t const *p_data, size_t data_size, uint8_t *p_digest, size_t *const p_digest_size) |
| Function for computing a hash from arbitrary data in a single integrated step. More...
|
|
Provides cryptographic hash related functionality through nrf_crypto.
Context type for Hash.
- Note
- The size of this type is scaled for the largest Hash backend context that is enabled in SDK configuration header file.
Function for computing a hash from arbitrary data in a single integrated step.
This function calculates the hash digest from arbitruary data in a single integrated step. This means calling init, update and finalize in one step.
- Note
- The context object is assumed to be an opaque type defined by the nrf_crypto backend.
-
The return values NRF_ERROR_CRYPTO_BUSY, NRF_ERROR_CRYPTO_INPUT_LOCATION and NRF_ERROR_CRYPTO_INPUT_LOCATION can only occur in CC310 backend.
- Parameters
-
[in,out] | p_context | Pointer to structure holding context information for the hash calculation. If this is set to NULL, it will be allocated by the user configurable allocate/free function NRF_CRYPTO_ALLOC and NRF_CRYPTO_FREE. |
[in] | p_info | Pointer to structure holding info about hash algorithm for the computed hash. |
[in] | p_data | Pointer to data to be hashed. |
[in] | data_size | Length of the data to be hashed. |
[out] | p_digest | Pointer to buffer holding the calculated hash digest. |
[in,out] | p_digest_size | Pointer to a variable holding the length of the calculated hash. Set this to the length of buffer that p_digest is pointing to. |
- Return values
-
NRF_SUCCESS | The hash initialization was successful. |
NRF_ERROR_CRYPTO_NOT_INITIALIZED | nrf_crypto_init was not called prior to this crypto function. |
NRF_ERROR_CRYPTO_CONTEXT_NULL | A NULL pointer was provided for the context structure. |
NRF_ERROR_CRYPTO_INPUT_NULL | p_info or p_data was NULL. |
NRF_ERROR_CRYPTO_INPUT_LOCATION | Input data not in RAM. |
NRF_ERROR_CRYPTO_OUTPUT_NULL | p_digest or p_digest_size was NULL. |
NRF_ERROR_CRYPTO_OUTPUT_LENGTH | The length of p_digest was too small for the hash digest result. |
NRF_ERROR_CRYPTO_BUSY | The function could not be called because the nrf_crypto backend was busy. Please rerun the cryptographic routine at a later time. |
NRF_ERROR_CRYPTO_ALLOC_FAILED | Unable to allocate memory for the context. |
NRF_ERROR_CRYPTO_INTERNAL | An internal error occurred in the nrf_crypto backend. |
Function for finalizing computation of a hash digest from arbitrary data.
This function is called to get the calculated
- Note
- nrf_crypto_hash_init must be called prior to this function to configure the context structure used as input parameter to this function.
-
The input data for the calculated hash digest must be provided by calling nrf_crypto_hash_update one or more times.
-
The context object is assumed to be an opaque type defined by the nrf_crypto backend.
-
The return values NRF_ERROR_CRYPTO_BUSY and NRF_ERROR_CRYPTO_INPUT_LOCATION can only occur in CC310 backend.
- Parameters
-
[in] | p_context | Pointer to structure holding context information for the hash calculation. |
[out] | p_digest | Pointer to buffer holding the calculated hash digest. |
[in,out] | p_digest_size | Pointer to a variable holding the length of the calculated hash. Set this to the length of buffer that p_digest is pointing to. |
- Return values
-
NRF_SUCCESS | The hash digest was computed successfully. |
NRF_ERROR_CRYPTO_NOT_INITIALIZED | nrf_crypto_init was not called prior to this crypto function. |
NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED | The context was not initialized prior to this call or it was corrupted. Please call nrf_crypto_hash_init to initialize it. |
NRF_ERROR_CRYPTO_CONTEXT_NULL | A NULL pointer was provided for the context structure. |
NRF_ERROR_CRYPTO_OUTPUT_NULL | p_digest or p_digest_size was NULL. |
NRF_ERROR_CRYPTO_OUTPUT_LENGTH | The length of p_digest was too small for the hash digest result. |
NRF_ERROR_CRYPTO_BUSY | The function could not be called because the nrf_crypto backend was busy. Please rerun the cryptographic routine at a later time. |
NRF_ERROR_CRYPTO_INTERNAL | An internal error occurred in the nrf_crypto backend. |
Function for initializing the context structure required to compute a hash digest from arbitrary input data.
- Note
- The context structure is assumed to be an opaque type defined by the nrf_crypto backend.
-
The return codes NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE and NRF_ERROR_CRYPTO_INTERNAL only happens in cc310 backend.
- Parameters
-
[in,out] | p_context | Pointer to structure holding context information for the hash calculation. |
[in] | p_info | Pointer to structure holding info about the hash algorithm used to do the computed hash. |
- Return values
-
NRF_SUCCESS | The hash initialization was successful. |
NRF_ERROR_CRYPTO_NOT_INITIALIZED | nrf_crypto_init was not called prior to this crypto function. |
NRF_ERROR_CRYPTO_CONTEXT_NULL | A NULL pointer was provided for the context structure. |
NRF_ERROR_CRYPTO_INPUT_NULL | The pointer to the info structure was NULL. |
NRF_ERROR_CRYPTO_FEATURE_UNAVAILABLE | The function was called with a hash mode that is unavailable. |
NRF_ERROR_CRYPTO_INTERNAL | An internal error occurred when initializing the constext in the nrf_crypto backend. |
Function for updating the hash calculation with partial arbitrary data.
This function should be called one or more times until all arbituary input data required for the hash calcuation is provided.
- Note
- nrf_crypto_hash_init must be called prior to this function to configure the context structure used as input parameter to this function.
-
nrf_crypto_hash_finalize must be called after all arbitruary input data has been provided to get the calculated hash digest.
-
The context object is assumed to be an opaque type defined by the nrf_crypto backend.
-
The return values NRF_ERROR_CRYPTO_BUSY, NRF_ERROR_CRYPTO_INPUT_LOCATION and NRF_ERROR_CRYPTO_INPUT_LOCATION can only occur in CC310 backend.
- Parameters
-
[in,out] | p_context | Pointer to structure holding context information for the hash calculation. |
[in] | p_data | Pointer to data to be hashed. |
[in] | data_size | Length of the data to be hashed. |
- Return values
-
NRF_SUCCESS | The hash digest was computed successfully. |
NRF_ERROR_CRYPTO_NOT_INITIALIZED | nrf_crypto_init was not called prior to this crypto function. |
NRF_ERROR_CRYPTO_CONTEXT_NOT_INITIALIZED | The context was not initialized prior to this call or it was corrupted. Please call nrf_crypto_hash_init to initialize it. |
NRF_ERROR_CRYPTO_CONTEXT_NULL | A NULL pointer was provided for the context structure. |
NRF_ERROR_CRYPTO_INPUT_NULL | p_data was NULL. |
NRF_ERROR_CRYPTO_INPUT_LOCATION | Input data not in RAM. |
NRF_ERROR_CRYPTO_BUSY | The function could not be called because the nrf_crypto backend was busy. Please rerun the cryptographic routine at a later time. |
NRF_ERROR_CRYPTO_INTERNAL | An internal error occurred in the nrf_crypto backend. |
External variable declaration to info structure for SHA-256.
- Note
- The variable is defined in the nrf_crypto backend that is enabled in the SDK configuration header file.
External variable declaration to info structure for SHA-512.
- Note
- The variable is defined in the nrf_crypto backend that is enabled in the SDK configuration header file.