File indexing completed on 2025-01-18 09:54:54
0001
0002
0003
0004
0005
0006 #ifndef CRYPTOPP_BLOWFISH_H
0007 #define CRYPTOPP_BLOWFISH_H
0008
0009 #include "seckey.h"
0010 #include "secblock.h"
0011
0012 NAMESPACE_BEGIN(CryptoPP)
0013
0014
0015 struct Blowfish_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 4, 56>, public FixedRounds<16>
0016 {
0017 CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "Blowfish";}
0018 };
0019
0020
0021
0022
0023
0024 class Blowfish : public Blowfish_Info, public BlockCipherDocumentation
0025 {
0026
0027
0028 class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Blowfish_Info>
0029 {
0030 public:
0031 void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
0032 void UncheckedSetKey(const byte *key_string, unsigned int keylength, const NameValuePairs ¶ms);
0033
0034 private:
0035 void crypt_block(const word32 in[2], word32 out[2]) const;
0036
0037 static const word32 p_init[ROUNDS+2];
0038 static const word32 s_init[4*256];
0039
0040 FixedSizeSecBlock<word32, ROUNDS+2> pbox;
0041 FixedSizeSecBlock<word32, 4*256> sbox;
0042 };
0043
0044 public:
0045 typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
0046 typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
0047 };
0048
0049 typedef Blowfish::Encryption BlowfishEncryption;
0050 typedef Blowfish::Decryption BlowfishDecryption;
0051
0052 NAMESPACE_END
0053
0054 #endif