Crypto++  5.6.3
Free C++ class library of cryptographic schemes
twofish.h
Go to the documentation of this file.
1 // twofish.h - written and placed in the public domain by Wei Dai
2 
3 //! \file twofish.h
4 //! \brief Classes for the Twofish block cipher
5 
6 #ifndef CRYPTOPP_TWOFISH_H
7 #define CRYPTOPP_TWOFISH_H
8 
9 #include "seckey.h"
10 #include "secblock.h"
11 
12 NAMESPACE_BEGIN(CryptoPP)
13 
14 //! _
15 struct Twofish_Info : public FixedBlockSize<16>, public VariableKeyLength<16, 0, 32>, FixedRounds<16>
16 {
17  static const char *StaticAlgorithmName() {return "Twofish";}
18 };
19 
20 /// <a href="http://www.weidai.com/scan-mirror/cs.html#Twofish">Twofish</a>
22 {
23  class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<Twofish_Info>
24  {
25  public:
26  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
27 
28  protected:
29  static word32 h0(word32 x, const word32 *key, unsigned int kLen);
30  static word32 h(word32 x, const word32 *key, unsigned int kLen);
31 
32  static const byte q[2][256];
33  static const word32 mds[4][256];
34 
37  };
38 
39  class CRYPTOPP_NO_VTABLE Enc : public Base
40  {
41  public:
42  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
43  };
44 
45  class CRYPTOPP_NO_VTABLE Dec : public Base
46  {
47  public:
48  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
49  };
50 
51 public:
54 };
55 
58 
59 NAMESPACE_END
60 
61 #endif
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:385
Interface for one direction (encryption or decryption) of a block cipher.
Definition: cryptlib.h:1013
Classes and functions for secure memory allocations.
Inherited by block ciphers with fixed block size.
Definition: seckey.h:34
Twofish
Definition: twofish.h:21
Classes and functions for implementing secret key algorithms.
Inherited by ciphers with fixed number of rounds.
Definition: seckey.h:47
Inherited by keyed algorithms with variable key length.
Definition: seckey.h:152
Provides class member functions to access BlockCipher constants.
Definition: seckey.h:292
Crypto++ library namespace.
Interface for retrieving values given their names.
Definition: cryptlib.h:261