ReactOS 0.4.16-dev-297-gc569aee
gcm.h
Go to the documentation of this file.
1
14/*
15 * Copyright The Mbed TLS Contributors
16 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
17 *
18 * This file is provided under the Apache License 2.0, or the
19 * GNU General Public License v2.0 or later.
20 *
21 * **********
22 * Apache License 2.0:
23 *
24 * Licensed under the Apache License, Version 2.0 (the "License"); you may
25 * not use this file except in compliance with the License.
26 * You may obtain a copy of the License at
27 *
28 * http://www.apache.org/licenses/LICENSE-2.0
29 *
30 * Unless required by applicable law or agreed to in writing, software
31 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
32 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
33 * See the License for the specific language governing permissions and
34 * limitations under the License.
35 *
36 * **********
37 *
38 * **********
39 * GNU General Public License v2.0 or later:
40 *
41 * This program is free software; you can redistribute it and/or modify
42 * it under the terms of the GNU General Public License as published by
43 * the Free Software Foundation; either version 2 of the License, or
44 * (at your option) any later version.
45 *
46 * This program is distributed in the hope that it will be useful,
47 * but WITHOUT ANY WARRANTY; without even the implied warranty of
48 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
49 * GNU General Public License for more details.
50 *
51 * You should have received a copy of the GNU General Public License along
52 * with this program; if not, write to the Free Software Foundation, Inc.,
53 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
54 *
55 * **********
56 */
57
58#ifndef MBEDTLS_GCM_H
59#define MBEDTLS_GCM_H
60
61#if !defined(MBEDTLS_CONFIG_FILE)
62#include "config.h"
63#else
64#include MBEDTLS_CONFIG_FILE
65#endif
66
67#include "cipher.h"
68
69#include <stdint.h>
70
71#define MBEDTLS_GCM_ENCRYPT 1
72#define MBEDTLS_GCM_DECRYPT 0
73
74#define MBEDTLS_ERR_GCM_AUTH_FAILED -0x0012
76/* MBEDTLS_ERR_GCM_HW_ACCEL_FAILED is deprecated and should not be used. */
77#define MBEDTLS_ERR_GCM_HW_ACCEL_FAILED -0x0013
79#define MBEDTLS_ERR_GCM_BAD_INPUT -0x0014
81#ifdef __cplusplus
82extern "C" {
83#endif
84
85#if !defined(MBEDTLS_GCM_ALT)
86
90typedef struct mbedtls_gcm_context
91{
97 unsigned char base_ectr[16];
98 unsigned char y[16];
99 unsigned char buf[16];
100 int mode;
103}
105
106#else /* !MBEDTLS_GCM_ALT */
107#include "gcm_alt.h"
108#endif /* !MBEDTLS_GCM_ALT */
109
122
141 const unsigned char *key,
142 unsigned int keybits );
143
196 int mode,
197 size_t length,
198 const unsigned char *iv,
199 size_t iv_len,
200 const unsigned char *add,
201 size_t add_len,
202 const unsigned char *input,
203 unsigned char *output,
204 size_t tag_len,
205 unsigned char *tag );
206
241 size_t length,
242 const unsigned char *iv,
243 size_t iv_len,
244 const unsigned char *add,
245 size_t add_len,
246 const unsigned char *tag,
247 size_t tag_len,
248 const unsigned char *input,
249 unsigned char *output );
250
269 int mode,
270 const unsigned char *iv,
271 size_t iv_len,
272 const unsigned char *add,
273 size_t add_len );
274
301 size_t length,
302 const unsigned char *input,
303 unsigned char *output );
304
322 unsigned char *tag,
323 size_t tag_len );
324
333
334#if defined(MBEDTLS_SELF_TEST)
335
342int mbedtls_gcm_self_test( int verbose );
343
344#endif /* MBEDTLS_SELF_TEST */
345
346#ifdef __cplusplus
347}
348#endif
349
350
351#endif /* gcm.h */
This file contains an abstraction interface for use with the cipher primitives provided by the librar...
mbedtls_cipher_id_t
Supported cipher types.
Definition: cipher.h:109
UINT64 uint64_t
Definition: types.h:77
int mbedtls_gcm_starts(mbedtls_gcm_context *ctx, int mode, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len)
This function starts a GCM encryption or decryption operation.
int mbedtls_gcm_crypt_and_tag(mbedtls_gcm_context *ctx, int mode, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *input, unsigned char *output, size_t tag_len, unsigned char *tag)
This function performs GCM encryption or decryption of a buffer.
int mbedtls_gcm_finish(mbedtls_gcm_context *ctx, unsigned char *tag, size_t tag_len)
This function finishes the GCM operation and generates the authentication tag.
int mbedtls_gcm_update(mbedtls_gcm_context *ctx, size_t length, const unsigned char *input, unsigned char *output)
This function feeds an input buffer into an ongoing GCM encryption or decryption operation.
void mbedtls_gcm_init(mbedtls_gcm_context *ctx)
This function initializes the specified GCM context, to make references valid, and prepares the conte...
int mbedtls_gcm_setkey(mbedtls_gcm_context *ctx, mbedtls_cipher_id_t cipher, const unsigned char *key, unsigned int keybits)
This function associates a GCM context with a cipher algorithm and a key.
void mbedtls_gcm_free(mbedtls_gcm_context *ctx)
This function clears a GCM context and the underlying cipher sub-context.
int mbedtls_gcm_auth_decrypt(mbedtls_gcm_context *ctx, size_t length, const unsigned char *iv, size_t iv_len, const unsigned char *add, size_t add_len, const unsigned char *tag, size_t tag_len, const unsigned char *input, unsigned char *output)
This function performs a GCM authenticated decryption of a buffer.
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLenum mode
Definition: glext.h:6217
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
GLenum GLenum GLenum input
Definition: glext.h:9031
static DATA_BLOB cipher
Definition: protectdata.c:38
#define verbose
Definition: rosglue.h:36
Definition: copy.c:22
The GCM context structure.
Definition: gcm.h:91
unsigned char base_ectr[16]
Definition: gcm.h:97
mbedtls_cipher_context_t cipher_ctx
Definition: gcm.h:92
uint64_t HH[16]
Definition: gcm.h:94
uint64_t len
Definition: gcm.h:95
uint64_t add_len
Definition: gcm.h:96
uint64_t HL[16]
Definition: gcm.h:93
Definition: ecma_167.h:138