mbed TLS v3.1.0
|
This file contains Poly1305 definitions and functions. More...
#include "mbedtls/private_access.h"
#include "mbedtls/build_info.h"
#include <stdint.h>
#include <stddef.h>
#include "poly1305_alt.h"
Go to the source code of this file.
Macros | |
#define | MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA -0x0057 |
Functions | |
void | mbedtls_poly1305_init (mbedtls_poly1305_context *ctx) |
This function initializes the specified Poly1305 context. More... | |
void | mbedtls_poly1305_free (mbedtls_poly1305_context *ctx) |
This function releases and clears the specified Poly1305 context. More... | |
int | mbedtls_poly1305_starts (mbedtls_poly1305_context *ctx, const unsigned char key[32]) |
This function sets the one-time authentication key. More... | |
int | mbedtls_poly1305_update (mbedtls_poly1305_context *ctx, const unsigned char *input, size_t ilen) |
This functions feeds an input buffer into an ongoing Poly1305 computation. More... | |
int | mbedtls_poly1305_finish (mbedtls_poly1305_context *ctx, unsigned char mac[16]) |
This function generates the Poly1305 Message Authentication Code (MAC). More... | |
int | mbedtls_poly1305_mac (const unsigned char key[32], const unsigned char *input, size_t ilen, unsigned char mac[16]) |
This function calculates the Poly1305 MAC of the input buffer with the provided key. More... | |
int | mbedtls_poly1305_self_test (int verbose) |
The Poly1305 checkup routine. More... | |
This file contains Poly1305 definitions and functions.
Poly1305 is a one-time message authenticator that can be used to authenticate messages. Poly1305-AES was created by Daniel Bernstein https://cr.yp.to/mac/poly1305-20050329.pdf The generic Poly1305 algorithm (not tied to AES) was also standardized in RFC 7539.
Definition in file poly1305.h.
#define MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA -0x0057 |
Invalid input parameter(s).
Definition at line 42 of file poly1305.h.
int mbedtls_poly1305_finish | ( | mbedtls_poly1305_context * | ctx, |
unsigned char | mac[16] | ||
) |
This function generates the Poly1305 Message Authentication Code (MAC).
ctx | The Poly1305 context to use for the Poly1305 operation. This must be initialized and bound to a key. |
mac | The buffer to where the MAC is written. This must be a writable buffer of length 16 Bytes. |
0
on success. void mbedtls_poly1305_free | ( | mbedtls_poly1305_context * | ctx | ) |
This function releases and clears the specified Poly1305 context.
ctx | The Poly1305 context to clear. This may be NULL , in which case this function is a no-op. If it is not NULL , it must point to an initialized Poly1305 context. |
void mbedtls_poly1305_init | ( | mbedtls_poly1305_context * | ctx | ) |
This function initializes the specified Poly1305 context.
It must be the first API called before using the context.
It is usually followed by a call to mbedtls_poly1305_starts()
, then one or more calls to mbedtls_poly1305_update()
, then one call to mbedtls_poly1305_finish()
, then finally mbedtls_poly1305_free()
.
ctx | The Poly1305 context to initialize. This must not be NULL . |
int mbedtls_poly1305_mac | ( | const unsigned char | key[32], |
const unsigned char * | input, | ||
size_t | ilen, | ||
unsigned char | mac[16] | ||
) |
This function calculates the Poly1305 MAC of the input buffer with the provided key.
key | The buffer containing the 32 Byte (256 Bit) key. |
ilen | The length of the input data in Bytes. Any value is accepted. |
input | The buffer holding the input data. This pointer can be NULL if ilen == 0 . |
mac | The buffer to where the MAC is written. This must be a writable buffer of length 16 Bytes. |
0
on success. int mbedtls_poly1305_self_test | ( | int | verbose | ) |
The Poly1305 checkup routine.
0
on success. 1
on failure. int mbedtls_poly1305_starts | ( | mbedtls_poly1305_context * | ctx, |
const unsigned char | key[32] | ||
) |
This function sets the one-time authentication key.
ctx | The Poly1305 context to which the key should be bound. This must be initialized. |
key | The buffer containing the 32 Byte (256 Bit) key. |
0
on success. int mbedtls_poly1305_update | ( | mbedtls_poly1305_context * | ctx, |
const unsigned char * | input, | ||
size_t | ilen | ||
) |
This functions feeds an input buffer into an ongoing Poly1305 computation.
It is called between mbedtls_cipher_poly1305_starts()
and mbedtls_cipher_poly1305_finish()
. It can be called repeatedly to process a stream of data.
ctx | The Poly1305 context to use for the Poly1305 operation. This must be initialized and bound to a key. |
ilen | The length of the input data in Bytes. Any value is accepted. |
input | The buffer holding the input data. This pointer can be NULL if ilen == 0 . |
0
on success.