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

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

Issue 2740453006: Add QuicStringPiece which is actually StringPiece. (Closed)
Patch Set: fix compile error and rebase Created 3 years, 9 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/quic_decrypter.h ('k') | net/quic/core/crypto/quic_encrypter.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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/quic_decrypter.h" 5 #include "net/quic/core/crypto/quic_decrypter.h"
6 6
7 #include "crypto/hkdf.h" 7 #include "crypto/hkdf.h"
8 #include "net/quic/core/crypto/aes_128_gcm_12_decrypter.h" 8 #include "net/quic/core/crypto/aes_128_gcm_12_decrypter.h"
9 #include "net/quic/core/crypto/chacha20_poly1305_decrypter.h" 9 #include "net/quic/core/crypto/chacha20_poly1305_decrypter.h"
10 #include "net/quic/core/crypto/crypto_protocol.h" 10 #include "net/quic/core/crypto/crypto_protocol.h"
11 #include "net/quic/core/crypto/null_decrypter.h" 11 #include "net/quic/core/crypto/null_decrypter.h"
12 #include "net/quic/platform/api/quic_logging.h" 12 #include "net/quic/platform/api/quic_logging.h"
13 13
14 using base::StringPiece;
15 using std::string; 14 using std::string;
16 15
17 namespace net { 16 namespace net {
18 17
19 // static 18 // static
20 QuicDecrypter* QuicDecrypter::Create(QuicTag algorithm) { 19 QuicDecrypter* QuicDecrypter::Create(QuicTag algorithm) {
21 switch (algorithm) { 20 switch (algorithm) {
22 case kAESG: 21 case kAESG:
23 return new Aes128Gcm12Decrypter(); 22 return new Aes128Gcm12Decrypter();
24 case kCC20: 23 case kCC20:
25 return new ChaCha20Poly1305Decrypter(); 24 return new ChaCha20Poly1305Decrypter();
26 default: 25 default:
27 QUIC_LOG(FATAL) << "Unsupported algorithm: " << algorithm; 26 QUIC_LOG(FATAL) << "Unsupported algorithm: " << algorithm;
28 return nullptr; 27 return nullptr;
29 } 28 }
30 } 29 }
31 30
32 // static 31 // static
33 void QuicDecrypter::DiversifyPreliminaryKey(StringPiece preliminary_key, 32 void QuicDecrypter::DiversifyPreliminaryKey(QuicStringPiece preliminary_key,
34 StringPiece nonce_prefix, 33 QuicStringPiece nonce_prefix,
35 const DiversificationNonce& nonce, 34 const DiversificationNonce& nonce,
36 size_t key_size, 35 size_t key_size,
37 size_t nonce_prefix_size, 36 size_t nonce_prefix_size,
38 string* out_key, 37 string* out_key,
39 string* out_nonce_prefix) { 38 string* out_nonce_prefix) {
40 crypto::HKDF hkdf(preliminary_key.as_string() + nonce_prefix.as_string(), 39 crypto::HKDF hkdf(preliminary_key.as_string() + nonce_prefix.as_string(),
41 StringPiece(nonce.data(), nonce.size()), 40 QuicStringPiece(nonce.data(), nonce.size()),
42 "QUIC key diversification", 0, key_size, 0, 41 "QUIC key diversification", 0, key_size, 0,
43 nonce_prefix_size, 0); 42 nonce_prefix_size, 0);
44 *out_key = hkdf.server_write_key().as_string(); 43 *out_key = hkdf.server_write_key().as_string();
45 *out_nonce_prefix = hkdf.server_write_iv().as_string(); 44 *out_nonce_prefix = hkdf.server_write_iv().as_string();
46 } 45 }
47 46
48 } // namespace net 47 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/crypto/quic_decrypter.h ('k') | net/quic/core/crypto/quic_encrypter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698