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 "remoting/protocol/ssl_hmac_channel_authenticator.h" | 5 #include "remoting/protocol/ssl_hmac_channel_authenticator.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 | 59 |
60 base::FilePath cert_path = certs_dir.AppendASCII("unittest.selfsigned.der"); | 60 base::FilePath cert_path = certs_dir.AppendASCII("unittest.selfsigned.der"); |
61 ASSERT_TRUE(file_util::ReadFileToString(cert_path, &host_cert_)); | 61 ASSERT_TRUE(file_util::ReadFileToString(cert_path, &host_cert_)); |
62 | 62 |
63 base::FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); | 63 base::FilePath key_path = certs_dir.AppendASCII("unittest.key.bin"); |
64 std::string key_string; | 64 std::string key_string; |
65 ASSERT_TRUE(file_util::ReadFileToString(key_path, &key_string)); | 65 ASSERT_TRUE(file_util::ReadFileToString(key_path, &key_string)); |
66 std::string key_base64; | 66 std::string key_base64; |
67 base::Base64Encode(key_string, &key_base64); | 67 base::Base64Encode(key_string, &key_base64); |
68 key_pair_ = RsaKeyPair::FromString(key_base64); | 68 key_pair_ = RsaKeyPair::FromString(key_base64); |
69 ASSERT_TRUE(key_pair_); | 69 ASSERT_TRUE(key_pair_.get()); |
70 } | 70 } |
71 | 71 |
72 void RunChannelAuth(bool expected_fail) { | 72 void RunChannelAuth(bool expected_fail) { |
73 client_fake_socket_.reset(new FakeSocket()); | 73 client_fake_socket_.reset(new FakeSocket()); |
74 host_fake_socket_.reset(new FakeSocket()); | 74 host_fake_socket_.reset(new FakeSocket()); |
75 client_fake_socket_->PairWith(host_fake_socket_.get()); | 75 client_fake_socket_->PairWith(host_fake_socket_.get()); |
76 | 76 |
77 client_auth_->SecureAndAuthenticate( | 77 client_auth_->SecureAndAuthenticate( |
78 client_fake_socket_.PassAs<net::StreamSocket>(), | 78 client_fake_socket_.PassAs<net::StreamSocket>(), |
79 base::Bind(&SslHmacChannelAuthenticatorTest::OnClientConnected, | 79 base::Bind(&SslHmacChannelAuthenticatorTest::OnClientConnected, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( | 164 host_auth_ = SslHmacChannelAuthenticator::CreateForHost( |
165 host_cert_, key_pair_, kTestSharedSecret); | 165 host_cert_, key_pair_, kTestSharedSecret); |
166 | 166 |
167 RunChannelAuth(true); | 167 RunChannelAuth(true); |
168 | 168 |
169 ASSERT_TRUE(host_socket_.get() == NULL); | 169 ASSERT_TRUE(host_socket_.get() == NULL); |
170 } | 170 } |
171 | 171 |
172 } // namespace protocol | 172 } // namespace protocol |
173 } // namespace remoting | 173 } // namespace remoting |
OLD | NEW |