| 277 | } |
| 278 | |
| 279 | bool CCryptoKeyStore::EncryptKeys(CKeyingMaterial& vMasterKeyIn) { |
| 280 | LOCK(cs_KeyStore); |
| 281 | |
| 282 | if (!mapCryptedKeys.empty() || IsEncrypted()) |
| 283 | return false; |
| 284 | |
| 285 | fUseCrypto = true; |
| 286 | for (auto& mKey : mapKeys) { |
| 287 | CKey mainKey; |
| 288 | mKey.second.GetCKey(mainKey, false); |
| 289 | CPubKey vchPubKey = mainKey.GetPubKey(); |
| 290 | CKeyingMaterial vchSecret(mainKey.begin(), mainKey.end()); |
| 291 | vector<unsigned char> vchCryptedSecret; |
| 292 | if (!EncryptSecret(vMasterKeyIn, vchSecret, vchPubKey.GetHash(), vchCryptedSecret)) |
| 293 | return false; |
| 294 | |
| 295 | if (!AddCryptedKey(vchPubKey, vchCryptedSecret)) |
| 296 | return false; |
| 297 | |
| 298 | mKey.second.PurgeMainKey(); |
| 299 | } |
| 300 | |
| 301 | return true; |
| 302 | } |
nothing calls this directly
no test coverage detected