Fabcoin Core  0.16.2
P2P Digital Currency
des.h
Go to the documentation of this file.
1 // des.h - written and placed in the public domain by Wei Dai
2 
5 
6 #ifndef CRYPTOPP_DES_H
7 #define CRYPTOPP_DES_H
8 
9 #include "seckey.h"
10 #include "secblock.h"
11 
13 
14 class CRYPTOPP_DLL RawDES
17 {
18 public:
19  void RawSetKey(CipherDir direction, const byte *userKey);
20  void RawProcessBlock(word32 &l, word32 &r) const;
21 
22 protected:
23  static const word32 Spbox[8][64];
24 
26 };
27 
30 struct DES_Info : public FixedBlockSize<8>, public FixedKeyLength<8>
31 {
32  // disable DES in DLL version by not exporting this function
33  CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "DES";}
34 };
35 
43 class DES : public DES_Info, public BlockCipherDocumentation
44 {
47  class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_Info>, public RawDES
48  {
49  public:
50  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
51  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
52  };
53 
54 public:
56  static bool CheckKeyParityBits(const byte *key);
58  static void CorrectKeyParityBits(byte *key);
59 
62 };
63 
66 struct DES_EDE2_Info : public FixedBlockSize<8>, public FixedKeyLength<16>
67 {
68  CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return "DES-EDE2";}
69 };
70 
76 {
79  class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_EDE2_Info>
80  {
81  public:
82  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
83  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
84 
85  protected:
86  RawDES m_des1, m_des2;
87  };
88 
89 public:
92 };
93 
96 struct DES_EDE3_Info : public FixedBlockSize<8>, public FixedKeyLength<24>
97 {
98  CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return "DES-EDE3";}
99 };
100 
106 {
109  class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_EDE3_Info>
110  {
111  public:
112  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
113  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
114 
115  protected:
116  RawDES m_des1, m_des2, m_des3;
117  };
118 
119 public:
122 };
123 
126 struct DES_XEX3_Info : public FixedBlockSize<8>, public FixedKeyLength<24>
127 {
128  CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "DES-XEX3";}
129 };
130 
136 {
139  class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_XEX3_Info>
140  {
141  public:
142  void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs &params);
143  void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
144 
145  protected:
147  // VS2005 workaround: calling modules compiled with /clr gets unresolved external symbol DES::Base::ProcessAndXorBlock
148  // if we use DES::Encryption here directly without value_ptr.
150  };
151 
152 public:
155 };
156 
159 
162 
165 
168 
170 
171 #endif
Inherited by keyed algorithms with fixed key length.
Definition: seckey.h:127
static CRYPTOPP_DLL const char *CRYPTOPP_API StaticAlgorithmName()
Definition: des.h:68
uint8_t byte
Definition: Common.h:57
#define CRYPTOPP_STATIC_CONSTEXPR
Definition: config.h:892
DES_EDE2::Encryption DES_EDE2_Encryption
Definition: des.h:160
Provides Encryption and Decryption typedefs used by derived classes to implement a block cipher...
Definition: seckey.h:408
BlockCipherFinal< ENCRYPTION, Base > Encryption
Definition: des.h:120
CRYPTOPP_STATIC_CONSTEXPR const char * StaticAlgorithmName()
Definition: des.h:33
FixedSizeSecBlock< byte, BLOCKSIZE > m_x3
Definition: des.h:146
DES_EDE2 block cipher default operation.
Definition: des.h:79
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
DES block cipher default operation.
Definition: des.h:47
BlockCipherFinal< ENCRYPTION, Base > Encryption
Definition: des.h:60
CipherDir
Specifies a direction for a cipher to operate.
Definition: cryptlib.h:104
DES block cipher base class.
Definition: des.h:16
DES_EDE3 block cipher default operation.
Definition: des.h:109
DES block cipher.
Definition: des.h:43
BlockCipherFinal< DECRYPTION, Base > Decryption
Definition: des.h:91
DES_XEX3 block cipher default operation.
Definition: des.h:139
Classes and functions for secure memory allocations.
Inherited by algorithms with fixed block size.
Definition: seckey.h:40
DESX block cipher.
Definition: des.h:135
BlockCipherFinal< DECRYPTION, Base > Decryption
Definition: des.h:61
DES_XEX3::Decryption DES_XEX3_Decryption
Definition: des.h:167
value_ptr< DES::Encryption > m_des
Definition: des.h:149
BlockCipherFinal< ENCRYPTION, Base > Encryption
Definition: des.h:153
CRYPTOPP_STATIC_CONSTEXPR const char * StaticAlgorithmName()
Definition: des.h:128
3-key TripleDES block cipher
Definition: des.h:105
Classes and functions for implementing secret key algorithms.
DES_EDE2::Decryption DES_EDE2_Decryption
Definition: des.h:161
RawDES m_des3
Definition: des.h:116
2-key TripleDES block cipher information
Definition: des.h:66
Provides class member functions to key a block cipher.
Definition: seckey.h:324
3-key TripleDES block cipher information
Definition: des.h:96
2-key TripleDES block cipher
Definition: des.h:75
RawDES m_des2
Definition: des.h:86
DES block cipher information.
Definition: des.h:30
#define CRYPTOPP_API
Definition: config.h:705
DESX block cipher information.
Definition: des.h:126
BlockCipherFinal< DECRYPTION, Base > Decryption
Definition: des.h:154
#define CRYPTOPP_NO_VTABLE
Definition: config.h:369
DES_EDE3::Encryption DES_EDE3_Encryption
Definition: des.h:163
DES_EDE3::Decryption DES_EDE3_Decryption
Definition: des.h:164
FixedSizeSecBlock< word32, 32 > k
Definition: des.h:25
Value pointer.
Definition: smartptr.h:79
#define NAMESPACE_END
Definition: config.h:201
static CRYPTOPP_DLL const char *CRYPTOPP_API StaticAlgorithmName()
Definition: des.h:98
Provides a base implementation of Algorithm and SimpleKeyingInterface for block ciphers.
Definition: seckey.h:311
DES_XEX3::Encryption DES_XEX3_Encryption
Definition: des.h:166
DES::Encryption DESEncryption
Definition: des.h:157
#define CRYPTOPP_DLL
Definition: config.h:704
unsigned int word32
Definition: config.h:231
DES::Decryption DESDecryption
Definition: des.h:158
BlockCipherFinal< DECRYPTION, Base > Decryption
Definition: des.h:121
BlockCipherFinal< ENCRYPTION, Base > Encryption
Definition: des.h:90
Interface for retrieving values given their names.
Definition: cryptlib.h:279