10
NAMESPACE_BEGIN(CryptoPP)
12
class CRYPTOPP_DLL RawDES
15
void RawSetKey(CipherDir direction, const byte *userKey);
16
void RawProcessBlock(word32 &l, word32 &r) const;
19
static const word32 Spbox[8][64];
21
FixedSizeSecBlock<word32, 32> k;
25
struct DES_Info : public FixedBlockSize<8>, public FixedKeyLength<8>
27
// disable DES in DLL version by not exporting this function
28
static const char * StaticAlgorithmName() {return "DES";}
31
/// <a href="http://www.weidai.com/scan-mirror/cs.html#DES">DES</a>
32
/*! The DES implementation in Crypto++ ignores the parity bits
33
(the least significant bits of each byte) in the key. However
34
you can use CheckKeyParityBits() and CorrectKeyParityBits() to
35
check or correct the parity bits if you wish. */
36
class DES : public DES_Info, public BlockCipherDocumentation
38
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_Info>, public RawDES
41
void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms);
42
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
46
//! check DES key parity bits
47
static bool CheckKeyParityBits(const byte *key);
48
//! correct DES key parity bits
49
static void CorrectKeyParityBits(byte *key);
51
typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
52
typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
56
struct DES_EDE2_Info : public FixedBlockSize<8>, public FixedKeyLength<16>
58
CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return "DES-EDE2";}
61
/// <a href="http://www.weidai.com/scan-mirror/cs.html#DESede">DES-EDE2</a>
62
class DES_EDE2 : public DES_EDE2_Info, public BlockCipherDocumentation
64
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_EDE2_Info>
67
void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms);
68
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
71
RawDES m_des1, m_des2;
75
typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
76
typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
80
struct DES_EDE3_Info : public FixedBlockSize<8>, public FixedKeyLength<24>
82
CRYPTOPP_DLL static const char * CRYPTOPP_API StaticAlgorithmName() {return "DES-EDE3";}
85
/// <a href="http://www.weidai.com/scan-mirror/cs.html#DESede">DES-EDE3</a>
86
class DES_EDE3 : public DES_EDE3_Info, public BlockCipherDocumentation
88
class CRYPTOPP_DLL CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_EDE3_Info>
91
void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms);
92
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
95
RawDES m_des1, m_des2, m_des3;
99
typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
100
typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
104
struct DES_XEX3_Info : public FixedBlockSize<8>, public FixedKeyLength<24>
106
static const char *StaticAlgorithmName() {return "DES-XEX3";}
109
/// <a href="http://www.weidai.com/scan-mirror/cs.html#DESX">DES-XEX3</a>, AKA DESX
110
class DES_XEX3 : public DES_XEX3_Info, public BlockCipherDocumentation
112
class CRYPTOPP_NO_VTABLE Base : public BlockCipherImpl<DES_XEX3_Info>
115
void UncheckedSetKey(const byte *userKey, unsigned int length, const NameValuePairs ¶ms);
116
void ProcessAndXorBlock(const byte *inBlock, const byte *xorBlock, byte *outBlock) const;
119
FixedSizeSecBlock<byte, BLOCKSIZE> m_x1, m_x3;
120
// VS2005 workaround: calling modules compiled with /clr gets unresolved external symbol DES::Base::ProcessAndXorBlock
121
// if we use DES::Encryption here directly without value_ptr.
122
value_ptr<DES::Encryption> m_des;
126
typedef BlockCipherFinal<ENCRYPTION, Base> Encryption;
127
typedef BlockCipherFinal<DECRYPTION, Base> Decryption;
130
typedef DES::Encryption DESEncryption;
131
typedef DES::Decryption DESDecryption;
133
typedef DES_EDE2::Encryption DES_EDE2_Encryption;
134
typedef DES_EDE2::Decryption DES_EDE2_Decryption;
136
typedef DES_EDE3::Encryption DES_EDE3_Encryption;
137
typedef DES_EDE3::Decryption DES_EDE3_Decryption;
139
typedef DES_XEX3::Encryption DES_XEX3_Encryption;
140
typedef DES_XEX3::Decryption DES_XEX3_Decryption;