aboutsummaryrefslogtreecommitdiff
path: root/src/keystore.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-04-05 01:02:49 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2012-04-05 02:07:53 +0200
commite5c027b49b72d8245ebec26cb92d918377fd81e0 (patch)
tree1a29b0f4fcf1a3dc8b0305d553f9f9f1c93f0bf3 /src/keystore.cpp
parentb0a7e05a45a925d78efd00ecca6dce9b7a9530f9 (diff)
downloadbitcoin-e5c027b49b72d8245ebec26cb92d918377fd81e0.tar.xz
Verify status of encrypt/decrypt calls to detect failed padding
Diffstat (limited to 'src/keystore.cpp')
-rw-r--r--src/keystore.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/keystore.cpp b/src/keystore.cpp
index e76f7790f1..23f9e32fa2 100644
--- a/src/keystore.cpp
+++ b/src/keystore.cpp
@@ -84,6 +84,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.SetPubKey(vchPubKey);
key.SetSecret(vchSecret);
@@ -146,6 +148,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.SetPubKey(vchPubKey);
keyOut.SetSecret(vchSecret);
return true;