00001 #ifndef CRYPTOPP_BLOWFISH_H
00002 #define CRYPTOPP_BLOWFISH_H
00003
00006 #include "cryptlib.h"
00007 #include "misc.h"
00008
00009 NAMESPACE_BEGIN(CryptoPP)
00010
00012 class Blowfish : public FixedBlockSize<8>, public VariableKeyLength<16, 1, 72>
00013 {
00014 public:
00015 Blowfish(const byte *key_string, unsigned int keylength, CipherDir direction);
00016
00017 void ProcessBlock(byte * inoutBlock) const
00018 {Blowfish::ProcessBlock(inoutBlock, inoutBlock);}
00019 void ProcessBlock(const byte *inBlock, byte *outBlock) const;
00020
00021 enum {ROUNDS=16};
00022
00023 private:
00024 void crypt_block(const word32 in[2], word32 out[2]) const;
00025
00026 static const word32 p_init[ROUNDS+2];
00027 static const word32 s_init[4*256];
00028 SecBlock<word32> pbox, sbox;
00029 };
00030
00032 class BlowfishEncryption : public Blowfish
00033 {
00034 public:
00035 BlowfishEncryption(const byte *key_string, unsigned int keylength=DEFAULT_KEYLENGTH)
00036 : Blowfish(key_string, keylength, ENCRYPTION) {}
00037 };
00038
00040 class BlowfishDecryption : public Blowfish
00041 {
00042 public:
00043 BlowfishDecryption(const byte *key_string, unsigned int keylength=DEFAULT_KEYLENGTH)
00044 : Blowfish(key_string, keylength, DECRYPTION) {}
00045 };
00046
00047 NAMESPACE_END
00048
00049 #endif