mbed TLS v2.3.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(MBEDTLS_AES_ALT)
45 // Regular implementation
46 //
47 
48 #ifdef __cplusplus
49 extern "C" {
50 #endif
51 
60 typedef struct
61 {
62  int nr;
63  uint32_t *rk;
64  uint32_t buf[68];
65 }
67 
74 
81 
91 int mbedtls_aes_setkey_enc( mbedtls_aes_context *ctx, const unsigned char *key,
92  unsigned int keybits );
93 
103 int mbedtls_aes_setkey_dec( mbedtls_aes_context *ctx, const unsigned char *key,
104  unsigned int keybits );
105 
117  int mode,
118  const unsigned char input[16],
119  unsigned char output[16] );
120 
121 #if defined(MBEDTLS_CIPHER_MODE_CBC)
122 
145  int mode,
146  size_t length,
147  unsigned char iv[16],
148  const unsigned char *input,
149  unsigned char *output );
150 #endif /* MBEDTLS_CIPHER_MODE_CBC */
151 
152 #if defined(MBEDTLS_CIPHER_MODE_CFB)
153 
179  int mode,
180  size_t length,
181  size_t *iv_off,
182  unsigned char iv[16],
183  const unsigned char *input,
184  unsigned char *output );
185 
211  int mode,
212  size_t length,
213  unsigned char iv[16],
214  const unsigned char *input,
215  unsigned char *output );
216 #endif /*MBEDTLS_CIPHER_MODE_CFB */
217 
218 #if defined(MBEDTLS_CIPHER_MODE_CTR)
219 
242  size_t length,
243  size_t *nc_off,
244  unsigned char nonce_counter[16],
245  unsigned char stream_block[16],
246  const unsigned char *input,
247  unsigned char *output );
248 #endif /* MBEDTLS_CIPHER_MODE_CTR */
249 
260  const unsigned char input[16],
261  unsigned char output[16] );
262 
273  const unsigned char input[16],
274  unsigned char output[16] );
275 
276 #ifdef __cplusplus
277 }
278 #endif
279 
280 #else /* MBEDTLS_AES_ALT */
281 #include "aes_alt.h"
282 #endif /* MBEDTLS_AES_ALT */
283 
284 #ifdef __cplusplus
285 extern "C" {
286 #endif
287 
293 int mbedtls_aes_self_test( int verbose );
294 
295 #ifdef __cplusplus
296 }
297 #endif
298 
299 #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.
Configuration options (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:63
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:60