8#include <test/util/random.h>
9#include <test/util/setup_common.h>
11#include <boost/test/unit_test.hpp>
22 const std::vector<uint8_t> &
correctKey = std::vector<uint8_t>(),
23 const std::vector<uint8_t> &
correctIV = std::vector<uint8_t>()) {
29 crypt.vchKey.size()) == 0,
35 crypt.vchIV.size()) == 0,
44 const std::vector<uint8_t> &
correctKey = std::vector<uint8_t>(),
45 const std::vector<uint8_t> &
correctIV = std::vector<uint8_t>()) {
48 for (SecureString::const_iterator i(
passphrase.begin());
57 const std::vector<uint8_t> &
vchPlaintext = std::vector<uint8_t>()) {
70 std::vector<uint8_t>()) {
86 std::vector<uint8_t>()) {
91 for (std::vector<uint8_t>::const_iterator i(
vchPlaintextIn.begin());
102 ParseHex(
"0000deadbeef0000"),
"test", 25000,
104 "fc7aba077ad5f4c3a0988d8daa4810d0d4a0e3bcb53af662998898f33df0556a"),
105 ParseHex(
"cf2f2691526dd1aa220896fb8bf7c369"));
108 std::vector<uint8_t> vchSalt(8);
119 std::vector<uint8_t> vchSalt =
ParseHex(
"0000deadbeef0000");
124 ParseHex(
"22bcade09ac03ff6386914359cfe885cfeb5f77f"
125 "f0d670f102f619687453b29d"));
127 for (
int i = 0; i != 100; i++) {
135 std::vector<uint8_t> vchSalt =
ParseHex(
"0000deadbeef0000");
142 ParseHex(
"795643ce39d736088367822cdc50535ec6f10371"
143 "5e3e48f4f3b1a60a08ef59ca"));
145 ParseHex(
"de096f4a8f9bd97db012aa9d90d74de8cdea779c"
146 "3ee8bc7633d8b5d6da703486"));
148 ParseHex(
"32d0a8974e3afd9c6c3ebf4d66aa4e6419f8c173"
149 "de25947f98cf8b7ace49449c"));
151 ParseHex(
"e7c055cca2faa78cb9ac22c9357a90b4778ded9b"
152 "2cc220a14cea49f931e596ea"));
154 ParseHex(
"b88efddd668a6801d19516d6830da4ae9811988c"
155 "cbaf40df8fbb72f3f4d335fd"));
157 ParseHex(
"8cae76aa6a43694e961ebcb28c8ca8f8540b8415"
158 "3d72865e8561ddd93fa7bfa9"));
160 for (
int i = 0; i != 100; i++) {
Encryption/decryption context with key information.
bool SetKeyFromPassphrase(const SecureString &strKeyData, const std::vector< uint8_t > &chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod)
static void TestPassphrase(const std::vector< uint8_t > &vchSalt, const SecureString &passphrase, uint32_t rounds, const std::vector< uint8_t > &correctKey=std::vector< uint8_t >(), const std::vector< uint8_t > &correctIV=std::vector< uint8_t >())
static void TestEncryptSingle(const CCrypter &crypt, const CKeyingMaterial &vchPlaintext, const std::vector< uint8_t > &vchCiphertextCorrect=std::vector< uint8_t >())
static void TestPassphraseSingle(const std::vector< uint8_t > &vchSalt, const SecureString &passphrase, uint32_t rounds, const std::vector< uint8_t > &correctKey=std::vector< uint8_t >(), const std::vector< uint8_t > &correctIV=std::vector< uint8_t >())
static void TestEncrypt(const CCrypter &crypt, const std::vector< uint8_t > &vchPlaintextIn, const std::vector< uint8_t > &vchCiphertextCorrect=std::vector< uint8_t >())
static void TestDecrypt(const CCrypter &crypt, const std::vector< uint8_t > &vchCiphertext, const std::vector< uint8_t > &vchPlaintext=std::vector< uint8_t >())
const unsigned int WALLET_CRYPTO_SALT_SIZE
std::vector< uint8_t, secure_allocator< uint8_t > > CKeyingMaterial
#define BOOST_CHECK(expr)
void GetRandBytes(Span< uint8_t > bytes) noexcept
Overall design of the RNG and entropy sources.
uint256 GetRandHash() noexcept
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
static std::string ToString(const CService &ip)
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
template std::vector< std::byte > ParseHex(std::string_view)
BOOST_AUTO_TEST_CASE(passphrase)