mbed TLS v2.23.0: poly1305.h Source File

mbed TLS v2.23.0

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
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 * This file is part of Mbed TLS (https://tls.mbed.org)
32 */
33
34 #ifndef MBEDTLS_POLY1305_H
35 #define MBEDTLS_POLY1305_H
36
37 #if !defined(MBEDTLS_CONFIG_FILE)
38 #include "mbedtls/config.h"
39 #else
40 #include MBEDTLS_CONFIG_FILE
41 #endif
42
43 #include <stdint.h>
44 #include <stddef.h>
45
46 #define MBEDTLS_ERR_POLY1305_BAD_INPUT_DATA -0x0057
48 /* MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE is deprecated and should not be
49 * used. */
50 #define MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE -0x0059
52 /* MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED is deprecated and should not be used.
53 */
54 #define MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED -0x005B
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59
60 #if !defined(MBEDTLS_POLY1305_ALT)
61
62 typedef struct mbedtls_poly1305_context
63 {
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 }
70 mbedtls_poly1305_context;
71
72 #else /* MBEDTLS_POLY1305_ALT */
73 #include "poly1305_alt.h"
74 #endif /* MBEDTLS_POLY1305_ALT */
75
91 void mbedtls_poly1305_init( mbedtls_poly1305_context *ctx );
92
101 void mbedtls_poly1305_free( mbedtls_poly1305_context *ctx );
102
116 int mbedtls_poly1305_starts( mbedtls_poly1305_context *ctx,
117 const unsigned char key[32] );
118
137 int mbedtls_poly1305_update( mbedtls_poly1305_context *ctx,
138 const unsigned char *input,
139 size_t ilen );
140
153 int mbedtls_poly1305_finish( mbedtls_poly1305_context *ctx,
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 */
mbedtls_poly1305_self_test
int mbedtls_poly1305_self_test(int verbose)
The Poly1305 checkup routine.
mbedtls_poly1305_finish
int mbedtls_poly1305_finish(mbedtls_poly1305_context *ctx, unsigned char mac[16])
This function generates the Poly1305 Message Authentication Code (MAC).
mbedtls_poly1305_mac
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.
mbedtls_poly1305_context
struct mbedtls_poly1305_context mbedtls_poly1305_context
mbedtls_poly1305_context::queue_len
size_t queue_len
Definition: poly1305.h:68
mbedtls_poly1305_init
void mbedtls_poly1305_init(mbedtls_poly1305_context *ctx)
This function initializes the specified Poly1305 context.
mbedtls_poly1305_starts
int mbedtls_poly1305_starts(mbedtls_poly1305_context *ctx, const unsigned char key[32])
This function sets the one-time authentication key.
mbedtls_poly1305_context::acc
uint32_t acc[5]
Definition: poly1305.h:66
mbedtls_poly1305_context::r
uint32_t r[4]
Definition: poly1305.h:64
mbedtls_poly1305_update
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.
config.h
Configuration options (set of defines)
mbedtls_poly1305_free
void mbedtls_poly1305_free(mbedtls_poly1305_context *ctx)
This function releases and clears the specified Poly1305 context.
mbedtls_poly1305_context::s
uint32_t s[4]
Definition: poly1305.h:65
mbedtls_poly1305_context
Definition: poly1305.h:63
mbedtls_poly1305_context::queue
uint8_t queue[16]
Definition: poly1305.h:67