Go to the documentation of this file.
40 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
48 #if (CCM_SUPPORT == ENABLED)
68 size_t nLen,
const uint8_t *
a,
size_t aLen,
const uint8_t *
p, uint8_t *
c,
69 size_t length, uint8_t *
t,
size_t tLen)
78 if(cipher == NULL || context == NULL)
107 m =
MIN(aLen, 16 - 2);
121 m =
MIN(aLen, 16 - 6);
209 size_t nLen,
const uint8_t *
a,
size_t aLen,
const uint8_t *
c, uint8_t *
p,
210 size_t length,
const uint8_t *
t,
size_t tLen)
221 if(cipher == NULL || context == NULL)
250 m =
MIN(aLen, 16 - 2);
264 m =
MIN(aLen, 16 - 6);
332 for(
mask = 0,
m = 0;
m < tLen;
m++)
354 size_t tLen, uint8_t *
b)
360 if(nLen < 7 || nLen > 13)
364 if(tLen < 4 || tLen > 16 || (tLen % 2) != 0)
371 b[0] = (aLen > 0) ? 0x40 : 0x00;
373 b[0] |= ((tLen - 2) / 2) << 3;
381 for(i = 0; i < qLen; i++, q >>= 8)
383 b[15 - i] = q & 0xFF;
404 for(i = 0; i <
n; i++)
447 for(temp = 1, i = 0; i <
n; i++)
451 ctr[15 - i] = temp & 0xFF;
__weak_func error_t ccmDecrypt(const CipherAlgo *cipher, void *context, const uint8_t *n, size_t nLen, const uint8_t *a, size_t aLen, const uint8_t *c, uint8_t *p, size_t length, const uint8_t *t, size_t tLen)
Authenticated decryption using CCM.
void ccmXorBlock(uint8_t *x, const uint8_t *a, const uint8_t *b, size_t n)
XOR operation.
__weak_func error_t ccmEncrypt(const CipherAlgo *cipher, void *context, const uint8_t *n, size_t nLen, const uint8_t *a, size_t aLen, const uint8_t *p, uint8_t *c, size_t length, uint8_t *t, size_t tLen)
Authenticated encryption using CCM.
void ccmFormatCounter0(const uint8_t *n, size_t nLen, uint8_t *ctr)
Format initial counter value CTR(0)
void ccmIncCounter(uint8_t *ctr, size_t n)
Increment counter block.
CipherAlgoEncryptBlock encryptBlock
@ ERROR_INVALID_PARAMETER
Invalid parameter.
#define osMemcpy(dest, src, length)
@ ERROR_FAILURE
Generic error code.
error_t ccmFormatBlock0(size_t q, const uint8_t *n, size_t nLen, size_t aLen, size_t tLen, uint8_t *b)
Format first block B(0)
General definitions for cryptographic algorithms.
Common interface for encryption algorithms.
#define osMemset(p, value, length)
Cipher Block Chaining-Message Authentication Code (CCM)