| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/macros.h" | 9 #include "base/macros.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 | 45 |
| 46 namespace remoting { | 46 namespace remoting { |
| 47 | 47 |
| 48 using protocol::ChannelConfig; | 48 using protocol::ChannelConfig; |
| 49 | 49 |
| 50 namespace { | 50 namespace { |
| 51 | 51 |
| 52 const char kHostJid[] = "host_jid@example.com/host"; | 52 const char kHostJid[] = "host_jid@example.com/host"; |
| 53 const char kHostOwner[] = "jane.doe@example.com"; | 53 const char kHostOwner[] = "jane.doe@example.com"; |
| 54 const char kClientJid[] = "jane.doe@example.com/client"; | 54 const char kClientJid[] = "jane.doe@example.com/client"; |
| 55 const char kHostId[] = "ABC123"; |
| 56 const char kHostPin[] = "123456"; |
| 55 | 57 |
| 56 struct NetworkPerformanceParams { | 58 struct NetworkPerformanceParams { |
| 57 NetworkPerformanceParams(int bandwidth, | 59 NetworkPerformanceParams(int bandwidth, |
| 58 int max_buffers, | 60 int max_buffers, |
| 59 double latency_average_ms, | 61 double latency_average_ms, |
| 60 double latency_stddev_ms, | 62 double latency_stddev_ms, |
| 61 double out_of_order_rate) | 63 double out_of_order_rate) |
| 62 : bandwidth(bandwidth), | 64 : bandwidth(bandwidth), |
| 63 max_buffers(max_buffers), | 65 max_buffers(max_buffers), |
| 64 latency_average(base::TimeDelta::FromMillisecondsD(latency_average_ms)), | 66 latency_average(base::TimeDelta::FromMillisecondsD(latency_average_ms)), |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 certs_dir.AppendASCII("unittest.selfsigned.der"), &host_cert)); | 342 certs_dir.AppendASCII("unittest.selfsigned.der"), &host_cert)); |
| 341 | 343 |
| 342 base::FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); | 344 base::FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); |
| 343 std::string key_string; | 345 std::string key_string; |
| 344 ASSERT_TRUE(base::ReadFileToString(key_path, &key_string)); | 346 ASSERT_TRUE(base::ReadFileToString(key_path, &key_string)); |
| 345 std::string key_base64; | 347 std::string key_base64; |
| 346 base::Base64Encode(key_string, &key_base64); | 348 base::Base64Encode(key_string, &key_base64); |
| 347 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(key_base64); | 349 scoped_refptr<RsaKeyPair> key_pair = RsaKeyPair::FromString(key_base64); |
| 348 ASSERT_TRUE(key_pair.get()); | 350 ASSERT_TRUE(key_pair.get()); |
| 349 | 351 |
| 350 protocol::SharedSecretHash host_secret; | 352 std::string host_pin_hash = protocol::ApplySharedSecretHashFunction( |
| 351 host_secret.hash_function = protocol::AuthenticationMethod::NONE; | 353 protocol::HashFunction::HMAC_SHA256, kHostId, kHostPin); |
| 352 host_secret.value = "123456"; | |
| 353 scoped_ptr<protocol::AuthenticatorFactory> auth_factory = | 354 scoped_ptr<protocol::AuthenticatorFactory> auth_factory = |
| 354 protocol::Me2MeHostAuthenticatorFactory::CreateWithSharedSecret( | 355 protocol::Me2MeHostAuthenticatorFactory::CreateWithPin( |
| 355 true, kHostOwner, host_cert, key_pair, "", host_secret, nullptr); | 356 true, kHostOwner, host_cert, key_pair, "", host_pin_hash, nullptr); |
| 356 host_->SetAuthenticatorFactory(std::move(auth_factory)); | 357 host_->SetAuthenticatorFactory(std::move(auth_factory)); |
| 357 | 358 |
| 358 host_->AddStatusObserver(this); | 359 host_->AddStatusObserver(this); |
| 359 host_->Start(kHostOwner); | 360 host_->Start(kHostOwner); |
| 360 | 361 |
| 361 message_loop_.PostTask(FROM_HERE, | 362 message_loop_.PostTask(FROM_HERE, |
| 362 base::Bind(&ProtocolPerfTest::StartClientAfterHost, | 363 base::Bind(&ProtocolPerfTest::StartClientAfterHost, |
| 363 base::Unretained(this))); | 364 base::Unretained(this))); |
| 364 } | 365 } |
| 365 | 366 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 380 port_allocator_factory->socket_factory()->SetLatency( | 381 port_allocator_factory->socket_factory()->SetLatency( |
| 381 GetParam().latency_average, GetParam().latency_stddev); | 382 GetParam().latency_average, GetParam().latency_stddev); |
| 382 port_allocator_factory->socket_factory()->set_out_of_order_rate( | 383 port_allocator_factory->socket_factory()->set_out_of_order_rate( |
| 383 GetParam().out_of_order_rate); | 384 GetParam().out_of_order_rate); |
| 384 scoped_refptr<protocol::TransportContext> transport_context( | 385 scoped_refptr<protocol::TransportContext> transport_context( |
| 385 new protocol::TransportContext( | 386 new protocol::TransportContext( |
| 386 host_signaling_.get(), std::move(port_allocator_factory), nullptr, | 387 host_signaling_.get(), std::move(port_allocator_factory), nullptr, |
| 387 network_settings, protocol::TransportRole::CLIENT)); | 388 network_settings, protocol::TransportRole::CLIENT)); |
| 388 | 389 |
| 389 std::vector<protocol::AuthenticationMethod> auth_methods; | 390 std::vector<protocol::AuthenticationMethod> auth_methods; |
| 390 auth_methods.push_back(protocol::AuthenticationMethod::Spake2( | 391 auth_methods.push_back( |
| 391 protocol::AuthenticationMethod::NONE)); | 392 protocol::AuthenticationMethod::SPAKE2_SHARED_SECRET_HMAC); |
| 392 scoped_ptr<protocol::Authenticator> client_authenticator( | 393 scoped_ptr<protocol::Authenticator> client_authenticator( |
| 393 new protocol::NegotiatingClientAuthenticator( | 394 new protocol::NegotiatingClientAuthenticator( |
| 394 std::string(), // client_pairing_id | 395 std::string(), // client_pairing_id |
| 395 std::string(), // client_pairing_secret | 396 std::string(), // client_pairing_secret |
| 396 std::string(), // authentication_tag | 397 kHostId, |
| 397 base::Bind(&ProtocolPerfTest::FetchPin, base::Unretained(this)), | 398 base::Bind(&ProtocolPerfTest::FetchPin, base::Unretained(this)), |
| 398 nullptr, auth_methods)); | 399 nullptr, auth_methods)); |
| 399 client_.reset( | 400 client_.reset( |
| 400 new ChromotingClient(client_context_.get(), this, this, nullptr)); | 401 new ChromotingClient(client_context_.get(), this, this, nullptr)); |
| 401 client_->set_protocol_config(protocol_config_->Clone()); | 402 client_->set_protocol_config(protocol_config_->Clone()); |
| 402 client_->Start(client_signaling_.get(), std::move(client_authenticator), | 403 client_->Start(client_signaling_.get(), std::move(client_authenticator), |
| 403 transport_context, kHostJid, std::string()); | 404 transport_context, kHostJid, std::string()); |
| 404 } | 405 } |
| 405 | 406 |
| 406 void FetchPin( | 407 void FetchPin( |
| 407 bool pairing_supported, | 408 bool pairing_supported, |
| 408 const protocol::SecretFetchedCallback& secret_fetched_callback) { | 409 const protocol::SecretFetchedCallback& secret_fetched_callback) { |
| 409 secret_fetched_callback.Run("123456"); | 410 secret_fetched_callback.Run(kHostPin); |
| 410 } | 411 } |
| 411 | 412 |
| 412 void MeasureTotalLatency(bool webrtc) { | 413 void MeasureTotalLatency(bool webrtc) { |
| 413 scoped_refptr<test::CyclicFrameGenerator> frame_generator = | 414 scoped_refptr<test::CyclicFrameGenerator> frame_generator = |
| 414 test::CyclicFrameGenerator::Create(); | 415 test::CyclicFrameGenerator::Create(); |
| 415 frame_generator->set_draw_barcode(true); | 416 frame_generator->set_draw_barcode(true); |
| 416 | 417 |
| 417 desktop_environment_factory_.set_frame_generator(base::Bind( | 418 desktop_environment_factory_.set_frame_generator(base::Bind( |
| 418 &test::CyclicFrameGenerator::GenerateFrame, frame_generator)); | 419 &test::CyclicFrameGenerator::GenerateFrame, frame_generator)); |
| 419 | 420 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 | 631 |
| 631 TEST_P(ProtocolPerfTest, TotalLatencyIce) { | 632 TEST_P(ProtocolPerfTest, TotalLatencyIce) { |
| 632 MeasureTotalLatency(false); | 633 MeasureTotalLatency(false); |
| 633 } | 634 } |
| 634 | 635 |
| 635 TEST_P(ProtocolPerfTest, TotalLatencyWebrtc) { | 636 TEST_P(ProtocolPerfTest, TotalLatencyWebrtc) { |
| 636 MeasureTotalLatency(true); | 637 MeasureTotalLatency(true); |
| 637 } | 638 } |
| 638 | 639 |
| 639 } // namespace remoting | 640 } // namespace remoting |
| OLD | NEW |