mbed TLS v2.6.0
aes.h
Go to the documentation of this file.
1 
23 #ifndef MBEDTLS_AES_H
24 #define MBEDTLS_AES_H
25 
26 #if !defined(MBEDTLS_CONFIG_FILE)
27 #include "config.h"
28 #else
29 #include MBEDTLS_CONFIG_FILE
30 #endif
31 
32 #include <stddef.h>
33 #include <stdint.h>
34 
35 /* padlock.c and aesni.c rely on these values! */
36 #define MBEDTLS_AES_ENCRYPT 1
37 #define MBEDTLS_AES_DECRYPT 0
38 
39 #define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020
40 #define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022
42 #if ( defined(__ARMCC_VERSION) || defined(_MSC_VER) ) && \
43  !defined(inline) && !defined(__cplusplus)
44 #define inline __inline
45 #endif
46 
47 #if !defined(MBEDTLS_AES_ALT)
48 // Regular implementation
49 //
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
63 typedef struct
64 {
65  int nr;
66  uint32_t *rk;
67  uint32_t buf[68];
68 }
70 
77 
84 
94 int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
95  unsigned int keybits );
96 
106 int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
107  unsigned int keybits );
108 
120  int mode,
121  const unsigned char input[16],
122  unsigned char output[16] );
123 
124 #if defined(MBEDTLS_CIPHER_MODE_CBC)
125 
148  int mode,
149  size_t length,
150  unsigned char iv[16],
151  const unsigned char *input,
152  unsigned char *output );
153 #endif /* MBEDTLS_CIPHER_MODE_CBC */
154 
155 #if defined(MBEDTLS_CIPHER_MODE_CFB)
156 
182  int mode,
183  size_t length,
184  size_t *iv_off,
185  unsigned char iv[16],
186  const unsigned char *input,
187  unsigned char *output );
188 
214  int mode,
215  size_t length,
216  unsigned char iv[16],
217  const unsigned char *input,
218  unsigned char *output );
219 #endif /*MBEDTLS_CIPHER_MODE_CFB */
220 
221 #if defined(MBEDTLS_CIPHER_MODE_CTR)
222 
245  size_t length,
246  size_t *nc_off,
247  unsigned char nonce_counter[16],
248  unsigned char stream_block[16],
249  const unsigned char *input,
250  unsigned char *output );
251 #endif /* MBEDTLS_CIPHER_MODE_CTR */
252 
265  const unsigned char input[16],
266  unsigned char output[16] );
267 
280  const unsigned char input[16],
281  unsigned char output[16] );
282 
283 #if !defined(MBEDTLS_DEPRECATED_REMOVED)
284 #if defined(MBEDTLS_DEPRECATED_WARNING)
285 #define MBEDTLS_DEPRECATED __attribute__((deprecated))
286 #else
287 #define MBEDTLS_DEPRECATED
288 #endif
289 
300  const unsigned char input[16],
301  unsigned char output[16] );
302 
314  const unsigned char input[16],
315  unsigned char output[16] );
316 
317 #undef MBEDTLS_DEPRECATED
318 #endif /* !MBEDTLS_DEPRECATED_REMOVED */
319 
320 #ifdef __cplusplus
321 }
322 #endif
323 
324 #else /* MBEDTLS_AES_ALT */
325 #include "aes_alt.h"
326 #endif /* MBEDTLS_AES_ALT */
327 
328 #ifdef __cplusplus
329 extern "C" {
330 #endif
331 
337 int mbedtls_aes_self_test( int verbose );
338 
339 #ifdef __cplusplus
340 }
341 #endif
342 
343 #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:285
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:66
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:63
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.