| 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 "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "net/quic/crypto/cert_compressor.h" | 9 #include "net/quic/crypto/cert_compressor.h" |
| 10 #include "net/quic/crypto/chacha20_poly1305_encrypter.h" | 10 #include "net/quic/crypto/chacha20_poly1305_encrypter.h" |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; | 586 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; |
| 587 } | 587 } |
| 588 } | 588 } |
| 589 | 589 |
| 590 const uint32* reject_reasons; | 590 const uint32* reject_reasons; |
| 591 size_t num_reject_reasons; | 591 size_t num_reject_reasons; |
| 592 COMPILE_ASSERT(sizeof(QuicTag) == sizeof(uint32), header_out_of_sync); | 592 COMPILE_ASSERT(sizeof(QuicTag) == sizeof(uint32), header_out_of_sync); |
| 593 if (rej.GetTaglist(kRREJ, &reject_reasons, | 593 if (rej.GetTaglist(kRREJ, &reject_reasons, |
| 594 &num_reject_reasons) == QUIC_NO_ERROR) { | 594 &num_reject_reasons) == QUIC_NO_ERROR) { |
| 595 #if defined(DEBUG) | 595 #if defined(DEBUG) |
| 596 uint32 packed_error = 0; |
| 596 for (size_t i = 0; i < num_reject_reasons; ++i) { | 597 for (size_t i = 0; i < num_reject_reasons; ++i) { |
| 597 DVLOG(1) << "Reasons for rejection: " << reject_reasons[i]; | 598 HandshakeFailureReason reason = |
| 599 static_cast<HandshakeFailureReason>(reject_reasons[i]); |
| 600 packed_error |= RejectReasonToPackedError(reason); |
| 598 } | 601 } |
| 602 DVLOG(1) << "Reasons for rejection: " << packed_error; |
| 599 #endif | 603 #endif |
| 600 } | 604 } |
| 601 | 605 |
| 602 return QUIC_NO_ERROR; | 606 return QUIC_NO_ERROR; |
| 603 } | 607 } |
| 604 | 608 |
| 609 uint32 QuicCryptoClientConfig::RejectReasonToPackedError( |
| 610 HandshakeFailureReason reason) { |
| 611 switch (reason) { |
| 612 case HANDSHAKE_OK: |
| 613 return 0; |
| 614 case CLIENT_NONCE_UNKNOWN_FAILURE: |
| 615 return 1u << 5; |
| 616 case CLIENT_NONCE_INVALID_FAILURE: |
| 617 return 2u << 5; |
| 618 case SERVER_NONCE_INVALID_FAILURE: |
| 619 return 1u << 10; |
| 620 case SERVER_NONCE_DECRYPTION_FAILURE: |
| 621 return 2u << 10; |
| 622 case SERVER_NONCE_NOT_UNIQUE_FAILURE: |
| 623 return 3u << 10; |
| 624 case SERVER_CONFIG_INCHOATE_HELLO_FAILURE: |
| 625 return 1u << 15; |
| 626 case SERVER_CONFIG_UNKNOWN_CONFIG_FAILURE: |
| 627 return 2u << 15; |
| 628 case SOURCE_ADDRESS_TOKEN_INVALID_FAILURE: |
| 629 return 1u << 20; |
| 630 case SOURCE_ADDRESS_TOKEN_DECRYPTION_FAILURE: |
| 631 return 2u << 20; |
| 632 case SOURCE_ADDRESS_TOKEN_PARSE_FAILURE: |
| 633 return 3u << 20; |
| 634 case SOURCE_ADDRESS_TOKEN_DIFFERENT_IP_ADDRESS_FAILURE: |
| 635 return 4u << 20; |
| 636 case SOURCE_ADDRESS_TOKEN_CLOCK_SKEW_FAILURE: |
| 637 return 5u << 20; |
| 638 case SOURCE_ADDRESS_TOKEN_EXPIRED_FAILURE: |
| 639 return 6u << 20; |
| 640 default: |
| 641 LOG(FATAL) << "Unsupported RejectReason: " << reason; |
| 642 return 1u << 31; |
| 643 } |
| 644 } |
| 645 |
| 605 QuicErrorCode QuicCryptoClientConfig::ProcessServerHello( | 646 QuicErrorCode QuicCryptoClientConfig::ProcessServerHello( |
| 606 const CryptoHandshakeMessage& server_hello, | 647 const CryptoHandshakeMessage& server_hello, |
| 607 QuicConnectionId connection_id, | 648 QuicConnectionId connection_id, |
| 608 const QuicVersionVector& negotiated_versions, | 649 const QuicVersionVector& negotiated_versions, |
| 609 CachedState* cached, | 650 CachedState* cached, |
| 610 QuicCryptoNegotiatedParameters* out_params, | 651 QuicCryptoNegotiatedParameters* out_params, |
| 611 string* error_details) { | 652 string* error_details) { |
| 612 DCHECK(error_details != NULL); | 653 DCHECK(error_details != NULL); |
| 613 | 654 |
| 614 if (server_hello.tag() != kSHLO) { | 655 if (server_hello.tag() != kSHLO) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 756 return; | 797 return; |
| 757 } | 798 } |
| 758 | 799 |
| 759 // Update canonical version to point at the "most recent" entry. | 800 // Update canonical version to point at the "most recent" entry. |
| 760 canonical_server_map_[suffix_server_id] = server_id; | 801 canonical_server_map_[suffix_server_id] = server_id; |
| 761 | 802 |
| 762 server_state->InitializeFrom(*canonical_state); | 803 server_state->InitializeFrom(*canonical_state); |
| 763 } | 804 } |
| 764 | 805 |
| 765 } // namespace net | 806 } // namespace net |
| OLD | NEW |