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

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

Issue 2611613003: Add quic_logging (Closed)
Patch Set: fix failed test? Created 3 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
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 13
13 using base::StringPiece; 14 using base::StringPiece;
14 using std::string; 15 using std::string;
15 16
16 namespace net { 17 namespace net {
17 18
18 // static 19 // static
19 QuicDecrypter* QuicDecrypter::Create(QuicTag algorithm) { 20 QuicDecrypter* QuicDecrypter::Create(QuicTag algorithm) {
20 switch (algorithm) { 21 switch (algorithm) {
21 case kAESG: 22 case kAESG:
22 return new Aes128Gcm12Decrypter(); 23 return new Aes128Gcm12Decrypter();
23 case kCC20: 24 case kCC20:
24 return new ChaCha20Poly1305Decrypter(); 25 return new ChaCha20Poly1305Decrypter();
25 default: 26 default:
26 LOG(FATAL) << "Unsupported algorithm: " << algorithm; 27 QUIC_LOG(FATAL) << "Unsupported algorithm: " << algorithm;
27 return nullptr; 28 return nullptr;
28 } 29 }
29 } 30 }
30 31
31 // static 32 // static
32 void QuicDecrypter::DiversifyPreliminaryKey(StringPiece preliminary_key, 33 void QuicDecrypter::DiversifyPreliminaryKey(StringPiece preliminary_key,
33 StringPiece nonce_prefix, 34 StringPiece nonce_prefix,
34 const DiversificationNonce& nonce, 35 const DiversificationNonce& nonce,
35 size_t key_size, 36 size_t key_size,
36 size_t nonce_prefix_size, 37 size_t nonce_prefix_size,
37 string* out_key, 38 string* out_key,
38 string* out_nonce_prefix) { 39 string* out_nonce_prefix) {
39 crypto::HKDF hkdf(preliminary_key.as_string() + nonce_prefix.as_string(), 40 crypto::HKDF hkdf(preliminary_key.as_string() + nonce_prefix.as_string(),
40 StringPiece(nonce.data(), nonce.size()), 41 StringPiece(nonce.data(), nonce.size()),
41 "QUIC key diversification", 0, key_size, 0, 42 "QUIC key diversification", 0, key_size, 0,
42 nonce_prefix_size, 0); 43 nonce_prefix_size, 0);
43 *out_key = hkdf.server_write_key().as_string(); 44 *out_key = hkdf.server_write_key().as_string();
44 *out_nonce_prefix = hkdf.server_write_iv().as_string(); 45 *out_nonce_prefix = hkdf.server_write_iv().as_string();
45 } 46 }
46 47
47 } // namespace net 48 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/core/crypto/quic_crypto_server_config.cc ('k') | net/quic/core/crypto/quic_encrypter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698