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