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

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

Issue 935333002: Update from https://crrev.com/316786 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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/aead_base_decrypter_nss.cc ('k') | net/quic/crypto/aead_base_encrypter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/crypto/aead_base_decrypter_openssl.cc
diff --git a/net/quic/crypto/aead_base_decrypter_openssl.cc b/net/quic/crypto/aead_base_decrypter_openssl.cc
index 62a6fb82f27ad5cf566c545e95875a04841ed4e8..23116408fa787dff2360bf2293ae0c62da29b150 100644
--- a/net/quic/crypto/aead_base_decrypter_openssl.cc
+++ b/net/quic/crypto/aead_base_decrypter_openssl.cc
@@ -77,52 +77,49 @@ bool AeadBaseDecrypter::SetNoncePrefix(StringPiece nonce_prefix) {
}
bool AeadBaseDecrypter::Decrypt(StringPiece nonce,
- StringPiece associated_data,
- StringPiece ciphertext,
+ const StringPiece& associated_data,
+ const StringPiece& ciphertext,
uint8* output,
- size_t* output_length) {
+ size_t* output_length,
+ size_t max_output_length) {
if (ciphertext.length() < auth_tag_size_ ||
nonce.size() != nonce_prefix_size_ + sizeof(QuicPacketSequenceNumber)) {
return false;
}
if (!EVP_AEAD_CTX_open(
- ctx_.get(), output, output_length, ciphertext.size(),
- reinterpret_cast<const uint8_t*>(nonce.data()), nonce.size(),
- reinterpret_cast<const uint8_t*>(ciphertext.data()), ciphertext.size(),
- reinterpret_cast<const uint8_t*>(associated_data.data()),
- associated_data.size())) {
+ ctx_.get(), output, output_length, max_output_length,
+ reinterpret_cast<const uint8_t*>(nonce.data()), nonce.size(),
+ reinterpret_cast<const uint8_t*>(ciphertext.data()),
+ ciphertext.size(),
+ reinterpret_cast<const uint8_t*>(associated_data.data()),
+ associated_data.size())) {
// Because QuicFramer does trial decryption, decryption errors are expected
// when encryption level changes. So we don't log decryption errors.
ClearOpenSslErrors();
return false;
}
-
return true;
}
-QuicData* AeadBaseDecrypter::DecryptPacket(
- QuicPacketSequenceNumber sequence_number,
- StringPiece associated_data,
- StringPiece ciphertext) {
+bool AeadBaseDecrypter::DecryptPacket(QuicPacketSequenceNumber sequence_number,
+ const StringPiece& associated_data,
+ const StringPiece& ciphertext,
+ char* output,
+ size_t* output_length,
+ size_t max_output_length) {
if (ciphertext.length() < auth_tag_size_) {
- return nullptr;
+ return false;
}
- size_t plaintext_size = ciphertext.length();
- scoped_ptr<char[]> plaintext(new char[plaintext_size]);
uint8 nonce[sizeof(nonce_prefix_) + sizeof(sequence_number)];
const size_t nonce_size = nonce_prefix_size_ + sizeof(sequence_number);
DCHECK_LE(nonce_size, sizeof(nonce));
memcpy(nonce, nonce_prefix_, nonce_prefix_size_);
memcpy(nonce + nonce_prefix_size_, &sequence_number, sizeof(sequence_number));
- if (!Decrypt(StringPiece(reinterpret_cast<char*>(nonce), nonce_size),
- associated_data, ciphertext,
- reinterpret_cast<uint8*>(plaintext.get()),
- &plaintext_size)) {
- return nullptr;
- }
- return new QuicData(plaintext.release(), plaintext_size, true);
+ return Decrypt(StringPiece(reinterpret_cast<char*>(nonce), nonce_size),
+ associated_data, ciphertext, reinterpret_cast<uint8*>(output),
+ output_length, max_output_length);
}
StringPiece AeadBaseDecrypter::GetKey() const {
« no previous file with comments | « net/quic/crypto/aead_base_decrypter_nss.cc ('k') | net/quic/crypto/aead_base_encrypter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698