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 <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/metrics/histogram_macros.h" | 10 #include "base/metrics/histogram_macros.h" |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 | 520 |
521 QuicStringPiece scid; | 521 QuicStringPiece scid; |
522 if (!scfg->GetStringPiece(kSCID, &scid)) { | 522 if (!scfg->GetStringPiece(kSCID, &scid)) { |
523 *error_details = "SCFG missing SCID"; | 523 *error_details = "SCFG missing SCID"; |
524 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; | 524 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; |
525 } | 525 } |
526 out->SetStringPiece(kSCID, scid); | 526 out->SetStringPiece(kSCID, scid); |
527 | 527 |
528 out->SetStringPiece(kCertificateSCTTag, ""); | 528 out->SetStringPiece(kCertificateSCTTag, ""); |
529 | 529 |
530 const QuicTag* their_aeads; | 530 QuicTagVector their_aeads; |
531 const QuicTag* their_key_exchanges; | 531 QuicTagVector their_key_exchanges; |
532 size_t num_their_aeads, num_their_key_exchanges; | 532 if (scfg->GetTaglist(kAEAD, &their_aeads) != QUIC_NO_ERROR || |
533 if (scfg->GetTaglist(kAEAD, &their_aeads, &num_their_aeads) != | 533 scfg->GetTaglist(kKEXS, &their_key_exchanges) != QUIC_NO_ERROR) { |
534 QUIC_NO_ERROR || | |
535 scfg->GetTaglist(kKEXS, &their_key_exchanges, &num_their_key_exchanges) != | |
536 QUIC_NO_ERROR) { | |
537 *error_details = "Missing AEAD or KEXS"; | 534 *error_details = "Missing AEAD or KEXS"; |
538 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; | 535 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; |
539 } | 536 } |
540 | 537 |
541 // AEAD: the work loads on the client and server are symmetric. Since the | 538 // AEAD: the work loads on the client and server are symmetric. Since the |
542 // client is more likely to be CPU-constrained, break the tie by favoring | 539 // client is more likely to be CPU-constrained, break the tie by favoring |
543 // the client's preference. | 540 // the client's preference. |
544 // Key exchange: the client does more work than the server, so favor the | 541 // Key exchange: the client does more work than the server, so favor the |
545 // client's preference. | 542 // client's preference. |
546 size_t key_exchange_index; | 543 size_t key_exchange_index; |
547 if (!FindMutualQuicTag(aead, their_aeads, num_their_aeads, &out_params->aead, | 544 if (!FindMutualQuicTag(aead, their_aeads.data(), their_aeads.size(), |
548 nullptr) || | 545 &out_params->aead, nullptr) || |
549 !FindMutualQuicTag(kexs, their_key_exchanges, num_their_key_exchanges, | 546 !FindMutualQuicTag(kexs, their_key_exchanges.data(), |
550 &out_params->key_exchange, &key_exchange_index)) { | 547 their_key_exchanges.size(), &out_params->key_exchange, |
| 548 &key_exchange_index)) { |
551 *error_details = "Unsupported AEAD or KEXS"; | 549 *error_details = "Unsupported AEAD or KEXS"; |
552 return QUIC_CRYPTO_NO_SUPPORT; | 550 return QUIC_CRYPTO_NO_SUPPORT; |
553 } | 551 } |
554 out->SetVector(kAEAD, QuicTagVector{out_params->aead}); | 552 out->SetVector(kAEAD, QuicTagVector{out_params->aead}); |
555 out->SetVector(kKEXS, QuicTagVector{out_params->key_exchange}); | 553 out->SetVector(kKEXS, QuicTagVector{out_params->key_exchange}); |
556 | 554 |
557 if (!tb_key_params.empty() && | 555 if (!tb_key_params.empty() && |
558 server_id.privacy_mode() == PRIVACY_MODE_DISABLED) { | 556 server_id.privacy_mode() == PRIVACY_MODE_DISABLED) { |
559 const QuicTag* their_tbkps; | 557 QuicTagVector their_tbkps; |
560 size_t num_their_tbkps; | 558 switch (scfg->GetTaglist(kTBKP, &their_tbkps)) { |
561 switch (scfg->GetTaglist(kTBKP, &their_tbkps, &num_their_tbkps)) { | |
562 case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND: | 559 case QUIC_CRYPTO_MESSAGE_PARAMETER_NOT_FOUND: |
563 break; | 560 break; |
564 case QUIC_NO_ERROR: | 561 case QUIC_NO_ERROR: |
565 if (FindMutualQuicTag(tb_key_params, their_tbkps, num_their_tbkps, | 562 if (FindMutualQuicTag(tb_key_params, their_tbkps.data(), |
| 563 their_tbkps.size(), |
566 &out_params->token_binding_key_param, nullptr)) { | 564 &out_params->token_binding_key_param, nullptr)) { |
567 out->SetVector(kTBKP, | 565 out->SetVector(kTBKP, |
568 QuicTagVector{out_params->token_binding_key_param}); | 566 QuicTagVector{out_params->token_binding_key_param}); |
569 } | 567 } |
570 break; | 568 break; |
571 default: | 569 default: |
572 *error_details = "Invalid TBKP"; | 570 *error_details = "Invalid TBKP"; |
573 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; | 571 return QUIC_INVALID_CRYPTO_MESSAGE_PARAMETER; |
574 } | 572 } |
575 } | 573 } |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 } | 991 } |
994 | 992 |
995 // Update canonical version to point at the "most recent" entry. | 993 // Update canonical version to point at the "most recent" entry. |
996 canonical_server_map_[suffix_server_id] = server_id; | 994 canonical_server_map_[suffix_server_id] = server_id; |
997 | 995 |
998 server_state->InitializeFrom(*canonical_state); | 996 server_state->InitializeFrom(*canonical_state); |
999 return true; | 997 return true; |
1000 } | 998 } |
1001 | 999 |
1002 } // namespace net | 1000 } // namespace net |
OLD | NEW |