mbed TLS v2.16.7
poly1305.h
Go to the documentation of this file.
1 
15 /*
16  * Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved.
17  * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
18  *
19  * This file is provided under the Apache License 2.0, or the
20  * GNU General Public License v2.0 or later.
21  *
22  * **********
23  * Apache License 2.0:
24  *
25  * Licensed under the Apache License, Version 2.0 (the "License"); you may
26  * not use this file except in compliance with the License.
27  * You may obtain a copy of the License at
28  *
29  * http://www.apache.org/licenses/LICENSE-2.0
30  *
31  * Unless required by applicable law or agreed to in writing, software
32  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
33  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34  * See the License for the specific language governing permissions and
35  * limitations under the License.
36  *
37  * **********
38  *
39  * **********
40  * GNU General Public License v2.0 or later:
41  *
42  * This program is free software; you can redistribute it and/or modify
43  * it under the terms of the GNU General Public License as published by
44  * the Free Software Foundation; either version 2 of the License, or
45  * (at your option) any later version.
46  *
47  * This program is distributed in the hope that it will be useful,
48  * but WITHOUT ANY WARRANTY; without even the implied warranty of
49  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50  * GNU General Public License for more details.
51  *
52  * You should have received a copy of the GNU General Public License along
53  * with this program; if not, write to the Free Software Foundation, Inc.,
54  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
55  *
56  * **********
57  *
58  * This file is part of Mbed TLS (https://tls.mbed.org)
59  */
60 
61 #ifndef MBEDTLS_POLY1305_H
62 #define MBEDTLS_POLY1305_H
63 
64 #if !defined(MBEDTLS_CONFIG_FILE)
65 #include "config.h"
66 #else
67 #include MBEDTLS_CONFIG_FILE
68 #endif
69 
70 #include <stdint.h>
71 #include <stddef.h>
72 
73 #define MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA -0x0057
75 /* MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE is deprecated and should not be
76  * used. */
77 #define MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE -0x0059
79 /* MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED is deprecated and should not be used.
80  */
81 #define MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED -0x005B
83 #ifdef __cplusplus
84 extern "C" {
85 #endif
86 
87 #if !defined(MBEDTLS_POLY1305_ALT)
88 
90 {
91  uint32_t r[4];
92  uint32_t s[4];
93  uint32_t acc[5];
94  uint8_t queue[16];
95  size_t queue_len;
96 }
98 
99 #else /* MBEDTLS_POLY1305_ALT */
100 #include "poly1305_alt.h"
101 #endif /* MBEDTLS_POLY1305_ALT */
102 
119 
129 
144  const unsigned char key[32] );
145 
165  const unsigned char *input,
166  size_t ilen );
167 
181  unsigned char mac[16] );
182 
201 int mbedtls_poly1305_mac( const unsigned char key[32],
202  const unsigned char *input,
203  size_t ilen,
204  unsigned char mac[16] );
205 
206 #if defined(MBEDTLS_SELF_TEST)
207 
213 int mbedtls_poly1305_self_test( int verbose );
214 #endif /* MBEDTLS_SELF_TEST */
215 
216 #ifdef __cplusplus
217 }
218 #endif
219 
220 #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.