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_authenticator_base.h" | 5 #include "remoting/protocol/pairing_authenticator_base.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "remoting/base/constants.h" | 10 #include "remoting/base/constants.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 // Pass the message to the underlying authenticator for processing, but | 67 // Pass the message to the underlying authenticator for processing, but |
68 // check for a failed SPAKE exchange if we're using the paired secret. In | 68 // check for a failed SPAKE exchange if we're using the paired secret. In |
69 // this case the pairing protocol can continue by communicating the error | 69 // this case the pairing protocol can continue by communicating the error |
70 // to the peer and retrying with the PIN. | 70 // to the peer and retrying with the PIN. |
71 spake2_authenticator_->ProcessMessage( | 71 spake2_authenticator_->ProcessMessage( |
72 message, | 72 message, |
73 base::Bind(&PairingAuthenticatorBase::CheckForFailedSpakeExchange, | 73 base::Bind(&PairingAuthenticatorBase::CheckForFailedSpakeExchange, |
74 weak_factory_.GetWeakPtr(), resume_callback)); | 74 weak_factory_.GetWeakPtr(), resume_callback)); |
75 } | 75 } |
76 | 76 |
77 scoped_ptr<buzz::XmlElement> PairingAuthenticatorBase::GetNextMessage() { | 77 std::unique_ptr<buzz::XmlElement> PairingAuthenticatorBase::GetNextMessage() { |
78 DCHECK_EQ(state(), MESSAGE_READY); | 78 DCHECK_EQ(state(), MESSAGE_READY); |
79 scoped_ptr<buzz::XmlElement> result = spake2_authenticator_->GetNextMessage(); | 79 std::unique_ptr<buzz::XmlElement> result = |
| 80 spake2_authenticator_->GetNextMessage(); |
80 MaybeAddErrorMessage(result.get()); | 81 MaybeAddErrorMessage(result.get()); |
81 return result; | 82 return result; |
82 } | 83 } |
83 | 84 |
84 const std::string& PairingAuthenticatorBase::GetAuthKey() const { | 85 const std::string& PairingAuthenticatorBase::GetAuthKey() const { |
85 return spake2_authenticator_->GetAuthKey(); | 86 return spake2_authenticator_->GetAuthKey(); |
86 } | 87 } |
87 | 88 |
88 scoped_ptr<ChannelAuthenticator> | 89 std::unique_ptr<ChannelAuthenticator> |
89 PairingAuthenticatorBase::CreateChannelAuthenticator() const { | 90 PairingAuthenticatorBase::CreateChannelAuthenticator() const { |
90 return spake2_authenticator_->CreateChannelAuthenticator(); | 91 return spake2_authenticator_->CreateChannelAuthenticator(); |
91 } | 92 } |
92 | 93 |
93 void PairingAuthenticatorBase::MaybeAddErrorMessage(buzz::XmlElement* message) { | 94 void PairingAuthenticatorBase::MaybeAddErrorMessage(buzz::XmlElement* message) { |
94 if (!error_message_.empty()) { | 95 if (!error_message_.empty()) { |
95 buzz::XmlElement* pairing_failed_tag = | 96 buzz::XmlElement* pairing_failed_tag = |
96 new buzz::XmlElement(kPairingFailedTag); | 97 new buzz::XmlElement(kPairingFailedTag); |
97 pairing_failed_tag->AddAttr(kPairingErrorAttribute, error_message_); | 98 pairing_failed_tag->AddAttr(kPairingErrorAttribute, error_message_); |
98 message->AddElement(pairing_failed_tag); | 99 message->AddElement(pairing_failed_tag); |
(...skipping 25 matching lines...) Expand all Loading... |
124 spake2_authenticator_.reset(); | 125 spake2_authenticator_.reset(); |
125 CreateSpakeAuthenticatorWithPin(MESSAGE_READY, resume_callback); | 126 CreateSpakeAuthenticatorWithPin(MESSAGE_READY, resume_callback); |
126 return; | 127 return; |
127 } | 128 } |
128 | 129 |
129 resume_callback.Run(); | 130 resume_callback.Run(); |
130 } | 131 } |
131 | 132 |
132 } // namespace protocol | 133 } // namespace protocol |
133 } // namespace remoting | 134 } // namespace remoting |
OLD | NEW |