AES/CMAC helpers.
More...
#include <cstddef>
#include <cstdint>
Go to the source code of this file.
|
| namespace | m5 |
| | Top level namespace of M5stack.
|
| |
|
| bool | m5::nfc::crypto::aes_ecb_encrypt (uint8_t out[16], const uint8_t key[16], const uint8_t in[16]) |
| | AES-128 ECB encryption of a single 16-byte block.
|
| |
| bool | m5::nfc::crypto::aes_cbc_crypt (uint8_t *out, const uint8_t key[16], const uint8_t iv_in[16], const uint8_t *in, size_t len, bool encrypt) |
| | AES-128 CBC encrypt or decrypt.
|
| |
| bool | m5::nfc::crypto::cmac_subkeys (uint8_t k1[16], uint8_t k2[16], const uint8_t key[16]) |
| | Generate AES-CMAC subkeys K1 and K2.
|
| |
| bool | m5::nfc::crypto::cmac_aes_128 (uint8_t out[16], const uint8_t key[16], const uint8_t *msg, size_t msg_len) |
| | Calculate AES-CMAC (RFC 4493)
|
| |
◆ aes_cbc_crypt()
| bool m5::nfc::crypto::aes_cbc_crypt |
( |
uint8_t * | out, |
|
|
const uint8_t | key[16], |
|
|
const uint8_t | iv_in[16], |
|
|
const uint8_t * | in, |
|
|
size_t | len, |
|
|
bool | encrypt ) |
AES-128 CBC encrypt or decrypt.
- Parameters
-
| [out] | out | Output buffer (same size as in) |
| key | AES-128 key (16 bytes) |
| iv_in | Initialization vector (16 bytes) |
| in | Input buffer |
| len | Input buffer length (must be multiple of 16) |
| encrypt | True for encrypt, false for decrypt |
- Returns
- True if successful
◆ aes_ecb_encrypt()
| bool m5::nfc::crypto::aes_ecb_encrypt |
( |
uint8_t | out[16], |
|
|
const uint8_t | key[16], |
|
|
const uint8_t | in[16] ) |
AES-128 ECB encryption of a single 16-byte block.
- Parameters
-
| [out] | out | Encrypted output (16 bytes) |
| key | AES-128 key (16 bytes) |
| in | Plaintext input (16 bytes) |
- Returns
- True if successful
◆ cmac_aes_128()
| bool m5::nfc::crypto::cmac_aes_128 |
( |
uint8_t | out[16], |
|
|
const uint8_t | key[16], |
|
|
const uint8_t * | msg, |
|
|
size_t | msg_len ) |
Calculate AES-CMAC (RFC 4493)
- Parameters
-
| [out] | out | CMAC output (16 bytes) |
| key | AES-128 key (16 bytes) |
| msg | Message buffer |
| msg_len | Message length |
- Returns
- True if successful
◆ cmac_subkeys()
| bool m5::nfc::crypto::cmac_subkeys |
( |
uint8_t | k1[16], |
|
|
uint8_t | k2[16], |
|
|
const uint8_t | key[16] ) |
Generate AES-CMAC subkeys K1 and K2.
- Parameters
-
| [out] | k1 | Subkey K1 (16 bytes) |
| [out] | k2 | Subkey K2 (16 bytes) |
| key | AES-128 key (16 bytes) |
- Returns
- True if successful