mbed TLS v2.6.0
aes.h
Go to the documentation of this file.
1 
25 #ifndef MBEDTLS_AES_H
26 #define MBEDTLS_AES_H
27 
28 #if !defined(MBEDTLS_CONFIG_FILE)
29 #include "config.h"
30 #else
31 #include MBEDTLS_CONFIG_FILE
32 #endif
33 
34 #include <stddef.h>
35 #include <stdint.h>
36 
37 /* padlock.c and aesni.c rely on these values! */
38 #define MBEDTLS_AES_ENCRYPT 1
39 #define MBEDTLS_AES_DECRYPT 0
40 
41 #define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020
42 #define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022
44 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
45  !defined(inline) && !defined(__cplusplus)
46 #define inline __inline
47 #endif
48 
49 #if !defined(MBEDTLS_AES_ALT)
50 // Regular implementation
51 //
52 
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56 
65 typedef struct
66 {
67  int nr;
68  uint32_t *rk;
69  uint32_t buf[68];
70 }
72 
79 
86 
96 int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
97  unsigned int keybits );
98 
108 int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
109  unsigned int keybits );
110 
122  int mode,
123  const unsigned char input[16],
124  unsigned char output[16] );
125 
126 #if defined(MBEDTLS_CIPHER_MODE_CBC)
127 
150  int mode,
151  size_t length,
152  unsigned char iv[16],
153  const unsigned char *input,
154  unsigned char *output );
155 #endif /* MBEDTLS_CIPHER_MODE_CBC */
156 
157 #if defined(MBEDTLS_CIPHER_MODE_CFB)
158 
184  int mode,
185  size_t length,
186  size_t *iv_off,
187  unsigned char iv[16],
188  const unsigned char *input,
189  unsigned char *output );
190 
216  int mode,
217  size_t length,
218  unsigned char iv[16],
219  const unsigned char *input,
220  unsigned char *output );
221 #endif /*MBEDTLS_CIPHER_MODE_CFB */
222 
223 #if defined(MBEDTLS_CIPHER_MODE_CTR)
224 
247  size_t length,
248  size_t *nc_off,
249  unsigned char nonce_counter[16],
250  unsigned char stream_block[16],
251  const unsigned char *input,
252  unsigned char *output );
253 #endif /* MBEDTLS_CIPHER_MODE_CTR */
254 
267  const unsigned char input[16],
268  unsigned char output[16] );
269 
282  const unsigned char input[16],
283  unsigned char output[16] );
284 
285 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
286 #if defined(MBEDTLS_DEPRECATED_WARNING)
287 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
288 #else
289 #define MBEDTLS_DEPRECATED
290 #endif
291 
302  const unsigned char input[16],
303  unsigned char output[16] );
304 
316  const unsigned char input[16],
317  unsigned char output[16] );
318 
319 #undef MBEDTLS_DEPRECATED
320 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
321 
322 #ifdef __cplusplus
323 }
324 #endif
325 
326 #else /* MBEDTLS_AES_ALT */
327 #include "aes_alt.h"
328 #endif /* MBEDTLS_AES_ALT */
329 
330 #ifdef __cplusplus
331 extern "C" {
332 #endif
333 
339 int mbedtls_aes_self_test( int verbose );
340 
341 #ifdef __cplusplus
342 }
343 #endif
344 
345 #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.
#define MBEDTLS_DEPRECATED
Definition: aes.h:289
Configuration options (set of defines)
void mbedtls_aes_init(mbedtls_aes_context *ctx)
Initialize 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 (Only exposed to allow overriding it, see MBEDTLS_AES_ENCRYPT_...
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)
AES-CTR buffer encryption/decryption.
int mbedtls_aes_crypt_ecb(mbedtls_aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16])
AES-ECB block encryption/decryption.
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)
AES-CBC buffer encryption/decryption Length should be a multiple of the block size (16 bytes) ...
int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
AES key schedule (decryption)
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)
AES-CFB128 buffer encryption/decryption.
uint32_t * rk
Definition: aes.h:68
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)
AES-CFB8 buffer encryption/decryption.
int mbedtls_aes_setkey_enc(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
AES key schedule (encryption)
void mbedtls_aes_free(mbedtls_aes_context *ctx)
Clear AES context.
AES context structure.
Definition: aes.h:65
int mbedtls_internal_aes_decrypt(mbedtls_aes_context *ctx, const unsigned char input[16], unsigned char output[16])
Internal AES block decryption function (Only exposed to allow overriding it, see MBEDTLS_AES_DECRYPT_...
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.