mbed TLS v2.14.1
gcm.h
Go to the documentation of this file.
1 
14 /*
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_GCM_H
34 #define MBEDTLS_GCM_H
35 
36 #include "cipher.h"
37 
38 #include <stdint.h>
39 
40 #define MBEDTLS_GCM_ENCRYPT 1
41 #define MBEDTLS_GCM_DECRYPT 0
42 
43 #define MBEDTLS_ERR_GCM_AUTH_FAILED -0x0012
45 /* MBEDTLS_ERR_GCM_HW_ACCEL_FAILED is deprecated and should not be used. */
46 #define MBEDTLS_ERR_GCM_HW_ACCEL_FAILED -0x0013
48 #define MBEDTLS_ERR_GCM_BAD_INPUT -0x0014
50 #ifdef __cplusplus
51 extern "C" {
52 #endif
53 
54 #if !defined(MBEDTLS_GCM_ALT)
55 
59 typedef struct mbedtls_gcm_context
60 {
62  uint64_t HL[16];
63  uint64_t HH[16];
64  uint64_t len;
65  uint64_t add_len;
66  unsigned char base_ectr[16];
67  unsigned char y[16];
68  unsigned char buf[16];
69  int mode;
72 }
74 
75 #else /* !MBEDTLS_GCM_ALT */
76 #include "gcm_alt.h"
77 #endif /* !MBEDTLS_GCM_ALT */
78 
91 
108  mbedtls_cipher_id_t cipher,
109  const unsigned char *key,
110  unsigned int keybits );
111 
157  int mode,
158  size_t length,
159  const unsigned char *iv,
160  size_t iv_len,
161  const unsigned char *add,
162  size_t add_len,
163  const unsigned char *input,
164  unsigned char *output,
165  size_t tag_len,
166  unsigned char *tag );
167 
195  size_t length,
196  const unsigned char *iv,
197  size_t iv_len,
198  const unsigned char *add,
199  size_t add_len,
200  const unsigned char *tag,
201  size_t tag_len,
202  const unsigned char *input,
203  unsigned char *output );
204 
222  int mode,
223  const unsigned char *iv,
224  size_t iv_len,
225  const unsigned char *add,
226  size_t add_len );
227 
250  size_t length,
251  const unsigned char *input,
252  unsigned char *output );
253 
269  unsigned char *tag,
270  size_t tag_len );
271 
279 
286 int mbedtls_gcm_self_test( int verbose );
287 
288 #ifdef __cplusplus
289 }
290 #endif
291 
292 
293 #endif /* gcm.h */