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

Unified Diff: chrome/browser/chromeos/login/quick_unlock/pin_authentication.cc

Issue 1977923002: Implement pin storage backend. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Created 4 years, 7 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
Index: chrome/browser/chromeos/login/quick_unlock/pin_authentication.cc
diff --git a/chrome/browser/chromeos/login/quick_unlock/pin_authentication.cc b/chrome/browser/chromeos/login/quick_unlock/pin_authentication.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e51adbe7ec8e7fb463a2cb752099aa08ba1c7735
--- /dev/null
+++ b/chrome/browser/chromeos/login/quick_unlock/pin_authentication.cc
@@ -0,0 +1,36 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/login/quick_unlock/pin_authentication.h"
+
+#include "base/time/time.h"
+#include "chrome/browser/chromeos/login/quick_unlock/pin_storage.h"
+#include "chromeos/login/auth/key.h"
+
+namespace chromeos {
+
+namespace {
+// TODO(jdufault): Pull these values in from policy.
achuithb 2016/05/13 23:34:56 Reference a bug
jdufault 2016/05/16 22:08:47 Done.
+const int kMaximumUnlockAttempts = 3;
+base::TimeDelta kStrongAuthTimeout = base::TimeDelta::FromHours(24);
+} // namespace
+
+bool IsPinAvailable(PinStorage* storage) {
+ return storage->HasPin() &&
+ storage->UnlockAttemptCount() < kMaximumUnlockAttempts &&
+ storage->TimeSinceLastStrongAuth() < kStrongAuthTimeout;
+}
+
+bool IsValidPin(PinStorage* storage, const std::string& raw_pin) {
+ if (!IsPinAvailable(storage))
+ return false;
+
+ storage->AddUnlockAttempt();
+
+ Key key(raw_pin);
+ key.Transform(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, storage->pin_salt());
+ return key.GetSecret() == storage->pin_secret();
+}
stevenjb 2016/05/16 16:33:34 These both look like they should be PinStorage mem
jdufault 2016/05/16 22:08:47 Done.
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698