OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/negotiating_host_authenticator.h" | 5 #include "remoting/protocol/negotiating_host_authenticator.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <sstream> | 8 #include <sstream> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 18 matching lines...) Expand all Loading... |
29 const std::string& remote_id, | 29 const std::string& remote_id, |
30 const std::string& local_cert, | 30 const std::string& local_cert, |
31 scoped_refptr<RsaKeyPair> key_pair) | 31 scoped_refptr<RsaKeyPair> key_pair) |
32 : NegotiatingAuthenticatorBase(WAITING_MESSAGE), | 32 : NegotiatingAuthenticatorBase(WAITING_MESSAGE), |
33 local_id_(local_id), | 33 local_id_(local_id), |
34 remote_id_(remote_id), | 34 remote_id_(remote_id), |
35 local_cert_(local_cert), | 35 local_cert_(local_cert), |
36 local_key_pair_(key_pair) {} | 36 local_key_pair_(key_pair) {} |
37 | 37 |
38 // static | 38 // static |
39 scoped_ptr<NegotiatingHostAuthenticator> | 39 std::unique_ptr<NegotiatingHostAuthenticator> |
40 NegotiatingHostAuthenticator::CreateWithSharedSecret( | 40 NegotiatingHostAuthenticator::CreateWithSharedSecret( |
41 const std::string& local_id, | 41 const std::string& local_id, |
42 const std::string& remote_id, | 42 const std::string& remote_id, |
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_hash, | 45 const std::string& shared_secret_hash, |
46 scoped_refptr<PairingRegistry> pairing_registry) { | 46 scoped_refptr<PairingRegistry> pairing_registry) { |
47 scoped_ptr<NegotiatingHostAuthenticator> result( | 47 std::unique_ptr<NegotiatingHostAuthenticator> result( |
48 new NegotiatingHostAuthenticator(local_id, remote_id, local_cert, | 48 new NegotiatingHostAuthenticator(local_id, remote_id, local_cert, |
49 key_pair)); | 49 key_pair)); |
50 result->shared_secret_hash_ = shared_secret_hash; | 50 result->shared_secret_hash_ = shared_secret_hash; |
51 result->pairing_registry_ = pairing_registry; | 51 result->pairing_registry_ = pairing_registry; |
52 result->AddMethod(Method::SHARED_SECRET_SPAKE2_CURVE25519); | 52 result->AddMethod(Method::SHARED_SECRET_SPAKE2_CURVE25519); |
53 result->AddMethod(Method::SHARED_SECRET_SPAKE2_P224); | 53 result->AddMethod(Method::SHARED_SECRET_SPAKE2_P224); |
54 if (pairing_registry.get()) { | 54 if (pairing_registry.get()) { |
55 result->AddMethod(Method::PAIRED_SPAKE2_CURVE25519); | 55 result->AddMethod(Method::PAIRED_SPAKE2_CURVE25519); |
56 result->AddMethod(Method::PAIRED_SPAKE2_P224); | 56 result->AddMethod(Method::PAIRED_SPAKE2_P224); |
57 } | 57 } |
58 return result; | 58 return result; |
59 } | 59 } |
60 | 60 |
61 // static | 61 // static |
62 scoped_ptr<NegotiatingHostAuthenticator> | 62 std::unique_ptr<NegotiatingHostAuthenticator> |
63 NegotiatingHostAuthenticator::CreateWithThirdPartyAuth( | 63 NegotiatingHostAuthenticator::CreateWithThirdPartyAuth( |
64 const std::string& local_id, | 64 const std::string& local_id, |
65 const std::string& remote_id, | 65 const std::string& remote_id, |
66 const std::string& local_cert, | 66 const std::string& local_cert, |
67 scoped_refptr<RsaKeyPair> key_pair, | 67 scoped_refptr<RsaKeyPair> key_pair, |
68 scoped_refptr<TokenValidatorFactory> token_validator_factory) { | 68 scoped_refptr<TokenValidatorFactory> token_validator_factory) { |
69 scoped_ptr<NegotiatingHostAuthenticator> result( | 69 std::unique_ptr<NegotiatingHostAuthenticator> result( |
70 new NegotiatingHostAuthenticator(local_id, remote_id, local_cert, | 70 new NegotiatingHostAuthenticator(local_id, remote_id, local_cert, |
71 key_pair)); | 71 key_pair)); |
72 result->token_validator_factory_ = token_validator_factory; | 72 result->token_validator_factory_ = token_validator_factory; |
73 result->AddMethod(Method::THIRD_PARTY_SPAKE2_CURVE25519); | 73 result->AddMethod(Method::THIRD_PARTY_SPAKE2_CURVE25519); |
74 result->AddMethod(Method::THIRD_PARTY_SPAKE2_P224); | 74 result->AddMethod(Method::THIRD_PARTY_SPAKE2_P224); |
75 return result; | 75 return result; |
76 } | 76 } |
77 | 77 |
78 NegotiatingHostAuthenticator::~NegotiatingHostAuthenticator() {} | 78 NegotiatingHostAuthenticator::~NegotiatingHostAuthenticator() {} |
79 | 79 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 base::Unretained(this), | 159 base::Unretained(this), |
160 base::Owned(new buzz::XmlElement(*message)), | 160 base::Owned(new buzz::XmlElement(*message)), |
161 resume_callback)); | 161 resume_callback)); |
162 return; | 162 return; |
163 } | 163 } |
164 | 164 |
165 // If the client is using the host's current method, just process the message. | 165 // If the client is using the host's current method, just process the message. |
166 ProcessMessageInternal(message, resume_callback); | 166 ProcessMessageInternal(message, resume_callback); |
167 } | 167 } |
168 | 168 |
169 scoped_ptr<buzz::XmlElement> NegotiatingHostAuthenticator::GetNextMessage() { | 169 std::unique_ptr<buzz::XmlElement> |
| 170 NegotiatingHostAuthenticator::GetNextMessage() { |
170 return GetNextMessageInternal(); | 171 return GetNextMessageInternal(); |
171 } | 172 } |
172 | 173 |
173 void NegotiatingHostAuthenticator::CreateAuthenticator( | 174 void NegotiatingHostAuthenticator::CreateAuthenticator( |
174 Authenticator::State preferred_initial_state, | 175 Authenticator::State preferred_initial_state, |
175 const base::Closure& resume_callback) { | 176 const base::Closure& resume_callback) { |
176 DCHECK(current_method_ != Method::INVALID); | 177 DCHECK(current_method_ != Method::INVALID); |
177 | 178 |
178 switch(current_method_) { | 179 switch(current_method_) { |
179 case Method::INVALID: | 180 case Method::INVALID: |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 current_authenticator_ = V2Authenticator::CreateForHost( | 235 current_authenticator_ = V2Authenticator::CreateForHost( |
235 local_cert_, local_key_pair_, shared_secret_hash_, | 236 local_cert_, local_key_pair_, shared_secret_hash_, |
236 preferred_initial_state); | 237 preferred_initial_state); |
237 resume_callback.Run(); | 238 resume_callback.Run(); |
238 break; | 239 break; |
239 } | 240 } |
240 } | 241 } |
241 | 242 |
242 } // namespace protocol | 243 } // namespace protocol |
243 } // namespace remoting | 244 } // namespace remoting |
OLD | NEW |