Leancrypto 1.7.2
Post-Quantum Cryptographic Library
Data Structures | Macros | Functions
lc_poly1305.h File Reference
#include "ext_headers.h"
+ Include dependency graph for lc_poly1305.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  lc_poly1305_context
 

Macros

#define LC_POLY1305_STATE_SIZE   (sizeof(struct lc_poly1305_context))
 
#define LC_POLY1305_TAGSIZE   (16)
 
#define LC_POLY1305_KEYSIZE   (32)
 

Functions

void lc_poly1305_init (struct lc_poly1305_context *ctx, const uint8_t key[LC_POLY1305_KEYSIZE])
 Initialize the Poly1305 algorithm with a key. More...
 
void lc_poly1305_update (struct lc_poly1305_context *ctx, const uint8_t *m, size_t bytes)
 Add data to the Poly1305 context to digest it. More...
 
void lc_poly1305_final (struct lc_poly1305_context *ctx, uint8_t mac[LC_POLY1305_TAGSIZE])
 Calculate the Poly1305 keyed message digest from the state. More...
 

Data Structure Documentation

◆ lc_poly1305_context

struct lc_poly1305_context

Definition at line 33 of file lc_poly1305.h.

Data Fields
size_t aligner
uint8_t opaque[136]

Macro Definition Documentation

◆ LC_POLY1305_KEYSIZE

#define LC_POLY1305_KEYSIZE   (32)

Definition at line 40 of file lc_poly1305.h.

◆ LC_POLY1305_STATE_SIZE

#define LC_POLY1305_STATE_SIZE   (sizeof(struct lc_poly1305_context))

Definition at line 38 of file lc_poly1305.h.

◆ LC_POLY1305_TAGSIZE

#define LC_POLY1305_TAGSIZE   (16)

Definition at line 39 of file lc_poly1305.h.

Function Documentation

◆ lc_poly1305_final()

void lc_poly1305_final ( struct lc_poly1305_context *  ctx,
uint8_t  mac[LC_POLY1305_TAGSIZE] 
)

Calculate the Poly1305 keyed message digest from the state.

Note
With the call to this API, the context may not be needed any more and should be zeroized at this point to prevent leaving potentially sensitive data in memory.
Parameters
[in]ctxPoly1305 context holding the state
[in]macbuffer which receives the 16 byte authenticator.

◆ lc_poly1305_init()

void lc_poly1305_init ( struct lc_poly1305_context *  ctx,
const uint8_t  key[LC_POLY1305_KEYSIZE] 
)

Initialize the Poly1305 algorithm with a key.

Note
The ctx can be allocated either on heap or stack. Once done, it should be zeroized to provide a clean slate.
Warning
This algorithm is intended only in conjunction with ChaCha20 to form ChaCha20-Poly1305. For some use cases (like SSH), a separate access to the algorithm is needed and thus provided with this API.
Parameters
[in]ctxPoly1305 context holding the state
[in]key32 byte key that is only used for this message and is discarded immediately after

◆ lc_poly1305_update()

void lc_poly1305_update ( struct lc_poly1305_context *  ctx,
const uint8_t *  m,
size_t  bytes 
)

Add data to the Poly1305 context to digest it.

Parameters
[in]ctxPoly1305 context holding the state
[in]mpointer to the message fragment to be processed
[in]byteslength of the message fragment in bytes