mbed TLS v2.0.0
aes.h
Go to the documentation of this file.
1 
24 #ifndef MBEDTLS_AES_H
25 #define MBEDTLS_AES_H
26 
27 #if !defined(MBEDTLS_CONFIG_FILE)
28 #include "config.h"
29 #else
30 #include MBEDTLS_CONFIG_FILE
31 #endif
32 
33 #include <stddef.h>
34 #include <stdint.h>
35 
36 /* padlock.c and aesni.c rely on these values! */
37 #define MBEDTLS_AES_ENCRYPT 1
38 #define MBEDTLS_AES_DECRYPT 0
39 
40 #define MBEDTLS_ERR_AES_INVALID_KEY_LENGTH -0x0020
41 #define MBEDTLS_ERR_AES_INVALID_INPUT_LENGTH -0x0022
43 #if !defined(MBEDTLS_AES_ALT)
44 // Regular implementation
45 //
46 
47 #ifdef __cplusplus
48 extern "C" {
49 #endif
50 
59 typedef struct
60 {
61  int nr;
62  uint32_t *rk;
63  uint32_t buf[68];
64 }
66 
73 
80 
90 int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
91  unsigned int keybits );
92 
102 int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
103  unsigned int keybits );
104 
116  int mode,
117  const unsigned char input[16],
118  unsigned char output[16] );
119 
120 #if defined(MBEDTLS_CIPHER_MODE_CBC)
121 
144  int mode,
145  size_t length,
146  unsigned char iv[16],
147  const unsigned char *input,
148  unsigned char *output );
149 #endif /* MBEDTLS_CIPHER_MODE_CBC */
150 
151 #if defined(MBEDTLS_CIPHER_MODE_CFB)
152 
178  int mode,
179  size_t length,
180  size_t *iv_off,
181  unsigned char iv[16],
182  const unsigned char *input,
183  unsigned char *output );
184 
210  int mode,
211  size_t length,
212  unsigned char iv[16],
213  const unsigned char *input,
214  unsigned char *output );
215 #endif /*MBEDTLS_CIPHER_MODE_CFB */
216 
217 #if defined(MBEDTLS_CIPHER_MODE_CTR)
218 
241  size_t length,
242  size_t *nc_off,
243  unsigned char nonce_counter[16],
244  unsigned char stream_block[16],
245  const unsigned char *input,
246  unsigned char *output );
247 #endif /* MBEDTLS_CIPHER_MODE_CTR */
248 
259  const unsigned char input[16],
260  unsigned char output[16] );
261 
272  const unsigned char input[16],
273  unsigned char output[16] );
274 
275 #ifdef __cplusplus
276 }
277 #endif
278 
279 #else /* MBEDTLS_AES_ALT */
280 #include "aes_alt.h"
281 #endif /* MBEDTLS_AES_ALT */
282 
283 #ifdef __cplusplus
284 extern "C" {
285 #endif
286 
292 int mbedtls_aes_self_test( int verbose );
293 
294 #ifdef __cplusplus
295 }
296 #endif
297 
298 #endif /* aes.h */
void mbedtls_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_...
int mbedtls_aes_self_test(int verbose)
Checkup routine.
Compatibility names (set of defines)
void mbedtls_aes_init(mbedtls_aes_context *ctx)
Initialize AES context.
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.
void mbedtls_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_...
uint32_t * rk
Definition: aes.h:62
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:59