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

Unified Diff: net/quic/crypto/aead_base_decrypter_nss.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.h ('k') | net/quic/crypto/aead_base_decrypter_openssl.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_, &param,
- output, &output_len, ciphertext.length(),
+ if (pk11_decrypt_(aead_key.get(), aead_mechanism_, &param, 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 {
« no previous file with comments | « net/quic/crypto/aead_base_decrypter.h ('k') | net/quic/crypto/aead_base_decrypter_openssl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698