ReactOS  0.4.15-dev-494-g1d8c567
aes.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 OR GPL-2.0-or-later
18  *
19  * This file is provided under the Apache License 2.0, or the
20  * GNU General Public License v2.0 or later.
21  *
22  * **********
23  * Apache License 2.0:
24  *
25  * Licensed under the Apache License, Version 2.0 (the "License"); you may
26  * not use this file except in compliance with the License.
27  * You may obtain a copy of the License at
28  *
29  * http://www.apache.org/licenses/LICENSE-2.0
30  *
31  * Unless required by applicable law or agreed to in writing, software
32  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
33  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
34  * See the License for the specific language governing permissions and
35  * limitations under the License.
36  *
37  * **********
38  *
39  * **********
40  * GNU General Public License v2.0 or later:
41  *
42  * This program is free software; you can redistribute it and/or modify
43  * it under the terms of the GNU General Public License as published by
44  * the Free Software Foundation; either version 2 of the License, or
45  * (at your option) any later version.
46  *
47  * This program is distributed in the hope that it will be useful,
48  * but WITHOUT ANY WARRANTY; without even the implied warranty of
49  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
50  * GNU General Public License for more details.
51  *
52  * You should have received a copy of the GNU General Public License along
53  * with this program; if not, write to the Free Software Foundation, Inc.,
54  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
55  *
56  * **********
57  *
58  * This file is part of Mbed TLS (https://tls.mbed.org)
59  */
60 
61 #ifndef MBEDTLS_AES_H
62 #define MBEDTLS_AES_H
63 
64 #if !defined(MBEDTLS_CONFIG_FILE)
65 #include "config.h"
66 #else
67 #include MBEDTLS_CONFIG_FILE
68 #endif
69 
70 #include <stddef.h>
71 #include <stdint.h>
72 
73 /* padlock.c and aesni.c rely on these values! */
74 #define MBEDTLS_AES_ENCRYPT 1
75 #define MBEDTLS_AES_DECRYPT 0
77 /* Error codes in range 0x0020-0x0022 */
78 #define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020
79 #define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022
81 /* Error codes in range 0x0023-0x0025 */
82 #define MBEDTLS_ERR_AES_FEATURE_UNAVAILABLE -0x0023
83 #define MBEDTLS_ERR_AES_HW_ACCEL_FAILED -0x0025
85 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
86  !defined(inline) && !defined(__cplusplus)
87 #define inline __inline
88 #endif
89 
90 #if !defined(MBEDTLS_AES_ALT)
91 // Regular implementation
92 //
93 
94 #ifdef __cplusplus
95 extern "C" {
96 #endif
97 
101 typedef struct
102 {
103  int nr;
105  uint32_t buf[68];
113 }
115 
125 
132 
146 int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
147  unsigned int keybits );
148 
161 int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
162  unsigned int keybits );
163 
185  int mode,
186  const unsigned char input[16],
187  unsigned char output[16] );
188 
189 #if defined(MBEDTLS_CIPHER_MODE_CBC)
190 
227  int mode,
228  size_t length,
229  unsigned char iv[16],
230  const unsigned char *input,
231  unsigned char *output );
232 #endif /* MBEDTLS_CIPHER_MODE_CBC */
233 
234 #if defined(MBEDTLS_CIPHER_MODE_CFB)
235 
270  int mode,
271  size_t length,
272  size_t *iv_off,
273  unsigned char iv[16],
274  const unsigned char *input,
275  unsigned char *output );
276 
310  int mode,
311  size_t length,
312  unsigned char iv[16],
313  const unsigned char *input,
314  unsigned char *output );
315 #endif /*MBEDTLS_CIPHER_MODE_CFB */
316 
317 #if defined(MBEDTLS_CIPHER_MODE_CTR)
318 
347  size_t length,
348  size_t *nc_off,
349  unsigned char nonce_counter[16],
350  unsigned char stream_block[16],
351  const unsigned char *input,
352  unsigned char *output );
353 #endif /* MBEDTLS_CIPHER_MODE_CTR */
354 
367  const unsigned char input[16],
368  unsigned char output[16] );
369 
382  const unsigned char input[16],
383  unsigned char output[16] );
384 
385 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
386 #if defined(MBEDTLS_DEPRECATED_WARNING)
387 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
388 #else
389 #define MBEDTLS_DEPRECATED
390 #endif
391 
402  const unsigned char input[16],
403  unsigned char output[16] );
404 
416  const unsigned char input[16],
417  unsigned char output[16] );
418 
419 #undef MBEDTLS_DEPRECATED
420 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
421 
422 #ifdef __cplusplus
423 }
424 #endif
425 
426 #else /* MBEDTLS_AES_ALT */
427 #include "aes_alt.h"
428 #endif /* MBEDTLS_AES_ALT */
429 
430 #ifdef __cplusplus
431 extern "C" {
432 #endif
433 
439 int mbedtls_aes_self_test( int verbose );
440 
441 #ifdef __cplusplus
442 }
443 #endif
444 
445 #endif /* aes.h */
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_aes_self_test(int verbose)
Checkup routine.
static UCHAR ULONG UCHAR ULONG UCHAR * output
Definition: bcrypt.c:29
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define MBEDTLS_DEPRECATED
Definition: aes.h:389
void mbedtls_aes_init(mbedtls_aes_context *ctx)
This function initializes the specified AES context.
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...
#define verbose
Definition: rosglue.h:36
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_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_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_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
This function sets the decryption key.
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
GLenum mode
Definition: glext.h:6217
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.
uint32_t * rk
Definition: aes.h:104
GLenum GLenum GLenum input
Definition: glext.h:9031
UINT32 uint32_t
Definition: types.h:75
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.
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.
The AES context-type definition.
Definition: aes.h:101
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...
Definition: path.c:41
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.