PolarSSL v1.3.2
aes.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_AES_H
28 #define POLARSSL_AES_H
29 
30 #include "config.h"
31 
32 #include <string.h>
33 
34 #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
35 #include <basetsd.h>
36 typedef UINT32 uint32_t;
37 #else
38 #include <inttypes.h>
39 #endif
40 
41 #define AES_ENCRYPT 1
42 #define AES_DECRYPT 0
43 
44 #define POLARSSL_ERR_AES_INVALID_KEY_LENGTH -0x0020
45 #define POLARSSL_ERR_AES_INVALID_INPUT_LENGTH -0x0022
47 #if !defined(POLARSSL_AES_ALT)
48 // Regular implementation
49 //
50 
51 #ifdef __cplusplus
52 extern "C" {
53 #endif
54 
58 typedef struct
59 {
60  int nr;
61  uint32_t *rk;
62  uint32_t buf[68];
63 }
65 
75 int aes_setkey_enc( aes_context *ctx, const unsigned char *key, unsigned int keysize );
76 
86 int aes_setkey_dec( aes_context *ctx, const unsigned char *key, unsigned int keysize );
87 
98 int aes_crypt_ecb( aes_context *ctx,
99  int mode,
100  const unsigned char input[16],
101  unsigned char output[16] );
102 
103 #if defined(POLARSSL_CIPHER_MODE_CBC)
104 
118 int aes_crypt_cbc( aes_context *ctx,
119  int mode,
120  size_t length,
121  unsigned char iv[16],
122  const unsigned char *input,
123  unsigned char *output );
124 #endif /* POLARSSL_CIPHER_MODE_CBC */
125 
143 int aes_crypt_cfb128( aes_context *ctx,
144  int mode,
145  size_t length,
146  size_t *iv_off,
147  unsigned char iv[16],
148  const unsigned char *input,
149  unsigned char *output );
150 
173 int aes_crypt_ctr( aes_context *ctx,
174  size_t length,
175  size_t *nc_off,
176  unsigned char nonce_counter[16],
177  unsigned char stream_block[16],
178  const unsigned char *input,
179  unsigned char *output );
180 
181 #ifdef __cplusplus
182 }
183 #endif
184 
185 #else /* POLARSSL_AES_ALT */
186 #include "aes_alt.h"
187 #endif /* POLARSSL_AES_ALT */
188 
189 #ifdef __cplusplus
190 extern "C" {
191 #endif
192 
198 int aes_self_test( int verbose );
199 
200 #ifdef __cplusplus
201 }
202 #endif
203 
204 #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:58
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.
uint32_t * rk
Definition: aes.h:61
int nr
Definition: aes.h:60
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.
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.