MCPcopy Create free account
hub / github.com/LUX-Core/lux / CheckKey

Method CheckKey

src/cryptopp/default.cpp:182–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

180
181template <class BC, class H, class Info>
182void DataDecryptor<BC,H,Info>::CheckKey(const byte *salt, const byte *keyCheck)
183{
184 SecByteBlock check(STDMAX((unsigned int)2*BLOCKSIZE, (unsigned int)DIGESTSIZE));
185
186 H hash;
187 hash.Update(m_passphrase, m_passphrase.size());
188 hash.Update(salt, SALTLENGTH);
189 hash.Final(check);
190
191 SecByteBlock key(KEYLENGTH);
192 SecByteBlock IV(BLOCKSIZE);
193 GenerateKeyIV<BC,H,Info>(m_passphrase, m_passphrase.size(), salt, SALTLENGTH, ITERATIONS, key, IV);
194
195 m_cipher.SetKeyWithIV(key, key.size(), IV);
196 member_ptr<StreamTransformationFilter> decryptor(new StreamTransformationFilter(m_cipher));
197
198 decryptor->Put(keyCheck, BLOCKSIZE);
199 decryptor->ForceNextPut();
200 decryptor->Get(check+BLOCKSIZE, BLOCKSIZE);
201
202 SetFilter(decryptor.release());
203
204 if (!VerifyBufsEqual(check, check+BLOCKSIZE, BLOCKSIZE))
205 {
206 m_state = KEY_BAD;
207 if (m_throwException)
208 throw KeyBadErr();
209 }
210 else
211 m_state = KEY_GOOD;
212}
213
214// ********************************************************
215

Callers

nothing calls this directly

Calls 9

VerifyBufsEqualFunction · 0.85
KeyBadErrClass · 0.85
SetKeyWithIVMethod · 0.80
ForceNextPutMethod · 0.80
UpdateMethod · 0.45
sizeMethod · 0.45
PutMethod · 0.45
GetMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected