Mbed TLS v2.28.5
poly1305.h
Go to the documentation of this file.
1 
15 /*
16  * Copyright The Mbed TLS Contributors
17  * SPDX-License-Identifier: Apache-2.0
18  *
19  * Licensed under the Apache License, Version 2.0 (the "License"); you may
20  * not use this file except in compliance with the License.
21  * You may obtain a copy of the License at
22  *
23  * http://www.apache.org/licenses/LICENSE-2.0
24  *
25  * Unless required by applicable law or agreed to in writing, software
26  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
27  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28  * See the License for the specific language governing permissions and
29  * limitations under the License.
30  */
31 
32 #ifndef MBEDTLS_POLY1305_H
33 #define MBEDTLS_POLY1305_H
34 
35 #if !defined(MBEDTLS_CONFIG_FILE)
36 #include "mbedtls/config.h"
37 #else
38 #include MBEDTLS_CONFIG_FILE
39 #endif
40 
41 #include <stdint.h>
42 #include <stddef.h>
43 
45 #define MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA -0x0057
46 
47 /* MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE is deprecated and should not be
48  * used. */
50 #define MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE -0x0059
51 
52 /* MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED is deprecated and should not be used.
53  */
55 #define MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED -0x005B
56 
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60 
61 #if !defined(MBEDTLS_POLY1305_ALT)
62 
63 typedef struct mbedtls_poly1305_context {
64  uint32_t r[4];
65  uint32_t s[4];
66  uint32_t acc[5];
67  uint8_t queue[16];
68  size_t queue_len;
69 }
71 
72 #else /* MBEDTLS_POLY1305_ALT */
73 #include "poly1305_alt.h"
74 #endif /* MBEDTLS_POLY1305_ALT */
75 
92 
102 
117  const unsigned char key[32]);
118 
138  const unsigned char *input,
139  size_t ilen);
140 
154  unsigned char mac[16]);
155 
174 int mbedtls_poly1305_mac(const unsigned char key[32],
175  const unsigned char *input,
176  size_t ilen,
177  unsigned char mac[16]);
178 
179 #if defined(MBEDTLS_SELF_TEST)
180 
186 int mbedtls_poly1305_self_test(int verbose);
187 #endif /* MBEDTLS_SELF_TEST */
188 
189 #ifdef __cplusplus
190 }
191 #endif
192 
193 #endif /* MBEDTLS_POLY1305_H */
Configuration options (set of defines)
int mbedtls_poly1305_self_test(int verbose)
The Poly1305 checkup routine.
struct mbedtls_poly1305_context mbedtls_poly1305_context
int mbedtls_poly1305_starts(mbedtls_poly1305_context *ctx, const unsigned char key[32])
This function sets the one-time authentication key.
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.
void mbedtls_poly1305_init(mbedtls_poly1305_context *ctx)
This function initializes the specified Poly1305 context.
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_free(mbedtls_poly1305_context *ctx)
This function releases and clears the specified Poly1305 context.