00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef _AES_H
00038 #define _AES_H
00039
00040 #if defined(__cplusplus)
00041 extern "C"
00042 {
00043 #endif
00044
00045 #define AES_128
00046 #define AES_192
00047 #define AES_256
00048 #define AES_VAR
00049
00050
00051
00052 #define AES_ENCRYPT
00053
00054
00055
00056 #include "limits.h"
00057
00058 #if UCHAR_MAX == 0xff
00059 typedef unsigned char aes_08t;
00060 #else
00061 #error Please define aes_08t as an 8-bit unsigned integer type in aes.h
00062 #endif
00063
00064 #if UINT_MAX == 0xffffffff
00065 typedef unsigned int aes_32t;
00066 #elif ULONG_MAX == 0xffffffff
00067 typedef unsigned long aes_32t;
00068 #else
00069 #error Please define aes_32t as a 32-bit unsigned integer type in aes.h
00070 #endif
00071
00072
00073
00074 #define AES_BLOCK_SIZE 16
00075 #define KS_LENGTH (4 * AES_BLOCK_SIZE)
00076 #define N_COLS (AES_BLOCK_SIZE >> 2)
00077
00078 #ifndef AES_DLL
00079 #define aes_rval void
00080 #else
00081 #define aes_rval void __declspec(dllexport) _stdcall
00082 #endif
00083
00084
00085
00086
00087 void gen_tabs(void);
00088
00089
00090
00091
00092 #ifdef AES_ENCRYPT
00093
00094 typedef struct
00095 { aes_32t k_sch[KS_LENGTH];
00096 aes_32t n_rnd;
00097 } aes_encrypt_ctx;
00098
00099 #if defined(AES_128) || defined(AES_VAR)
00100 aes_rval aes_encrypt_key128(const void *in_key, aes_encrypt_ctx cx[1]);
00101 #endif
00102
00103 #if defined(AES_192) || defined(AES_VAR)
00104 aes_rval aes_encrypt_key192(const void *in_key, aes_encrypt_ctx cx[1]);
00105 #endif
00106
00107 #if defined(AES_256) || defined(AES_VAR)
00108 aes_rval aes_encrypt_key256(const void *in_key, aes_encrypt_ctx cx[1]);
00109 #endif
00110
00111 #if defined(AES_VAR)
00112 aes_rval aes_encrypt_key(const void *in_key, int key_len, aes_encrypt_ctx cx[1]);
00113 #endif
00114
00115 aes_rval aes_encrypt(const void *in_blk, void *out_blk, const aes_encrypt_ctx cx[1]);
00116 #endif
00117
00118 #ifdef AES_DECRYPT
00119
00120 typedef struct
00121 { aes_32t k_sch[KS_LENGTH];
00122 aes_32t n_rnd;
00123 } aes_decrypt_ctx;
00124
00125 #if defined(AES_128) || defined(AES_VAR)
00126 aes_rval aes_decrypt_key128(const void *in_key, aes_decrypt_ctx cx[1]);
00127 #endif
00128
00129 #if defined(AES_192) || defined(AES_VAR)
00130 aes_rval aes_decrypt_key192(const void *in_key, aes_decrypt_ctx cx[1]);
00131 #endif
00132
00133 #if defined(AES_256) || defined(AES_VAR)
00134 aes_rval aes_decrypt_key256(const void *in_key, aes_decrypt_ctx cx[1]);
00135 #endif
00136
00137 #if defined(AES_VAR)
00138 aes_rval aes_decrypt_key(const void *in_key, int key_len, aes_decrypt_ctx cx[1]);
00139 #endif
00140
00141 aes_rval aes_decrypt(const void *in_blk, void *out_blk, const aes_decrypt_ctx cx[1]);
00142 #endif
00143
00144 #if defined(__cplusplus)
00145 }
00146 #endif
00147
00148 #endif