Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:54:54

0001 // blowfish.h - originally written and placed in the public domain by Wei Dai

0002 
0003 /// \file blowfish.h

0004 /// \brief Classes for the Blowfish block cipher

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 /// \brief Blowfish block cipher information

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 // <a href="http://www.cryptopp.com/wiki/Blowfish">Blowfish</a>

0021 
0022 /// \brief Blowfish block cipher

0023 /// \since Crypto++ 1.0

0024 class Blowfish : public Blowfish_Info, public BlockCipherDocumentation
0025 {
0026     /// \brief Class specific implementation and overrides used to operate the cipher.

0027     /// \details Implementations and overrides in \p Base apply to both \p ENCRYPTION and \p DECRYPTION directions

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 &params);
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