00001
00002
00003
00004
00005
00006 #ifndef CRYPTOPP_BLOWFISH_H
00007 #define CRYPTOPP_BLOWFISH_H
00008
00009 #include "seckey.h"
00010 #include "secblock.h"
00011
00012 NAMESPACE_BEGIN(CryptoPP)
00013
00014
00015
00016 struct Blowfish_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 4, 56>, public FixedRounds<16>
00017 {
00018 static const char *StaticAlgorithmName() {return "Blowfish";}
00019 };
00020
00021
00022
00023
00024
00025 class Blowfish : public Blowfish_Info, public BlockCipherDocumentation
00026 {
00027
00028
00029
00030 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Blowfish_Info>
00031 {
00032 public:
00033 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
00034 void UncheckedSetKey(const byte *key_string, unsigned int keylength, const NameValuePairs ¶ms);
00035
00036 private:
00037 void crypt_block(const word32 in[2], word32 out[2]) const;
00038
00039 static const word32 p_init[ROUNDS+2];
00040 static const word32 s_init[4*256];
00041
00042 FixedSizeSecBlock<word32, ROUNDS+2> pbox;
00043 FixedSizeSecBlock<word32, 4*256> sbox;
00044 };
00045
00046 public:
00047 typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
00048 typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
00049 };
00050
00051 typedef Blowfish::Encryption BlowfishEncryption;
00052 typedef Blowfish::Decryption BlowfishDecryption;
00053
00054 NAMESPACE_END
00055
00056 #endif