Low-level crypto API for an AES unit implemented in ATxmega MCUs .
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
Macros | |
#define | AES_DIR_VOID (AES_DIR_ENCRYPT + AES_DIR_DECRYPT + 1) |
#define | COMP_SR(SUB, val) (((val) << SUB ## _bp) & SUB ## _bm) |
Functions | |
void | sal_aes_exec (uint8_t *data) |
En/decrypt one AES block. More... | |
void | sal_aes_read (uint8_t *data) |
Reads the result of previous AES en/decryption. More... | |
void | sal_aes_restart (void) |
Re-inits key and state after a sleep or chip reset. More... | |
bool | sal_aes_setup (uint8_t *key, uint8_t enc_mode, uint8_t dir) |
Setup AES unit. More... | |
void | sal_init (void) |
Initialization of SAL. More... | |
Variables | |
static bool | dec_initialized = false |
static uint8_t | dec_key [AES_KEYSIZE] |
static uint8_t | enc_key [AES_KEYSIZE] |
static uint8_t * | keyp |
static uint8_t | last_dir = AES_DIR_VOID |
static uint8_t | mode_byte |
#define AES_DIR_VOID (AES_DIR_ENCRYPT + AES_DIR_DECRYPT + 1) |
Referenced by sal_aes_setup().
#define COMP_SR | ( | SUB, | |
val | |||
) | (((val) << SUB ## _bp) & SUB ## _bm) |
Referenced by sal_aes_setup(), and sal_init().
void sal_aes_exec | ( | uint8_t * | data | ) |
En/decrypt one AES block.
The function returns after the AES operation is finished.
[in] | data | AES block to be en/decrypted |
References AES_BLOCKSIZE, and keyp.
Referenced by compute_mic(), encrypt_with_padding(), and sal_aes_setup().
void sal_aes_read | ( | uint8_t * | data | ) |
Reads the result of previous AES en/decryption.
This function returns the result of the previous AES operation.
[out] | data | - result of previous operation |
References AES_BLOCKSIZE.
Referenced by compute_mic(), and encrypt_pldmic().
void sal_aes_restart | ( | void | ) |
Re-inits key and state after a sleep or chip reset.
Re-inits key and state after a sleep or TRX reset.
This function is void for ATxmega since the key must be re-initialized before every block encryption anyway.
Referenced by stb_ccm_secure().
bool sal_aes_setup | ( | uint8_t * | key, |
uint8_t | enc_mode, | ||
uint8_t | dir | ||
) |
Setup AES unit.
This function performs the following tasks as part of the setup of the AES unit: key initialization, set encryption direction and encryption mode.
In general, the contents of SRAM buffer is destroyed. When using sal_aes_wrrd(), sal_aes_read() needs to be called in order to get the result of the last AES operation before you may call sal_aes_setup() again.
[in] | key | AES key or NULL (NULL: use last key) |
[in] | enc_mode | AES_MODE_ECB or AES_MODE_CBC |
[in] | dir | AES_DIR_ENCRYPT or AES_DIR_DECRYPT |
References AES_AUTO, AES_BLOCKSIZE, AES_DECRYPT, AES_DIR_DECRYPT, AES_DIR_ENCRYPT, AES_DIR_VOID, AES_KEYSIZE, AES_MODE_CBC, AES_MODE_ECB, COMP_SR, dec_initialized, dec_key, enc_key, keyp, last_dir, mode_byte, and sal_aes_exec().
Referenced by compute_mic(), encrypt_pldmic(), and stb_ccm_secure().
void sal_init | ( | void | ) |
Initialization of SAL.
This functions initializes the SAL.
References COMP_SR, SYSCLK_AES, sysclk_enable_module(), and SYSCLK_PORT_GEN.
Referenced by stb_init().
Referenced by sal_aes_setup().
|
static |
Referenced by sal_aes_setup().
|
static |
Referenced by sal_aes_setup().
|
static |
Referenced by sal_aes_exec(), and sal_aes_setup().
|
static |
Referenced by sal_aes_setup().
|
static |
Referenced by sal_aes_setup().