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_CmacFinalNoFree (Cmac *cmac, byte *out, word32 *outSz)
 Generate the final result using Cipher-based Message Authentication Code, deferring context cleanup. More...
 
int wc_CmacFinal (Cmac *cmac, byte *out, word32 *outSz)
 Generate the final result using Cipher-based Message Authentication Code, and clean up the context with wc_CmacFree(). More...
 
int wc_CmacFree (Cmac *cmac)
 Clean up allocations in a CMAC context. More...
 
int wc_AesCmacGenerate (byte *out, word32 *outSz, const byte *in, word32 inSz, const byte *key, word32 keySz)
 Single shot function 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 function 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 function 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 function 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 function 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 function 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, and clean up the context with wc_CmacFree().

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, and clean up the context wi...
See also
wc_InitCmac
wc_CmacFinalNoFree
wc_CmacFinalNoFree
wc_CmacFree

◆ wc_CmacFinalNoFree()

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

Generate the final result using Cipher-based Message Authentication Code, deferring context cleanup.

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

Example

ret = wc_CmacFinalNoFree(cmac, out, &outSz);
(void)wc_CmacFree(cmac);
int wc_CmacFinalNoFree(Cmac *cmac, byte *out, word32 *outSz)
Generate the final result using Cipher-based Message Authentication Code, deferring context cleanup.
int wc_CmacFree(Cmac *cmac)
Clean up allocations in a CMAC context.
See also
wc_InitCmac
wc_CmacFinal
wc_CmacFinalNoFree
wc_CmacFree

◆ wc_CmacFree()

int wc_CmacFree ( Cmac *  cmac)

Clean up allocations in a CMAC context.

Returns
0 on success
Parameters
cmacpointer to the Cmac structure

Example

ret = wc_CmacFinalNoFree(cmac, out, &outSz);
(void)wc_CmacFree(cmac);
See also
wc_InitCmac
wc_CmacFinalNoFree
wc_CmacFinal
wc_CmacFree

◆ 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_CmacFinalNoFree
wc_CmacFree

◆ 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 compatibility

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_CmacFinalNoFree
wc_CmacFree

◆ 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 compatibility
heappointer to the heap hint used for dynamic allocation. Typically used with our static memory option. Can be NULL.
devIdID to use with crypto callbacks or async hardware. Set to INVALID_DEVID (-2) if not used

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
wc_CmacFinalNoFree
wc_CmacFree