@@ -133,8 +133,9 @@ static void TestAES256CBC(const std::string &hexkey, const std::string &hexiv, b
133133static void TestChaCha20 (const std::string &hex_message, const std::string &hexkey, uint64_t nonce, uint64_t seek, const std::string& hexout)
134134{
135135 std::vector<unsigned char > key = ParseHex (hexkey);
136+ assert (key.size () == 32 );
136137 std::vector<unsigned char > m = ParseHex (hex_message);
137- ChaCha20 rng (key.data (), key. size () );
138+ ChaCha20 rng (key.data ());
138139 rng.SetIV (nonce);
139140 rng.Seek64 (seek);
140141 std::vector<unsigned char > out = ParseHex (hexout);
@@ -460,7 +461,7 @@ BOOST_AUTO_TEST_CASE(aes_cbc_testvectors) {
460461
461462BOOST_AUTO_TEST_CASE (chacha20_testvector)
462463{
463- // Test vector from RFC 7539
464+ // Test vectors from RFC 7539
464465
465466 // test encryption
466467 TestChaCha20 (" 4c616469657320616e642047656e746c656d656e206f662074686520636c617373206f66202739393a204966204920636f756"
@@ -503,12 +504,12 @@ BOOST_AUTO_TEST_CASE(chacha20_testvector)
503504BOOST_AUTO_TEST_CASE (chacha20_midblock)
504505{
505506 auto key = ParseHex (" 0000000000000000000000000000000000000000000000000000000000000000" );
506- ChaCha20 c20{key.data (), 32 };
507+ ChaCha20 c20{key.data ()};
507508 // get one block of keystream
508509 unsigned char block[64 ];
509510 c20.Keystream (block, CHACHA20_ROUND_OUTPUT);
510511 unsigned char b1[5 ], b2[7 ], b3[52 ];
511- c20 = ChaCha20{key.data (), 32 };
512+ c20 = ChaCha20{key.data ()};
512513 c20.Keystream (b1, 5 );
513514 c20.Keystream (b2, 7 );
514515 c20.Keystream (b3, 52 );
@@ -635,7 +636,7 @@ static void TestChaCha20Poly1305AEAD(bool must_succeed, unsigned int expected_aa
635636 ChaCha20Poly1305AEAD aead (aead_K_1.data (), aead_K_1.size (), aead_K_2.data (), aead_K_2.size ());
636637
637638 // create a chacha20 instance to compare against
638- ChaCha20 cmp_ctx (aead_K_1.data (), 32 );
639+ ChaCha20 cmp_ctx (aead_K_1.data ());
639640
640641 // encipher
641642 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