OPTIGA Trust M  1.1.0
C++ library for Optiga Trust M Chip Security Controller
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
47 /* MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE is deprecated and should not be
48  * used. */
49 #define MBEDTLS_ERR_POLY1305_FEATURE_UNAVAILABLE -0x0059
51 /* MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED is deprecated and should not be used.
52  */
53 #define MBEDTLS_ERR_POLY1305_HW_ACCEL_FAILED -0x005B
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 #if !defined(MBEDTLS_POLY1305_ALT)
60 
62 {
63  uint32_t r[4];
64  uint32_t s[4];
65  uint32_t acc[5];
66  uint8_t queue[16];
67  size_t queue_len;
68 }
70 
71 #else /* MBEDTLS_POLY1305_ALT */
72 #include "poly1305_alt.h"
73 #endif /* MBEDTLS_POLY1305_ALT */
74 
91 
101 
116  const unsigned char key[32] );
117 
137  const unsigned char *input,
138  size_t ilen );
139 
153  unsigned char mac[16] );
154 
173 int mbedtls_poly1305_mac( const unsigned char key[32],
174  const unsigned char *input,
175  size_t ilen,
176  unsigned char mac[16] );
177 
178 #if defined(MBEDTLS_SELF_TEST)
179 
185 int mbedtls_poly1305_self_test( int verbose );
186 #endif /* MBEDTLS_SELF_TEST */
187 
188 #ifdef __cplusplus
189 }
190 #endif
191 
192 #endif /* MBEDTLS_POLY1305_H */
size_t queue_len
Definition: poly1305.h:67
Definition: poly1305.h:61
Configuration options (set of defines)
uint8_t queue[16]
Definition: poly1305.h:66
struct mbedtls_poly1305_context mbedtls_poly1305_context
uint32_t r[4]
Definition: poly1305.h:63
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.
uint32_t s[4]
Definition: poly1305.h:64
uint32_t acc[5]
Definition: poly1305.h:65
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.