Mbed TLS v2.28.9
poly1305.h
Go to the documentation of this file.
1 
15 /*
16  * Copyright The Mbed TLS Contributors
17  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
18  */
19 
20 #ifndef MBEDTLS_POLY1305_H
21 #define MBEDTLS_POLY1305_H
22 
23 #if !defined(MBEDTLS_CONFIG_FILE)
24 #include "mbedtls/config.h"
25 #else
26 #include MBEDTLS_CONFIG_FILE
27 #endif
28 
29 #include <stdint.h>
30 #include <stddef.h>
31 
33 #define MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA -0x0057
34 
35 /* MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE is deprecated and should not be
36  * used. */
38 #define MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE -0x0059
39 
40 /* MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED is deprecated and should not be used.
41  */
43 #define MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED -0x005B
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 
49 #if !defined(MBEDTLS_POLY1305_ALT)
50 
51 typedef struct mbedtls_poly1305_context {
52  uint32_t r[4];
53  uint32_t s[4];
54  uint32_t acc[5];
55  uint8_t queue[16];
56  size_t queue_len;
57 }
59 
60 #else /* MBEDTLS_POLY1305_ALT */
61 #include "poly1305_alt.h"
62 #endif /* MBEDTLS_POLY1305_ALT */
63 
80 
90 
105  const unsigned char key[32]);
106 
126  const unsigned char *input,
127  size_t ilen);
128 
142  unsigned char mac[16]);
143 
162 int mbedtls_poly1305_mac(const unsigned char key[32],
163  const unsigned char *input,
164  size_t ilen,
165  unsigned char mac[16]);
166 
167 #if defined(MBEDTLS_SELF_TEST)
174 int mbedtls_poly1305_self_test(int verbose);
175 #endif /* MBEDTLS_SELF_TEST */
176 
177 #ifdef __cplusplus
178 }
179 #endif
180 
181 #endif /* MBEDTLS_POLY1305_H */
Configuration options (set of defines)
struct mbedtls_poly1305_context mbedtls_poly1305_context
int mbedtls_poly1305_self_test(int verbose)
The Poly1305 checkup routine.
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.
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.
int mbedtls_poly1305_finish(mbedtls_poly1305_context *ctx, unsigned char mac[16])
This function generates the Poly1305 Message Authentication Code (MAC).
void mbedtls_poly1305_init(mbedtls_poly1305_context *ctx)
This function initializes the specified Poly1305 context.
int mbedtls_poly1305_starts(mbedtls_poly1305_context *ctx, const unsigned char key[32])
This function sets the one-time authentication key.
void mbedtls_poly1305_free(mbedtls_poly1305_context *ctx)
This function releases and clears the specified Poly1305 context.