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

Side by Side Diff: net/quic/crypto/crypto_secret_boxer.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 unified diff | Download patch
« no previous file with comments | « net/quic/crypto/crypto_framer.cc ('k') | net/quic/crypto/null_decrypter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/quic/crypto/crypto_secret_boxer.h" 5 #include "net/quic/crypto/crypto_secret_boxer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "net/quic/crypto/crypto_protocol.h" 9 #include "net/quic/crypto/crypto_protocol.h"
10 #include "net/quic/crypto/quic_decrypter.h" 10 #include "net/quic/crypto/quic_decrypter.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 nonce.size() - sizeof(sequence_number)); 81 nonce.size() - sizeof(sequence_number));
82 memcpy(&sequence_number, nonce.data() + nonce_prefix.size(), 82 memcpy(&sequence_number, nonce.data() + nonce_prefix.size(),
83 sizeof(sequence_number)); 83 sizeof(sequence_number));
84 84
85 scoped_ptr<QuicDecrypter> decrypter(QuicDecrypter::Create(kAESG)); 85 scoped_ptr<QuicDecrypter> decrypter(QuicDecrypter::Create(kAESG));
86 if (!decrypter->SetKey(key_)) { 86 if (!decrypter->SetKey(key_)) {
87 DLOG(DFATAL) << "CryptoSecretBoxer's decrypter->SetKey failed."; 87 DLOG(DFATAL) << "CryptoSecretBoxer's decrypter->SetKey failed.";
88 return false; 88 return false;
89 } 89 }
90 decrypter->SetNoncePrefix(nonce_prefix); 90 decrypter->SetNoncePrefix(nonce_prefix);
91 scoped_ptr<QuicData> decrypted( 91 char plaintext[kMaxPacketSize];
92 decrypter->DecryptPacket(sequence_number, StringPiece(), ciphertext)); 92 size_t plaintext_length = 0;
93 if (!decrypted.get()) { 93 const bool success = decrypter->DecryptPacket(
94 sequence_number, StringPiece() /* associated data */, ciphertext,
95 plaintext, &plaintext_length, kMaxPacketSize);
96 if (!success) {
94 return false; 97 return false;
95 } 98 }
96 99
97 out_storage->resize(decrypted->length()); 100 out_storage->resize(plaintext_length);
98 out_storage->assign(decrypted->data(), decrypted->length()); 101 out_storage->assign(plaintext, plaintext_length);
99 out->set(out_storage->data(), decrypted->length()); 102 out->set(out_storage->data(), plaintext_length);
100 return true; 103 return true;
101 } 104 }
102 105
103 } // namespace net 106 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/crypto_framer.cc ('k') | net/quic/crypto/null_decrypter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698