PolarSSL v1.3.4
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 /* padlock.c and aesni.c rely on these values! */
42 #define AES_ENCRYPT 1
43 #define AES_DECRYPT 0
44 
45 #define POLARSSL_ERR_AES_INVALID_KEY_LENGTH -0x0020
46 #define POLARSSL_ERR_AES_INVALID_INPUT_LENGTH -0x0022
48 #if !defined(POLARSSL_AES_ALT)
49 // Regular implementation
50 //
51 
52 #ifdef __cplusplus
53 extern "C" {
54 #endif
55 
64 typedef struct
65 {
66  int nr;
67  uint32_t *rk;
68  uint32_t buf[68];
69 }
71 
81 int aes_setkey_enc( aes_context *ctx, const unsigned char *key, unsigned int keysize );
82 
92 int aes_setkey_dec( aes_context *ctx, const unsigned char *key, unsigned int keysize );
93 
104 int aes_crypt_ecb( aes_context *ctx,
105  int mode,
106  const unsigned char input[16],
107  unsigned char output[16] );
108 
109 #if defined(POLARSSL_CIPHER_MODE_CBC)
110 
124 int aes_crypt_cbc( aes_context *ctx,
125  int mode,
126  size_t length,
127  unsigned char iv[16],
128  const unsigned char *input,
129  unsigned char *output );
130 #endif /* POLARSSL_CIPHER_MODE_CBC */
131 
149 int aes_crypt_cfb128( aes_context *ctx,
150  int mode,
151  size_t length,
152  size_t *iv_off,
153  unsigned char iv[16],
154  const unsigned char *input,
155  unsigned char *output );
156 
173 int aes_crypt_cfb8( aes_context *ctx,
174  int mode,
175  size_t length,
176  unsigned char iv[16],
177  const unsigned char *input,
178  unsigned char *output );
179 
202 int aes_crypt_ctr( aes_context *ctx,
203  size_t length,
204  size_t *nc_off,
205  unsigned char nonce_counter[16],
206  unsigned char stream_block[16],
207  const unsigned char *input,
208  unsigned char *output );
209 
210 #ifdef __cplusplus
211 }
212 #endif
213 
214 #else /* POLARSSL_AES_ALT */
215 #include "aes_alt.h"
216 #endif /* POLARSSL_AES_ALT */
217 
218 #ifdef __cplusplus
219 extern "C" {
220 #endif
221 
227 int aes_self_test( int verbose );
228 
229 #ifdef __cplusplus
230 }
231 #endif
232 
233 #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:64
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:67
int nr
Definition: aes.h:66
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.