PolarSSL v1.3.7
aes.h
Go to the documentation of this file.
1 
27 #ifndef POLARSSL_AES_H
28 #define POLARSSL_AES_H
29 
30 #if !defined(POLARSSL_CONFIG_FILE)
31 #include "config.h"
32 #else
33 #include POLARSSL_CONFIG_FILE
34 #endif
35 
36 #include <string.h>
37 
38 #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
39 #include <basetsd.h>
40 typedef UINT32 uint32_t;
41 #else
42 #include <inttypes.h>
43 #endif
44 
45 /* padlock.c and aesni.c rely on these values! */
46 #define AES_ENCRYPT 1
47 #define AES_DECRYPT 0
48 
49 #define POLARSSL_ERR_AES_INVALID_KEY_LENGTH -0x0020
50 #define POLARSSL_ERR_AES_INVALID_INPUT_LENGTH -0x0022
52 #if !defined(POLARSSL_AES_ALT)
53 // Regular implementation
54 //
55 
56 #ifdef __cplusplus
57 extern "C" {
58 #endif
59 
68 typedef struct
69 {
70  int nr;
71  uint32_t *rk;
72  uint32_t buf[68];
73 }
75 
85 int aes_setkey_enc( aes_context *ctx, const unsigned char *key,
86  unsigned int keysize );
87 
97 int aes_setkey_dec( aes_context *ctx, const unsigned char *key,
98  unsigned int keysize );
99 
110 int aes_crypt_ecb( aes_context *ctx,
111  int mode,
112  const unsigned char input[16],
113  unsigned char output[16] );
114 
115 #if defined(POLARSSL_CIPHER_MODE_CBC)
116 
130 int aes_crypt_cbc( aes_context *ctx,
131  int mode,
132  size_t length,
133  unsigned char iv[16],
134  const unsigned char *input,
135  unsigned char *output );
136 #endif /* POLARSSL_CIPHER_MODE_CBC */
137 
138 #if defined(POLARSSL_CIPHER_MODE_CFB)
139 
156 int aes_crypt_cfb128( aes_context *ctx,
157  int mode,
158  size_t length,
159  size_t *iv_off,
160  unsigned char iv[16],
161  const unsigned char *input,
162  unsigned char *output );
163 
180 int aes_crypt_cfb8( aes_context *ctx,
181  int mode,
182  size_t length,
183  unsigned char iv[16],
184  const unsigned char *input,
185  unsigned char *output );
186 #endif /*POLARSSL_CIPHER_MODE_CFB */
187 
188 #if defined(POLARSSL_CIPHER_MODE_CTR)
189 
211 int aes_crypt_ctr( aes_context *ctx,
212  size_t length,
213  size_t *nc_off,
214  unsigned char nonce_counter[16],
215  unsigned char stream_block[16],
216  const unsigned char *input,
217  unsigned char *output );
218 #endif /* POLARSSL_CIPHER_MODE_CTR */
219 
220 #ifdef __cplusplus
221 }
222 #endif
223 
224 #else /* POLARSSL_AES_ALT */
225 #include "aes_alt.h"
226 #endif /* POLARSSL_AES_ALT */
227 
228 #ifdef __cplusplus
229 extern "C" {
230 #endif
231 
237 int aes_self_test( int verbose );
238 
239 #ifdef __cplusplus
240 }
241 #endif
242 
243 #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:68
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.
uint32_t * rk
Definition: aes.h:71
int nr
Definition: aes.h:70
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.