mbed TLS v1.3.18
aes.h
Go to the documentation of this file.
1 
24 #ifndef POLARSSL_AES_H
25 #define POLARSSL_AES_H
26 
27 #if !defined(POLARSSL_CONFIG_FILE)
28 #include "config.h"
29 #else
30 #include POLARSSL_CONFIG_FILE
31 #endif
32 
33 #include <stddef.h>
34 
35 #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
36 #include <basetsd.h>
37 typedef UINT32 uint32_t;
38 #else
39 #include <inttypes.h>
40 #endif
41 
42 /* padlock.c and aesni.c rely on these values! */
43 #define AES_ENCRYPT 1
44 #define AES_DECRYPT 0
45 
46 #define POLARSSL_ERR_AES_INVALID_KEY_LENGTH -0x0020
47 #define POLARSSL_ERR_AES_INVALID_INPUT_LENGTH -0x0022
49 #if !defined(POLARSSL_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 
78 void aes_init( aes_context *ctx );
79 
85 void aes_free( aes_context *ctx );
86 
96 int aes_setkey_enc( aes_context *ctx, const unsigned char *key,
97  unsigned int keysize );
98 
108 int aes_setkey_dec( aes_context *ctx, const unsigned char *key,
109  unsigned int keysize );
110 
121 int aes_crypt_ecb( aes_context *ctx,
122  int mode,
123  const unsigned char input[16],
124  unsigned char output[16] );
125 
126 #if defined(POLARSSL_CIPHER_MODE_CBC)
127 
149 int aes_crypt_cbc( aes_context *ctx,
150  int mode,
151  size_t length,
152  unsigned char iv[16],
153  const unsigned char *input,
154  unsigned char *output );
155 #endif /* POLARSSL_CIPHER_MODE_CBC */
156 
157 #if defined(POLARSSL_CIPHER_MODE_CFB)
158 
183 int aes_crypt_cfb128( aes_context *ctx,
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 
215 int aes_crypt_cfb8( aes_context *ctx,
216  int mode,
217  size_t length,
218  unsigned char iv[16],
219  const unsigned char *input,
220  unsigned char *output );
221 #endif /*POLARSSL_CIPHER_MODE_CFB */
222 
223 #if defined(POLARSSL_CIPHER_MODE_CTR)
224 
246 int aes_crypt_ctr( aes_context *ctx,
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 /* POLARSSL_CIPHER_MODE_CTR */
254 
255 #ifdef __cplusplus
256 }
257 #endif
258 
259 #else /* POLARSSL_AES_ALT */
260 #include "aes_alt.h"
261 #endif /* POLARSSL_AES_ALT */
262 
263 #ifdef __cplusplus
264 extern "C" {
265 #endif
266 
272 int aes_self_test( int verbose );
273 
274 #ifdef __cplusplus
275 }
276 #endif
277 
278 #endif /* aes.h */
int aes_crypt_cfb128(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.
AES context structure.
Definition: aes.h:65
Configuration options (set of defines)
int aes_setkey_dec(aes_context *ctx, const unsigned char *key, unsigned int keysize)
AES key schedule (decryption)
int aes_crypt_cbc(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 aes_self_test(int verbose)
Checkup routine.
int aes_crypt_cfb8(aes_context *ctx, int mode, size_t length, unsigned char iv[16], const unsigned char *input, unsigned char *output)
AES-CFB8 buffer encryption/decryption.
void aes_free(aes_context *ctx)
Clear AES context.
uint32_t * rk
Definition: aes.h:68
int nr
Definition: aes.h:67
int aes_setkey_enc(aes_context *ctx, const unsigned char *key, unsigned int keysize)
AES key schedule (encryption)
int aes_crypt_ecb(aes_context *ctx, int mode, const unsigned char input[16], unsigned char output[16])
AES-ECB block encryption/decryption.
void aes_init(aes_context *ctx)
Initialize AES context.
int aes_crypt_ctr(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.