twofish.h

Go to the documentation of this file.
00001 #ifndef CRYPTOPP_TWOFISH_H
00002 #define CRYPTOPP_TWOFISH_H
00003 
00004 /** \file
00005 */
00006 
00007 #include "seckey.h"
00008 #include "secblock.h"
00009 
00010 NAMESPACE_BEGIN(CryptoPP)
00011 
00012 //! _
00013 struct Twofish_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 0, 32>, FixedRounds<16>
00014 {
00015         static const char *StaticAlgorithmName() {return "Twofish";}
00016 };
00017 
00018 /// <a href="http://www.weidai.com/scan-mirror/cs.html#Twofish">Twofish</a>
00019 class Twofish : public Twofish_Info, public BlockCipherDocumentation
00020 {
00021         class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Twofish_Info>
00022         {
00023         public:
00024                 void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
00025 
00026         protected:
00027                 static word32 h0(word32 x, const word32 *key, unsigned int kLen);
00028                 static word32 h(word32 x, const word32 *key, unsigned int kLen);
00029 
00030                 static const byte q[2][256];
00031                 static const word32 mds[4][256];
00032 
00033                 FixedSizeSecBlock<word32, 40> m_k;
00034                 FixedSizeSecBlock<word32[256], 4> m_s;
00035         };
00036 
00037         class CRYPTOPP_NO_VTABLE Enc : public Base
00038         {
00039         public:
00040                 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00041         };
00042 
00043         class CRYPTOPP_NO_VTABLE Dec : public Base
00044         {
00045         public:
00046                 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00047         };
00048 
00049 public:
00050         typedef BlockCipherFinal<ENCRYPTION, Enc> Encryption;
00051         typedef BlockCipherFinal<DECRYPTION, Dec> Decryption;
00052 };
00053 
00054 typedef Twofish::Encryption TwofishEncryption;
00055 typedef Twofish::Decryption TwofishDecryption;
00056 
00057 NAMESPACE_END
00058 
00059 #endif

Generated on Sat Dec 23 02:07:11 2006 for Crypto++ by  doxygen 1.5.1-p1