@@ -18,55 +18,55 @@ class TestCrypter
18
18
{
19
19
public:
20
20
static void TestPassphraseSingle (const std::vector<unsigned char >& vchSalt, const SecureString& passphrase, uint32_t rounds,
21
- const std::vector<unsigned char >& correctKey = std::vector< unsigned char >() ,
22
- const std::vector<unsigned char>& correctIV=std::vector<unsigned char>() )
21
+ const std::vector<unsigned char >& correctKey = {} ,
22
+ const std::vector<unsigned char >& correctIV = {} )
23
23
{
24
24
CCrypter crypt;
25
25
crypt.SetKeyFromPassphrase (passphrase, vchSalt, rounds, 0 );
26
26
27
27
if (!correctKey.empty ())
28
- BOOST_CHECK_MESSAGE (memcmp (crypt.vchKey .data (), correctKey.data (), crypt.vchKey .size ()) == 0 , \
28
+ BOOST_CHECK_MESSAGE (memcmp (crypt.vchKey .data (), correctKey.data (), crypt.vchKey .size ()) == 0 ,
29
29
HexStr (crypt.vchKey ) + std::string (" != " ) + HexStr (correctKey));
30
30
if (!correctIV.empty ())
31
31
BOOST_CHECK_MESSAGE (memcmp (crypt.vchIV .data (), correctIV.data (), crypt.vchIV .size ()) == 0 ,
32
32
HexStr (crypt.vchIV ) + std::string (" != " ) + HexStr (correctIV));
33
33
}
34
34
35
35
static void TestPassphrase (const std::vector<unsigned char >& vchSalt, const SecureString& passphrase, uint32_t rounds,
36
- const std::vector<unsigned char >& correctKey = std::vector< unsigned char >() ,
37
- const std::vector<unsigned char>& correctIV=std::vector<unsigned char>() )
36
+ const std::vector<unsigned char >& correctKey = {} ,
37
+ const std::vector<unsigned char >& correctIV = {} )
38
38
{
39
39
TestPassphraseSingle (vchSalt, passphrase, rounds, correctKey, correctIV);
40
40
for (SecureString::const_iterator i (passphrase.begin ()); i != passphrase.end (); ++i)
41
41
TestPassphraseSingle (vchSalt, SecureString (i, passphrase.end ()), rounds);
42
42
}
43
43
44
- static void TestDecrypt (const CCrypter& crypt, const std::vector<unsigned char >& vchCiphertext, \
45
- const std::vector<unsigned char >& vchPlaintext = std::vector< unsigned char >() )
44
+ static void TestDecrypt (const CCrypter& crypt, const std::vector<unsigned char >& vchCiphertext,
45
+ const std::vector<unsigned char >& vchCorrectPlaintext = {} )
46
46
{
47
47
CKeyingMaterial vchDecrypted;
48
48
crypt.Decrypt (vchCiphertext, vchDecrypted);
49
49
if (vchPlaintext.size ())
50
- BOOST_CHECK ( CKeyingMaterial (vchPlaintext .begin (), vchPlaintext .end ()) == vchDecrypted );
50
+ BOOST_CHECK_EQUAL_COLLECTIONS (vchDecrypted .begin (), vchDecrypted .end (), vchCorrectPlaintext. begin (), vchCorrectPlaintext. end () );
51
51
}
52
52
53
53
static void TestEncryptSingle (const CCrypter& crypt, const CKeyingMaterial& vchPlaintext,
54
- const std::vector<unsigned char >& vchCiphertextCorrect = std::vector< unsigned char >() )
54
+ const std::vector<unsigned char >& vchCiphertextCorrect = {} )
55
55
{
56
56
std::vector<unsigned char > vchCiphertext;
57
57
crypt.Encrypt (vchPlaintext, vchCiphertext);
58
58
59
59
if (!vchCiphertextCorrect.empty ())
60
- BOOST_CHECK (vchCiphertext == vchCiphertextCorrect);
60
+ BOOST_CHECK_EQUAL_COLLECTIONS (vchCiphertext. begin (), vchCiphertext. end (), vchCiphertextCorrect. begin (), vchCiphertextCorrect. end () );
61
61
62
62
const std::vector<unsigned char > vchPlaintext2 (vchPlaintext.begin (), vchPlaintext.end ());
63
63
TestDecrypt (crypt, vchCiphertext, vchPlaintext2);
64
64
}
65
65
66
- static void TestEncrypt (const CCrypter& crypt, const std::vector<unsigned char >& vchPlaintextIn, \
67
- const std::vector<unsigned char >& vchCiphertextCorrect = std::vector< unsigned char >() )
66
+ static void TestEncrypt (const CCrypter& crypt, const std::vector<unsigned char >& vchPlaintextIn,
67
+ const std::vector<unsigned char >& vchCiphertextCorrect = {} )
68
68
{
69
- TestEncryptSingle (crypt, CKeyingMaterial ( vchPlaintextIn.begin (), vchPlaintextIn.end ()) , vchCiphertextCorrect);
69
+ TestEncryptSingle (crypt, CKeyingMaterial{ vchPlaintextIn.begin (), vchPlaintextIn.end ()} , vchCiphertextCorrect);
70
70
for (std::vector<unsigned char >::const_iterator i (vchPlaintextIn.begin ()); i != vchPlaintextIn.end (); ++i)
71
71
TestEncryptSingle (crypt, CKeyingMaterial (i, vchPlaintextIn.end ()));
72
72
}
@@ -76,8 +76,8 @@ static void TestEncrypt(const CCrypter& crypt, const std::vector<unsigned char>&
76
76
BOOST_AUTO_TEST_CASE (passphrase) {
77
77
// These are expensive.
78
78
79
- TestCrypter::TestPassphrase (ParseHex (" 0000deadbeef0000" ), " test" , 25000 , \
80
- ParseHex (" fc7aba077ad5f4c3a0988d8daa4810d0d4a0e3bcb53af662998898f33df0556a" ), \
79
+ TestCrypter::TestPassphrase (ParseHex (" 0000deadbeef0000" ), " test" , 25000 ,
80
+ ParseHex (" fc7aba077ad5f4c3a0988d8daa4810d0d4a0e3bcb53af662998898f33df0556a" ),
81
81
ParseHex (" cf2f2691526dd1aa220896fb8bf7c369" ));
82
82
83
83
std::string hash (GetRandHash ().ToString ());
0 commit comments