Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Unified Diff: net/quic/crypto/chacha20_poly1305_decrypter_test.cc

Issue 885443002: Roll Chrome into Mojo. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Rebase to ToT mojo Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/quic/crypto/aes_128_gcm_12_decrypter_test.cc ('k') | net/quic/crypto/crypto_protocol.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 312e2d4da3b3ae7dfb1ce29fae2b4509a9d94022..54ca9ff4c8941bae5bfb447026311b415d7a7a1a 100644
--- a/net/quic/crypto/chacha20_poly1305_decrypter_test.cc
+++ b/net/quic/crypto/chacha20_poly1305_decrypter_test.cc
@@ -75,15 +75,13 @@ QuicData* DecryptWithNonce(ChaCha20Poly1305Decrypter* decrypter,
StringPiece nonce,
StringPiece associated_data,
StringPiece ciphertext) {
- size_t plaintext_size = ciphertext.length();
- scoped_ptr<char[]> plaintext(new char[plaintext_size]);
-
- if (!decrypter->Decrypt(nonce, associated_data, ciphertext,
- reinterpret_cast<unsigned char*>(plaintext.get()),
- &plaintext_size)) {
- return nullptr;
- }
- return new QuicData(plaintext.release(), plaintext_size, true);
+ QuicPacketSequenceNumber sequence_number;
+ StringPiece nonce_prefix(nonce.data(),
+ nonce.size() - sizeof(sequence_number));
+ decrypter->SetNoncePrefix(nonce_prefix);
+ memcpy(&sequence_number, nonce.data() + nonce_prefix.size(),
+ sizeof(sequence_number));
+ return decrypter->DecryptPacket(sequence_number, associated_data, ciphertext);
}
TEST(ChaCha20Poly1305DecrypterTest, Decrypt) {
« no previous file with comments | « net/quic/crypto/aes_128_gcm_12_decrypter_test.cc ('k') | net/quic/crypto/crypto_protocol.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698