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

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

Issue 1009543004: Create a Perspective enum to use instead of a bool is_server to improve (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added NET_EXPORT_PRIVATE to fix compiler error Created 5 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/crypto/crypto_utils.h ('k') | net/quic/crypto/quic_crypto_client_config.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/crypto/crypto_utils.h" 5 #include "net/quic/crypto/crypto_utils.h"
6 6
7 #include "crypto/hkdf.h" 7 #include "crypto/hkdf.h"
8 #include "net/base/net_util.h" 8 #include "net/base/net_util.h"
9 #include "net/quic/crypto/crypto_handshake.h" 9 #include "net/quic/crypto/crypto_handshake.h"
10 #include "net/quic/crypto/crypto_protocol.h" 10 #include "net/quic/crypto/crypto_protocol.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 StringPiece nonce = client_nonce; 98 StringPiece nonce = client_nonce;
99 string nonce_storage; 99 string nonce_storage;
100 if (!server_nonce.empty()) { 100 if (!server_nonce.empty()) {
101 nonce_storage = client_nonce.as_string() + server_nonce.as_string(); 101 nonce_storage = client_nonce.as_string() + server_nonce.as_string();
102 nonce = nonce_storage; 102 nonce = nonce_storage;
103 } 103 }
104 104
105 crypto::HKDF hkdf(premaster_secret, nonce, hkdf_input, key_bytes, 105 crypto::HKDF hkdf(premaster_secret, nonce, hkdf_input, key_bytes,
106 nonce_prefix_bytes, subkey_secret_bytes); 106 nonce_prefix_bytes, subkey_secret_bytes);
107 if (perspective == SERVER) { 107 if (perspective == Perspective::IS_SERVER) {
108 if (!crypters->encrypter->SetKey(hkdf.server_write_key()) || 108 if (!crypters->encrypter->SetKey(hkdf.server_write_key()) ||
109 !crypters->encrypter->SetNoncePrefix(hkdf.server_write_iv()) || 109 !crypters->encrypter->SetNoncePrefix(hkdf.server_write_iv()) ||
110 !crypters->decrypter->SetKey(hkdf.client_write_key()) || 110 !crypters->decrypter->SetKey(hkdf.client_write_key()) ||
111 !crypters->decrypter->SetNoncePrefix(hkdf.client_write_iv())) { 111 !crypters->decrypter->SetNoncePrefix(hkdf.client_write_iv())) {
112 return false; 112 return false;
113 } 113 }
114 } else { 114 } else {
115 if (!crypters->encrypter->SetKey(hkdf.client_write_key()) || 115 if (!crypters->encrypter->SetKey(hkdf.client_write_key()) ||
116 !crypters->encrypter->SetNoncePrefix(hkdf.client_write_iv()) || 116 !crypters->encrypter->SetNoncePrefix(hkdf.client_write_iv()) ||
117 !crypters->decrypter->SetKey(hkdf.server_write_key()) || 117 !crypters->decrypter->SetKey(hkdf.server_write_key()) ||
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 StringPiece() /* no salt */, 153 StringPiece() /* no salt */,
154 info, 154 info,
155 result_len, 155 result_len,
156 0 /* no fixed IV */, 156 0 /* no fixed IV */,
157 0 /* no subkey secret */); 157 0 /* no subkey secret */);
158 hkdf.client_write_key().CopyToString(result); 158 hkdf.client_write_key().CopyToString(result);
159 return true; 159 return true;
160 } 160 }
161 161
162 } // namespace net 162 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/crypto_utils.h ('k') | net/quic/crypto/quic_crypto_client_config.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698