TrustCore SDK NanoCrypto API reference  version 7.0
poly1305.h
Go to the documentation of this file.
1 /*
2  * poly1305.h
3  *
4  * Implementation of the POLY1305 MAC
5  *
6  * Copyright 2019-2024 DigiCert, Inc. All Rights Reserved.
7  * Proprietary and Confidential Material.
8  *
9  * Adapted from the public domain implementation in
10  * <https://github.com/floodyberry/poly1305-donna>
11  */
12 
26 #ifndef __POLY1305_HEADER__
27 #define __POLY1305_HEADER__
28 
29 #include "../cap/capdecl.h"
30 
31 #if (defined(__ENABLE_MOCANA_CRYPTO_INTERFACE__))
32 #include "../crypto_interface/crypto_interface_poly1305_priv.h"
33 #endif
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #define MOC_POLY1305_STATE_INIT 0xC0DED00D
40 #define MOC_POLY1305_STATE_UPDATE 0xC0DED00E
41 #define MOC_POLY1305_STATE_FINAL 0xC0DED00F
42 
43 typedef struct Poly1305Ctx
44 {
45  ubyte4 aligner;
46  ubyte opaque[136];
47  ubyte4 state;
48 
49  MocSymCtx pMocSymCtx;
50  ubyte enabled;
51 } Poly1305Ctx;
52 
53 
74 MOC_EXTERN MSTATUS Poly1305Init(MOC_HASH(hwAccelDescr hwAccelCtx) Poly1305Ctx *ctx, const ubyte key[32]);
75 
97 MOC_EXTERN MSTATUS Poly1305Update(MOC_HASH(hwAccelDescr hwAccelCtx) Poly1305Ctx *ctx, const ubyte *m, ubyte4 bytes);
98 
118 MOC_EXTERN MSTATUS Poly1305Final(MOC_HASH(hwAccelDescr hwAccelCtx) Poly1305Ctx *ctx, ubyte mac[16]);
119 
120 
142 MOC_EXTERN MSTATUS Poly1305_completeDigest(MOC_HASH(hwAccelDescr hwAccelCtx) ubyte mac[16], const ubyte *m, ubyte4 bytes,
143  const ubyte key[32]);
144 
145 #ifdef __cplusplus
146 }
147 #endif
148 
149 #endif /* POLY1305_DONNA_H */
150 
MOC_EXTERN MSTATUS Poly1305_completeDigest(MOC_HASH(hwAccelDescr hwAccelCtx) ubyte mac[16], const ubyte *m, ubyte4 bytes, const ubyte key[32])
One shot API that will compute a poly1305 mac context free.
MOC_EXTERN MSTATUS Poly1305Init(MOC_HASH(hwAccelDescr hwAccelCtx) Poly1305Ctx *ctx, const ubyte key[32])
Initializes a Poly1305Ctx with a 32 byte (256 bit) key.
MOC_EXTERN MSTATUS Poly1305Update(MOC_HASH(hwAccelDescr hwAccelCtx) Poly1305Ctx *ctx, const ubyte *m, ubyte4 bytes)
Updates a Poly1305Ctx with message data.
MOC_EXTERN MSTATUS Poly1305Final(MOC_HASH(hwAccelDescr hwAccelCtx) Poly1305Ctx *ctx, ubyte mac[16])
Finalizes a Poly1305Ctx and computes the resulting mac.