mbed TLS v2.2.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(MBEDTLS_AES_ALT)
43 // Regular implementation
44 //
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
58 typedef struct
59 {
60  int nr;
61  uint32_t *rk;
62  uint32_t buf[68];
63 }
65 
72 
79 
89 int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
90  unsigned int keybits );
91 
101 int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
102  unsigned int keybits );
103 
115  int mode,
116  const unsigned char input[16],
117  unsigned char output[16] );
118 
119 #if defined(MBEDTLS_CIPHER_MODE_CBC)
120 
142 int mbedtls_aes_crypt_cbc( mbedtls_aes_context *ctx,
143  int mode,
144  size_t length,
145  unsigned char iv[16],
146  const unsigned char *input,
147  unsigned char *output );
148 #endif /* MBEDTLS_CIPHER_MODE_CBC */
149 
150 #if defined(MBEDTLS_CIPHER_MODE_CFB)
151 
176 int mbedtls_aes_crypt_cfb128( mbedtls_aes_context *ctx,
177  int mode,
178  size_t length,
179  size_t *iv_off,
180  unsigned char iv[16],
181  const unsigned char *input,
182  unsigned char *output );
183 
208 int mbedtls_aes_crypt_cfb8( mbedtls_aes_context *ctx,
209  int mode,
210  size_t length,
211  unsigned char iv[16],
212  const unsigned char *input,
213  unsigned char *output );
214 #endif /*MBEDTLS_CIPHER_MODE_CFB */
215 
216 #if defined(MBEDTLS_CIPHER_MODE_CTR)
217 
239 int mbedtls_aes_crypt_ctr( mbedtls_aes_context *ctx,
240  size_t length,
241  size_t *nc_off,
242  unsigned char nonce_counter[16],
243  unsigned char stream_block[16],
244  const unsigned char *input,
245  unsigned char *output );
246 #endif /* MBEDTLS_CIPHER_MODE_CTR */
247 
257 void mbedtls_aes_encrypt( mbedtls_aes_context *ctx,
258  const unsigned char input[16],
259  unsigned char output[16] );
260 
270 void mbedtls_aes_decrypt( mbedtls_aes_context *ctx,
271  const unsigned char input[16],
272  unsigned char output[16] );
273 
274 #ifdef __cplusplus
275 }
276 #endif
277 
278 #else /* MBEDTLS_AES_ALT */
279 #include "aes_alt.h"
280 #endif /* MBEDTLS_AES_ALT */
281 
282 #ifdef __cplusplus
283 extern "C" {
284 #endif
285 
291 int mbedtls_aes_self_test( int verbose );
292 
293 #ifdef __cplusplus
294 }
295 #endif
296 
297 #endif /* aes.h */
int mbedtls_aes_self_test(int verbose)
Checkup routine.
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.
Compatibility names (set of defines)
void mbedtls_aes_init(mbedtls_aes_context *ctx)
Initialize AES context.
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 block cipher.
int mbedtls_aes_setkey_dec(mbedtls_aes_context *ctx, const unsigned char *key, unsigned int keybits)
AES key schedule (decryption)
AES context structure.
Definition: aes_alt.h:68