Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: remoting/protocol/negotiating_client_authenticator.cc

Issue 1800823002: Add Curve25519 version of pairing authenticators (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_client_authenticator.h" 5 #include "remoting/protocol/negotiating_client_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
29 : NegotiatingAuthenticatorBase(MESSAGE_READY), 29 : NegotiatingAuthenticatorBase(MESSAGE_READY),
30 local_id_(local_id), 30 local_id_(local_id),
31 remote_id_(remote_id), 31 remote_id_(remote_id),
32 config_(config), 32 config_(config),
33 weak_factory_(this) { 33 weak_factory_(this) {
34 if (!config_.fetch_third_party_token_callback.is_null()) { 34 if (!config_.fetch_third_party_token_callback.is_null()) {
35 AddMethod(Method::THIRD_PARTY_SPAKE2_CURVE25519); 35 AddMethod(Method::THIRD_PARTY_SPAKE2_CURVE25519);
36 AddMethod(Method::THIRD_PARTY_SPAKE2_P224); 36 AddMethod(Method::THIRD_PARTY_SPAKE2_P224);
37 } 37 }
38 38
39 AddMethod(Method::PAIRED_SPAKE2_CURVE25519);
39 AddMethod(Method::PAIRED_SPAKE2_P224); 40 AddMethod(Method::PAIRED_SPAKE2_P224);
40 41
41 AddMethod(Method::SHARED_SECRET_SPAKE2_CURVE25519); 42 AddMethod(Method::SHARED_SECRET_SPAKE2_CURVE25519);
42 AddMethod(Method::SHARED_SECRET_SPAKE2_P224); 43 AddMethod(Method::SHARED_SECRET_SPAKE2_P224);
43 44
44 AddMethod(Method::SHARED_SECRET_PLAIN_SPAKE2_P224); 45 AddMethod(Method::SHARED_SECRET_PLAIN_SPAKE2_P224);
45 } 46 }
46 47
47 NegotiatingClientAuthenticator::~NegotiatingClientAuthenticator() {} 48 NegotiatingClientAuthenticator::~NegotiatingClientAuthenticator() {}
48 49
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 return result; 118 return result;
118 } 119 }
119 return GetNextMessageInternal(); 120 return GetNextMessageInternal();
120 } 121 }
121 122
122 void NegotiatingClientAuthenticator::CreateAuthenticatorForCurrentMethod( 123 void NegotiatingClientAuthenticator::CreateAuthenticatorForCurrentMethod(
123 Authenticator::State preferred_initial_state, 124 Authenticator::State preferred_initial_state,
124 const base::Closure& resume_callback) { 125 const base::Closure& resume_callback) {
125 DCHECK_EQ(state(), PROCESSING_MESSAGE); 126 DCHECK_EQ(state(), PROCESSING_MESSAGE);
126 DCHECK(current_method_ != Method::INVALID); 127 DCHECK(current_method_ != Method::INVALID);
127 if (current_method_ == Method::THIRD_PARTY_SPAKE2_P224) { 128 switch (current_method_) {
128 current_authenticator_.reset(new ThirdPartyClientAuthenticator( 129 case Method::INVALID:
129 base::Bind(&V2Authenticator::CreateForClient), 130 NOTREACHED();
130 config_.fetch_third_party_token_callback)); 131 break;
131 resume_callback.Run(); 132
132 } else if (current_method_ == Method::THIRD_PARTY_SPAKE2_CURVE25519) { 133 case Method::THIRD_PARTY_SPAKE2_P224:
133 current_authenticator_.reset(new ThirdPartyClientAuthenticator( 134 current_authenticator_.reset(new ThirdPartyClientAuthenticator(
134 base::Bind(&Spake2Authenticator::CreateForClient, local_id_, 135 base::Bind(&V2Authenticator::CreateForClient),
135 remote_id_), 136 config_.fetch_third_party_token_callback));
136 config_.fetch_third_party_token_callback)); 137 resume_callback.Run();
137 resume_callback.Run(); 138 break;
138 } else if (current_method_ == Method::PAIRED_SPAKE2_P224) { 139
139 PairingClientAuthenticator* pairing_authenticator = 140 case Method::THIRD_PARTY_SPAKE2_CURVE25519:
140 new PairingClientAuthenticator( 141 current_authenticator_.reset(new ThirdPartyClientAuthenticator(
141 config_, base::Bind(&V2Authenticator::CreateForClient)); 142 base::Bind(&Spake2Authenticator::CreateForClient, local_id_,
142 current_authenticator_ = make_scoped_ptr(pairing_authenticator); 143 remote_id_),
143 pairing_authenticator->Start(preferred_initial_state, resume_callback); 144 config_.fetch_third_party_token_callback));
144 } else { 145 resume_callback.Run();
145 DCHECK(current_method_ == Method::SHARED_SECRET_PLAIN_SPAKE2_P224 || 146 break;
146 current_method_ == Method::SHARED_SECRET_SPAKE2_P224 || 147
147 current_method_ == Method::SHARED_SECRET_SPAKE2_CURVE25519); 148 case Method::PAIRED_SPAKE2_P224: {
148 config_.fetch_secret_callback.Run( 149 PairingClientAuthenticator* pairing_authenticator =
149 false, 150 new PairingClientAuthenticator(
150 base::Bind( 151 config_, base::Bind(&V2Authenticator::CreateForClient));
151 &NegotiatingClientAuthenticator::CreateSharedSecretAuthenticator, 152 current_authenticator_ = make_scoped_ptr(pairing_authenticator);
152 weak_factory_.GetWeakPtr(), preferred_initial_state, 153 pairing_authenticator->Start(preferred_initial_state, resume_callback);
153 resume_callback)); 154 break;
155 }
156
157 case Method::PAIRED_SPAKE2_CURVE25519: {
158 PairingClientAuthenticator* pairing_authenticator =
159 new PairingClientAuthenticator(
160 config_, base::Bind(&Spake2Authenticator::CreateForClient,
161 local_id_, remote_id_));
162 current_authenticator_ = make_scoped_ptr(pairing_authenticator);
163 pairing_authenticator->Start(preferred_initial_state, resume_callback);
164 break;
165 }
166
167 case Method::SHARED_SECRET_PLAIN_SPAKE2_P224:
168 case Method::SHARED_SECRET_SPAKE2_P224:
169 case Method::SHARED_SECRET_SPAKE2_CURVE25519:
170 config_.fetch_secret_callback.Run(
171 false,
172 base::Bind(
173 &NegotiatingClientAuthenticator::CreateSharedSecretAuthenticator,
174 weak_factory_.GetWeakPtr(), preferred_initial_state,
175 resume_callback));
176 break;
154 } 177 }
155 } 178 }
156 179
157 void NegotiatingClientAuthenticator::CreatePreferredAuthenticator() { 180 void NegotiatingClientAuthenticator::CreatePreferredAuthenticator() {
158 if (is_paired() && 181 if (is_paired() &&
159 std::find(methods_.begin(), methods_.end(), Method::PAIRED_SPAKE2_P224) != 182 std::find(methods_.begin(), methods_.end(), Method::PAIRED_SPAKE2_P224) !=
160 methods_.end()) { 183 methods_.end()) {
161 PairingClientAuthenticator* pairing_authenticator = 184 PairingClientAuthenticator* pairing_authenticator =
162 new PairingClientAuthenticator( 185 new PairingClientAuthenticator(
163 config_, base::Bind(&V2Authenticator::CreateForClient)); 186 config_, base::Bind(&V2Authenticator::CreateForClient));
(...skipping 21 matching lines...) Expand all
185 } 208 }
186 resume_callback.Run(); 209 resume_callback.Run();
187 } 210 }
188 211
189 bool NegotiatingClientAuthenticator::is_paired() { 212 bool NegotiatingClientAuthenticator::is_paired() {
190 return !config_.pairing_client_id.empty() && !config_.pairing_secret.empty(); 213 return !config_.pairing_client_id.empty() && !config_.pairing_secret.empty();
191 } 214 }
192 215
193 } // namespace protocol 216 } // namespace protocol
194 } // namespace remoting 217 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/negotiating_authenticator_unittest.cc ('k') | remoting/protocol/negotiating_host_authenticator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698