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

blowfish.h

Go to the documentation of this file.
00001 #ifndef CRYPTOPP_BLOWFISH_H
00002 #define CRYPTOPP_BLOWFISH_H
00003 
00004 /** \file */
00005 
00006 #include "seckey.h"
00007 #include "secblock.h"
00008 
00009 NAMESPACE_BEGIN(CryptoPP)
00010 
00011 struct Blowfish_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 56>, public FixedRounds<16>
00012 {
00013         static const char *StaticAlgorithmName() {return "Blowfish";}
00014 };
00015 
00016 //! <a href="http://www.weidai.com/scan-mirror/cs.html#Blowfish">Blowfish</a>
00017 class Blowfish : public Blowfish_Info, public BlockCipherDocumentation
00018 {
00019         class Base : public BlockCipherBaseTemplate<Blowfish_Info>
00020         {
00021         public:
00022                 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00023                 void UncheckedSetKey(CipherDir direction, const byte *key_string, unsigned int keylength);
00024 
00025         private:
00026                 void crypt_block(const word32 in[2], word32 out[2]) const;
00027 
00028                 static const word32 p_init[ROUNDS+2];
00029                 static const word32 s_init[4*256];
00030 
00031                 FixedSizeSecBlock<word32, ROUNDS+2> pbox;
00032                 FixedSizeSecBlock<word32, 4*256> sbox;
00033         };
00034 
00035 public:
00036         typedef BlockCipherTemplate<ENCRYPTION, Base> Encryption;
00037         typedef BlockCipherTemplate<DECRYPTION, Base> Decryption;
00038 };
00039 
00040 typedef Blowfish::Encryption BlowfishEncryption;
00041 typedef Blowfish::Decryption BlowfishDecryption;
00042 
00043 NAMESPACE_END
00044 
00045 #endif

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