| 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 <openssl/bn.h> | 7 #include <openssl/bn.h> |
| 8 #include <openssl/ec.h> | 8 #include <openssl/ec.h> |
| 9 #include <openssl/ecdsa.h> | 9 #include <openssl/ecdsa.h> |
| 10 #include <openssl/evp.h> | 10 #include <openssl/evp.h> |
| (...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 920 crypto_framer.set_visitor(&crypto_visitor); | 920 crypto_framer.set_visitor(&crypto_visitor); |
| 921 | 921 |
| 922 size_t index = *inout_packet_index; | 922 size_t index = *inout_packet_index; |
| 923 for (; index < source_conn->encrypted_packets_.size(); index++) { | 923 for (; index < source_conn->encrypted_packets_.size(); index++) { |
| 924 if (!framer.ProcessPacket(*source_conn->encrypted_packets_[index])) { | 924 if (!framer.ProcessPacket(*source_conn->encrypted_packets_[index])) { |
| 925 // The framer will be unable to decrypt forward-secure packets sent after | 925 // The framer will be unable to decrypt forward-secure packets sent after |
| 926 // the handshake is complete. Don't treat them as handshake packets. | 926 // the handshake is complete. Don't treat them as handshake packets. |
| 927 break; | 927 break; |
| 928 } | 928 } |
| 929 | 929 |
| 930 for (const QuicStreamFrame* stream_frame : framer.stream_frames()) { | 930 for (const auto& stream_frame : framer.stream_frames()) { |
| 931 ASSERT_TRUE(crypto_framer.ProcessInput( | 931 ASSERT_TRUE(crypto_framer.ProcessInput( |
| 932 StringPiece(stream_frame->data_buffer, stream_frame->data_length))); | 932 StringPiece(stream_frame->data_buffer, stream_frame->data_length))); |
| 933 ASSERT_FALSE(crypto_visitor.error()); | 933 ASSERT_FALSE(crypto_visitor.error()); |
| 934 } | 934 } |
| 935 QuicConnectionPeer::SetCurrentPacket( | 935 QuicConnectionPeer::SetCurrentPacket( |
| 936 dest_conn, source_conn->encrypted_packets_[index]->AsStringPiece()); | 936 dest_conn, source_conn->encrypted_packets_[index]->AsStringPiece()); |
| 937 } | 937 } |
| 938 *inout_packet_index = index; | 938 *inout_packet_index = index; |
| 939 | 939 |
| 940 QuicConnectionPeer::SwapCrypters(dest_conn, framer.framer()); | 940 QuicConnectionPeer::SwapCrypters(dest_conn, framer.framer()); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 net::QuicCryptoServerConfig::ConfigOptions old_config_options; | 973 net::QuicCryptoServerConfig::ConfigOptions old_config_options; |
| 974 net::QuicCryptoServerConfig::ConfigOptions new_config_options; | 974 net::QuicCryptoServerConfig::ConfigOptions new_config_options; |
| 975 old_config_options.id = "old-config-id"; | 975 old_config_options.id = "old-config-id"; |
| 976 delete crypto_config->AddDefaultConfig(net::QuicRandom::GetInstance(), clock, | 976 delete crypto_config->AddDefaultConfig(net::QuicRandom::GetInstance(), clock, |
| 977 old_config_options); | 977 old_config_options); |
| 978 std::unique_ptr<QuicServerConfigProtobuf> primary_config( | 978 std::unique_ptr<QuicServerConfigProtobuf> primary_config( |
| 979 crypto_config->GenerateConfig(net::QuicRandom::GetInstance(), clock, | 979 crypto_config->GenerateConfig(net::QuicRandom::GetInstance(), clock, |
| 980 new_config_options)); | 980 new_config_options)); |
| 981 primary_config->set_primary_time(clock->WallNow().ToUNIXSeconds()); | 981 primary_config->set_primary_time(clock->WallNow().ToUNIXSeconds()); |
| 982 std::unique_ptr<net::CryptoHandshakeMessage> msg( | 982 std::unique_ptr<net::CryptoHandshakeMessage> msg( |
| 983 crypto_config->AddConfig(primary_config.get(), clock->WallNow())); | 983 crypto_config->AddConfig(std::move(primary_config), clock->WallNow())); |
| 984 StringPiece orbit; | 984 StringPiece orbit; |
| 985 CHECK(msg->GetStringPiece(net::kORBT, &orbit)); | 985 CHECK(msg->GetStringPiece(net::kORBT, &orbit)); |
| 986 string nonce; | 986 string nonce; |
| 987 net::CryptoUtils::GenerateNonce( | 987 net::CryptoUtils::GenerateNonce( |
| 988 clock->WallNow(), net::QuicRandom::GetInstance(), | 988 clock->WallNow(), net::QuicRandom::GetInstance(), |
| 989 StringPiece(reinterpret_cast<const char*>(orbit.data()), | 989 StringPiece(reinterpret_cast<const char*>(orbit.data()), |
| 990 sizeof(orbit.size())), | 990 sizeof(orbit.size())), |
| 991 &nonce); | 991 &nonce); |
| 992 return ("#" + net::QuicUtils::HexEncode(nonce)); | 992 return ("#" + net::QuicUtils::HexEncode(nonce)); |
| 993 } | 993 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 1012 // Pass a inchoate CHLO. | 1012 // Pass a inchoate CHLO. |
| 1013 FullChloGenerator generator(crypto_config, server_ip, client_addr, clock, | 1013 FullChloGenerator generator(crypto_config, server_ip, client_addr, clock, |
| 1014 proof, compressed_certs_cache, out); | 1014 proof, compressed_certs_cache, out); |
| 1015 crypto_config->ValidateClientHello( | 1015 crypto_config->ValidateClientHello( |
| 1016 inchoate_chlo, client_addr.address(), server_ip, version, clock, proof, | 1016 inchoate_chlo, client_addr.address(), server_ip, version, clock, proof, |
| 1017 generator.GetValidateClientHelloCallback()); | 1017 generator.GetValidateClientHelloCallback()); |
| 1018 } | 1018 } |
| 1019 | 1019 |
| 1020 } // namespace test | 1020 } // namespace test |
| 1021 } // namespace net | 1021 } // namespace net |
| OLD | NEW |