Crypto++  5.6.3
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  static 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_Info
24 //! \brief Blowfish block cipher
26 {
27  //! \class Base
28  //! \brief Class specific implementation and overrides used to operate the cipher.
29  //! \details Implementations and overrides in \p Base apply to both \p ENCRYPTION and \p DECRYPTION directions
30  class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Blowfish_Info>
31  {
32  public:
33  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
34  void UncheckedSetKey(const byte *key_string, unsigned int keylength, const NameValuePairs &params);
35 
36  private:
37  void crypt_block(const word32 in[2], word32 out[2]) const;
38 
39  static const word32 p_init[ROUNDS+2];
40  static const word32 s_init[4*256];
41 
44  };
45 
46 public:
49 };
50 
53 
54 NAMESPACE_END
55 
56 #endif
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:396
Classes and functions for secure memory allocations.
Inherited by algorithms with fixed block size.
Definition: seckey.h:34
Classes and functions for implementing secret key algorithms.
Provides class member functions to key a block cipher.
Definition: seckey.h:316
Blowfish block cipher information.
Definition: blowfish.h:16
Inherited by algorithms with fixed number of rounds.
Definition: seckey.h:47
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:157
static const int ROUNDS
The number of rounds for the algorithm provided as a constant.
Definition: seckey.h:51
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:303
Crypto++ library namespace.
Interface for retrieving values given their names.
Definition: cryptlib.h:277