Provides cryptographic hash related functionality through nrf_crypto. More...
Typedefs |
|
|
typedef
nrf_crypto_backend_hash_context_t |
nrf_crypto_hash_context_t |
|
Context type for Hash.
More...
|
|
| typedef uint8_t | nrf_crypto_hash_sha256_digest_t [(32)] |
|
Type definition for an array holding a SHA-256 hash digest.
|
|
| typedef uint8_t | nrf_crypto_hash_sha512_digest_t [(64)] |
|
Type definition for an array holding a SHA-512 hash digest.
|
|
Functions |
|
| 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...
|
|
Variables |
|
| const nrf_crypto_hash_info_t | g_nrf_crypto_hash_sha256_info |
|
External variable declaration to info structure for SHA-256.
More...
|
|
| const nrf_crypto_hash_info_t | g_nrf_crypto_hash_sha512_info |
|
External variable declaration to info structure for SHA-512.
More...
|
|
Detailed Description
Provides cryptographic hash related functionality through nrf_crypto.
Typedef Documentation
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 Documentation
| 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.
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.
| 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.
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.
| 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.
- 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.
| 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.
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.
Variable Documentation
| const nrf_crypto_hash_info_t g_nrf_crypto_hash_sha256_info |
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 .
| const nrf_crypto_hash_info_t g_nrf_crypto_hash_sha512_info |
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 .