| 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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 old_config_options.id = "old-config-id"; | 125 old_config_options.id = "old-config-id"; |
| 126 delete crypto_config.AddDefaultConfig(QuicRandom::GetInstance(), &clock, | 126 delete crypto_config.AddDefaultConfig(QuicRandom::GetInstance(), &clock, |
| 127 old_config_options); | 127 old_config_options); |
| 128 QuicCryptoServerConfig::ConfigOptions new_config_options; | 128 QuicCryptoServerConfig::ConfigOptions new_config_options; |
| 129 std::unique_ptr<QuicServerConfigProtobuf> primary_config( | 129 std::unique_ptr<QuicServerConfigProtobuf> primary_config( |
| 130 crypto_config.GenerateConfig(QuicRandom::GetInstance(), &clock, | 130 crypto_config.GenerateConfig(QuicRandom::GetInstance(), &clock, |
| 131 new_config_options)); | 131 new_config_options)); |
| 132 primary_config->set_primary_time(clock.WallNow().ToUNIXSeconds()); | 132 primary_config->set_primary_time(clock.WallNow().ToUNIXSeconds()); |
| 133 std::unique_ptr<CryptoHandshakeMessage> msg( | 133 std::unique_ptr<CryptoHandshakeMessage> msg( |
| 134 crypto_config.AddConfig(std::move(primary_config), clock.WallNow())); | 134 crypto_config.AddConfig(std::move(primary_config), clock.WallNow())); |
| 135 StringPiece orbit; | 135 QuicStringPiece orbit; |
| 136 ASSERT_TRUE(msg->GetStringPiece(kORBT, &orbit)); | 136 ASSERT_TRUE(msg->GetStringPiece(kORBT, &orbit)); |
| 137 string nonce; | 137 string nonce; |
| 138 CryptoUtils::GenerateNonce( | 138 CryptoUtils::GenerateNonce( |
| 139 clock.WallNow(), QuicRandom::GetInstance(), | 139 clock.WallNow(), QuicRandom::GetInstance(), |
| 140 StringPiece(reinterpret_cast<const char*>(orbit.data()), | 140 QuicStringPiece(reinterpret_cast<const char*>(orbit.data()), |
| 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 CryptoHandshakeMessage inchoate_chlo = crypto_test_utils::CreateCHLO( | 151 CryptoHandshakeMessage inchoate_chlo = crypto_test_utils::CreateCHLO( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 164 // Verify that full_chlo can pass crypto_config's verification. | 164 // Verify that full_chlo can pass crypto_config's verification. |
| 165 ShloVerifier shlo_verifier(&crypto_config, server_addr, client_addr, &clock, | 165 ShloVerifier shlo_verifier(&crypto_config, server_addr, client_addr, &clock, |
| 166 signed_config, &compressed_certs_cache); | 166 signed_config, &compressed_certs_cache); |
| 167 crypto_config.ValidateClientHello( | 167 crypto_config.ValidateClientHello( |
| 168 full_chlo, client_addr.host(), server_addr, version, &clock, | 168 full_chlo, client_addr.host(), server_addr, version, &clock, |
| 169 signed_config, shlo_verifier.GetValidateClientHelloCallback()); | 169 signed_config, shlo_verifier.GetValidateClientHelloCallback()); |
| 170 } | 170 } |
| 171 | 171 |
| 172 } // namespace test | 172 } // namespace test |
| 173 } // namespace net | 173 } // namespace net |
| OLD | NEW |