| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/test_tools/crypto_test_utils.h" | 5 #include "net/quic/test_tools/crypto_test_utils.h" |
| 6 | 6 |
| 7 #include "net/quic/core/crypto/crypto_server_config_protobuf.h" | 7 #include "net/quic/core/crypto/crypto_server_config_protobuf.h" |
| 8 #include "net/quic/core/quic_utils.h" | 8 #include "net/quic/core/quic_utils.h" |
| 9 #include "net/quic/platform/api/quic_text_utils.h" | 9 #include "net/quic/platform/api/quic_text_utils.h" |
| 10 #include "net/quic/test_tools/mock_clock.h" | 10 #include "net/quic/test_tools/mock_clock.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 sizeof(orbit.size())), | 141 sizeof(orbit.size())), |
| 142 &nonce); | 142 &nonce); |
| 143 string nonce_hex = "#" + QuicTextUtils::HexEncode(nonce); | 143 string nonce_hex = "#" + QuicTextUtils::HexEncode(nonce); |
| 144 | 144 |
| 145 char public_value[32]; | 145 char public_value[32]; |
| 146 memset(public_value, 42, sizeof(public_value)); | 146 memset(public_value, 42, sizeof(public_value)); |
| 147 string pub_hex = | 147 string pub_hex = |
| 148 "#" + QuicTextUtils::HexEncode(public_value, sizeof(public_value)); | 148 "#" + QuicTextUtils::HexEncode(public_value, sizeof(public_value)); |
| 149 | 149 |
| 150 QuicVersion version(AllSupportedVersions().front()); | 150 QuicVersion version(AllSupportedVersions().front()); |
| 151 // clang-format off | 151 CryptoHandshakeMessage inchoate_chlo = crypto_test_utils::CreateCHLO( |
| 152 CryptoHandshakeMessage inchoate_chlo = crypto_test_utils::Message( | 152 {{"PDMD", "X509"}, |
| 153 "CHLO", | 153 {"AEAD", "AESG"}, |
| 154 "PDMD", "X509", | 154 {"KEXS", "C255"}, |
| 155 "AEAD", "AESG", | 155 {"COPT", "SREJ"}, |
| 156 "KEXS", "C255", | 156 {"PUBS", pub_hex}, |
| 157 "COPT", "SREJ", | 157 {"NONC", nonce_hex}, |
| 158 "PUBS", pub_hex.c_str(), | 158 {"VER\0", QuicTagToString(QuicVersionToQuicTag(version))}}, |
| 159 "NONC", nonce_hex.c_str(), | 159 kClientHelloMinimumSize); |
| 160 "VER\0", QuicTagToString(QuicVersionToQuicTag(version)).c_str(), | |
| 161 "$padding", static_cast<int>(kClientHelloMinimumSize), | |
| 162 nullptr); | |
| 163 // clang-format on | |
| 164 | 160 |
| 165 crypto_test_utils::GenerateFullCHLO( | 161 crypto_test_utils::GenerateFullCHLO( |
| 166 inchoate_chlo, &crypto_config, server_addr, client_addr, version, &clock, | 162 inchoate_chlo, &crypto_config, server_addr, client_addr, version, &clock, |
| 167 signed_config, &compressed_certs_cache, &full_chlo); | 163 signed_config, &compressed_certs_cache, &full_chlo); |
| 168 // Verify that full_chlo can pass crypto_config's verification. | 164 // Verify that full_chlo can pass crypto_config's verification. |
| 169 ShloVerifier shlo_verifier(&crypto_config, server_addr, client_addr, &clock, | 165 ShloVerifier shlo_verifier(&crypto_config, server_addr, client_addr, &clock, |
| 170 signed_config, &compressed_certs_cache); | 166 signed_config, &compressed_certs_cache); |
| 171 crypto_config.ValidateClientHello( | 167 crypto_config.ValidateClientHello( |
| 172 full_chlo, client_addr.host(), server_addr, version, &clock, | 168 full_chlo, client_addr.host(), server_addr, version, &clock, |
| 173 signed_config, shlo_verifier.GetValidateClientHelloCallback()); | 169 signed_config, shlo_verifier.GetValidateClientHelloCallback()); |
| 174 } | 170 } |
| 175 | 171 |
| 176 } // namespace test | 172 } // namespace test |
| 177 } // namespace net | 173 } // namespace net |
| OLD | NEW |