X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fkeystore.cpp;h=5b8420674df83693d64731f0d2e4141262259807;hb=d11488abd05cb39a9f481e7c4c35f780197a3d28;hp=4a59010fdbd4775518170b1c16ac1eedb508f7c4;hpb=882164196e5b1971313493f95a6d027f05e2ec92;p=novacoin.git diff --git a/src/keystore.cpp b/src/keystore.cpp index 4a59010..5b84206 100644 --- a/src/keystore.cpp +++ b/src/keystore.cpp @@ -1,23 +1,13 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers // Distributed under the MIT/X11 software license, see the accompanying -// file license.txt or http://www.opensource.org/licenses/mit-license.php. +// file COPYING or http://www.opensource.org/licenses/mit-license.php. #include "headers.h" #include "crypter.h" #include "db.h" #include "script.h" -std::vector CKeyStore::GenerateNewKey() -{ - RandAddSeedPerfmon(); - CKey key; - key.MakeNewKey(); - if (!AddKey(key)) - throw std::runtime_error("CKeyStore::GenerateNewKey() : AddKey failed"); - return key.GetPubKey(); -} - bool CKeyStore::GetPubKey(const CBitcoinAddress &address, std::vector &vchPubKeyOut) const { CKey key; @@ -94,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); @@ -156,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; @@ -192,7 +186,7 @@ bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn) BOOST_FOREACH(KeyMap::value_type& mKey, mapKeys) { CKey key; - if (!key.SetSecret(mKey.second.first, false)) + if (!key.SetSecret(mKey.second.first, mKey.second.second)) return false; const std::vector vchPubKey = key.GetPubKey(); std::vector vchCryptedSecret;