Botan
1.11.15
|
00001 /* 00002 * Twofish 00003 * (C) 1999-2007 Jack Lloyd 00004 * 00005 * Botan is released under the Simplified BSD License (see license.txt) 00006 */ 00007 00008 #ifndef BOTAN_TWOFISH_H__ 00009 #define BOTAN_TWOFISH_H__ 00010 00011 #include <botan/block_cipher.h> 00012 00013 namespace Botan { 00014 00015 /** 00016 * Twofish, an AES finalist 00017 */ 00018 class BOTAN_DLL Twofish : public Block_Cipher_Fixed_Params<16, 16, 32, 8> 00019 { 00020 public: 00021 void encrypt_n(const byte in[], byte out[], size_t blocks) const; 00022 void decrypt_n(const byte in[], byte out[], size_t blocks) const; 00023 00024 void clear(); 00025 std::string name() const { return "Twofish"; } 00026 BlockCipher* clone() const { return new Twofish; } 00027 private: 00028 void key_schedule(const byte[], size_t); 00029 00030 static void rs_mul(byte[4], byte, size_t); 00031 00032 static const u32bit MDS0[256]; 00033 static const u32bit MDS1[256]; 00034 static const u32bit MDS2[256]; 00035 static const u32bit MDS3[256]; 00036 static const byte Q0[256]; 00037 static const byte Q1[256]; 00038 static const byte RS[32]; 00039 static const byte EXP_TO_POLY[255]; 00040 static const byte POLY_TO_EXP[255]; 00041 00042 secure_vector<u32bit> SB, RK; 00043 }; 00044 00045 } 00046 00047 #endif