00001 #ifndef CRYPTOPP_TWOFISH_H
00002 #define CRYPTOPP_TWOFISH_H
00003
00007 #include "cryptlib.h"
00008 #include "misc.h"
00009
00010 NAMESPACE_BEGIN(CryptoPP)
00011
00013 class Twofish : public FixedBlockSize<16>, public VariableKeyLength<16, 0, 32>
00014 {
00015 protected:
00016 Twofish(const byte *userKey, unsigned int keylength);
00017 static word32 h0(word32 x, const word32 *key, unsigned int kLen);
00018 static word32 h(word32 x, const word32 *key, unsigned int kLen);
00019
00020 static const byte q[2][256];
00021 static const word32 mds[4][256];
00022
00023 SecBlock<word32> m_k;
00024 SecBlock<word32[256]> m_s;
00025 };
00026
00028 class TwofishEncryption : public Twofish
00029 {
00030 public:
00031 TwofishEncryption(const byte *userKey, unsigned int keylength=DEFAULT_KEYLENGTH)
00032 : Twofish(userKey, keylength) {}
00033
00034 void ProcessBlock(const byte *inBlock, byte * outBlock) const;
00035 void ProcessBlock(byte * inoutBlock) const
00036 {TwofishEncryption::ProcessBlock(inoutBlock, inoutBlock);}
00037 };
00038
00040 class TwofishDecryption : public Twofish
00041 {
00042 public:
00043 TwofishDecryption(const byte *userKey, unsigned int keylength=DEFAULT_KEYLENGTH)
00044 : Twofish(userKey, keylength) {}
00045
00046 void ProcessBlock(const byte *inBlock, byte * outBlock) const;
00047 void ProcessBlock(byte * inoutBlock) const
00048 {TwofishDecryption::ProcessBlock(inoutBlock, inoutBlock);}
00049 };
00050
00051 NAMESPACE_END
00052
00053 #endif