| 38 | } |
| 39 | |
| 40 | bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::vector<unsigned char>& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod) |
| 41 | { |
| 42 | if (nRounds < 1 || chSalt.size() != WALLET_CRYPTO_SALT_SIZE) |
| 43 | return false; |
| 44 | |
| 45 | int i = 0; |
| 46 | if (nDerivationMethod == 0) |
| 47 | i = BytesToKeySHA512AES(chSalt, strKeyData, nRounds, vchKey.data(), vchIV.data()); |
| 48 | |
| 49 | if (i != (int)WALLET_CRYPTO_KEY_SIZE) |
| 50 | { |
| 51 | memory_cleanse(vchKey.data(), vchKey.size()); |
| 52 | memory_cleanse(vchIV.data(), vchIV.size()); |
| 53 | return false; |
| 54 | } |
| 55 | |
| 56 | fKeySet = true; |
| 57 | return true; |
| 58 | } |
| 59 | |
| 60 | bool CCrypter::SetKey(const CKeyingMaterial& chNewKey, const std::vector<unsigned char>& chNewIV) |
| 61 | { |