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 <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/strings/string_util.h" | |
10 #include "crypto/openssl_util.h" | 9 #include "crypto/openssl_util.h" |
11 #include "crypto/secure_hash.h" | 10 #include "crypto/secure_hash.h" |
12 #include "net/quic/core/crypto/channel_id.h" | 11 #include "net/quic/core/crypto/channel_id.h" |
13 #include "net/quic/core/crypto/common_cert_set.h" | 12 #include "net/quic/core/crypto/common_cert_set.h" |
14 #include "net/quic/core/crypto/crypto_handshake.h" | 13 #include "net/quic/core/crypto/crypto_handshake.h" |
15 #include "net/quic/core/crypto/crypto_server_config_protobuf.h" | 14 #include "net/quic/core/crypto/crypto_server_config_protobuf.h" |
16 #include "net/quic/core/crypto/quic_crypto_server_config.h" | 15 #include "net/quic/core/crypto/quic_crypto_server_config.h" |
17 #include "net/quic/core/crypto/quic_decrypter.h" | 16 #include "net/quic/core/crypto/quic_decrypter.h" |
18 #include "net/quic/core/crypto/quic_encrypter.h" | 17 #include "net/quic/core/crypto/quic_encrypter.h" |
19 #include "net/quic/core/crypto/quic_random.h" | 18 #include "net/quic/core/crypto/quic_random.h" |
20 #include "net/quic/core/quic_crypto_client_stream.h" | 19 #include "net/quic/core/quic_crypto_client_stream.h" |
21 #include "net/quic/core/quic_crypto_server_stream.h" | 20 #include "net/quic/core/quic_crypto_server_stream.h" |
22 #include "net/quic/core/quic_crypto_stream.h" | 21 #include "net/quic/core/quic_crypto_stream.h" |
23 #include "net/quic/core/quic_server_id.h" | 22 #include "net/quic/core/quic_server_id.h" |
24 #include "net/quic/core/quic_utils.h" | 23 #include "net/quic/core/quic_utils.h" |
25 #include "net/quic/platform/api/quic_clock.h" | 24 #include "net/quic/platform/api/quic_clock.h" |
26 #include "net/quic/platform/api/quic_socket_address.h" | 25 #include "net/quic/platform/api/quic_socket_address.h" |
| 26 #include "net/quic/platform/api/quic_text_utils.h" |
27 #include "net/quic/test_tools/quic_connection_peer.h" | 27 #include "net/quic/test_tools/quic_connection_peer.h" |
28 #include "net/quic/test_tools/quic_framer_peer.h" | 28 #include "net/quic/test_tools/quic_framer_peer.h" |
29 #include "net/quic/test_tools/quic_test_utils.h" | 29 #include "net/quic/test_tools/quic_test_utils.h" |
30 #include "net/quic/test_tools/simple_quic_framer.h" | 30 #include "net/quic/test_tools/simple_quic_framer.h" |
31 #include "third_party/boringssl/src/include/openssl/bn.h" | 31 #include "third_party/boringssl/src/include/openssl/bn.h" |
32 #include "third_party/boringssl/src/include/openssl/ec.h" | 32 #include "third_party/boringssl/src/include/openssl/ec.h" |
33 #include "third_party/boringssl/src/include/openssl/ecdsa.h" | 33 #include "third_party/boringssl/src/include/openssl/ecdsa.h" |
34 #include "third_party/boringssl/src/include/openssl/evp.h" | 34 #include "third_party/boringssl/src/include/openssl/evp.h" |
35 #include "third_party/boringssl/src/include/openssl/obj_mac.h" | 35 #include "third_party/boringssl/src/include/openssl/obj_mac.h" |
36 #include "third_party/boringssl/src/include/openssl/sha.h" | 36 #include "third_party/boringssl/src/include/openssl/sha.h" |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
985 std::unique_ptr<net::CryptoHandshakeMessage> msg( | 985 std::unique_ptr<net::CryptoHandshakeMessage> msg( |
986 crypto_config->AddConfig(std::move(primary_config), clock->WallNow())); | 986 crypto_config->AddConfig(std::move(primary_config), clock->WallNow())); |
987 StringPiece orbit; | 987 StringPiece orbit; |
988 CHECK(msg->GetStringPiece(net::kORBT, &orbit)); | 988 CHECK(msg->GetStringPiece(net::kORBT, &orbit)); |
989 string nonce; | 989 string nonce; |
990 net::CryptoUtils::GenerateNonce( | 990 net::CryptoUtils::GenerateNonce( |
991 clock->WallNow(), net::QuicRandom::GetInstance(), | 991 clock->WallNow(), net::QuicRandom::GetInstance(), |
992 StringPiece(reinterpret_cast<const char*>(orbit.data()), | 992 StringPiece(reinterpret_cast<const char*>(orbit.data()), |
993 sizeof(orbit.size())), | 993 sizeof(orbit.size())), |
994 &nonce); | 994 &nonce); |
995 return ("#" + net::QuicUtils::HexEncode(nonce)); | 995 return ("#" + QuicTextUtils::HexEncode(nonce)); |
996 } | 996 } |
997 | 997 |
998 string CryptoTestUtils::GenerateClientPublicValuesHex() { | 998 string CryptoTestUtils::GenerateClientPublicValuesHex() { |
999 char public_value[32]; | 999 char public_value[32]; |
1000 memset(public_value, 42, sizeof(public_value)); | 1000 memset(public_value, 42, sizeof(public_value)); |
1001 return ("#" + net::QuicUtils::HexEncode(public_value, sizeof(public_value))); | 1001 return ("#" + QuicTextUtils::HexEncode(public_value, sizeof(public_value))); |
1002 } | 1002 } |
1003 | 1003 |
1004 // static | 1004 // static |
1005 void CryptoTestUtils::GenerateFullCHLO( | 1005 void CryptoTestUtils::GenerateFullCHLO( |
1006 const CryptoHandshakeMessage& inchoate_chlo, | 1006 const CryptoHandshakeMessage& inchoate_chlo, |
1007 QuicCryptoServerConfig* crypto_config, | 1007 QuicCryptoServerConfig* crypto_config, |
1008 QuicSocketAddress server_addr, | 1008 QuicSocketAddress server_addr, |
1009 QuicSocketAddress client_addr, | 1009 QuicSocketAddress client_addr, |
1010 QuicVersion version, | 1010 QuicVersion version, |
1011 const QuicClock* clock, | 1011 const QuicClock* clock, |
1012 QuicReferenceCountedPointer<QuicSignedServerConfig> proof, | 1012 QuicReferenceCountedPointer<QuicSignedServerConfig> proof, |
1013 QuicCompressedCertsCache* compressed_certs_cache, | 1013 QuicCompressedCertsCache* compressed_certs_cache, |
1014 CryptoHandshakeMessage* out) { | 1014 CryptoHandshakeMessage* out) { |
1015 // Pass a inchoate CHLO. | 1015 // Pass a inchoate CHLO. |
1016 FullChloGenerator generator(crypto_config, server_addr, client_addr, clock, | 1016 FullChloGenerator generator(crypto_config, server_addr, client_addr, clock, |
1017 proof, compressed_certs_cache, out); | 1017 proof, compressed_certs_cache, out); |
1018 crypto_config->ValidateClientHello( | 1018 crypto_config->ValidateClientHello( |
1019 inchoate_chlo, client_addr.host(), server_addr, version, clock, proof, | 1019 inchoate_chlo, client_addr.host(), server_addr, version, clock, proof, |
1020 generator.GetValidateClientHelloCallback()); | 1020 generator.GetValidateClientHelloCallback()); |
1021 } | 1021 } |
1022 | 1022 |
1023 } // namespace test | 1023 } // namespace test |
1024 } // namespace net | 1024 } // namespace net |
OLD | NEW |