ReactOS 0.4.15-dev-7953-g1f49173
aes.h
Go to the documentation of this file.
1
23/*
24 * Copyright The Mbed TLS Contributors
25 * SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
26 *
27 * This file is provided under the Apache License 2.0, or the
28 * GNU General Public License v2.0 or later.
29 *
30 * **********
31 * Apache License 2.0:
32 *
33 * Licensed under the Apache License, Version 2.0 (the "License"); you may
34 * not use this file except in compliance with the License.
35 * You may obtain a copy of the License at
36 *
37 * http://www.apache.org/licenses/LICENSE-2.0
38 *
39 * Unless required by applicable law or agreed to in writing, software
40 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
41 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
42 * See the License for the specific language governing permissions and
43 * limitations under the License.
44 *
45 * **********
46 *
47 * **********
48 * GNU General Public License v2.0 or later:
49 *
50 * This program is free software; you can redistribute it and/or modify
51 * it under the terms of the GNU General Public License as published by
52 * the Free Software Foundation; either version 2 of the License, or
53 * (at your option) any later version.
54 *
55 * This program is distributed in the hope that it will be useful,
56 * but WITHOUT ANY WARRANTY; without even the implied warranty of
57 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
58 * GNU General Public License for more details.
59 *
60 * You should have received a copy of the GNU General Public License along
61 * with this program; if not, write to the Free Software Foundation, Inc.,
62 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
63 *
64 * **********
65 */
66
67#ifndef MBEDTLS_AES_H
68#define MBEDTLS_AES_H
69
70#if !defined(MBEDTLS_CONFIG_FILE)
71#include "config.h"
72#else
73#include MBEDTLS_CONFIG_FILE
74#endif
75
76#include <stddef.h>
77#include <stdint.h>
78
79/* padlock.c and aesni.c rely on these values! */
80#define MBEDTLS_AES_ENCRYPT 1
81#define MBEDTLS_AES_DECRYPT 0
83/* Error codes in range 0x0020-0x0022 */
84#define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020
85#define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022
87/* Error codes in range 0x0021-0x0025 */
88#define MBEDTLS_ERR_AES_BAD_INPUT_DATA -0x0021
90/* MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE is deprecated and should not be used. */
91#define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023
93/* MBEDTLS_ERR_AES_HW_ACCEL_FAILED is deprecated and should not be used. */
94#define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025
96#if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
97 !defined(inline) && !defined(__cplusplus)
98#define inline __inline
99#endif
100
101#ifdef __cplusplus
102extern "C" {
103#endif
104
105#if !defined(MBEDTLS_AES_ALT)
106// Regular implementation
107//
108
113{
114 int nr;
124}
126
127#if defined(MBEDTLS_CIPHER_MODE_XTS)
132{
138#endif /* MBEDTLS_CIPHER_MODE_XTS */
139
140#else /* MBEDTLS_AES_ALT */
141#include "aes_alt.h"
142#endif /* MBEDTLS_AES_ALT */
143
153
162
163#if defined(MBEDTLS_CIPHER_MODE_XTS)
173
182#endif /* MBEDTLS_CIPHER_MODE_XTS */
183
200 unsigned int keybits );
201
218 unsigned int keybits );
219
220#if defined(MBEDTLS_CIPHER_MODE_XTS)
238 const unsigned char *key,
239 unsigned int keybits );
240
258 const unsigned char *key,
259 unsigned int keybits );
260#endif /* MBEDTLS_CIPHER_MODE_XTS */
261
286 int mode,
287 const unsigned char input[16],
288 unsigned char output[16] );
289
290#if defined(MBEDTLS_CIPHER_MODE_CBC)
333 int mode,
334 size_t length,
335 unsigned char iv[16],
336 const unsigned char *input,
337 unsigned char *output );
338#endif /* MBEDTLS_CIPHER_MODE_CBC */
339
340#if defined(MBEDTLS_CIPHER_MODE_XTS)
377 int mode,
378 size_t length,
379 const unsigned char data_unit[16],
380 const unsigned char *input,
381 unsigned char *output );
382#endif /* MBEDTLS_CIPHER_MODE_XTS */
383
384#if defined(MBEDTLS_CIPHER_MODE_CFB)
425 int mode,
426 size_t length,
427 size_t *iv_off,
428 unsigned char iv[16],
429 const unsigned char *input,
430 unsigned char *output );
431
469 int mode,
470 size_t length,
471 unsigned char iv[16],
472 const unsigned char *input,
473 unsigned char *output );
474#endif /*MBEDTLS_CIPHER_MODE_CFB */
475
476#if defined(MBEDTLS_CIPHER_MODE_OFB)
523 size_t length,
524 size_t *iv_off,
525 unsigned char iv[16],
526 const unsigned char *input,
527 unsigned char *output );
528
529#endif /* MBEDTLS_CIPHER_MODE_OFB */
530
531#if defined(MBEDTLS_CIPHER_MODE_CTR)
609 size_t length,
610 size_t *nc_off,
611 unsigned char nonce_counter[16],
612 unsigned char stream_block[16],
613 const unsigned char *input,
614 unsigned char *output );
615#endif /* MBEDTLS_CIPHER_MODE_CTR */
616
629 const unsigned char input[16],
630 unsigned char output[16] );
631
644 const unsigned char input[16],
645 unsigned char output[16] );
646
647#if !defined(MBEDTLS_DEPRECATED_REMOVED)
648#if defined(MBEDTLS_DEPRECATED_WARNING)
649#define MBEDTLS_DEPRECATED __attribute__((deprecated))
650#else
651#define MBEDTLS_DEPRECATED
652#endif
664 const unsigned char input[16],
665 unsigned char output[16] );
666
678 const unsigned char input[16],
679 unsigned char output[16] );
680
681#undef MBEDTLS_DEPRECATED
682#endif /* !MBEDTLS_DEPRECATED_REMOVED */
683
684
685#if defined(MBEDTLS_SELF_TEST)
692int mbedtls_aes_self_test( int verbose );
693
694#endif /* MBEDTLS_SELF_TEST */
695
696#ifdef __cplusplus
697}
698#endif
699
700#endif /* aes.h */
int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16])
This function performs an AES single-block encryption or decryption operation.
int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
This function sets the decryption key.
void mbedtls_aes_xts_init(mbedtls_aes_xts_context *ctx)
This function initializes the specified AES XTS context.
int mbedtls_aes_crypt_ofb(mbedtls_aes_context *ctx, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output)
This function performs an AES-OFB (Output Feedback Mode) encryption or decryption operation.
int mbedtls_aes_crypt_cbc(mbedtls_aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output)
This function performs an AES-CBC encryption or decryption operation on full blocks.
int mbedtls_aes_crypt_ctr(mbedtls_aes_context *ctx, size_t length, size_t *nc_off, unsigned char nonce_counter[16], unsigned char stream_block[16], const unsigned char *input, unsigned char *output)
This function performs an AES-CTR encryption or decryption operation.
int mbedtls_aes_xts_setkey_dec(mbedtls_aes_xts_context *ctx, const unsigned char *key, unsigned int keybits)
This function prepares an XTS context for decryption and sets the decryption key.
int mbedtls_aes_crypt_xts(mbedtls_aes_xts_context *ctx, int mode, size_t length, const unsigned char data_unit[16], const unsigned char *input, unsigned char *output)
This function performs an AES-XTS encryption or decryption operation for an entire XTS data unit.
int mbedtls_internal_aes_encrypt(mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16])
Internal AES block encryption function. This is only exposed to allow overriding it using MBEDTLS_AES...
void mbedtls_aes_xts_free(mbedtls_aes_xts_context *ctx)
This function releases and clears the specified AES XTS context.
int mbedtls_aes_crypt_cfb128(mbedtls_aes_context *ctx, int mode, size_t length, size_t *iv_off, unsigned char iv[16], const unsigned char *input, unsigned char *output)
This function performs an AES-CFB128 encryption or decryption operation.
int mbedtls_aes_crypt_cfb8(mbedtls_aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output)
This function performs an AES-CFB8 encryption or decryption operation.
void mbedtls_aes_init(mbedtls_aes_context *ctx)
This function initializes the specified AES context.
#define MBEDTLS_DEPRECATED
Definition: aes.h:651
MBEDTLS_DEPRECATED void mbedtls_aes_decrypt(mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16])
Deprecated internal AES block decryption function without return value.
int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
This function sets the encryption key.
void mbedtls_aes_free(mbedtls_aes_context *ctx)
This function releases and clears the specified AES context.
MBEDTLS_DEPRECATED void mbedtls_aes_encrypt(mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16])
Deprecated internal AES block encryption function without return value.
int mbedtls_internal_aes_decrypt(mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16])
Internal AES block decryption function. This is only exposed to allow overriding it using see MBEDTLS...
int mbedtls_aes_xts_setkey_enc(mbedtls_aes_xts_context *ctx, const unsigned char *key, unsigned int keybits)
This function prepares an XTS context for encryption and sets the encryption key.
UINT32 uint32_t
Definition: types.h:75
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
#define verbose
Definition: rosglue.h:36
Definition: copy.c:22
The AES context-type definition.
Definition: aes.h:113
uint32_t * rk
Definition: aes.h:115
The AES XTS context-type definition.
Definition: aes.h:132
mbedtls_aes_context crypt
Definition: aes.h:133
mbedtls_aes_context tweak
Definition: aes.h:135