InPlay API
|
HAL AES. More...
Data Structures | |
struct | aes_cfg_t |
AES cryptography configuration structure. More... | |
Enumerations | |
enum | aes_crypto_status { AES_ERR_OK = 0, AES_ERR_NOT_INIT = 1, AES_ERR_ALREADY_INIT = 2, AES_ERR_DEV_BAD_STATE = 3, AES_ERR_MAC_DOES_NOT_MATCH = 4, AES_ERR_HW_MEM_USED_BY_ECC = 5 } |
AES function status return. More... | |
enum | aes_crypto_type { AES_CRYPTO_TYPE_ENCRYPT = 1, AES_CRYPTO_TYPE_DECRYPT = 0 } |
AES cryptography type. More... | |
enum | aes_crypto_mode { AES_CRYPTO_MODE_ECB = 0, AES_CRYPTO_MODE_CBC = 1, AES_CRYPTO_MODE_CTR = 2, AES_CRYPTO_MODE_CCM = 3, AES_CRYPTO_MODE_CMAC = 4, AES_CRYPTO_MODE_XCBC = 6, AES_CRYPTO_MODE_F8 = 9 } |
AES cryptography mode. More... | |
enum | aes_key_size { AES_KEY_SIZE_128 = 0, AES_KEY_SIZE_192 = 1, AES_KEY_SIZE_256 = 2 } |
AES key size. More... | |
Functions | |
int | hal_aes_open (void) |
Initialize AES driver for power management and interrupt purposes. More... | |
int | hal_aes_close (void) |
De-Initialize AES driver for power management and interrupt purposes. More... | |
int | hal_aes_is_open (void) |
Ecc and Aes shared the same HW memory. This is to inform Ecc that Aes currently is using the HW memory. More... | |
int | hal_aes_config (aes_cfg_t *cfg) |
AES cryptography configuration function, call this function before calling hal_aes_encrypt/hal_aes_decrypt. More... | |
void | hal_aes_set_aad_length (uint32_t length) |
Set the AAD data length, CCM mode only. Must be multiple of 16 bytes. More... | |
int | hal_aes_encrypt (const uint8_t *input, uint32_t length, uint8_t *output, bool end) |
Do the encrypt process. More... | |
void | hal_aes_get_encrypt_mac (uint8_t *mac, uint32_t buf_sz) |
Get the MAC result after encryption, only for CMAC, CCM and XCBC modes. More... | |
void | hal_aes_get_iv (uint8_t iv[16]) |
Get the IV result after encryption, only for CBC and F8 modes. More... | |
int | hal_aes_decrypt (const uint8_t *input, uint32_t length, uint8_t *output, bool end) |
Do the decrypt process. More... | |
HAL AES.
enum aes_crypto_mode |
AES cryptography mode.
enum aes_crypto_status |
AES function status return.
enum aes_crypto_type |
enum aes_key_size |
int hal_aes_close | ( | void | ) |
De-Initialize AES driver for power management and interrupt purposes.
int hal_aes_config | ( | aes_cfg_t * | cfg | ) |
AES cryptography configuration function, call this function before calling hal_aes_encrypt/hal_aes_decrypt.
[in] | cfg |
int hal_aes_decrypt | ( | const uint8_t * | input, |
uint32_t | length, | ||
uint8_t * | output, | ||
bool | end | ||
) |
Do the decrypt process.
[in] | Input | The ciphertext to be decrypted. For CCM mode, AAD data is included and before ciphertext |
[in] | Length | Number of bytes in message, should be <= 128bytes (CCM mode requires the total number of bytes in formatted input data, see "r" in NIST Special Publication 800-38C) |
[out] | Output | The plaintext decrypted, for CCM mode, AAD is not included, only plaintext |
[in] | end | Set to "true" if this is the last data segment to be decrypted. This function can be called many times to decrypt multi data segments after AES is configured if the data length exceeds 128 bytes. |
int hal_aes_encrypt | ( | const uint8_t * | input, |
uint32_t | length, | ||
uint8_t * | output, | ||
bool | end | ||
) |
Do the encrypt process.
[in] | Input | Pointer to the plain text to be encrypted, For CCM mode, AAD data is included(see "B" in NIST Special Publication 800-38C). |
[in] | Length | Number of bytes in message, should <= 128bytes. (CCM mode requires the total number of bytes in formatted input data, see "r" in NIST Special Publication 800-38C) |
[out] | Output | Pointer to the output ciphertext |
[in] | end | Set to "true" if this is the last data segment to be encrypted. This function can be called many times to encrypt multi data segments if the data length exceeds 128 bytes. |
void hal_aes_get_encrypt_mac | ( | uint8_t * | mac, |
uint32_t | buf_sz | ||
) |
Get the MAC result after encryption, only for CMAC, CCM and XCBC modes.
[out] | mac | Pointer to the buffer to save message authentication code |
[in] | buf_sz | Buffer size of the message authentication code |
void hal_aes_get_iv | ( | uint8_t | iv[16] | ) |
Get the IV result after encryption, only for CBC and F8 modes.
[out] | iv[16] | Pointer to the buffer to save Initialization Value |
int hal_aes_is_open | ( | void | ) |
Ecc and Aes shared the same HW memory. This is to inform Ecc that Aes currently is using the HW memory.
int hal_aes_open | ( | void | ) |
Initialize AES driver for power management and interrupt purposes.
void hal_aes_set_aad_length | ( | uint32_t | length | ) |
Set the AAD data length, CCM mode only. Must be multiple of 16 bytes.
length[in] | : Number of bytes in formatted input data minus bytes in formatted payload ("r" - "m" in NIST Special Publication 800-38C) |