AES Engine LLD API.
More...
|
| file | hw_aes.h |
| | Definition of API for the AES Engine Low Level Driver.
|
| |
AES Engine LLD API.
◆ HW_AES_KEY_EXPAND
AES key expansion modes.
| Enumerator |
|---|
| HW_AES_KEY_EXPAND_BY_SW | The key expansion is performed by the software
|
| HW_AES_KEY_EXPAND_BY_HW | The key expansion is performed by the hardware accelerator
|
◆ HW_AES_KEY_SIZE
AES key size.
| Enumerator |
|---|
| HW_AES_KEY_SIZE_128 | AES Key 128-bit
|
| HW_AES_KEY_SIZE_192 | AES Key 192-bit
|
| HW_AES_KEY_SIZE_256 | AES Key 256-bit
|
◆ HW_AES_MODE
AES Mode.
| Enumerator |
|---|
| HW_AES_MODE_ECB | AES Mode ECB
|
| HW_AES_MODE_CTR | AES Mode CTR
|
| HW_AES_MODE_CBC | AES Mode CBC
|
◆ HW_AES_OPERATION
AES operation.
| Enumerator |
|---|
| HW_AES_OPERATION_DECRYPT | Perform AES Decryption
|
| HW_AES_OPERATION_ENCRYPT | Perform AES Encryption
|
◆ HW_AES_OUTPUT_DATA_MODE
AES Output Mode.
| Enumerator |
|---|
| HW_AES_OUTPUT_DATA_MODE_ALL | Write back to the memory all the output data
|
| HW_AES_OUTPUT_DATA_MODE_FINAL_BLOCK | Write back to the memory only the final block of the output data
|
◆ hw_aes_check_input_data_len_restrictions()
| bool hw_aes_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 the AES mode and the Input Data Mode (wait_more_input). If the rules indicated by the next table are NOT fulfilled the function returns false, otherwise true.
| mode | wait_more_input = true | wait_more_input = false |
| HW_AES_ECB | multiple of 16 | multiple of 16 |
| HW_AES_CBC | multiple of 16 | no restrictions |
| HW_AES_CTR | multiple of 16 | no restrictions |
- Returns
- True if the restrictions are fulfilled, otherwise false.
◆ hw_aes_get_mode()
◆ hw_aes_init()
AES engine initialization function.
Configure the AES engine provided that the crypto engine is NOT locked by the HASH engine. If the function returns HW_AES_ERROR_NONE, the operation can be started by calling the hw_aes_start_operation().
- Parameters
-
| [in] | aes_cfg | AES engine configuration structure |
- Returns
- HW_AES_ERROR_NONE if the AES engine has been successfully initialized, otherwise an error code.
- Warning
- When AES operation has been completed, the hw_aes_hash_deinit() should be called in order for the crypto engine to be unlocked from AES. 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_aes_config_t
-
HW_AES_ERROR
◆ hw_aes_is_key_valid()
| bool hw_aes_is_key_valid |
( |
uint8_t |
idx | ) |
|
Check whether the Encryption Key is revoked or not.
- Parameters
-
| [in] | idx | eFlash memory cell_offset where the key is located |
- Precondition
- Make sure that eFlash is available for reading
- Warning
- The acceptable idx range is from 0 to 15
- Returns
- true if key is valid, otherwise false
◆ hw_aes_key_address_get()
| uint32_t hw_aes_key_address_get |
( |
uint8_t |
key_idx | ) |
|
Get User Data Encryption Key memory address.
Returns address of User Data Encryption Key for given key index within the memory that the keys are stored
- Parameters
-
- Warning
- The acceptable range for the key_idx is 0 - 7.
- Returns
- key memory address or 0 if key has been revoked
◆ hw_aes_load_keys()
Load the AES keys from OTP/RAM to Crypto Engine.
- Parameters
-
| [in] | key_src_addr | The address of the AES Keys which can reside either in OTP or in RAM. In the former case use the hw_otpc_get_aes_key_address() to get their address. |
| [in] | key_size | The AES Key size. |
| [in] | key_exp | Select whether the keys will be expanded by software or by hardware. |
- See also
- HW_AES_KEY_SIZE
-
HW_AES_KEY_EXPAND
◆ hw_aes_set_init_vector()
| void hw_aes_set_init_vector |
( |
const uint8_t * |
iv_cnt_ptr | ) |
|
Set the Initialization Vector in CBC Mode or the Counter in CTR Mode.
- Parameters
-
| [in] | iv_cnt_ptr | Pointer of the Initialization Vector in CBC Mode or the Initialization Counter in CTR Mode. |
- Note
- Only applicable to AES CBC/CTR modes.
◆ hw_aes_set_key_expansion()
Set AES key expansion mode.
- Parameters
-
| [in] | key_expand | AES key expansion mode. |
- See also
- HW_AES_KEY_EXPAND
◆ hw_aes_set_key_size()
Set AES key size.
- Parameters
-
| [in] | key_size | AES key size. |
- See also
- HW_AES_KEY_SIZE
◆ hw_aes_set_mode()
| __STATIC_INLINE void hw_aes_set_mode |
( |
HW_AES_MODE |
aes_mode | ) |
|
◆ hw_aes_set_operation()
Set AES operation, e.g. encryption or decryption.
- Parameters
-
| [in] | operation | AES operation. |
- See also
- HW_AES_OPERATION
◆ hw_aes_set_output_data_mode()
Set AES engine output data mode.
- Parameters
-
| [in] | output_data_mode | AES output data mode. |
- See also
- HW_AES_OUTPUT_DATA_MODE
◆ hw_aes_start_operation()
Start AES operation (Encryption/Decryption).
- Parameters
-
| [in] | aes_operation | AES operation (Encryption or Decryption). |
- See also
- HW_AES_OPERATION