TrustCore SDK NanoCrypto API reference  version 7.0
aes_eax.h
Go to the documentation of this file.
1 /*
2  * aes_eax.h
3  *
4  * AES-EAX Implementation
5  *
6  * Copyright 2019-2024 DigiCert, Inc. All Rights Reserved.
7  * Proprietary and Confidential Material.
8  *
9  * The EAX mode of operation is not tied to the AES
10  * cipher, it can be used with any cipher, but this
11  * implementation does not parameterize the cipher
12  * used, since AES is only used for this mode currently.
13  * "Do the simplest thing that works".
14  *
15  */
16 
27 /*------------------------------------------------------------------*/
28 
29 #ifndef __AES_EAX_HEADER__
30 #define __AES_EAX_HEADER__
31 
32 #include "../cap/capdecl.h"
33 
34 #ifdef __ENABLE_MOCANA_CRYPTO_INTERFACE__
35 #include "../crypto_interface/crypto_interface_aes_eax_priv.h"
36 #endif
37 
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
41 
42 
43 typedef struct AES_EAX_Ctx
44 {
45  AES_CTR_Ctx *pAesCTRCtx; /* used for encryption */
46  AES_OMAC_Ctx headerOMAC; /* tweak = 1 */
47  AES_OMAC_Ctx cipherOMAC; /* tweak = 2 */
48  ubyte N[AES_BLOCK_SIZE]; /* OMAC of the nonce */
49  MocSymCtx pMocSymCtx;
50  ubyte enabled;
51 
52 } AES_EAX_Ctx;
53 
54 /*------------------------------------------------------------------*/
55 
74 MOC_EXTERN MSTATUS AES_EAX_init(MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte* keyMaterial,
75  ubyte4 keyLength,
76  const ubyte* nonce,
77  ubyte4 nonceLength,
78  AES_EAX_Ctx* pCtx);
79 
95 MOC_EXTERN MSTATUS AES_EAX_updateHeader(MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte* headerData,
96  sbyte4 dataLength,
97  AES_EAX_Ctx* pCtx);
98 
113 MOC_EXTERN MSTATUS AES_EAX_encryptMessage(MOC_SYM(hwAccelDescr hwAccelCtx) ubyte* msgData,
114  sbyte4 msgLen, AES_EAX_Ctx* pCtx);
115 
134 MOC_EXTERN MSTATUS AES_EAX_decryptMessage(MOC_SYM(hwAccelDescr hwAccelCtx) ubyte* msgData,
135  sbyte4 msgLen, AES_EAX_Ctx* pCtx);
136 
157 MOC_EXTERN MSTATUS AES_EAX_final(MOC_SYM(hwAccelDescr hwAccelCtx) ubyte tag[/*tagLen*/],
158  sbyte4 tagLen, AES_EAX_Ctx* pCtx);
159 
182 MOC_EXTERN MSTATUS AES_EAX_generateTag( MOC_SYM(hwAccelDescr hwAccelCtx)
183  const ubyte* cipherText, sbyte4 cipherLen,
184  const ubyte* header, sbyte4 headerLen,
185  ubyte tag[/*tagLen*/], sbyte4 tagLen,
186  AES_EAX_Ctx* pCtx);
187 
207 MOC_EXTERN MSTATUS AES_EAX_getPlainText( MOC_SYM(hwAccelDescr hwAccelCtx)
208  ubyte* cipherText, sbyte4 cipherLen,
209  AES_EAX_Ctx* pCtx);
210 
223 MOC_EXTERN MSTATUS AES_EAX_clear(MOC_SYM(hwAccelDescr hwAccelCtx) AES_EAX_Ctx* pCtx);
224 
225 #ifdef __cplusplus
226 }
227 #endif
228 
229 #endif /* __AES_EAX_HEADER__ */
230 
MOC_EXTERN MSTATUS AES_EAX_final(MOC_SYM(hwAccelDescr hwAccelCtx) ubyte tag[], sbyte4 tagLen, AES_EAX_Ctx *pCtx)
Finalizes an AES-EAX encryption or decryption and outputs the tag for authentication.
MOC_EXTERN MSTATUS AES_EAX_encryptMessage(MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *msgData, sbyte4 msgLen, AES_EAX_Ctx *pCtx)
Encrypts in-place a buffer of data with an initialized AES-EAX context.
MOC_EXTERN MSTATUS AES_EAX_generateTag(MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte *cipherText, sbyte4 cipherLen, const ubyte *header, sbyte4 headerLen, ubyte tag[], sbyte4 tagLen, AES_EAX_Ctx *pCtx)
Generates an AES-EAX tag from the ciphertext and header.
MOC_EXTERN MSTATUS AES_EAX_getPlainText(MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *cipherText, sbyte4 cipherLen, AES_EAX_Ctx *pCtx)
Decrypts ciphertext in-place from an initialized AES-EAX context.
MOC_EXTERN MSTATUS AES_EAX_decryptMessage(MOC_SYM(hwAccelDescr hwAccelCtx) ubyte *msgData, sbyte4 msgLen, AES_EAX_Ctx *pCtx)
Decrypts in-place a buffer of data with an initialized AES-EAX context.
MOC_EXTERN MSTATUS AES_EAX_clear(MOC_SYM(hwAccelDescr hwAccelCtx) AES_EAX_Ctx *pCtx)
Zeros and frees memory allocated within an AES-EAX context.
MOC_EXTERN MSTATUS AES_EAX_init(MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte *keyMaterial, ubyte4 keyLength, const ubyte *nonce, ubyte4 nonceLength, AES_EAX_Ctx *pCtx)
Initializes an AES-EAX context with a key and nonce value.
MOC_EXTERN MSTATUS AES_EAX_updateHeader(MOC_SYM(hwAccelDescr hwAccelCtx) const ubyte *headerData, sbyte4 dataLength, AES_EAX_Ctx *pCtx)
Updates the header portion of an AES-EAX context with a buffer of data.