OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/quic_crypto_client_config.h" | 5 #include "net/quic/crypto/quic_crypto_client_config.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "net/quic/crypto/cert_compressor.h" | 8 #include "net/quic/crypto/cert_compressor.h" |
9 #include "net/quic/crypto/channel_id.h" | 9 #include "net/quic/crypto/channel_id.h" |
10 #include "net/quic/crypto/common_cert_set.h" | 10 #include "net/quic/crypto/common_cert_set.h" |
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 for (vector<string>::const_iterator i = certs.begin(); | 377 for (vector<string>::const_iterator i = certs.begin(); |
378 i != certs.end(); ++i) { | 378 i != certs.end(); ++i) { |
379 hashes.push_back(QuicUtils::FNV1a_64_Hash(i->data(), i->size())); | 379 hashes.push_back(QuicUtils::FNV1a_64_Hash(i->data(), i->size())); |
380 } | 380 } |
381 out->SetVector(kCCRT, hashes); | 381 out->SetVector(kCCRT, hashes); |
382 } | 382 } |
383 } | 383 } |
384 | 384 |
385 QuicErrorCode QuicCryptoClientConfig::FillClientHello( | 385 QuicErrorCode QuicCryptoClientConfig::FillClientHello( |
386 const string& server_hostname, | 386 const string& server_hostname, |
387 QuicGuid guid, | 387 QuicConnectionId connection_id, |
388 const QuicVersion preferred_version, | 388 const QuicVersion preferred_version, |
389 const CachedState* cached, | 389 const CachedState* cached, |
390 QuicWallTime now, | 390 QuicWallTime now, |
391 QuicRandom* rand, | 391 QuicRandom* rand, |
392 QuicCryptoNegotiatedParameters* out_params, | 392 QuicCryptoNegotiatedParameters* out_params, |
393 CryptoHandshakeMessage* out, | 393 CryptoHandshakeMessage* out, |
394 string* error_details) const { | 394 string* error_details) const { |
395 DCHECK(error_details != NULL); | 395 DCHECK(error_details != NULL); |
396 | 396 |
397 FillInchoateClientHello(server_hostname, preferred_version, cached, | 397 FillInchoateClientHello(server_hostname, preferred_version, cached, |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 const size_t orig_min_size = out->minimum_size(); | 500 const size_t orig_min_size = out->minimum_size(); |
501 out->set_minimum_size(0); | 501 out->set_minimum_size(0); |
502 | 502 |
503 CryptoHandshakeMessage cetv; | 503 CryptoHandshakeMessage cetv; |
504 cetv.set_tag(kCETV); | 504 cetv.set_tag(kCETV); |
505 | 505 |
506 string hkdf_input; | 506 string hkdf_input; |
507 const QuicData& client_hello_serialized = out->GetSerialized(); | 507 const QuicData& client_hello_serialized = out->GetSerialized(); |
508 hkdf_input.append(QuicCryptoConfig::kCETVLabel, | 508 hkdf_input.append(QuicCryptoConfig::kCETVLabel, |
509 strlen(QuicCryptoConfig::kCETVLabel) + 1); | 509 strlen(QuicCryptoConfig::kCETVLabel) + 1); |
510 hkdf_input.append(reinterpret_cast<char*>(&guid), sizeof(guid)); | 510 hkdf_input.append(reinterpret_cast<char*>(&connection_id), |
| 511 sizeof(connection_id)); |
511 hkdf_input.append(client_hello_serialized.data(), | 512 hkdf_input.append(client_hello_serialized.data(), |
512 client_hello_serialized.length()); | 513 client_hello_serialized.length()); |
513 hkdf_input.append(cached->server_config()); | 514 hkdf_input.append(cached->server_config()); |
514 | 515 |
515 string key, signature; | 516 string key, signature; |
516 if (!channel_id_signer_->Sign(server_hostname, hkdf_input, | 517 if (!channel_id_signer_->Sign(server_hostname, hkdf_input, |
517 &key, &signature)) { | 518 &key, &signature)) { |
518 *error_details = "Channel ID signature failed"; | 519 *error_details = "Channel ID signature failed"; |
519 return QUIC_INVALID_CHANNEL_ID_SIGNATURE; | 520 return QUIC_INVALID_CHANNEL_ID_SIGNATURE; |
520 } | 521 } |
(...skipping 20 matching lines...) Expand all Loading... |
541 return QUIC_ENCRYPTION_FAILURE; | 542 return QUIC_ENCRYPTION_FAILURE; |
542 } | 543 } |
543 | 544 |
544 out->SetStringPiece(kCETV, cetv_ciphertext->AsStringPiece()); | 545 out->SetStringPiece(kCETV, cetv_ciphertext->AsStringPiece()); |
545 out->MarkDirty(); | 546 out->MarkDirty(); |
546 | 547 |
547 out->set_minimum_size(orig_min_size); | 548 out->set_minimum_size(orig_min_size); |
548 } | 549 } |
549 | 550 |
550 out_params->hkdf_input_suffix.clear(); | 551 out_params->hkdf_input_suffix.clear(); |
551 out_params->hkdf_input_suffix.append(reinterpret_cast<char*>(&guid), | 552 out_params->hkdf_input_suffix.append(reinterpret_cast<char*>(&connection_id), |
552 sizeof(guid)); | 553 sizeof(connection_id)); |
553 const QuicData& client_hello_serialized = out->GetSerialized(); | 554 const QuicData& client_hello_serialized = out->GetSerialized(); |
554 out_params->hkdf_input_suffix.append(client_hello_serialized.data(), | 555 out_params->hkdf_input_suffix.append(client_hello_serialized.data(), |
555 client_hello_serialized.length()); | 556 client_hello_serialized.length()); |
556 out_params->hkdf_input_suffix.append(cached->server_config()); | 557 out_params->hkdf_input_suffix.append(cached->server_config()); |
557 | 558 |
558 string hkdf_input; | 559 string hkdf_input; |
559 const size_t label_len = strlen(QuicCryptoConfig::kInitialLabel) + 1; | 560 const size_t label_len = strlen(QuicCryptoConfig::kInitialLabel) + 1; |
560 hkdf_input.reserve(label_len + out_params->hkdf_input_suffix.size()); | 561 hkdf_input.reserve(label_len + out_params->hkdf_input_suffix.size()); |
561 hkdf_input.append(QuicCryptoConfig::kInitialLabel, label_len); | 562 hkdf_input.append(QuicCryptoConfig::kInitialLabel, label_len); |
562 hkdf_input.append(out_params->hkdf_input_suffix); | 563 hkdf_input.append(out_params->hkdf_input_suffix); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
629 *error_details = "Proof missing"; | 630 *error_details = "Proof missing"; |
630 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; | 631 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; |
631 } | 632 } |
632 } | 633 } |
633 | 634 |
634 return QUIC_NO_ERROR; | 635 return QUIC_NO_ERROR; |
635 } | 636 } |
636 | 637 |
637 QuicErrorCode QuicCryptoClientConfig::ProcessServerHello( | 638 QuicErrorCode QuicCryptoClientConfig::ProcessServerHello( |
638 const CryptoHandshakeMessage& server_hello, | 639 const CryptoHandshakeMessage& server_hello, |
639 QuicGuid guid, | 640 QuicConnectionId connection_id, |
640 const QuicVersionVector& negotiated_versions, | 641 const QuicVersionVector& negotiated_versions, |
641 CachedState* cached, | 642 CachedState* cached, |
642 QuicCryptoNegotiatedParameters* out_params, | 643 QuicCryptoNegotiatedParameters* out_params, |
643 string* error_details) { | 644 string* error_details) { |
644 DCHECK(error_details != NULL); | 645 DCHECK(error_details != NULL); |
645 | 646 |
646 if (server_hello.tag() != kSHLO) { | 647 if (server_hello.tag() != kSHLO) { |
647 *error_details = "Bad tag"; | 648 *error_details = "Bad tag"; |
648 return QUIC_INVALID_CRYPTO_MESSAGE_TYPE; | 649 return QUIC_INVALID_CRYPTO_MESSAGE_TYPE; |
649 } | 650 } |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 CachedState* canonical_cached = | 732 CachedState* canonical_cached = |
732 canonical_crypto_config->LookupOrCreate(canonical_server_hostname); | 733 canonical_crypto_config->LookupOrCreate(canonical_server_hostname); |
733 if (!canonical_cached->proof_valid()) { | 734 if (!canonical_cached->proof_valid()) { |
734 return; | 735 return; |
735 } | 736 } |
736 CachedState* cached = LookupOrCreate(server_hostname); | 737 CachedState* cached = LookupOrCreate(server_hostname); |
737 cached->InitializeFrom(*canonical_cached); | 738 cached->InitializeFrom(*canonical_cached); |
738 } | 739 } |
739 | 740 |
740 } // namespace net | 741 } // namespace net |
OLD | NEW |