| 367 | } |
| 368 | #endif |
| 369 | bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn) |
| 370 | { |
| 371 | LOCK(cs_KeyStore); |
| 372 | if (!mapCryptedKeys.empty() || IsCrypted()) |
| 373 | return false; |
| 374 | |
| 375 | fUseCrypto = true; |
| 376 | for (KeyMap::value_type& mKey : mapKeys) { |
| 377 | const CKey& key = mKey.second; |
| 378 | CPubKey vchPubKey = key.GetPubKey(); |
| 379 | CKeyingMaterial vchSecret(key.begin(), key.end()); |
| 380 | std::vector<unsigned char> vchCryptedSecret; |
| 381 | if (!EncryptSecret(vMasterKeyIn, vchSecret, vchPubKey.GetHash(), vchCryptedSecret)) |
| 382 | return false; |
| 383 | if (!AddCryptedKey(vchPubKey, vchCryptedSecret)) |
| 384 | return false; |
| 385 | } |
| 386 | mapKeys.clear(); |
| 387 | return true; |
| 388 | } |
| 389 | bool CCryptoKeyStore::EncryptHDChain(const CKeyingMaterial& vMasterKeyIn) |
| 390 | { |
| 391 | // should call EncryptKeys first |