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

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

Issue 2907743003: Change CryptoHandshakeMessage::GetTaglist to tag a QuicTagVector* (Closed)
Patch Set: Created 3 years, 7 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) 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/core/crypto/crypto_utils.h" 5 #include "net/quic/core/crypto/crypto_utils.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "crypto/hkdf.h" 9 #include "crypto/hkdf.h"
10 #include "net/quic/core/crypto/crypto_handshake.h" 10 #include "net/quic/core/crypto/crypto_handshake.h"
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 const CryptoHandshakeMessage& server_hello, 181 const CryptoHandshakeMessage& server_hello,
182 const QuicVersionVector& negotiated_versions, 182 const QuicVersionVector& negotiated_versions,
183 string* error_details) { 183 string* error_details) {
184 DCHECK(error_details != nullptr); 184 DCHECK(error_details != nullptr);
185 185
186 if (server_hello.tag() != kSHLO) { 186 if (server_hello.tag() != kSHLO) {
187 *error_details = "Bad tag"; 187 *error_details = "Bad tag";
188 return QUIC_INVALID_CRYPTO_MESSAGE_TYPE; 188 return QUIC_INVALID_CRYPTO_MESSAGE_TYPE;
189 } 189 }
190 190
191 const QuicTag* supported_version_tags; 191 QuicTagVector supported_version_tags;
192 size_t num_supported_versions; 192 if (server_hello.GetTaglist(kVER, &supported_version_tags) != QUIC_NO_ERROR) {
193
194 if (server_hello.GetTaglist(kVER, &supported_version_tags,
195 &num_supported_versions) != QUIC_NO_ERROR) {
196 *error_details = "server hello missing version list"; 193 *error_details = "server hello missing version list";
197 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; 194 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER;
198 } 195 }
199 if (!negotiated_versions.empty()) { 196 if (!negotiated_versions.empty()) {
200 bool mismatch = num_supported_versions != negotiated_versions.size(); 197 bool mismatch = supported_version_tags.size() != negotiated_versions.size();
201 for (size_t i = 0; i < num_supported_versions && !mismatch; ++i) { 198 for (size_t i = 0; i < supported_version_tags.size() && !mismatch; ++i) {
202 mismatch = QuicTagToQuicVersion(supported_version_tags[i]) != 199 mismatch = QuicTagToQuicVersion(supported_version_tags[i]) !=
203 negotiated_versions[i]; 200 negotiated_versions[i];
204 } 201 }
205 // The server sent a list of supported versions, and the connection 202 // The server sent a list of supported versions, and the connection
206 // reports that there was a version negotiation during the handshake. 203 // reports that there was a version negotiation during the handshake.
207 // Ensure that these two lists are identical. 204 // Ensure that these two lists are identical.
208 if (mismatch) { 205 if (mismatch) {
209 *error_details = "Downgrade attack detected"; 206 *error_details = "Downgrade attack detected";
210 return QUIC_VERSION_NEGOTIATION_MISMATCH; 207 return QUIC_VERSION_NEGOTIATION_MISMATCH;
211 } 208 }
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 string* output, 292 string* output,
296 Perspective perspective) { 293 Perspective perspective) {
297 const QuicData& serialized = message.GetSerialized(perspective); 294 const QuicData& serialized = message.GetSerialized(perspective);
298 uint8_t digest[SHA256_DIGEST_LENGTH]; 295 uint8_t digest[SHA256_DIGEST_LENGTH];
299 SHA256(reinterpret_cast<const uint8_t*>(serialized.data()), 296 SHA256(reinterpret_cast<const uint8_t*>(serialized.data()),
300 serialized.length(), digest); 297 serialized.length(), digest);
301 output->assign(reinterpret_cast<const char*>(digest), sizeof(digest)); 298 output->assign(reinterpret_cast<const char*>(digest), sizeof(digest));
302 } 299 }
303 300
304 } // namespace net 301 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698