| 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/core/crypto/quic_crypto_client_config.h" | 5 #include "net/quic/core/crypto/quic_crypto_client_config.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 525 *error_details = "Missing AEAD or KEXS"; | 525 *error_details = "Missing AEAD or KEXS"; |
| 526 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; | 526 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; |
| 527 } | 527 } |
| 528 | 528 |
| 529 // AEAD: the work loads on the client and server are symmetric. Since the | 529 // AEAD: the work loads on the client and server are symmetric. Since the |
| 530 // client is more likely to be CPU-constrained, break the tie by favoring | 530 // client is more likely to be CPU-constrained, break the tie by favoring |
| 531 // the client's preference. | 531 // the client's preference. |
| 532 // Key exchange: the client does more work than the server, so favor the | 532 // Key exchange: the client does more work than the server, so favor the |
| 533 // client's preference. | 533 // client's preference. |
| 534 size_t key_exchange_index; | 534 size_t key_exchange_index; |
| 535 if (!QuicUtils::FindMutualTag(aead, their_aeads, num_their_aeads, | 535 if (!FindMutualQuicTag(aead, their_aeads, num_their_aeads, &out_params->aead, |
| 536 &out_params->aead, nullptr) || | 536 nullptr) || |
| 537 !QuicUtils::FindMutualTag( | 537 !FindMutualQuicTag(kexs, their_key_exchanges, num_their_key_exchanges, |
| 538 kexs, their_key_exchanges, num_their_key_exchanges, | 538 &out_params->key_exchange, &key_exchange_index)) { |
| 539 &out_params->key_exchange, &key_exchange_index)) { | |
| 540 *error_details = "Unsupported AEAD or KEXS"; | 539 *error_details = "Unsupported AEAD or KEXS"; |
| 541 return QUIC_CRYPTO_NO_SUPPORT; | 540 return QUIC_CRYPTO_NO_SUPPORT; |
| 542 } | 541 } |
| 543 out->SetVector(kAEAD, QuicTagVector{out_params->aead}); | 542 out->SetVector(kAEAD, QuicTagVector{out_params->aead}); |
| 544 out->SetVector(kKEXS, QuicTagVector{out_params->key_exchange}); | 543 out->SetVector(kKEXS, QuicTagVector{out_params->key_exchange}); |
| 545 | 544 |
| 546 if (!tb_key_params.empty() && | 545 if (!tb_key_params.empty() && |
| 547 server_id.privacy_mode() == PRIVACY_MODE_DISABLED) { | 546 server_id.privacy_mode() == PRIVACY_MODE_DISABLED) { |
| 548 const QuicTag* their_tbkps; | 547 const QuicTag* their_tbkps; |
| 549 size_t num_their_tbkps; | 548 size_t num_their_tbkps; |
| 550 switch (scfg->GetTaglist(kTBKP, &their_tbkps, &num_their_tbkps)) { | 549 switch (scfg->GetTaglist(kTBKP, &their_tbkps, &num_their_tbkps)) { |
| 551 case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND: | 550 case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND: |
| 552 break; | 551 break; |
| 553 case QUIC_NO_ERROR: | 552 case QUIC_NO_ERROR: |
| 554 if (QuicUtils::FindMutualTag( | 553 if (FindMutualQuicTag(tb_key_params, their_tbkps, num_their_tbkps, |
| 555 tb_key_params, their_tbkps, num_their_tbkps, | 554 &out_params->token_binding_key_param, nullptr)) { |
| 556 &out_params->token_binding_key_param, nullptr)) { | |
| 557 out->SetVector(kTBKP, | 555 out->SetVector(kTBKP, |
| 558 QuicTagVector{out_params->token_binding_key_param}); | 556 QuicTagVector{out_params->token_binding_key_param}); |
| 559 } | 557 } |
| 560 break; | 558 break; |
| 561 default: | 559 default: |
| 562 *error_details = "Invalid TBKP"; | 560 *error_details = "Invalid TBKP"; |
| 563 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; | 561 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; |
| 564 } | 562 } |
| 565 } | 563 } |
| 566 | 564 |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 } | 973 } |
| 976 | 974 |
| 977 // Update canonical version to point at the "most recent" entry. | 975 // Update canonical version to point at the "most recent" entry. |
| 978 canonical_server_map_[suffix_server_id] = server_id; | 976 canonical_server_map_[suffix_server_id] = server_id; |
| 979 | 977 |
| 980 server_state->InitializeFrom(*canonical_state); | 978 server_state->InitializeFrom(*canonical_state); |
| 981 return true; | 979 return true; |
| 982 } | 980 } |
| 983 | 981 |
| 984 } // namespace net | 982 } // namespace net |
| OLD | NEW |