Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

dsAES.h

Go to the documentation of this file.
00001 
00021 #include <dsCypher.h>
00022 
00023                              
00024 #define KEYLENGTH(keybits) ((keybits)/8)
00025 #define RKLENGTH(keybits)  ((keybits)/8+28)
00026 #define NROUNDS(keybits)   ((keybits)/32+6)
00027 
00028 #define dsCypher_AES_OPTIMIZE_SPEED
00029 
00030 class  dsAES : public dsBlockCypher
00031 {
00032     /* This table is small and always static */
00033     static const dsCypher_word32_t dsAES::_rcon[10];
00034     
00035     /* These two tables always static and used 
00036        to generate all other one either on object creation
00037        or on_fly 
00038      */  
00039     static const dsCypher_word32_t dsAES::_Te0[256]  dsCypher_SECTION;
00040     static const dsCypher_word32_t dsAES::_Td0[256]  dsCypher_SECTION;
00041 
00042     /* These tables always filled-up on object
00043        creation */
00044 
00045     dsCypher_word32_t dsAES::_FSb[256];
00046     dsCypher_word32_t dsAES::_RSb[256];
00047 
00048     /* Prepared key storage */
00049     dsCypher_word32_t _rk[ RKLENGTH(128) ];
00050 
00051 #ifdef dsCypher_AES_OPTIMIZE_SPEED
00052    
00053     /* All necessary constant pre-generated object startup -
00054        it require additional 6k memory, but make 
00055        encryption/decryption
00056        about 3 times faster 
00057     */
00058 
00059     dsCypher_word32_t dsAES::_Te1[256];
00060     dsCypher_word32_t dsAES::_Te2[256];
00061     dsCypher_word32_t dsAES::_Te3[256];
00062 
00063     dsCypher_word32_t dsAES::_Td1[256];
00064     dsCypher_word32_t dsAES::_Td2[256];
00065     dsCypher_word32_t dsAES::_Td3[256];
00066 #endif
00067 
00068     void adjustKeForDecryption();
00069     void buildSTables();
00070 
00071 public:
00072     
00073     /* dsCypher interfaces */
00074     virtual void setKey(const dsCypher_byte_t *p_key, dsCypher_word32_t p_keyLen, keyMode km) dsCypher_SECTION;
00075 
00081     virtual void encryptBlock(const dsCypher_word32_t *inBlock, dsCypher_word32_t *outBlock)  dsCypher_SECTION;
00082     virtual void decryptBlock(const dsCypher_word32_t *inBlock, dsCypher_word32_t *outBlock)  dsCypher_SECTION;
00083 
00084     dsAES(const dsCypher_byte_t *p_key, dsCypher_word32_t p_keyLen);
00085     dsAES();
00086 
00087 #ifdef WITH_TEST_VECTORS
00088     virtual const dsCypher_byte_t * testExpectedResult( cmMODES p_mode );
00089     virtual const dsCypher_word32_t testExpectedResultLen( cmMODES p_mode );
00090     virtual const char *testAlgName();
00091 #endif
00092 };
00093 
00094 
00095 
00096 

Generated on Mon May 16 18:26:57 2005 for libdms4 by doxygen1.3-rc2