Go to the documentation of this file.
36 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
43 #if (CMAC_SUPPORT == ENABLED)
59 const void *
data,
size_t dataLen, uint8_t *mac,
size_t macLen)
62 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
68 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
77 error =
cmacInit(context, cipher, key, keyLen);
88 #if (CRYPTO_STATIC_MEM_SUPPORT == DISABLED)
108 const void *key,
size_t keyLen)
114 if(context == NULL || cipher == NULL)
318 void cmacMul(uint8_t *
x,
const uint8_t *
a,
size_t n, uint8_t rb)
328 for(i = 0; i < (
n - 1); i++)
330 x[i] = (
a[i] << 1) | (
a[i + 1] >> 7);
337 x[i] ^= rb & ~(
c - 1);
354 for(i = 0; i <
n; i++)
const CipherAlgo * cipher
uint8_t k2[MAX_CIPHER_BLOCK_SIZE]
void cmacDeinit(CmacContext *context)
Release CMAC context.
uint8_t buffer[MAX_CIPHER_BLOCK_SIZE]
CipherAlgoEncryptBlock encryptBlock
void cmacMul(uint8_t *x, const uint8_t *a, size_t n, uint8_t rb)
Multiplication by x in GF(2^128)
uint8_t mac[MAX_CIPHER_BLOCK_SIZE]
@ ERROR_INVALID_PARAMETER
Invalid parameter.
#define osMemcpy(dest, src, length)
General definitions for cryptographic algorithms.
void cmacXorBlock(uint8_t *x, const uint8_t *a, const uint8_t *b, size_t n)
XOR operation.
void cmacReset(CmacContext *context)
Reset CMAC context.
error_t cmacCompute(const CipherAlgo *cipher, const void *key, size_t keyLen, const void *data, size_t dataLen, uint8_t *mac, size_t macLen)
Compute CMAC using the specified cipher algorithm.
Common interface for encryption algorithms.
error_t cmacInit(CmacContext *context, const CipherAlgo *cipher, const void *key, size_t keyLen)
Initialize CMAC calculation.
#define cryptoAllocMem(size)
void cmacUpdate(CmacContext *context, const void *data, size_t dataLen)
Update the CMAC context with a portion of the message being hashed.
uint8_t k1[MAX_CIPHER_BLOCK_SIZE]
CMAC (Cipher-based Message Authentication Code)
#define osMemset(p, value, length)
error_t cmacFinal(CmacContext *context, uint8_t *mac, size_t macLen)
Finish the CMAC calculation.
CipherContext cipherContext