00001
00016 #ifndef C4E_AES_H
00017 #define C4E_AES_H
00018
00019
00020
00021
00022 #include "c4e_arch.h"
00023 #include "c4e_cipher.h"
00024
00025
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029
00030
00031
00032
00033
00034 #define C4E_AES_STATE_COLUMNS 4U
00035 #define C4E_AES_STATE_ROWS 4U
00040 #define C4E_AES_STATE_SIZE ((C4E_AES_STATE_COLUMNS * C4E_AES_STATE_ROWS) \
00041 / sizeof(C4eAesState))
00042
00043 #define C4E_AES128_ROUNDS 10U
00044 #define C4E_AES192_ROUNDS 12U
00045 #define C4E_AES256_ROUNDS 14U
00052 #define C4E_AES_CTX_SIZE(rnds) (((rnds) + 2U) * C4E_AES_STATE_SIZE)
00053
00054
00066 #define C4E_AES128_CTX_SIZE C4E_AES_CTX_SIZE(C4E_AES128_ROUNDS)
00067
00071 #define C4E_AES192_CTX_SIZE C4E_AES_CTX_SIZE(C4E_AES192_ROUNDS)
00072
00076 #define C4E_AES256_CTX_SIZE C4E_AES_CTX_SIZE(C4E_AES256_ROUNDS)
00077
00081 #define C4E_AES_MAX_CTX_SIZE C4E_AES256_CTX_SIZE
00082
00083
00084 #define C4E_AES128_KEY_SIZE 16U
00085 #define C4E_AES192_KEY_SIZE 24U
00086 #define C4E_AES256_KEY_SIZE 32U
00089 #define C4E_AES_BLOCK_SIZE 16U
00092
00093
00094
00104 #ifdef C4E_HAVE_UINT32
00105 typedef C4eArchUint32 C4eAesState;
00106 #else
00107 typedef C4eArchUint8 C4eAesState;
00108 #endif
00109
00110
00111
00112
00113
00114
00115
00116
00117
00133 void c4e_aes_setup(C4eCipherId algo, C4E_CONST C4eArchUint8* key, C4eAesState* ctx);
00134
00135
00136
00137
00158 void c4e_aes_encrypt(C4eCipherId algo,
00159 C4eAesState* C4E_RESTRICT ctx,
00160 C4E_CONST C4eArchUint8* C4E_RESTRICT plain,
00161 C4eArchUint8* C4E_RESTRICT cipher);
00162
00163
00164
00165
00186 void c4e_aes_decrypt(C4eCipherId algo,
00187 C4eAesState* C4E_RESTRICT ctx,
00188 C4E_CONST C4eArchUint8* C4E_RESTRICT cipher,
00189 C4eArchUint8* C4E_RESTRICT plain);
00190
00191
00196 #ifdef __cplusplus
00197 }
00198 #endif
00199
00200
00201
00202 #endif
00203
00204
00205
00206
00207