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

Side by Side Diff: net/quic/core/crypto/crypto_secret_boxer.cc

Issue 2681793002: Landing Recent QUIC changes until 5:30 PM, Feb 3, 2017 UTC-5 (Closed)
Patch Set: sync and rebase Created 3 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/core/crypto/crypto_framer_test.cc ('k') | net/quic/core/crypto/crypto_server_test.cc » ('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/core/crypto/crypto_secret_boxer.h" 5 #include "net/quic/core/crypto/crypto_secret_boxer.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "net/quic/core/crypto/aes_128_gcm_12_decrypter.h" 10 #include "net/quic/core/crypto/aes_128_gcm_12_decrypter.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 101
102 std::unique_ptr<Aes128Gcm12Decrypter> decrypter(new Aes128Gcm12Decrypter()); 102 std::unique_ptr<Aes128Gcm12Decrypter> decrypter(new Aes128Gcm12Decrypter());
103 char plaintext[kMaxPacketSize]; 103 char plaintext[kMaxPacketSize];
104 size_t plaintext_length = 0; 104 size_t plaintext_length = 0;
105 bool ok = false; 105 bool ok = false;
106 { 106 {
107 QuicReaderMutexLock l(&lock_); 107 QuicReaderMutexLock l(&lock_);
108 for (const string& key : keys_) { 108 for (const string& key : keys_) {
109 if (decrypter->SetKey(key)) { 109 if (decrypter->SetKey(key)) {
110 decrypter->SetNoncePrefix(nonce_prefix); 110 decrypter->SetNoncePrefix(nonce_prefix);
111 if (decrypter->DecryptPacket(QUIC_VERSION_36, 111 if (decrypter->DecryptPacket(QUIC_VERSION_36, packet_number,
112 /*path_id=*/0u, packet_number,
113 /*associated data=*/StringPiece(), 112 /*associated data=*/StringPiece(),
114 ciphertext, plaintext, &plaintext_length, 113 ciphertext, plaintext, &plaintext_length,
115 kMaxPacketSize)) { 114 kMaxPacketSize)) {
116 ok = true; 115 ok = true;
117 break; 116 break;
118 } 117 }
119 } 118 }
120 } 119 }
121 } 120 }
122 if (!ok) { 121 if (!ok) {
123 return false; 122 return false;
124 } 123 }
125 124
126 out_storage->resize(plaintext_length); 125 out_storage->resize(plaintext_length);
127 out_storage->assign(plaintext, plaintext_length); 126 out_storage->assign(plaintext, plaintext_length);
128 out->set(out_storage->data(), plaintext_length); 127 out->set(out_storage->data(), plaintext_length);
129 return true; 128 return true;
130 } 129 }
131 130
132 } // namespace net 131 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/crypto/crypto_framer_test.cc ('k') | net/quic/core/crypto/crypto_server_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698