@@ -58,12 +58,12 @@ void TestRIPEMD160(const std::string &in, const std::string &hexout) { TestVecto
58
58
59
59
void TestHMACSHA256 (const std::string &hexkey, const std::string &hexin, const std::string &hexout) {
60
60
std::vector<unsigned char > key = ParseHex (hexkey);
61
- TestVector (CHMAC_SHA256 (& key[ 0 ] , key.size ()), ParseHex (hexin), ParseHex (hexout));
61
+ TestVector (CHMAC_SHA256 (key. data () , key.size ()), ParseHex (hexin), ParseHex (hexout));
62
62
}
63
63
64
64
void TestHMACSHA512 (const std::string &hexkey, const std::string &hexin, const std::string &hexout) {
65
65
std::vector<unsigned char > key = ParseHex (hexkey);
66
- TestVector (CHMAC_SHA512 (& key[ 0 ] , key.size ()), ParseHex (hexin), ParseHex (hexout));
66
+ TestVector (CHMAC_SHA512 (key. data () , key.size ()), ParseHex (hexin), ParseHex (hexout));
67
67
}
68
68
69
69
void TestAES128 (const std::string &hexkey, const std::string &hexin, const std::string &hexout)
@@ -76,13 +76,13 @@ void TestAES128(const std::string &hexkey, const std::string &hexin, const std::
76
76
assert (key.size () == 16 );
77
77
assert (in.size () == 16 );
78
78
assert (correctout.size () == 16 );
79
- AES128Encrypt enc (& key[ 0 ] );
79
+ AES128Encrypt enc (key. data () );
80
80
buf.resize (correctout.size ());
81
81
buf2.resize (correctout.size ());
82
- enc.Encrypt (& buf[ 0 ], &in[ 0 ] );
82
+ enc.Encrypt (buf. data (), in. data () );
83
83
BOOST_CHECK_EQUAL (HexStr (buf), HexStr (correctout));
84
- AES128Decrypt dec (& key[ 0 ] );
85
- dec.Decrypt (& buf2[ 0 ], & buf[ 0 ] );
84
+ AES128Decrypt dec (key. data () );
85
+ dec.Decrypt (buf2. data (), buf. data () );
86
86
BOOST_CHECK_EQUAL (HexStr (buf2), HexStr (in));
87
87
}
88
88
@@ -96,12 +96,12 @@ void TestAES256(const std::string &hexkey, const std::string &hexin, const std::
96
96
assert (key.size () == 32 );
97
97
assert (in.size () == 16 );
98
98
assert (correctout.size () == 16 );
99
- AES256Encrypt enc (& key[ 0 ] );
99
+ AES256Encrypt enc (key. data () );
100
100
buf.resize (correctout.size ());
101
- enc.Encrypt (& buf[ 0 ], &in[ 0 ] );
101
+ enc.Encrypt (buf. data (), in. data () );
102
102
BOOST_CHECK (buf == correctout);
103
- AES256Decrypt dec (& key[ 0 ] );
104
- dec.Decrypt (& buf[ 0 ], & buf[ 0 ] );
103
+ AES256Decrypt dec (key. data () );
104
+ dec.Decrypt (buf. data (), buf. data () );
105
105
BOOST_CHECK (buf == in);
106
106
}
107
107
@@ -114,16 +114,16 @@ void TestAES128CBC(const std::string &hexkey, const std::string &hexiv, bool pad
114
114
std::vector<unsigned char > realout (in.size () + AES_BLOCKSIZE);
115
115
116
116
// Encrypt the plaintext and verify that it equals the cipher
117
- AES128CBCEncrypt enc (& key[ 0 ], &iv[ 0 ] , pad);
118
- int size = enc.Encrypt (&in[ 0 ] , in.size (), & realout[ 0 ] );
117
+ AES128CBCEncrypt enc (key. data (), iv. data () , pad);
118
+ int size = enc.Encrypt (in. data () , in.size (), realout. data () );
119
119
realout.resize (size);
120
120
BOOST_CHECK (realout.size () == correctout.size ());
121
121
BOOST_CHECK_MESSAGE (realout == correctout, HexStr (realout) + std::string (" != " ) + hexout);
122
122
123
123
// Decrypt the cipher and verify that it equals the plaintext
124
124
std::vector<unsigned char > decrypted (correctout.size ());
125
- AES128CBCDecrypt dec (& key[ 0 ], &iv[ 0 ] , pad);
126
- size = dec.Decrypt (& correctout[ 0 ] , correctout.size (), & decrypted[ 0 ] );
125
+ AES128CBCDecrypt dec (key. data (), iv. data () , pad);
126
+ size = dec.Decrypt (correctout. data () , correctout.size (), decrypted. data () );
127
127
decrypted.resize (size);
128
128
BOOST_CHECK (decrypted.size () == in.size ());
129
129
BOOST_CHECK_MESSAGE (decrypted == in, HexStr (decrypted) + std::string (" != " ) + hexin);
@@ -133,12 +133,12 @@ void TestAES128CBC(const std::string &hexkey, const std::string &hexiv, bool pad
133
133
{
134
134
std::vector<unsigned char > sub (i, in.end ());
135
135
std::vector<unsigned char > subout (sub.size () + AES_BLOCKSIZE);
136
- int _size = enc.Encrypt (& sub[ 0 ] , sub.size (), & subout[ 0 ] );
136
+ int _size = enc.Encrypt (sub. data () , sub.size (), subout. data () );
137
137
if (_size != 0 )
138
138
{
139
139
subout.resize (_size);
140
140
std::vector<unsigned char > subdecrypted (subout.size ());
141
- _size = dec.Decrypt (& subout[ 0 ] , subout.size (), & subdecrypted[ 0 ] );
141
+ _size = dec.Decrypt (subout. data () , subout.size (), subdecrypted. data () );
142
142
subdecrypted.resize (_size);
143
143
BOOST_CHECK (decrypted.size () == in.size ());
144
144
BOOST_CHECK_MESSAGE (subdecrypted == sub, HexStr (subdecrypted) + std::string (" != " ) + HexStr (sub));
@@ -155,16 +155,16 @@ void TestAES256CBC(const std::string &hexkey, const std::string &hexiv, bool pad
155
155
std::vector<unsigned char > realout (in.size () + AES_BLOCKSIZE);
156
156
157
157
// Encrypt the plaintext and verify that it equals the cipher
158
- AES256CBCEncrypt enc (& key[ 0 ], &iv[ 0 ] , pad);
159
- int size = enc.Encrypt (&in[ 0 ] , in.size (), & realout[ 0 ] );
158
+ AES256CBCEncrypt enc (key. data (), iv. data () , pad);
159
+ int size = enc.Encrypt (in. data () , in.size (), realout. data () );
160
160
realout.resize (size);
161
161
BOOST_CHECK (realout.size () == correctout.size ());
162
162
BOOST_CHECK_MESSAGE (realout == correctout, HexStr (realout) + std::string (" != " ) + hexout);
163
163
164
164
// Decrypt the cipher and verify that it equals the plaintext
165
165
std::vector<unsigned char > decrypted (correctout.size ());
166
- AES256CBCDecrypt dec (& key[ 0 ], &iv[ 0 ] , pad);
167
- size = dec.Decrypt (& correctout[ 0 ] , correctout.size (), & decrypted[ 0 ] );
166
+ AES256CBCDecrypt dec (key. data (), iv. data () , pad);
167
+ size = dec.Decrypt (correctout. data () , correctout.size (), decrypted. data () );
168
168
decrypted.resize (size);
169
169
BOOST_CHECK (decrypted.size () == in.size ());
170
170
BOOST_CHECK_MESSAGE (decrypted == in, HexStr (decrypted) + std::string (" != " ) + hexin);
@@ -174,12 +174,12 @@ void TestAES256CBC(const std::string &hexkey, const std::string &hexiv, bool pad
174
174
{
175
175
std::vector<unsigned char > sub (i, in.end ());
176
176
std::vector<unsigned char > subout (sub.size () + AES_BLOCKSIZE);
177
- int _size = enc.Encrypt (& sub[ 0 ] , sub.size (), & subout[ 0 ] );
177
+ int _size = enc.Encrypt (sub. data () , sub.size (), subout. data () );
178
178
if (_size != 0 )
179
179
{
180
180
subout.resize (_size);
181
181
std::vector<unsigned char > subdecrypted (subout.size ());
182
- _size = dec.Decrypt (& subout[ 0 ] , subout.size (), & subdecrypted[ 0 ] );
182
+ _size = dec.Decrypt (subout. data () , subout.size (), subdecrypted. data () );
183
183
subdecrypted.resize (_size);
184
184
BOOST_CHECK (decrypted.size () == in.size ());
185
185
BOOST_CHECK_MESSAGE (subdecrypted == sub, HexStr (subdecrypted) + std::string (" != " ) + HexStr (sub));
0 commit comments