| 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/v2_authenticator.h" | 5 #include "remoting/protocol/v2_authenticator.h" |
| 6 | 6 |
| 7 #include "base/base64.h" | 7 #include "base/base64.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "remoting/base/constants.h" | 9 #include "remoting/base/constants.h" |
| 10 #include "remoting/base/rsa_key_pair.h" | 10 #include "remoting/base/rsa_key_pair.h" |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 // static | 41 // static |
| 42 scoped_ptr<Authenticator> V2Authenticator::CreateForHost( | 42 scoped_ptr<Authenticator> V2Authenticator::CreateForHost( |
| 43 const std::string& local_cert, | 43 const std::string& local_cert, |
| 44 scoped_refptr<RsaKeyPair> key_pair, | 44 scoped_refptr<RsaKeyPair> key_pair, |
| 45 const std::string& shared_secret, | 45 const std::string& shared_secret, |
| 46 Authenticator::State initial_state) { | 46 Authenticator::State initial_state) { |
| 47 scoped_ptr<V2Authenticator> result(new V2Authenticator( | 47 scoped_ptr<V2Authenticator> result(new V2Authenticator( |
| 48 P224EncryptedKeyExchange::kPeerTypeServer, shared_secret, initial_state)); | 48 P224EncryptedKeyExchange::kPeerTypeServer, shared_secret, initial_state)); |
| 49 result->local_cert_ = local_cert; | 49 result->local_cert_ = local_cert; |
| 50 result->local_key_pair_ = key_pair; | 50 result->local_key_pair_ = key_pair; |
| 51 return result.Pass(); | 51 return std::move(result); |
| 52 } | 52 } |
| 53 | 53 |
| 54 V2Authenticator::V2Authenticator( | 54 V2Authenticator::V2Authenticator( |
| 55 crypto::P224EncryptedKeyExchange::PeerType type, | 55 crypto::P224EncryptedKeyExchange::PeerType type, |
| 56 const std::string& shared_secret, | 56 const std::string& shared_secret, |
| 57 Authenticator::State initial_state) | 57 Authenticator::State initial_state) |
| 58 : certificate_sent_(false), | 58 : certificate_sent_(false), |
| 59 key_exchange_impl_(type, shared_secret), | 59 key_exchange_impl_(type, shared_secret), |
| 60 state_(initial_state), | 60 state_(initial_state), |
| 61 started_(false), | 61 started_(false), |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 std::string base64_cert; | 171 std::string base64_cert; |
| 172 base::Base64Encode(local_cert_, &base64_cert); | 172 base::Base64Encode(local_cert_, &base64_cert); |
| 173 certificate_tag->SetBodyText(base64_cert); | 173 certificate_tag->SetBodyText(base64_cert); |
| 174 message->AddElement(certificate_tag); | 174 message->AddElement(certificate_tag); |
| 175 certificate_sent_ = true; | 175 certificate_sent_ = true; |
| 176 } | 176 } |
| 177 | 177 |
| 178 if (state_ != ACCEPTED) { | 178 if (state_ != ACCEPTED) { |
| 179 state_ = WAITING_MESSAGE; | 179 state_ = WAITING_MESSAGE; |
| 180 } | 180 } |
| 181 return message.Pass(); | 181 return message; |
| 182 } | 182 } |
| 183 | 183 |
| 184 const std::string& V2Authenticator::GetAuthKey() const { | 184 const std::string& V2Authenticator::GetAuthKey() const { |
| 185 return auth_key_; | 185 return auth_key_; |
| 186 } | 186 } |
| 187 | 187 |
| 188 scoped_ptr<ChannelAuthenticator> | 188 scoped_ptr<ChannelAuthenticator> |
| 189 V2Authenticator::CreateChannelAuthenticator() const { | 189 V2Authenticator::CreateChannelAuthenticator() const { |
| 190 DCHECK_EQ(state(), ACCEPTED); | 190 DCHECK_EQ(state(), ACCEPTED); |
| 191 CHECK(!auth_key_.empty()); | 191 CHECK(!auth_key_.empty()); |
| 192 | 192 |
| 193 if (is_host_side()) { | 193 if (is_host_side()) { |
| 194 return SslHmacChannelAuthenticator::CreateForHost( | 194 return SslHmacChannelAuthenticator::CreateForHost( |
| 195 local_cert_, local_key_pair_, auth_key_); | 195 local_cert_, local_key_pair_, auth_key_); |
| 196 } else { | 196 } else { |
| 197 return SslHmacChannelAuthenticator::CreateForClient( | 197 return SslHmacChannelAuthenticator::CreateForClient( |
| 198 remote_cert_, auth_key_); | 198 remote_cert_, auth_key_); |
| 199 } | 199 } |
| 200 } | 200 } |
| 201 | 201 |
| 202 bool V2Authenticator::is_host_side() const { | 202 bool V2Authenticator::is_host_side() const { |
| 203 return local_key_pair_.get() != nullptr; | 203 return local_key_pair_.get() != nullptr; |
| 204 } | 204 } |
| 205 | 205 |
| 206 } // namespace protocol | 206 } // namespace protocol |
| 207 } // namespace remoting | 207 } // namespace remoting |
| OLD | NEW |