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 19 matching lines...) Expand all Loading... |
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 scoped_ptr<NegotiatingHostAuthenticator> |
40 NegotiatingHostAuthenticator::CreateForIt2Me(const std::string& local_id, | 40 NegotiatingHostAuthenticator::CreateWithSharedSecret( |
41 const std::string& remote_id, | |
42 const std::string& local_cert, | |
43 scoped_refptr<RsaKeyPair> key_pair, | |
44 const std::string& access_code) { | |
45 scoped_ptr<NegotiatingHostAuthenticator> result( | |
46 new NegotiatingHostAuthenticator(local_id, remote_id, local_cert, | |
47 key_pair)); | |
48 result->shared_secret_hash_ = access_code; | |
49 result->AddMethod(Method::SHARED_SECRET_PLAIN_SPAKE2_P224); | |
50 return result; | |
51 } | |
52 | |
53 // static | |
54 scoped_ptr<NegotiatingHostAuthenticator> | |
55 NegotiatingHostAuthenticator::CreateWithPin( | |
56 const std::string& local_id, | 41 const std::string& local_id, |
57 const std::string& remote_id, | 42 const std::string& remote_id, |
58 const std::string& local_cert, | 43 const std::string& local_cert, |
59 scoped_refptr<RsaKeyPair> key_pair, | 44 scoped_refptr<RsaKeyPair> key_pair, |
60 const std::string& pin_hash, | 45 const std::string& shared_secret_hash, |
61 scoped_refptr<PairingRegistry> pairing_registry) { | 46 scoped_refptr<PairingRegistry> pairing_registry) { |
62 scoped_ptr<NegotiatingHostAuthenticator> result( | 47 scoped_ptr<NegotiatingHostAuthenticator> result( |
63 new NegotiatingHostAuthenticator(local_id, remote_id, local_cert, | 48 new NegotiatingHostAuthenticator(local_id, remote_id, local_cert, |
64 key_pair)); | 49 key_pair)); |
65 result->shared_secret_hash_ = pin_hash; | 50 result->shared_secret_hash_ = shared_secret_hash; |
66 result->pairing_registry_ = pairing_registry; | 51 result->pairing_registry_ = pairing_registry; |
67 result->AddMethod(Method::SHARED_SECRET_SPAKE2_CURVE25519); | 52 result->AddMethod(Method::SHARED_SECRET_SPAKE2_CURVE25519); |
68 result->AddMethod(Method::SHARED_SECRET_SPAKE2_P224); | 53 result->AddMethod(Method::SHARED_SECRET_SPAKE2_P224); |
69 if (pairing_registry.get()) { | 54 if (pairing_registry.get()) { |
70 result->AddMethod(Method::PAIRED_SPAKE2_CURVE25519); | 55 result->AddMethod(Method::PAIRED_SPAKE2_CURVE25519); |
71 result->AddMethod(Method::PAIRED_SPAKE2_P224); | 56 result->AddMethod(Method::PAIRED_SPAKE2_P224); |
72 } | 57 } |
73 return result; | 58 return result; |
74 } | 59 } |
75 | 60 |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 break; | 223 break; |
239 } | 224 } |
240 | 225 |
241 case Method::SHARED_SECRET_SPAKE2_CURVE25519: | 226 case Method::SHARED_SECRET_SPAKE2_CURVE25519: |
242 current_authenticator_ = Spake2Authenticator::CreateForHost( | 227 current_authenticator_ = Spake2Authenticator::CreateForHost( |
243 local_id_, remote_id_, local_cert_, local_key_pair_, | 228 local_id_, remote_id_, local_cert_, local_key_pair_, |
244 shared_secret_hash_, preferred_initial_state); | 229 shared_secret_hash_, preferred_initial_state); |
245 resume_callback.Run(); | 230 resume_callback.Run(); |
246 break; | 231 break; |
247 | 232 |
248 case Method::SHARED_SECRET_PLAIN_SPAKE2_P224: | |
249 case Method::SHARED_SECRET_SPAKE2_P224: | 233 case Method::SHARED_SECRET_SPAKE2_P224: |
250 current_authenticator_ = V2Authenticator::CreateForHost( | 234 current_authenticator_ = V2Authenticator::CreateForHost( |
251 local_cert_, local_key_pair_, shared_secret_hash_, | 235 local_cert_, local_key_pair_, shared_secret_hash_, |
252 preferred_initial_state); | 236 preferred_initial_state); |
253 resume_callback.Run(); | 237 resume_callback.Run(); |
254 break; | 238 break; |
255 } | 239 } |
256 } | 240 } |
257 | 241 |
258 } // namespace protocol | 242 } // namespace protocol |
259 } // namespace remoting | 243 } // namespace remoting |
OLD | NEW |