Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

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 struct Twofish_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 0, 32>, FixedRounds<16>
00013 {
00014         static const char *StaticAlgorithmName() {return "Twofish";}
00015 };
00016 
00017 /// <a href="http://www.weidai.com/scan-mirror/cs.html#Twofish">Twofish</a>
00018 class Twofish : public Twofish_Info, public BlockCipherDocumentation
00019 {
00020         class Base : public BlockCipherBaseTemplate<Twofish_Info>
00021         {
00022         public:
00023                 void UncheckedSetKey(CipherDir direction, const byte *userKey, unsigned int length);
00024 
00025         protected:
00026                 static word32 h0(word32 x, const word32 *key, unsigned int kLen);
00027                 static word32 h(word32 x, const word32 *key, unsigned int kLen);
00028 
00029                 static const byte q[2][256];
00030                 static const word32 mds[4][256];
00031 
00032                 FixedSizeSecBlock<word32, 40> m_k;
00033                 FixedSizeSecBlock<word32[256], 4> m_s;
00034         };
00035 
00036         class Enc : public Base
00037         {
00038         public:
00039                 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00040         };
00041 
00042         class Dec : public Base
00043         {
00044         public:
00045                 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00046         };
00047 
00048 public:
00049         typedef BlockCipherTemplate<ENCRYPTION, Enc> Encryption;
00050         typedef BlockCipherTemplate<DECRYPTION, Dec> Decryption;
00051 };
00052 
00053 typedef Twofish::Encryption TwofishEncryption;
00054 typedef Twofish::Decryption TwofishDecryption;
00055 
00056 NAMESPACE_END
00057 
00058 #endif

Generated on Sun Mar 14 20:44:29 2004 for Crypto++ by doxygen 1.3.6-20040222