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

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

Issue 1421853006: Landing Recent QUIC changes until: Fri Oct 30 22:23:58 2015 +0000 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix comments Created 5 years, 1 month 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/proof_source.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_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 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 0 /* no subkey secret */); 158 0 /* no subkey secret */);
159 hkdf.client_write_key().CopyToString(result); 159 hkdf.client_write_key().CopyToString(result);
160 return true; 160 return true;
161 } 161 }
162 162
163 // static 163 // static
164 uint64 CryptoUtils::ComputeLeafCertHash(const std::string& cert) { 164 uint64 CryptoUtils::ComputeLeafCertHash(const std::string& cert) {
165 return QuicUtils::FNV1a_64_Hash(cert.data(), cert.size()); 165 return QuicUtils::FNV1a_64_Hash(cert.data(), cert.size());
166 } 166 }
167 167
168 QuicErrorCode CryptoUtils::ValidateServerHello(
169 const CryptoHandshakeMessage& server_hello,
170 const QuicVersionVector& negotiated_versions,
171 string* error_details) {
172 DCHECK(error_details != nullptr);
173
174 if (server_hello.tag() != kSHLO) {
175 *error_details = "Bad tag";
176 return QUIC_INVALID_CRYPTO_MESSAGE_TYPE;
177 }
178
179 const QuicTag* supported_version_tags;
180 size_t num_supported_versions;
181
182 if (server_hello.GetTaglist(kVER, &supported_version_tags,
183 &num_supported_versions) != QUIC_NO_ERROR) {
184 *error_details = "server hello missing version list";
185 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER;
186 }
187 if (!negotiated_versions.empty()) {
188 bool mismatch = num_supported_versions != negotiated_versions.size();
189 for (size_t i = 0; i < num_supported_versions && !mismatch; ++i) {
190 mismatch = QuicTagToQuicVersion(supported_version_tags[i]) !=
191 negotiated_versions[i];
192 }
193 // The server sent a list of supported versions, and the connection
194 // reports that there was a version negotiation during the handshake.
195 // Ensure that these two lists are identical.
196 if (mismatch) {
197 *error_details = "Downgrade attack detected";
198 return QUIC_VERSION_NEGOTIATION_MISMATCH;
199 }
200 }
201 return QUIC_NO_ERROR;
202 }
203
168 } // namespace net 204 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/crypto/crypto_utils.h ('k') | net/quic/crypto/proof_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698