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/pairing_client_authenticator.h" | 5 #include "remoting/protocol/pairing_client_authenticator.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.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/protocol/auth_util.h" |
11 #include "remoting/protocol/authentication_method.h" | |
12 #include "remoting/protocol/channel_authenticator.h" | 11 #include "remoting/protocol/channel_authenticator.h" |
13 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" | 12 #include "third_party/webrtc/libjingle/xmllite/xmlelement.h" |
14 | 13 |
15 namespace remoting { | 14 namespace remoting { |
16 namespace protocol { | 15 namespace protocol { |
17 | 16 |
18 PairingClientAuthenticator::PairingClientAuthenticator( | 17 PairingClientAuthenticator::PairingClientAuthenticator( |
19 const std::string& client_id, | 18 const std::string& client_id, |
20 const std::string& paired_secret, | 19 const std::string& paired_secret, |
21 const CreateBaseAuthenticatorCallback& create_base_authenticator_callback, | 20 const CreateBaseAuthenticatorCallback& create_base_authenticator_callback, |
22 const FetchSecretCallback& fetch_pin_callback, | 21 const FetchSecretCallback& fetch_pin_callback, |
23 const std::string& authentication_tag) | 22 const std::string& host_id) |
24 : client_id_(client_id), | 23 : client_id_(client_id), |
25 paired_secret_(paired_secret), | 24 paired_secret_(paired_secret), |
26 create_base_authenticator_callback_(create_base_authenticator_callback), | 25 create_base_authenticator_callback_(create_base_authenticator_callback), |
27 fetch_pin_callback_(fetch_pin_callback), | 26 fetch_pin_callback_(fetch_pin_callback), |
28 authentication_tag_(authentication_tag), | 27 host_id_(host_id), |
29 weak_factory_(this) { | 28 weak_factory_(this) { |
30 spake2_authenticator_ = | 29 spake2_authenticator_ = |
31 create_base_authenticator_callback_.Run(paired_secret_, MESSAGE_READY); | 30 create_base_authenticator_callback_.Run(paired_secret_, MESSAGE_READY); |
32 using_paired_secret_ = true; | 31 using_paired_secret_ = true; |
33 } | 32 } |
34 | 33 |
35 PairingClientAuthenticator::~PairingClientAuthenticator() {} | 34 PairingClientAuthenticator::~PairingClientAuthenticator() {} |
36 | 35 |
37 Authenticator::State PairingClientAuthenticator::state() const { | 36 Authenticator::State PairingClientAuthenticator::state() const { |
38 if (waiting_for_pin_) | 37 if (waiting_for_pin_) |
(...skipping 26 matching lines...) Expand all Loading... |
65 } | 64 } |
66 | 65 |
67 void PairingClientAuthenticator::OnPinFetched( | 66 void PairingClientAuthenticator::OnPinFetched( |
68 State initial_state, | 67 State initial_state, |
69 const base::Closure& resume_callback, | 68 const base::Closure& resume_callback, |
70 const std::string& pin) { | 69 const std::string& pin) { |
71 DCHECK(waiting_for_pin_); | 70 DCHECK(waiting_for_pin_); |
72 DCHECK(!spake2_authenticator_); | 71 DCHECK(!spake2_authenticator_); |
73 waiting_for_pin_ = false; | 72 waiting_for_pin_ = false; |
74 spake2_authenticator_ = create_base_authenticator_callback_.Run( | 73 spake2_authenticator_ = create_base_authenticator_callback_.Run( |
75 ApplySharedSecretHashFunction(HashFunction::HMAC_SHA256, | 74 GetSharedSecretHash(host_id_, pin), initial_state); |
76 authentication_tag_, pin), | |
77 initial_state); | |
78 resume_callback.Run(); | 75 resume_callback.Run(); |
79 } | 76 } |
80 | 77 |
81 } // namespace protocol | 78 } // namespace protocol |
82 } // namespace remoting | 79 } // namespace remoting |
OLD | NEW |