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

Unified Diff: remoting/protocol/negotiating_host_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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/negotiating_host_authenticator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/negotiating_host_authenticator.cc
diff --git a/remoting/protocol/negotiating_host_authenticator.cc b/remoting/protocol/negotiating_host_authenticator.cc
index 59b200d4ee7a1cf3664333149e81f44c144dc7fd..c0b9cbd6ef95192814dfa2fb943334a4f76af0ad 100644
--- a/remoting/protocol/negotiating_host_authenticator.cc
+++ b/remoting/protocol/negotiating_host_authenticator.cc
@@ -36,22 +36,23 @@ NegotiatingHostAuthenticator::NegotiatingHostAuthenticator(
local_key_pair_(key_pair) {}
// static
-scoped_ptr<Authenticator> NegotiatingHostAuthenticator::CreateForIt2Me(
- const std::string& local_id,
- const std::string& remote_id,
- const std::string& local_cert,
- scoped_refptr<RsaKeyPair> key_pair,
- const std::string& access_code) {
+scoped_ptr<NegotiatingHostAuthenticator>
+NegotiatingHostAuthenticator::CreateForIt2Me(const std::string& local_id,
+ const std::string& remote_id,
+ const std::string& local_cert,
+ scoped_refptr<RsaKeyPair> key_pair,
+ const std::string& access_code) {
scoped_ptr<NegotiatingHostAuthenticator> result(
new NegotiatingHostAuthenticator(local_id, remote_id, local_cert,
key_pair));
result->shared_secret_hash_ = access_code;
result->AddMethod(Method::SHARED_SECRET_PLAIN_SPAKE2_P224);
- return std::move(result);
+ return result;
}
// static
-scoped_ptr<Authenticator> NegotiatingHostAuthenticator::CreateWithPin(
+scoped_ptr<NegotiatingHostAuthenticator>
+NegotiatingHostAuthenticator::CreateWithPin(
const std::string& local_id,
const std::string& remote_id,
const std::string& local_cert,
@@ -66,13 +67,14 @@ scoped_ptr<Authenticator> NegotiatingHostAuthenticator::CreateWithPin(
result->AddMethod(Method::SHARED_SECRET_SPAKE2_CURVE25519);
result->AddMethod(Method::SHARED_SECRET_SPAKE2_P224);
if (pairing_registry.get()) {
+ result->AddMethod(Method::PAIRED_SPAKE2_CURVE25519);
result->AddMethod(Method::PAIRED_SPAKE2_P224);
}
- return std::move(result);
+ return result;
}
// static
-scoped_ptr<Authenticator>
+scoped_ptr<NegotiatingHostAuthenticator>
NegotiatingHostAuthenticator::CreateWithThirdPartyAuth(
const std::string& local_id,
const std::string& remote_id,
@@ -85,7 +87,7 @@ NegotiatingHostAuthenticator::CreateWithThirdPartyAuth(
result->token_validator_factory_ = token_validator_factory;
result->AddMethod(Method::THIRD_PARTY_SPAKE2_CURVE25519);
result->AddMethod(Method::THIRD_PARTY_SPAKE2_P224);
- return std::move(result);
+ return result;
}
NegotiatingHostAuthenticator::~NegotiatingHostAuthenticator() {}
@@ -188,38 +190,69 @@ void NegotiatingHostAuthenticator::CreateAuthenticator(
const base::Closure& resume_callback) {
DCHECK(current_method_ != Method::INVALID);
- if (current_method_ == Method::THIRD_PARTY_SPAKE2_P224) {
- current_authenticator_.reset(new ThirdPartyHostAuthenticator(
- base::Bind(&V2Authenticator::CreateForHost, local_cert_,
- local_key_pair_),
- token_validator_factory_->CreateTokenValidator(local_id_, remote_id_)));
- } else if (current_method_ == Method::THIRD_PARTY_SPAKE2_CURVE25519) {
- current_authenticator_.reset(new ThirdPartyHostAuthenticator(
- base::Bind(&Spake2Authenticator::CreateForHost, local_id_, remote_id_,
- local_cert_, local_key_pair_),
- token_validator_factory_->CreateTokenValidator(local_id_, remote_id_)));
- } else if (current_method_ == Method::PAIRED_SPAKE2_P224) {
- PairingHostAuthenticator* pairing_authenticator =
- new PairingHostAuthenticator(pairing_registry_,
- base::Bind(&V2Authenticator::CreateForHost,
- local_cert_, local_key_pair_),
- shared_secret_hash_);
- current_authenticator_.reset(pairing_authenticator);
- pairing_authenticator->Initialize(client_id_, preferred_initial_state,
- resume_callback);
- return;
- } else if (current_method_ == Method::SHARED_SECRET_SPAKE2_CURVE25519) {
- current_authenticator_ = Spake2Authenticator::CreateForHost(
- local_id_, remote_id_, local_cert_, local_key_pair_,
- shared_secret_hash_, preferred_initial_state);
- } else {
- DCHECK(current_method_ == Method::SHARED_SECRET_PLAIN_SPAKE2_P224 ||
- current_method_ == Method::SHARED_SECRET_SPAKE2_P224);
- current_authenticator_ = V2Authenticator::CreateForHost(
- local_cert_, local_key_pair_, shared_secret_hash_,
- preferred_initial_state);
+ switch(current_method_) {
+ case Method::INVALID:
+ NOTREACHED();
+ break;
+
+ case Method::THIRD_PARTY_SPAKE2_P224:
+ current_authenticator_.reset(new ThirdPartyHostAuthenticator(
+ base::Bind(&V2Authenticator::CreateForHost, local_cert_,
+ local_key_pair_),
+ token_validator_factory_->CreateTokenValidator(local_id_,
+ remote_id_)));
+ resume_callback.Run();
+ break;
+
+ case Method::THIRD_PARTY_SPAKE2_CURVE25519:
+ current_authenticator_.reset(new ThirdPartyHostAuthenticator(
+ base::Bind(&Spake2Authenticator::CreateForHost, local_id_, remote_id_,
+ local_cert_, local_key_pair_),
+ token_validator_factory_->CreateTokenValidator(local_id_,
+ remote_id_)));
+ resume_callback.Run();
+ break;
+
+ case Method::PAIRED_SPAKE2_P224: {
+ PairingHostAuthenticator* pairing_authenticator =
+ new PairingHostAuthenticator(
+ pairing_registry_, base::Bind(&V2Authenticator::CreateForHost,
+ local_cert_, local_key_pair_),
+ shared_secret_hash_);
+ current_authenticator_.reset(pairing_authenticator);
+ pairing_authenticator->Initialize(client_id_, preferred_initial_state,
+ resume_callback);
+ break;
+ }
+
+ case Method::PAIRED_SPAKE2_CURVE25519: {
+ PairingHostAuthenticator* pairing_authenticator =
+ new PairingHostAuthenticator(
+ pairing_registry_,
+ base::Bind(&Spake2Authenticator::CreateForHost, local_id_,
+ remote_id_, local_cert_, local_key_pair_),
+ shared_secret_hash_);
+ current_authenticator_.reset(pairing_authenticator);
+ pairing_authenticator->Initialize(client_id_, preferred_initial_state,
+ resume_callback);
+ break;
+ }
+
+ case Method::SHARED_SECRET_SPAKE2_CURVE25519:
+ current_authenticator_ = Spake2Authenticator::CreateForHost(
+ local_id_, remote_id_, local_cert_, local_key_pair_,
+ shared_secret_hash_, preferred_initial_state);
+ resume_callback.Run();
+ break;
+
+ case Method::SHARED_SECRET_PLAIN_SPAKE2_P224:
+ case Method::SHARED_SECRET_SPAKE2_P224:
+ current_authenticator_ = V2Authenticator::CreateForHost(
+ local_cert_, local_key_pair_, shared_secret_hash_,
+ preferred_initial_state);
+ resume_callback.Run();
+ break;
}
- resume_callback.Run();
}
} // namespace protocol
« no previous file with comments | « remoting/protocol/negotiating_host_authenticator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698