00001
00027 #ifndef POLARSSL_AES_H
00028 #define POLARSSL_AES_H
00029
00030 #include "config.h"
00031
00032 #include <string.h>
00033
00034 #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32)
00035 #include <basetsd.h>
00036 typedef UINT32 uint32_t;
00037 #else
00038 #include <inttypes.h>
00039 #endif
00040
00041 #define AES_ENCRYPT 1
00042 #define AES_DECRYPT 0
00043
00044 #define POLARSSL_ERR_AES_INVALID_KEY_LENGTH -0x0020
00045 #define POLARSSL_ERR_AES_INVALID_INPUT_LENGTH -0x0022
00047 #if !defined(POLARSSL_AES_ALT)
00048
00049
00050
00051 #ifdef __cplusplus
00052 extern "C" {
00053 #endif
00054
00058 typedef struct
00059 {
00060 int nr;
00061 uint32_t *rk;
00062 uint32_t buf[68];
00063 }
00064 aes_context;
00065
00075 int aes_setkey_enc( aes_context *ctx, const unsigned char *key, unsigned int keysize );
00076
00086 int aes_setkey_dec( aes_context *ctx, const unsigned char *key, unsigned int keysize );
00087
00098 int aes_crypt_ecb( aes_context *ctx,
00099 int mode,
00100 const unsigned char input[16],
00101 unsigned char output[16] );
00102
00103 #if defined(POLARSSL_CIPHER_MODE_CBC)
00104
00118 int aes_crypt_cbc( aes_context *ctx,
00119 int mode,
00120 size_t length,
00121 unsigned char iv[16],
00122 const unsigned char *input,
00123 unsigned char *output );
00124 #endif
00125
00143 int aes_crypt_cfb128( aes_context *ctx,
00144 int mode,
00145 size_t length,
00146 size_t *iv_off,
00147 unsigned char iv[16],
00148 const unsigned char *input,
00149 unsigned char *output );
00150
00173 int aes_crypt_ctr( aes_context *ctx,
00174 size_t length,
00175 size_t *nc_off,
00176 unsigned char nonce_counter[16],
00177 unsigned char stream_block[16],
00178 const unsigned char *input,
00179 unsigned char *output );
00180
00181 #ifdef __cplusplus
00182 }
00183 #endif
00184
00185 #else
00186 #include "aes_alt.h"
00187 #endif
00188
00189 #ifdef __cplusplus
00190 extern "C" {
00191 #endif
00192
00198 int aes_self_test( int verbose );
00199
00200 #ifdef __cplusplus
00201 }
00202 #endif
00203
00204 #endif