TrustCore SDK NanoCrypto API reference  version 7.0
aes_cmac.h
Go to the documentation of this file.
1 /*
2  * aes_cmac.h
3  *
4  * AES-CMAC Implementation
5  *
6  * Copyright 2019-2024 DigiCert, Inc. All Rights Reserved.
7  * Proprietary and Confidential Material.
8  *
9  */
19 /*------------------------------------------------------------------*/
20 
21 #ifndef __AES_CMAC_HEADER__
22 #define __AES_CMAC_HEADER__
23 
24 #include "../cap/capdecl.h"
25 
26 #ifdef __ENABLE_MOCANA_CRYPTO_INTERFACE__
27 #include "../crypto_interface/crypto_interface_aes_cmac_priv.h"
28 #endif
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
34 #define CMAC_RESULT_SIZE AES_BLOCK_SIZE
35 
36 typedef struct AES_OMAC_Ctx
37 {
38  ubyte currBlock[AES_BLOCK_SIZE];
39  /* bytes received -- we delay the processing until more bytes are
40  received or final is called */
41  ubyte pending[AES_BLOCK_SIZE] ;
42  /* length of bytes received above <= AES_BLOCK_SIZE */
43  ubyte pendingLen;
44 } AES_OMAC_Ctx;
45 
46 typedef struct AESCMAC_Ctx
47 {
48  aesCipherContext *pAesCtx;
49  AES_OMAC_Ctx omacCtx;
50  MocSymCtx pMocSymCtx;
51  ubyte enabled;
52 
53 } AESCMAC_Ctx;
54 
55 /*------------------------------------------------------------------*/
56 
57 /* Function prototypes */
58 /* AES CMAC -- cf RFC 4493 for explanations of parameters. */
59 /* http://www.ietf.org/rfc/rfc4493.txt */
60 
118 MOC_EXTERN MSTATUS AESCMAC_init(MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte *pKeyMaterial, sbyte4 keyLength, AESCMAC_Ctx *pCtx);
119 
169 MOC_EXTERN MSTATUS AESCMAC_update(MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte* pData, sbyte4 dataLength, AESCMAC_Ctx* pCtx);
170 
215 MOC_EXTERN MSTATUS AESCMAC_final(MOC_SYM(hwAccelDescr hwAccelCtx) ubyte cmac[CMAC_RESULT_SIZE], AESCMAC_Ctx* pCtx);
216 
240 MOC_EXTERN MSTATUS AESCMAC_clear(MOC_SYM(hwAccelDescr hwAccelCtx) AESCMAC_Ctx* pCtx);
241 
244 /* These functions are for future use */
245 MOC_EXTERN MSTATUS AESCMAC_initExt(MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte *pKeyMaterial, sbyte4 keyLength, AESCMAC_Ctx *pCtx, void *pExtCtx);
246 MOC_EXTERN MSTATUS AESCMAC_updateExt(MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte* pData, sbyte4 dataLength, AESCMAC_Ctx* pCtx, void *pExtCtx);
247 MOC_EXTERN MSTATUS AESCMAC_finalExt(MOC_SYM(hwAccelDescr hwAccelCtx) ubyte cmac[CMAC_RESULT_SIZE], AESCMAC_Ctx* pCtx, void *pExtCtx);
248 
249 /* reusable functions -- to be used internally by mocana only */
250 MOC_EXTERN MSTATUS AES_OMAC_init(AES_OMAC_Ctx* pOMACCtx);
251 MOC_EXTERN MSTATUS AES_OMAC_update(MOC_SYM(hwAccelDescr hwAccelCtx) aesCipherContext* pAESCtx, AES_OMAC_Ctx* pOMACCtx, const ubyte* data, sbyte4 dataLength);
252 MOC_EXTERN MSTATUS AES_OMAC_final( MOC_SYM(hwAccelDescr hwAccelCtx) aesCipherContext* pAESCtx, AES_OMAC_Ctx* pOMACCtx, ubyte cmac[CMAC_RESULT_SIZE]);
255 #ifdef __cplusplus
256 }
257 #endif
258 
259 #endif /* __AES_CMAC_HEADER__ */
260 
MOC_EXTERN MSTATUS AESCMAC_clear(MOC_SYM(hwAccelDescr hwAccelCtx) AESCMAC_Ctx *pCtx)
Clear an existing AES-CMAC context so it is ready for re-use.
MOC_EXTERN MSTATUS AESCMAC_update(MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte *pData, sbyte4 dataLength, AESCMAC_Ctx *pCtx)
Calcluate intermediate AES-CMAC digest value.
MOC_EXTERN MSTATUS AESCMAC_final(MOC_SYM(hwAccelDescr hwAccelCtx) ubyte cmac[CMAC_RESULT_SIZE], AESCMAC_Ctx *pCtx)
Calculate final CMAC digest value.
MOC_EXTERN MSTATUS AESCMAC_init(MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte *pKeyMaterial, sbyte4 keyLength, AESCMAC_Ctx *pCtx)
Initialize a context data structure for AES-CMAC hash and prepare the key schedule.