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

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

Issue 868953002: Remove unused QuicDecrypter::Decrypt method and implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@merge_84442484
Patch Set: Created 5 years, 11 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/chacha20_poly1305_decrypter_test.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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return ret; 67 return ret;
68 } 68 }
69 69
70 bool CryptoSecretBoxer::Unbox(StringPiece ciphertext, 70 bool CryptoSecretBoxer::Unbox(StringPiece ciphertext,
71 string* out_storage, 71 string* out_storage,
72 StringPiece* out) const { 72 StringPiece* out) const {
73 if (ciphertext.size() < kBoxNonceSize) { 73 if (ciphertext.size() < kBoxNonceSize) {
74 return false; 74 return false;
75 } 75 }
76 76
77 char nonce[kBoxNonceSize]; 77 StringPiece nonce(ciphertext.data(), kBoxNonceSize);
78 memcpy(nonce, ciphertext.data(), kBoxNonceSize);
79 ciphertext.remove_prefix(kBoxNonceSize); 78 ciphertext.remove_prefix(kBoxNonceSize);
80 79
81 size_t len = ciphertext.size(); 80 size_t len = ciphertext.size();
82 out_storage->resize(len); 81 out_storage->resize(len);
83 char* data = const_cast<char*>(out_storage->data()); 82 char* data = const_cast<char*>(out_storage->data());
84 83
85 scoped_ptr<QuicDecrypter> decrypter(QuicDecrypter::Create(kAESG)); 84 scoped_ptr<QuicDecrypter> decrypter(QuicDecrypter::Create(kAESG));
86 if (!decrypter->SetKey(key_)) { 85 if (!decrypter->SetKey(key_)) {
87 DLOG(DFATAL) << "CryptoSecretBoxer's decrypter->SetKey failed."; 86 DLOG(DFATAL) << "CryptoSecretBoxer's decrypter->SetKey failed.";
88 return false; 87 return false;
89 } 88 }
90 if (!decrypter->Decrypt(StringPiece(nonce, kBoxNonceSize), StringPiece(), 89
91 ciphertext, reinterpret_cast<unsigned char*>(data), 90 QuicPacketSequenceNumber sequence_number;
92 &len)) { 91 StringPiece nonce_prefix(nonce.data(),
92 nonce.size() - sizeof(sequence_number));
93 decrypter->SetNoncePrefix(nonce_prefix);
94 memcpy(&sequence_number, nonce.data() + nonce_prefix.size(),
95 sizeof(sequence_number));
96 scoped_ptr<QuicData> decrypted(
97 decrypter->DecryptPacket(sequence_number, StringPiece(), ciphertext));
98 if (!decrypted.get()) {
93 return false; 99 return false;
94 } 100 }
95 101
96 out->set(data, len); 102 memcpy(data, decrypted->data(), decrypted->length());
103 out->set(data, decrypted->length());
Ryan Hamilton 2015/01/23 00:29:13 consider using out->assign(decrypted->data(), decr
ramant (doing other things) 2015/01/23 00:47:54 Used std::string's assign to copy the data in the
97 return true; 104 return true;
98 } 105 }
99 106
100 } // namespace net 107 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/chacha20_poly1305_decrypter_test.cc ('k') | net/quic/crypto/null_decrypter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698