| Index: net/quic/crypto/chacha20_poly1305_decrypter_test.cc
|
| diff --git a/net/quic/crypto/chacha20_poly1305_decrypter_test.cc b/net/quic/crypto/chacha20_poly1305_decrypter_test.cc
|
| index 1825187bb33d51a53e1cc4c73ceab953fe11f762..a8113aca95131f5549ff7958ef48d01164dc0641 100644
|
| --- a/net/quic/crypto/chacha20_poly1305_decrypter_test.cc
|
| +++ b/net/quic/crypto/chacha20_poly1305_decrypter_test.cc
|
| @@ -29,39 +29,36 @@ struct TestVector {
|
| };
|
|
|
| const TestVector test_vectors[] = {
|
| - { "4290bcb154173531f314af57f3be3b5006da371ece272afa1b5dbdd110"
|
| - "0a1007",
|
| - "cd7cf67be39c794a",
|
| - "87e229d4500845a079c0",
|
| - "e3e446f7ede9a19b62a4677dabf4e3d24b876bb28475", // "3896e1d6" truncated.
|
| - "86d09974840bded2a5ca"
|
| - },
|
| - // Modify the ciphertext (ChaCha20 encryption output).
|
| - { "4290bcb154173531f314af57f3be3b5006da371ece272afa1b5dbdd110"
|
| - "0a1007",
|
| - "cd7cf67be39c794a",
|
| - "87e229d4500845a079c0",
|
| - "f3e446f7ede9a19b62a4677dabf4e3d24b876bb28475", // "3896e1d6" truncated.
|
| - NULL // FAIL
|
| - },
|
| - // Modify the ciphertext (Poly1305 authenticator).
|
| - { "4290bcb154173531f314af57f3be3b5006da371ece272afa1b5dbdd110"
|
| - "0a1007",
|
| - "cd7cf67be39c794a",
|
| - "87e229d4500845a079c0",
|
| - "e3e446f7ede9a19b62a4677dabf4e3d24b876bb28476", // "3896e1d6" truncated.
|
| - NULL // FAIL
|
| - },
|
| - // Modify the associated data.
|
| - { "4290bcb154173531f314af57f3be3b5006da371ece272afa1b5dbdd110"
|
| - "0a1007",
|
| - "dd7cf67be39c794a",
|
| - "87e229d4500845a079c0",
|
| - "e3e446f7ede9a19b62a4677dabf4e3d24b876bb28475", // "3896e1d6" truncated.
|
| - NULL // FAIL
|
| - },
|
| - { NULL }
|
| -};
|
| + {"4290bcb154173531f314af57f3be3b5006da371ece272afa1b5dbdd110"
|
| + "0a1007",
|
| + "cd7cf67be39c794a", "87e229d4500845a079c0",
|
| + "e3e446f7ede9a19b62a4677dabf4e3d24b876bb28475", // "3896e1d6" truncated.
|
| + "86d09974840bded2a5ca"},
|
| + // Modify the ciphertext (ChaCha20 encryption output).
|
| + {
|
| + "4290bcb154173531f314af57f3be3b5006da371ece272afa1b5dbdd110"
|
| + "0a1007",
|
| + "cd7cf67be39c794a", "87e229d4500845a079c0",
|
| + "f3e446f7ede9a19b62a4677dabf4e3d24b876bb28475", // "3896e1d6" truncated.
|
| + NULL // FAIL
|
| + },
|
| + // Modify the ciphertext (Poly1305 authenticator).
|
| + {
|
| + "4290bcb154173531f314af57f3be3b5006da371ece272afa1b5dbdd110"
|
| + "0a1007",
|
| + "cd7cf67be39c794a", "87e229d4500845a079c0",
|
| + "e3e446f7ede9a19b62a4677dabf4e3d24b876bb28476", // "3896e1d6" truncated.
|
| + NULL // FAIL
|
| + },
|
| + // Modify the associated data.
|
| + {
|
| + "4290bcb154173531f314af57f3be3b5006da371ece272afa1b5dbdd110"
|
| + "0a1007",
|
| + "dd7cf67be39c794a", "87e229d4500845a079c0",
|
| + "e3e446f7ede9a19b62a4677dabf4e3d24b876bb28475", // "3896e1d6" truncated.
|
| + NULL // FAIL
|
| + },
|
| + {NULL}};
|
|
|
| } // namespace
|
|
|
| @@ -77,7 +74,9 @@ QuicData* DecryptWithNonce(ChaCha20Poly1305Decrypter* decrypter,
|
| size_t plaintext_size = ciphertext.length();
|
| scoped_ptr<char[]> plaintext(new char[plaintext_size]);
|
|
|
| - if (!decrypter->Decrypt(nonce, associated_data, ciphertext,
|
| + if (!decrypter->Decrypt(nonce,
|
| + associated_data,
|
| + ciphertext,
|
| reinterpret_cast<unsigned char*>(plaintext.get()),
|
| &plaintext_size)) {
|
| return NULL;
|
| @@ -112,10 +111,12 @@ TEST(ChaCha20Poly1305DecrypterTest, Decrypt) {
|
| ChaCha20Poly1305Decrypter decrypter;
|
| ASSERT_TRUE(decrypter.SetKey(key));
|
| scoped_ptr<QuicData> decrypted(DecryptWithNonce(
|
| - &decrypter, iv,
|
| + &decrypter,
|
| + iv,
|
| // This deliberately tests that the decrypter can handle an AAD that
|
| // is set to NULL, as opposed to a zero-length, non-NULL pointer.
|
| - StringPiece(aad.length() ? aad.data() : NULL, aad.length()), ct));
|
| + StringPiece(aad.length() ? aad.data() : NULL, aad.length()),
|
| + ct));
|
| if (!decrypted.get()) {
|
| EXPECT_FALSE(has_pt);
|
| continue;
|
| @@ -123,8 +124,8 @@ TEST(ChaCha20Poly1305DecrypterTest, Decrypt) {
|
| EXPECT_TRUE(has_pt);
|
|
|
| ASSERT_EQ(pt.length(), decrypted->length());
|
| - test::CompareCharArraysWithHexError("plaintext", decrypted->data(),
|
| - pt.length(), pt.data(), pt.length());
|
| + test::CompareCharArraysWithHexError(
|
| + "plaintext", decrypted->data(), pt.length(), pt.data(), pt.length());
|
| }
|
| }
|
|
|
|
|