00001
00038 #ifndef __RIJNDAEL_API_FST_H
00039 #define __RIJNDAEL_API_FST_H
00040
00041
00042 #include "rijndael-alg-fst.h"
00043
00044
00045 #define DIR_ENCRYPT 0
00046 #define DIR_DECRYPT 1
00047 #define MODE_ECB 1
00048 #define MODE_CBC 2
00049 #define MODE_CFB1 3
00050 #define TRUE 1
00051 #define FALSE 0
00052 #define BITSPERBLOCK 128
00053
00054
00055 #define BAD_KEY_DIR -1
00056 #define BAD_KEY_MAT -2
00057 #define BAD_KEY_INSTANCE -3
00058 #define BAD_CIPHER_MODE -4
00059 #define BAD_CIPHER_STATE -5
00060 #define BAD_BLOCK_LENGTH -6
00061 #define BAD_CIPHER_INSTANCE -7
00062 #define BAD_DATA -8
00063 #define BAD_OTHER -9
00064
00065
00066 #define MAX_KEY_SIZE 64
00067 #define MAX_IV_SIZE 16
00068
00069
00070 #if 0
00071 typedef unsigned char BYTE;
00072 #else
00073 # ifndef WIN32
00074 typedef unsigned char BYTE;
00075 # else
00076 # include <windows.h>
00077 # endif
00078 #endif
00079
00080 typedef struct {
00081 BYTE direction;
00082 int keyLen;
00083 char keyMaterial[MAX_KEY_SIZE+1];
00084 int Nr;
00085 u32 rk[4*(MAXNR + 1)];
00086 u32 ek[4*(MAXNR + 1)];
00087 } keyInstance;
00088
00089
00090 typedef struct {
00091 BYTE mode;
00092 BYTE IV[MAX_IV_SIZE];
00093 } cipherInstance;
00094
00095
00096
00097 int makeKey(keyInstance *key, BYTE direction, int keyLen, char *keyMaterial);
00098
00099 int cipherInit(cipherInstance *cipher, BYTE mode, char *IV);
00100
00101 int blockEncrypt(cipherInstance *cipher, keyInstance *key,
00102 BYTE *input, int inputLen, BYTE *outBuffer);
00103
00104 int padEncrypt(cipherInstance *cipher, keyInstance *key,
00105 BYTE *input, int inputOctets, BYTE *outBuffer);
00106
00107 int blockDecrypt(cipherInstance *cipher, keyInstance *key,
00108 BYTE *input, int inputLen, BYTE *outBuffer);
00109
00110 int padDecrypt(cipherInstance *cipher, keyInstance *key,
00111 BYTE *input, int inputOctets, BYTE *outBuffer);
00112
00113 #ifdef INTERMEDIATE_VALUE_KAT
00114 int cipherUpdateRounds(cipherInstance *cipher, keyInstance *key,
00115 BYTE *input, int inputLen, BYTE *outBuffer, int Rounds);
00116 #endif
00117
00118 #endif