mbed TLS v2.13.0
poly1305.h
Go to the documentation of this file.
1 
15 /* Copyright (C) 2006-2018, Arm Limited (or its affiliates), All Rights Reserved.
16  * SPDX-License-Identifier: Apache-2.0
17  *
18  * Licensed under the Apache License, Version 2.0 (the "License"); you may
19  * not use this file except in compliance with the License.
20  * You may obtain a copy of the License at
21  *
22  * http://www.apache.org/licenses/LICENSE-2.0
23  *
24  * Unless required by applicable law or agreed to in writing, software
25  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
26  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27  * See the License for the specific language governing permissions and
28  * limitations under the License.
29  *
30  * This file is part of Mbed TLS (https://tls.mbed.org)
31  */
32 
33 #ifndef MBEDTLS_POLY1305_H
34 #define MBEDTLS_POLY1305_H
35 
36 #if !defined(MBEDTLS_CONFIG_FILE)
37 #include "mbedtls/config.h"
38 #else
39 #include MBEDTLS_CONFIG_FILE
40 #endif
41 
42 #include <stdint.h>
43 #include <stddef.h>
44 
45 #define MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA -0x0057
46 #define MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE -0x0059
47 #define MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED -0x005B
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52 
53 #if !defined(MBEDTLS_POLY1305_ALT)
54 
56 {
57  uint32_t r[4];
58  uint32_t s[4];
59  uint32_t acc[5];
60  uint8_t queue[16];
61  size_t queue_len;
62 }
64 
65 #else /* MBEDTLS_POLY1305_ALT */
66 #include "poly1305_alt.h"
67 #endif /* MBEDTLS_POLY1305_ALT */
68 
84 
91 
106  const unsigned char key[32] );
107 
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)
168 
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_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.