3 #ifndef CRYPTOPP_LUBYRACK_H
4 #define CRYPTOPP_LUBYRACK_H
11 NAMESPACE_BEGIN(CryptoPP)
15 CRYPTOPP_CONSTANT(RESULT = 2*T::DIGESTSIZE)
22 static std::string StaticAlgorithmName() {
return std::string(
"LR/")+T::StaticAlgorithmName();}
33 void UncheckedSetKey(
const byte *userKey,
unsigned int length,
const NameValuePairs ¶ms)
35 this->AssertValidKeyLength(length);
40 key.Assign(userKey, 2*L);
44 CRYPTOPP_CONSTANT(S=T::DIGESTSIZE)
52 class CRYPTOPP_NO_VTABLE Enc :
public Base
57 #define KR this->key+this->L
58 #define BL this->buffer
59 #define BR this->buffer+this->S
61 #define IR inBlock+this->S
63 #define OR outBlock+this->S
65 void ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const
67 this->hm.Update(KL, this->L);
68 this->hm.Update(IL, this->S);
70 xorbuf(BR, IR, this->S);
72 this->hm.Update(KR, this->L);
73 this->hm.Update(BR, this->S);
75 xorbuf(BL, IL, this->S);
77 this->hm.Update(KL, this->L);
78 this->hm.Update(BL, this->S);
79 this->hm.Final(this->digest);
80 xorbuf(BR, this->digest, this->S);
82 this->hm.Update(KR, this->L);
83 this->hm.Update(OR, this->S);
84 this->hm.Final(this->digest);
85 xorbuf(BL, this->digest, this->S);
88 xorbuf(outBlock, xorBlock, this->buffer, 2*this->S);
90 memcpy_s(outBlock, 2*this->S, this->buffer, 2*this->S);
94 class CRYPTOPP_NO_VTABLE Dec :
public Base
97 void ProcessAndXorBlock(
const byte *inBlock,
const byte *xorBlock, byte *outBlock)
const
99 this->hm.Update(KR, this->L);
100 this->hm.Update(IR, this->S);
102 xorbuf(BL, IL, this->S);
104 this->hm.Update(KL, this->L);
105 this->hm.Update(BL, this->S);
107 xorbuf(BR, IR, this->S);
109 this->hm.Update(KR, this->L);
110 this->hm.Update(BR, this->S);
111 this->hm.Final(this->digest);
112 xorbuf(BL, this->digest, this->S);
114 this->hm.Update(KL, this->L);
115 this->hm.Update(OL, this->S);
116 this->hm.Final(this->digest);
117 xorbuf(BR, this->digest, this->S);
120 xorbuf(outBlock, xorBlock, this->buffer, 2*this->S);
122 memcpy(outBlock, this->buffer, 2*this->S);
These objects usually should not be used directly. See CipherModeDocumentation instead.
to be inherited by block ciphers with fixed block size
support query of variable key length, template parameters are default, min, max, multiple (default mu...
interface for retrieving values given their names