Crypto++  5.6.5
Free C++ class library of cryptographic schemes
blowfish.h
Go to the documentation of this file.
1 // blowfish.h - written and placed in the public domain by Wei Dai
2 
3 //! \file blowfish.h
4 //! \brief Classes for the Blowfish block cipher
5 
6 #ifndef CRYPTOPP_BLOWFISH_H
7 #define CRYPTOPP_BLOWFISH_H
8 
9 #include "seckey.h"
10 #include "secblock.h"
11 
12 NAMESPACE_BEGIN(CryptoPP)
13 
14 //! \class Blowfish_Info
15 //! \brief Blowfish block cipher information
16 struct Blowfish_Info : public FixedBlockSize<8>, public VariableKeyLength<16, 4, 56>, public FixedRounds<16>
17 {
18  CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "Blowfish";}
19 };
20 
21 // <a href="http://www.weidai.com/scan-mirror/cs.html#Blowfish">Blowfish</a>
22 
23 //! \class Blowfish
24 //! \brief Blowfish block cipher
25 //! \since Crypto++ 1.0
27 {
28  //! \class Base
29  //! \brief Class specific implementation and overrides used to operate the cipher.
30  //! \details Implementations and overrides in \p Base apply to both \p ENCRYPTION and \p DECRYPTION directions
31  class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Blowfish_Info>
32  {
33  public:
34  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
35  void UncheckedSetKey(const byte *key_string, unsigned int keylength, const NameValuePairs &params);
36 
37  private:
38  void crypt_block(const word32 in[2], word32 out[2]) const;
39 
40  static const word32 p_init[ROUNDS+2];
41  static const word32 s_init[4*256];
42 
45  };
46 
47 public:
50 };
51 
54 
55 NAMESPACE_END
56 
57 #endif
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:408
Blowfish block cipher.
Definition: blowfish.h:26
Classes and functions for secure memory allocations.
Inherited by algorithms with fixed block size.
Definition: seckey.h:40
Classes and functions for implementing secret key algorithms.
Provides class member functions to key a block cipher.
Definition: seckey.h:324
Blowfish block cipher information.
Definition: blowfish.h:16
Inherited by algorithms with fixed number of rounds.
Definition: seckey.h:53
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:169
static const int ROUNDS
The number of rounds for the algorithm provided as a constant.
Definition: seckey.h:57
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:311
Crypto++ library namespace.
Interface for retrieving values given their names.
Definition: cryptlib.h:279