Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/test/wallet_crypto_tests.cpp
Show All 18 Lines | static void TestPassphraseSingle( | ||||
const std::vector<uint8_t> &vchSalt, const SecureString &passphrase, | const std::vector<uint8_t> &vchSalt, const SecureString &passphrase, | ||||
uint32_t rounds, | uint32_t rounds, | ||||
const std::vector<uint8_t> &correctKey = std::vector<uint8_t>(), | const std::vector<uint8_t> &correctKey = std::vector<uint8_t>(), | ||||
const std::vector<uint8_t> &correctIV = std::vector<uint8_t>()) { | const std::vector<uint8_t> &correctIV = std::vector<uint8_t>()) { | ||||
CCrypter crypt; | CCrypter crypt; | ||||
crypt.SetKeyFromPassphrase(passphrase, vchSalt, rounds, 0); | crypt.SetKeyFromPassphrase(passphrase, vchSalt, rounds, 0); | ||||
if (!correctKey.empty()) { | if (!correctKey.empty()) { | ||||
BOOST_CHECK_MESSAGE( | BOOST_CHECK_MESSAGE(memcmp(crypt.vchKey.data(), correctKey.data(), | ||||
memcmp(crypt.vchKey.data(), correctKey.data(), | |||||
crypt.vchKey.size()) == 0, | crypt.vchKey.size()) == 0, | ||||
HexStr(crypt.vchKey.begin(), crypt.vchKey.end()) + | HexStr(crypt.vchKey) + std::string(" != ") + | ||||
std::string(" != ") + | HexStr(correctKey)); | ||||
HexStr(correctKey.begin(), correctKey.end())); | |||||
} | } | ||||
if (!correctIV.empty()) { | if (!correctIV.empty()) { | ||||
BOOST_CHECK_MESSAGE(memcmp(crypt.vchIV.data(), correctIV.data(), | BOOST_CHECK_MESSAGE(memcmp(crypt.vchIV.data(), correctIV.data(), | ||||
crypt.vchIV.size()) == 0, | crypt.vchIV.size()) == 0, | ||||
HexStr(crypt.vchIV.begin(), crypt.vchIV.end()) + | HexStr(crypt.vchIV) + std::string(" != ") + | ||||
std::string(" != ") + | HexStr(correctIV)); | ||||
HexStr(correctIV.begin(), correctIV.end())); | |||||
} | } | ||||
} | } | ||||
static void TestPassphrase( | static void TestPassphrase( | ||||
const std::vector<uint8_t> &vchSalt, const SecureString &passphrase, | const std::vector<uint8_t> &vchSalt, const SecureString &passphrase, | ||||
uint32_t rounds, | uint32_t rounds, | ||||
const std::vector<uint8_t> &correctKey = std::vector<uint8_t>(), | const std::vector<uint8_t> &correctKey = std::vector<uint8_t>(), | ||||
const std::vector<uint8_t> &correctIV = std::vector<uint8_t>()) { | const std::vector<uint8_t> &correctIV = std::vector<uint8_t>()) { | ||||
▲ Show 20 Lines • Show All 122 Lines • Show Last 20 Lines |