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

Side by Side Diff: chrome/browser/chromeos/login/quick_unlock/pin_storage.cc

Issue 2150763002: Enable PIN configuration settings. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Fix tests Created 4 years, 5 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "chrome/browser/chromeos/login/quick_unlock/pin_storage.h" 5 #include "chrome/browser/chromeos/login/quick_unlock/pin_storage.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "chrome/browser/chromeos/login/quick_unlock/quick_unlock_utils.h"
9 #include "chrome/common/pref_names.h" 10 #include "chrome/common/pref_names.h"
10 #include "chromeos/login/auth/key.h" 11 #include "chromeos/login/auth/key.h"
11 #include "components/pref_registry/pref_registry_syncable.h" 12 #include "components/pref_registry/pref_registry_syncable.h"
12 #include "components/prefs/pref_service.h" 13 #include "components/prefs/pref_service.h"
13 #include "crypto/random.h" 14 #include "crypto/random.h"
14 15
15 namespace chromeos { 16 namespace chromeos {
16 17
17 namespace { 18 namespace {
18 19
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 98
98 std::string PinStorage::PinSalt() const { 99 std::string PinStorage::PinSalt() const {
99 return pref_service_->GetString(prefs::kQuickUnlockPinSalt); 100 return pref_service_->GetString(prefs::kQuickUnlockPinSalt);
100 } 101 }
101 102
102 std::string PinStorage::PinSecret() const { 103 std::string PinStorage::PinSecret() const {
103 return pref_service_->GetString(prefs::kQuickUnlockPinSecret); 104 return pref_service_->GetString(prefs::kQuickUnlockPinSecret);
104 } 105 }
105 106
106 bool PinStorage::IsPinAuthenticationAvailable() const { 107 bool PinStorage::IsPinAuthenticationAvailable() const {
107 return IsPinSet() && unlock_attempt_count() < kMaximumUnlockAttempts && 108 const bool exceeded_unlock_attempts =
108 HasStrongAuth() && TimeSinceLastStrongAuth() < kStrongAuthTimeout; 109 unlock_attempt_count() >= kMaximumUnlockAttempts;
110 const bool has_strong_auth =
111 HasStrongAuth() && TimeSinceLastStrongAuth() < kStrongAuthTimeout;
112
113 return IsQuickUnlockEnabled() && IsPinSet() && has_strong_auth &&
114 !exceeded_unlock_attempts;
109 } 115 }
110 116
111 bool PinStorage::TryAuthenticatePin(const std::string& pin) { 117 bool PinStorage::TryAuthenticatePin(const std::string& pin) {
112 if (!IsPinAuthenticationAvailable()) 118 if (!IsPinAuthenticationAvailable())
113 return false; 119 return false;
114 120
115 AddUnlockAttempt(); 121 AddUnlockAttempt();
116 return ComputeSecret(pin, PinSalt()) == PinSecret(); 122 return ComputeSecret(pin, PinSalt()) == PinSecret();
117 } 123 }
118 124
119 } // namespace chromeos 125 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698