OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "crypto/rsa_private_key.h" | 9 #include "crypto/rsa_private_key.h" |
10 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
(...skipping 26 matching lines...) Expand all Loading... |
37 // static | 37 // static |
38 V2Authenticator* V2Authenticator::CreateForClient( | 38 V2Authenticator* V2Authenticator::CreateForClient( |
39 const std::string& shared_secret) { | 39 const std::string& shared_secret) { |
40 return new V2Authenticator( | 40 return new V2Authenticator( |
41 P224EncryptedKeyExchange::kPeerTypeClient, shared_secret); | 41 P224EncryptedKeyExchange::kPeerTypeClient, shared_secret); |
42 } | 42 } |
43 | 43 |
44 // static | 44 // static |
45 V2Authenticator* V2Authenticator::CreateForHost( | 45 V2Authenticator* V2Authenticator::CreateForHost( |
46 const std::string& local_cert, | 46 const std::string& local_cert, |
47 crypto::RSAPrivateKey* local_private_key, | 47 const crypto::RSAPrivateKey& local_private_key, |
48 const std::string& shared_secret) { | 48 const std::string& shared_secret) { |
49 V2Authenticator* result = new V2Authenticator( | 49 V2Authenticator* result = new V2Authenticator( |
50 P224EncryptedKeyExchange::kPeerTypeServer, shared_secret); | 50 P224EncryptedKeyExchange::kPeerTypeServer, shared_secret); |
51 result->local_cert_ = local_cert; | 51 result->local_cert_ = local_cert; |
52 result->local_private_key_.reset(local_private_key->Copy()); | 52 result->local_private_key_.reset(local_private_key.Copy()); |
53 result->state_ = WAITING_MESSAGE; | 53 result->state_ = WAITING_MESSAGE; |
54 return result; | 54 return result; |
55 } | 55 } |
56 | 56 |
57 V2Authenticator::V2Authenticator( | 57 V2Authenticator::V2Authenticator( |
58 crypto::P224EncryptedKeyExchange::PeerType type, | 58 crypto::P224EncryptedKeyExchange::PeerType type, |
59 const std::string& shared_secret) | 59 const std::string& shared_secret) |
60 : certificate_sent_(false), | 60 : certificate_sent_(false), |
61 key_exchange_impl_(type, shared_secret), | 61 key_exchange_impl_(type, shared_secret), |
62 state_(MESSAGE_READY) { | 62 state_(MESSAGE_READY) { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 } else { | 176 } else { |
177 return SslHmacChannelAuthenticator::CreateForClient( | 177 return SslHmacChannelAuthenticator::CreateForClient( |
178 remote_cert_, auth_key_); | 178 remote_cert_, auth_key_); |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 bool V2Authenticator::is_host_side() const { | 182 bool V2Authenticator::is_host_side() const { |
183 return local_private_key_.get() != NULL; | 183 return local_private_key_.get() != NULL; |
184 } | 184 } |
185 | 185 |
186 V2HostAuthenticatorFactory::V2HostAuthenticatorFactory( | |
187 const std::string& local_cert, | |
188 const crypto::RSAPrivateKey* local_private_key, | |
189 const std::string& shared_secret) | |
190 : local_cert_(local_cert), | |
191 local_private_key_(local_private_key->Copy()), | |
192 shared_secret_(shared_secret) { | |
193 CHECK(local_private_key_.get()); | |
194 } | |
195 | |
196 V2HostAuthenticatorFactory::~V2HostAuthenticatorFactory() { | |
197 } | |
198 | |
199 Authenticator* V2HostAuthenticatorFactory::CreateAuthenticator( | |
200 const std::string& remote_jid, | |
201 const buzz::XmlElement* first_message) { | |
202 if (!V2Authenticator::IsEkeMessage(first_message)) | |
203 return NULL; | |
204 return V2Authenticator::CreateForHost( | |
205 local_cert_, local_private_key_.get(), shared_secret_); | |
206 } | |
207 | |
208 } // namespace protocol | 186 } // namespace protocol |
209 } // namespace remoting | 187 } // namespace remoting |
OLD | NEW |