00001 /* 00002 * $Id: rijndael-api-fst.h,v 12.0 2004/11/17 03:43:17 bostic Exp $ 00003 */ 00041 #ifndef __RIJNDAEL_API_FST_H 00042 #define __RIJNDAEL_API_FST_H 00043 00044 #include "crypto/rijndael/rijndael-alg-fst.h" 00045 00046 /* Generic Defines */ 00047 #define DIR_ENCRYPT 0 /* Are we encrpyting? */ 00048 #define DIR_DECRYPT 1 /* Are we decrpyting? */ 00049 #define MODE_ECB 1 /* Are we ciphering in ECB mode? */ 00050 #define MODE_CBC 2 /* Are we ciphering in CBC mode? */ 00051 #define MODE_CFB1 3 /* Are we ciphering in 1-bit CFB mode? */ 00052 #undef TRUE 00053 #define TRUE 1 00054 #undef FALSE 00055 #define FALSE 0 00056 #define BITSPERBLOCK 128 /* Default number of bits in a cipher block */ 00057 00058 /* Error Codes */ 00059 #define BAD_KEY_DIR -1 /* Key direction is invalid, e.g., unknown value */ 00060 #define BAD_KEY_MAT -2 /* Key material not of correct length */ 00061 #define BAD_KEY_INSTANCE -3 /* Key passed is not valid */ 00062 #define BAD_CIPHER_MODE -4 /* Params struct passed to cipherInit invalid */ 00063 #define BAD_CIPHER_STATE -5 /* Cipher in wrong state (e.g., not initialized) */ 00064 #define BAD_BLOCK_LENGTH -6 00065 #define BAD_CIPHER_INSTANCE -7 00066 #define BAD_DATA -8 /* Data contents are invalid, e.g., invalid padding */ 00067 #define BAD_OTHER -9 /* Unknown error */ 00068 00069 /* Algorithm-specific Defines */ 00070 #define MAX_KEY_SIZE 64 /* # of ASCII char's needed to represent a key */ 00071 #define MAX_IV_SIZE 16 /* # bytes needed to represent an IV */ 00072 00073 /* Typedefs */ 00074 00075 /* The structure for key information */ 00076 typedef struct { 00077 u_int8_t direction; /* Key used for encrypting or decrypting? */ 00078 int keyLen; /* Length of the key */ 00079 char keyMaterial[MAX_KEY_SIZE+1]; /* Raw key data in ASCII, e.g., user input or KAT values */ 00080 int Nr; /* key-length-dependent number of rounds */ 00081 u32 rk[4*(MAXNR + 1)]; /* key schedule */ 00082 u32 ek[4*(MAXNR + 1)]; /* CFB1 key schedule (encryption only) */ 00083 } keyInstance; 00084 00085 /* The structure for cipher information */ 00086 typedef struct { /* changed order of the components */ 00087 u_int8_t mode; /* MODE_ECB, MODE_CBC, or MODE_CFB1 */ 00088 u_int8_t IV[MAX_IV_SIZE]; /* A possible Initialization Vector for ciphering */ 00089 } cipherInstance; 00090 00091 #endif /* __RIJNDAEL_API_FST_H */