SmartSnippets DA1459x SDK
Files | Data Structures | Enumerations | Functions

HASH Engine LLD API. More...

Files

file  hw_hash.h
 Definition of API for the HASH Engine Low Level Driver.
 

Data Structures

struct  hw_hash_config_t
 HASH engine configuration structure. More...
 

Enumerations

enum  HW_HASH_ERROR
 HASH engine error codes.
 
enum  HW_HASH_TYPE { HW_HASH_TYPE_SHA_256_224 = 0, HW_HASH_TYPE_SHA_256 = 1 }
 HASH Type. More...
 
enum  HW_HASH_OUTPUT_LENGTH_MAX { HW_HASH_OUTPUT_LEN_MAX_SHA_256_224 = 28, HW_HASH_OUTPUT_LEN_MAX_SHA_256 = 32 }
 The maximum allowed output length of the HASH engine in bytes for all supported HASH types. More...
 

Functions

__STATIC_INLINE void hw_hash_set_type (HW_HASH_TYPE hash_type)
 Set HASH type. More...
 
__STATIC_INLINE void hw_hash_set_output_data_len (HW_HASH_TYPE hash_type, uint8_t output_data_len)
 Set HASH output length. More...
 
bool hw_hash_check_input_data_len_restrictions (void)
 Check if the restrictions of the input data length are fulfilled. More...
 
HW_HASH_ERROR hw_hash_init (const hw_hash_config_t *hash_cfg)
 HASH engine initialization function. More...
 

Detailed Description

HASH Engine LLD API.

Enumeration Type Documentation

◆ HW_HASH_OUTPUT_LENGTH_MAX

The maximum allowed output length of the HASH engine in bytes for all supported HASH types.

Enumerator
HW_HASH_OUTPUT_LEN_MAX_SHA_256_224 

The maximum allowed output length for HASH Type SHA-256/224

HW_HASH_OUTPUT_LEN_MAX_SHA_256 

The maximum allowed output length for HASH Type SHA-256

◆ HW_HASH_TYPE

HASH Type.

Enumerator
HW_HASH_TYPE_SHA_256_224 

HASH Type SHA-256/224

HW_HASH_TYPE_SHA_256 

HASH Type SHA-256

Function Documentation

◆ hw_hash_check_input_data_len_restrictions()

bool hw_hash_check_input_data_len_restrictions ( void  )

Check if the restrictions of the input data length are fulfilled.

There are some restrictions in terms of the acceptable values of the data_len with regards to Input Data Mode, indicated by the next table:

wait_more_input = true wait_more_input = false
multiple of 8 no restrictions
Returns
true if the restrictions are fulfilled, otherwise false

◆ hw_hash_init()

HW_HASH_ERROR hw_hash_init ( const hw_hash_config_t hash_cfg)

HASH engine initialization function.

Configure the HASH engine provided that the crypto engine is NOT locked by the AES engine. If the function returns HW_HASH_ERROR_NONE, the operation can be started by calling the hw_aes_hash_start().

Parameters
[in]hash_cfgConfiguration structure for HASH engine.
Returns
HW_HASH_ERROR_NONE if the HASH engine has been successfully initialized, otherwise an error code.
Warning
When HASHing has been completed, the hw_aes_hash_deinit() should be called in order for the crypto engine to be unlocked from HASH. This is mandatory in case that both AES and HASH are used by the same application. The two blocks make use of the same hardware accelerator, thus they are mutually exclusive and cannot be used simultaneously. The functions hw_aes_init(), hw_hash_init() and hw_aes_hash_deinit() incorporate a mechanism which ensures mutual exclusion and prevents race condition, provided that the user doesn't call the functions hw_aes_hash_disable_clock(), hw_aes_hash_enable_clock(), hw_aes_set_mode() and hw_hash_set_type(). The aforementioned functions affect some AES/HASH register fields which are used by this mechanism and might violate it. Therefore, it is highly recommended to use the corresponding init/deinit functions instead.
See also
hw_hash_config_t
HW_HASH_ERROR

◆ hw_hash_set_output_data_len()

__STATIC_INLINE void hw_hash_set_output_data_len ( HW_HASH_TYPE  hash_type,
uint8_t  output_data_len 
)

Set HASH output length.

There are restrictions with regards to the maximum length of the output data. If the selected output_data_len exceeds the maximum allowed length determined by HW_HASH_OUTPUT_LEN_MAX this function automatically equalizes the output length with the maximum allowed value.

Parameters
[in]hash_typeHASH type
[in]output_data_lenHASH output length
See also
HW_HASH_TYPE
HW_HASH_OUTPUT_LEN_MAX

◆ hw_hash_set_type()

__STATIC_INLINE void hw_hash_set_type ( HW_HASH_TYPE  hash_type)

Set HASH type.

Parameters
[in]hash_typeHASH type
See also
HW_HASH_TYPE