PolarSSL v1.2.10
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 #ifdef _MSC_VER
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 
54 typedef struct
55 {
56  int nr;
57  uint32_t *rk;
58  uint32_t buf[68];
59 }
61 
62 #ifdef __cplusplus
63 extern "C" {
64 #endif
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 
117 int aes_crypt_cbc( aes_context *ctx,
118  int mode,
119  size_t length,
120  unsigned char iv[16],
121  const unsigned char *input,
122  unsigned char *output );
123 
142 int aes_crypt_cfb128( aes_context *ctx,
143  int mode,
144  size_t length,
145  size_t *iv_off,
146  unsigned char iv[16],
147  const unsigned char *input,
148  unsigned char *output );
149 
171 int aes_crypt_ctr( aes_context *ctx,
172  size_t length,
173  size_t *nc_off,
174  unsigned char nonce_counter[16],
175  unsigned char stream_block[16],
176  const unsigned char *input,
177  unsigned char *output );
178 
179 #ifdef __cplusplus
180 }
181 #endif
182 
183 #else /* POLARSSL_AES_ALT */
184 #include "aes_alt.h"
185 #endif /* POLARSSL_AES_ALT */
186 
187 #ifdef __cplusplus
188 extern "C" {
189 #endif
190 
196 int aes_self_test( int verbose );
197 
198 #ifdef __cplusplus
199 }
200 #endif
201 
202 #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:54
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:57
int nr
Definition: aes.h:56
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.