My Project
Functions
Algorithm - CMAC

Functions

int wc_InitCmac (Cmac *cmac, const byte *key, word32 keySz, int type, void *unused)
 Initialize the Cmac structure with defaults. More...
 
int wc_InitCmac_ex (Cmac *cmac, const byte *key, word32 keySz, int type, void *unused, void *heap, int devId)
 Initialize the Cmac structure with defaults. More...
 
int wc_CmacUpdate (Cmac *cmac, const byte *in, word32 inSz)
 Add Cipher-based Message Authentication Code input data. More...
 
int wc_CmacFinal (Cmac *cmac, byte *out, word32 *outSz)
 Generate the final result using Cipher-based Message Authentication Code. More...
 
int wc_AesCmacGenerate (byte *out, word32 *outSz, const byte *in, word32 inSz, const byte *key, word32 keySz)
 Single shot fuction for generating a CMAC. More...
 
int wc_AesCmacVerify (const byte *check, word32 checkSz, const byte *in, word32 inSz, const byte *key, word32 keySz)
 Single shot fuction for validating a CMAC. More...
 
int wc_CMAC_Grow (Cmac *cmac, const byte *in, int inSz)
 Only used with WOLFSSL_HASH_KEEP when hardware requires single-shot and the updates must be cached in memory. More...
 

Detailed Description

Function Documentation

◆ wc_AesCmacGenerate()

int wc_AesCmacGenerate ( byte *  out,
word32 *  outSz,
const byte *  in,
word32  inSz,
const byte *  key,
word32  keySz 
)

Single shot fuction for generating a CMAC.

Returns
0 on success
Parameters
outpointer to return the result
outSzpointer size of output (in/out)
ininput data to process
inSzsize of input data
keykey pointer
keySzsize of the key pointer (16, 24 or 32)

Example

ret = wc_AesCmacGenerate(mac, &macSz, msg, msgSz, key, keySz);
int wc_AesCmacGenerate(byte *out, word32 *outSz, const byte *in, word32 inSz, const byte *key, word32 keySz)
Single shot fuction for generating a CMAC.
See also
wc_AesCmacVerify

◆ wc_AesCmacVerify()

int wc_AesCmacVerify ( const byte *  check,
word32  checkSz,
const byte *  in,
word32  inSz,
const byte *  key,
word32  keySz 
)

Single shot fuction for validating a CMAC.

Returns
0 on success
Parameters
checkpointer to return the result
checkSzsize of checkout buffer
ininput data to process
inSzsize of input data
keykey pointer
keySzsize of the key pointer (16, 24 or 32)

Example

ret = wc_AesCmacVerify(mac, macSz, msg, msgSz, key, keySz);
int wc_AesCmacVerify(const byte *check, word32 checkSz, const byte *in, word32 inSz, const byte *key, word32 keySz)
Single shot fuction for validating a CMAC.
See also
wc_AesCmacGenerate

◆ wc_CMAC_Grow()

int wc_CMAC_Grow ( Cmac *  cmac,
const byte *  in,
int  inSz 
)

Only used with WOLFSSL_HASH_KEEP when hardware requires single-shot and the updates must be cached in memory.

Returns
0 on success
Parameters
ininput data to process
inSzsize of input data

Example

ret = wc_CMAC_Grow(cmac, in, inSz)
int wc_CMAC_Grow(Cmac *cmac, const byte *in, int inSz)
Only used with WOLFSSL_HASH_KEEP when hardware requires single-shot and the updates must be cached in...

◆ wc_CmacFinal()

int wc_CmacFinal ( Cmac *  cmac,
byte *  out,
word32 *  outSz 
)

Generate the final result using Cipher-based Message Authentication Code.

Returns
0 on success
Parameters
cmacpointer to the Cmac structure
outpointer to return the result
outSzpointer size of output (in/out)

Example

ret = wc_CmacFinal(cmac, out, &outSz);
int wc_CmacFinal(Cmac *cmac, byte *out, word32 *outSz)
Generate the final result using Cipher-based Message Authentication Code.
See also
wc_InitCmac
wc_CmacFinal

◆ wc_CmacUpdate()

int wc_CmacUpdate ( Cmac *  cmac,
const byte *  in,
word32  inSz 
)

Add Cipher-based Message Authentication Code input data.

Returns
0 on success
Parameters
cmacpointer to the Cmac structure
ininput data to process
inSzsize of input data

Example

ret = wc_CmacUpdate(cmac, in, inSz);
int wc_CmacUpdate(Cmac *cmac, const byte *in, word32 inSz)
Add Cipher-based Message Authentication Code input data.
See also
wc_InitCmac
wc_CmacFinal

◆ wc_InitCmac()

int wc_InitCmac ( Cmac *  cmac,
const byte *  key,
word32  keySz,
int  type,
void *  unused 
)

Initialize the Cmac structure with defaults.

Returns
0 on success
Parameters
cmacpointer to the Cmac structure
keykey pointer
keySzsize of the key pointer (16, 24 or 32)
typeAlways WC_CMAC_AES = 1
unusednot used, exists for potential future use around compatiblity

Example

Cmac cmac[1];
ret = wc_InitCmac(cmac, key, keySz, WC_CMAC_AES, NULL);
if (ret == 0) {
ret = wc_CmacUpdate(cmac, in, inSz);
}
if (ret == 0) {
ret = wc_CmacFinal(cmac, out, outSz);
}
int wc_InitCmac(Cmac *cmac, const byte *key, word32 keySz, int type, void *unused)
Initialize the Cmac structure with defaults.
See also
wc_InitCmac_ex
wc_CmacUpdate
wc_CmacFinal

◆ wc_InitCmac_ex()

int wc_InitCmac_ex ( Cmac *  cmac,
const byte *  key,
word32  keySz,
int  type,
void *  unused,
void *  heap,
int  devId 
)

Initialize the Cmac structure with defaults.

Returns
0 on success
Parameters
cmacpointer to the Cmac structure
keykey pointer
keySzsize of the key pointer (16, 24 or 32)
typeAlways WC_CMAC_AES = 1
unusednot used, exists for potential future use around compatiblity
heappointer to the heap hint used for dynamic allocation. Typically used with our static memory option. Can be NULL.
devIdID to use with async hardware. Set to INVALID_DEVID if not using async hardware.

Example

Cmac cmac[1];
ret = wc_InitCmac_ex(cmac, key, keySz, WC_CMAC_AES, NULL, NULL, INVALID_DEVID);
if (ret == 0) {
ret = wc_CmacUpdate(cmac, in, inSz);
}
if (ret == 0) {
ret = wc_CmacFinal(cmac, out, &outSz);
}
int wc_InitCmac_ex(Cmac *cmac, const byte *key, word32 keySz, int type, void *unused, void *heap, int devId)
Initialize the Cmac structure with defaults.
See also
wc_InitCmac_ex
wc_CmacUpdate
wc_CmacFinal