M5Unit-NFC 0.0.3 git rev:59f5362
Loading...
Searching...
No Matches
aes.hpp File Reference

AES/CMAC helpers. More...

#include <cstddef>
#include <cstdint>

Go to the source code of this file.

Namespaces

namespace  m5
 Top level namespace of M5stack.
 

Functions

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)
 

Detailed Description

AES/CMAC helpers.

Function Documentation

◆ 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]outOutput buffer (same size as in)
keyAES-128 key (16 bytes)
iv_inInitialization vector (16 bytes)
inInput buffer
lenInput buffer length (must be multiple of 16)
encryptTrue 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]outEncrypted output (16 bytes)
keyAES-128 key (16 bytes)
inPlaintext 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]outCMAC output (16 bytes)
keyAES-128 key (16 bytes)
msgMessage buffer
msg_lenMessage 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]k1Subkey K1 (16 bytes)
[out]k2Subkey K2 (16 bytes)
keyAES-128 key (16 bytes)
Returns
True if successful