Index: net/quic/crypto/aead_base_decrypter_nss.cc |
diff --git a/net/quic/crypto/aead_base_decrypter_nss.cc b/net/quic/crypto/aead_base_decrypter_nss.cc |
index 2401222d3dccce8c9fb7b2b3c090d804d0076877..1ed4f3ab6e2b77739a813106076b77f9292d58dd 100644 |
--- a/net/quic/crypto/aead_base_decrypter_nss.cc |
+++ b/net/quic/crypto/aead_base_decrypter_nss.cc |
@@ -48,10 +48,11 @@ 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; |
@@ -100,8 +101,8 @@ bool AeadBaseDecrypter::Decrypt(StringPiece nonce, |
param.len = aead_params.len; |
unsigned int output_len; |
- if (pk11_decrypt_(aead_key.get(), aead_mechanism_, ¶m, |
- output, &output_len, ciphertext.length(), |
+ if (pk11_decrypt_(aead_key.get(), aead_mechanism_, ¶m, output, |
+ &output_len, max_output_length, |
reinterpret_cast<const unsigned char*>(ciphertext.data()), |
ciphertext.length()) != SECSuccess) { |
return false; |
@@ -115,28 +116,24 @@ bool AeadBaseDecrypter::Decrypt(StringPiece nonce, |
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; |
- scoped_ptr<char[]> plaintext(new char[ciphertext.length()]); |
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 { |