}
return true;
}
+
+bool CCryptoKeyStore::DecryptKeys(const CKeyingMaterial& vMasterKeyIn)
+{
+ {
+ LOCK(cs_KeyStore);
+ if (!IsCrypted())
+ return false;
+
+ CryptedKeyMap::const_iterator mi = mapCryptedKeys.begin();
+ for (; mi != mapCryptedKeys.end(); ++mi)
+ {
+ const CPubKey &vchPubKey = (*mi).second.first;
+ const std::vector<unsigned char> &vchCryptedSecret = (*mi).second.second;
+ CSecret vchSecret;
+ if(!DecryptSecret(vMasterKeyIn, vchCryptedSecret, vchPubKey.GetHash(), vchSecret))
+ return false;
+ if (vchSecret.size() != 32)
+ return false;
+ CKey key;
+ key.SetPubKey(vchPubKey);
+ key.SetSecret(vchSecret);
+ if (!CBasicKeyStore::AddKey(key))
+ return false;
+ }
+
+ mapCryptedKeys.clear();
+ }
+
+ return true;
+}