diff options
author | tengs <tengs@chromium.org> | 2015-06-29 11:47:15 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-29 18:48:54 +0000 |
commit | 7555b0b6c4fdc89292cfb504a3f7802221e6d45d (patch) | |
tree | 20170415d6d1d0f9095f7dd6b0696d9e3fa3c14d /components/proximity_auth/cryptauth/cryptauth_enrollment_manager.cc | |
parent | 839029f5f80f44b60d7402acafa87d6a272fa498 (diff) | |
download | chromium_src-7555b0b6c4fdc89292cfb504a3f7802221e6d45d.zip chromium_src-7555b0b6c4fdc89292cfb504a3f7802221e6d45d.tar.gz chromium_src-7555b0b6c4fdc89292cfb504a3f7802221e6d45d.tar.bz2 |
Fix CryptAuth enrollment logic.
The current enrollment flow is not quite right, so I needed to make some changes:
- Use the user's persistent key-pair to sign the inner message.
- Change the endpoint URLs
- Fill GcmDeviceInfo proto with fields that are validated by the server, such as the access token.
BUG=420315
TEST=manual and unit tests
Review URL: https://codereview.chromium.org/1151023005
Cr-Commit-Position: refs/heads/master@{#336602}
Diffstat (limited to 'components/proximity_auth/cryptauth/cryptauth_enrollment_manager.cc')
-rw-r--r-- | components/proximity_auth/cryptauth/cryptauth_enrollment_manager.cc | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/components/proximity_auth/cryptauth/cryptauth_enrollment_manager.cc b/components/proximity_auth/cryptauth/cryptauth_enrollment_manager.cc index e3179ac..2b87229 100644 --- a/components/proximity_auth/cryptauth/cryptauth_enrollment_manager.cc +++ b/components/proximity_auth/cryptauth/cryptauth_enrollment_manager.cc @@ -6,8 +6,13 @@ #include "base/prefs/pref_registry_simple.h" #include "base/prefs/pref_service.h" +#include "base/time/clock.h" +#include "base/time/time.h" +#include "components/proximity_auth/cryptauth/cryptauth_enroller.h" #include "components/proximity_auth/cryptauth/pref_names.h" +#include "components/proximity_auth/cryptauth/secure_message_delegate.h" #include "components/proximity_auth/cryptauth/sync_scheduler_impl.h" +#include "components/proximity_auth/logging/logging.h" namespace proximity_auth { @@ -33,11 +38,16 @@ const double kEnrollmentMaxJitterRatio = 0.2; CryptAuthEnrollmentManager::CryptAuthEnrollmentManager( scoped_ptr<base::Clock> clock, scoped_ptr<CryptAuthEnrollerFactory> enroller_factory, - const cryptauth::GcmDeviceInfo& device_info) + const std::string& user_public_key, + const std::string& user_private_key, + const cryptauth::GcmDeviceInfo& device_info, + PrefService* pref_service) : clock_(clock.Pass()), enroller_factory_(enroller_factory.Pass()), + user_public_key_(user_public_key), + user_private_key_(user_private_key), device_info_(device_info), - pref_service_(nullptr), + pref_service_(pref_service), weak_ptr_factory_(this) { } @@ -54,11 +64,9 @@ void CryptAuthEnrollmentManager::RegisterPrefs(PrefRegistrySimple* registry) { cryptauth::INVOCATION_REASON_UNKNOWN); } -void CryptAuthEnrollmentManager::Start(PrefService* pref_service) { - pref_service_ = pref_service; - +void CryptAuthEnrollmentManager::Start() { bool is_recovering_from_failure = - pref_service->GetBoolean( + pref_service_->GetBoolean( prefs::kCryptAuthEnrollmentIsRecoveringFromFailure) || !IsEnrollmentValid(); @@ -171,8 +179,9 @@ void CryptAuthEnrollmentManager::OnSyncRequested( invocation_reason = cryptauth::INVOCATION_REASON_FAILURE_RECOVERY; } + PA_LOG(INFO) << "Making enrollment with reason: " << invocation_reason; cryptauth_enroller_->Enroll( - device_info_, invocation_reason, + user_public_key_, user_private_key_, device_info_, invocation_reason, base::Bind(&CryptAuthEnrollmentManager::OnEnrollmentFinished, weak_ptr_factory_.GetWeakPtr())); } |