Verify status of encrypt/decrypt calls to detect failed padding

This commit is contained in:
Pieter Wuille
2012-04-05 18:03:48 -04:00
committed by Luke Dashjr
parent bf754cfd01
commit c7057326ea
2 changed files with 18 additions and 10 deletions
+4
View File
@@ -71,6 +71,8 @@ bool CCryptoKeyStore::Unlock(const CKeyingMaterial& vMasterKeyIn)
CSecret vchSecret;
if(!DecryptSecret(vMasterKeyIn, vchCryptedSecret, Hash(vchPubKey.begin(), vchPubKey.end()), vchSecret))
return false;
if (vchSecret.size() != 32)
return false;
CKey key;
key.SetSecret(vchSecret);
if (key.GetPubKey() == vchPubKey)
@@ -131,6 +133,8 @@ bool CCryptoKeyStore::GetKey(const CBitcoinAddress &address, CKey& keyOut) const
CSecret vchSecret;
if (!DecryptSecret(vMasterKey, vchCryptedSecret, Hash(vchPubKey.begin(), vchPubKey.end()), vchSecret))
return false;
if (vchSecret.size() != 32)
return false;
keyOut.SetSecret(vchSecret);
return true;
}