@@ -133,8 +133,9 @@ static void TestAES256CBC(const std::string &hexkey, const std::string &hexiv, b
133
133
static void TestChaCha20 (const std::string &hex_message, const std::string &hexkey, uint64_t nonce, uint64_t seek, const std::string& hexout)
134
134
{
135
135
std::vector<unsigned char > key = ParseHex (hexkey);
136
+ assert (key.size () == 32 );
136
137
std::vector<unsigned char > m = ParseHex (hex_message);
137
- ChaCha20 rng (key.data (), key. size () );
138
+ ChaCha20 rng (key.data ());
138
139
rng.SetIV (nonce);
139
140
rng.Seek64 (seek);
140
141
std::vector<unsigned char > out = ParseHex (hexout);
@@ -460,7 +461,7 @@ BOOST_AUTO_TEST_CASE(aes_cbc_testvectors) {
460
461
461
462
BOOST_AUTO_TEST_CASE (chacha20_testvector)
462
463
{
463
- // Test vector from RFC 7539
464
+ // Test vectors from RFC 7539
464
465
465
466
// test encryption
466
467
TestChaCha20 (" 4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756"
@@ -503,12 +504,12 @@ BOOST_AUTO_TEST_CASE(chacha20_testvector)
503
504
BOOST_AUTO_TEST_CASE (chacha20_midblock)
504
505
{
505
506
auto key = ParseHex (" 0000000000000000000000000000000000000000000000000000000000000000" );
506
- ChaCha20 c20{key.data (), 32 };
507
+ ChaCha20 c20{key.data ()};
507
508
// get one block of keystream
508
509
unsigned char block[64 ];
509
510
c20.Keystream (block, CHACHA20_ROUND_OUTPUT);
510
511
unsigned char b1[5 ], b2[7 ], b3[52 ];
511
- c20 = ChaCha20{key.data (), 32 };
512
+ c20 = ChaCha20{key.data ()};
512
513
c20.Keystream (b1, 5 );
513
514
c20.Keystream (b2, 7 );
514
515
c20.Keystream (b3, 52 );
@@ -635,7 +636,7 @@ static void TestChaCha20Poly1305AEAD(bool must_succeed, unsigned int expected_aa
635
636
ChaCha20Poly1305AEAD aead (aead_K_1.data (), aead_K_1.size (), aead_K_2.data (), aead_K_2.size ());
636
637
637
638
// create a chacha20 instance to compare against
638
- ChaCha20 cmp_ctx (aead_K_1.data (), 32 );
639
+ ChaCha20 cmp_ctx (aead_K_1.data ());
639
640
640
641
// encipher
641
642
bool res = aead.Crypt (seqnr_payload, seqnr_aad, aad_pos, ciphertext_buf.data (), ciphertext_buf.size (), plaintext_buf.data (), plaintext_buf.size (), true );
0 commit comments