Macros | |
#define | MIN(a, b) ((a) < (b)) ? (a) : (b) |
Functions | |
void | compute_mic (uint8_t *buffer, uint8_t *mic, uint8_t *nonce, uint8_t hdr_len, uint8_t pld_len) |
Computes MIC. More... | |
void | encrypt_pldmic (uint8_t *buffer, uint8_t *nonce, uint8_t mic_len, uint8_t pld_len) |
Encrypts and decrypts payload and MIC. More... | |
void | encrypt_with_padding (uint8_t *start, uint8_t buflen) |
CBC Encrypt data stream with null padding at the end. More... | |
#define MIN | ( | a, | |
b | |||
) | ((a) < (b)) ? (a) : (b) |
Referenced by compute_mic(), and encrypt_pldmic().
void compute_mic | ( | uint8_t * | buffer, |
uint8_t * | mic, | ||
uint8_t * | nonce, | ||
uint8_t | hdr_len, | ||
uint8_t | pld_len | ||
) |
Computes MIC.
This function computes the MIC according to CCM.
The key was initialized in other functions before.
[in] | buffer | Input data (frame, not padded yet) |
[out] | mic | Computed MIC of size AES_BLOCKSIZE |
[in] | nonce | The nonce: Initialization Vector (IV) as used in cryptography; the ZigBee nonce are the bytes 2...14 of this nonce |
[in] | hdr_len | Size of plain text header in bytes (may be 0) |
[in] | pld_len | Length of payload in bytes (may be 0) |
References AES_BLOCKSIZE, AES_DIR_ENCRYPT, AES_MODE_CBC, AES_MODE_ECB, encrypt_with_padding(), MIN, NULL, sal_aes_exec(), sal_aes_read(), sal_aes_setup(), and sal_aes_wrrd().
Referenced by stb_ccm_secure().
void encrypt_pldmic | ( | uint8_t * | buffer, |
uint8_t * | nonce, | ||
uint8_t | mic_len, | ||
uint8_t | pld_len | ||
) |
Encrypts and decrypts payload and MIC.
This function perform encryption and decryption of the payload and the MIC.
[in] | buffer | Input data (frame, not padded yet) |
[in] | nonce | The nonce |
[in] | mic_len | Size of MIC in bytes (may be 0) |
[in] | pld_len | Length of payload in bytes (may be 0) |
References AES_BLOCKSIZE, AES_DIR_ENCRYPT, AES_MODE_ECB, i, MIN, NULL, sal_aes_read(), sal_aes_setup(), and sal_aes_wrrd().
Referenced by stb_ccm_secure().
void encrypt_with_padding | ( | uint8_t * | start, |
uint8_t | buflen | ||
) |
CBC Encrypt data stream with null padding at the end.
This function preforms CBC Encryption in the actual mode with actual key and portions of AES_BLOCKSIZE length. If the last block has less than AES_BLOCKSIZE bytes, it is padded with null bytes to this length and then encrypted.
No result is return; the CBC-MAC must be read separately.
start | Pointer to start address |
buflen | Number of bytes to be encrypted; if 0, nothing happens |
References AES_BLOCKSIZE, NULL, sal_aes_exec(), and sal_aes_wrrd().
Referenced by compute_mic().