11#include <boost/test/unit_test.hpp> 
   19                 const std::vector<unsigned char>& correctKey = std::vector<unsigned char>(),
 
   20                 const std::vector<unsigned char>& correctIV=std::vector<unsigned char>())
 
   25    if(!correctKey.empty())
 
   26        BOOST_CHECK_MESSAGE(memcmp(crypt.
vchKey.data(), correctKey.data(), crypt.
vchKey.size()) == 0, \
 
   28    if(!correctIV.empty())
 
   29        BOOST_CHECK_MESSAGE(memcmp(crypt.
vchIV.data(), correctIV.data(), crypt.
vchIV.size()) == 0,
 
   34                 const std::vector<unsigned char>& correctKey = std::vector<unsigned char>(),
 
   35                 const std::vector<unsigned char>& correctIV=std::vector<unsigned char>())
 
   37    TestPassphraseSingle(vchSalt, passphrase, rounds, correctKey, correctIV);
 
   38    for(SecureString::const_iterator i(passphrase.begin()); i != passphrase.end(); ++i)
 
   39        TestPassphraseSingle(vchSalt, 
SecureString(i, passphrase.end()), rounds);
 
   43                        const std::vector<unsigned char>& vchPlaintext = std::vector<unsigned char>())
 
   46    crypt.
Decrypt(vchCiphertext, vchDecrypted);
 
   47    if (vchPlaintext.size())
 
   52                       const std::vector<unsigned char>& vchCiphertextCorrect = std::vector<unsigned char>())
 
   54    std::vector<unsigned char> vchCiphertext;
 
   55    crypt.
Encrypt(vchPlaintext, vchCiphertext);
 
   57    if (!vchCiphertextCorrect.empty())
 
   60    const std::vector<unsigned char> vchPlaintext2(vchPlaintext.begin(), vchPlaintext.end());
 
   61    TestDecrypt(crypt, vchCiphertext, vchPlaintext2);
 
   65                       const std::vector<unsigned char>& vchCiphertextCorrect = std::vector<unsigned char>())
 
   67    TestEncryptSingle(crypt, 
CKeyingMaterial(vchPlaintextIn.begin(), vchPlaintextIn.end()), vchCiphertextCorrect);
 
   68    for(std::vector<unsigned char>::const_iterator i(vchPlaintextIn.begin()); i != vchPlaintextIn.end(); ++i)
 
   78                                ParseHex(
"fc7aba077ad5f4c3a0988d8daa4810d0d4a0e3bcb53af662998898f33df0556a"), \
 
   79                                ParseHex(
"cf2f2691526dd1aa220896fb8bf7c369"));
 
   82    std::vector<unsigned char> vchSalt(8);
 
   91    std::vector<unsigned char> vchSalt = 
ParseHex(
"0000deadbeef0000");
 
   97    for (
int i = 0; i != 100; i++)
 
  106    std::vector<unsigned char> vchSalt = 
ParseHex(
"0000deadbeef0000");
 
  119    for (
int i = 0; i != 100; i++)
 
Encryption/decryption context with key information.
bool Encrypt(const CKeyingMaterial &vchPlaintext, std::vector< unsigned char > &vchCiphertext) const
bool SetKeyFromPassphrase(const SecureString &strKeyData, const std::vector< unsigned char > &chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod)
bool Decrypt(const std::vector< unsigned char > &vchCiphertext, CKeyingMaterial &vchPlaintext) const
std::vector< unsigned char, secure_allocator< unsigned char > > vchIV
std::vector< unsigned char, secure_allocator< unsigned char > > vchKey
static void TestPassphrase(const std::vector< unsigned char > &vchSalt, const SecureString &passphrase, uint32_t rounds, const std::vector< unsigned char > &correctKey=std::vector< unsigned char >(), const std::vector< unsigned char > &correctIV=std::vector< unsigned char >())
static void TestEncrypt(const CCrypter &crypt, const std::vector< unsigned char > &vchPlaintextIn, const std::vector< unsigned char > &vchCiphertextCorrect=std::vector< unsigned char >())
static void TestDecrypt(const CCrypter &crypt, const std::vector< unsigned char > &vchCiphertext, const std::vector< unsigned char > &vchPlaintext=std::vector< unsigned char >())
static void TestPassphraseSingle(const std::vector< unsigned char > &vchSalt, const SecureString &passphrase, uint32_t rounds, const std::vector< unsigned char > &correctKey=std::vector< unsigned char >(), const std::vector< unsigned char > &correctIV=std::vector< unsigned char >())
static void TestEncryptSingle(const CCrypter &crypt, const CKeyingMaterial &vchPlaintext, const std::vector< unsigned char > &vchCiphertextCorrect=std::vector< unsigned char >())
std::vector< unsigned char, secure_allocator< unsigned char > > CKeyingMaterial
const unsigned int WALLET_CRYPTO_SALT_SIZE
BOOST_AUTO_TEST_SUITE_END()
#define BOOST_FIXTURE_TEST_SUITE(a, b)
#define BOOST_CHECK(expr)
void GetRandBytes(unsigned char *buf, int num) noexcept
Overall design of the RNG and entropy sources.
uint256 GetRandHash() noexcept
std::basic_string< char, std::char_traits< char >, secure_allocator< char > > SecureString
static uint32_t InsecureRand32()
std::string HexStr(const Span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
std::vector< unsigned char > ParseHex(const char *psz)
std::string ToString(const T &t)
Locale-independent version of std::to_string.
BOOST_AUTO_TEST_CASE(passphrase)