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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/login/quick_unlock/pin_authentication.h"
6
7 #include "base/time/time.h"
8 #include "chrome/browser/chromeos/login/quick_unlock/pin_storage.h"
9 #include "chromeos/login/auth/key.h"
10
11 namespace chromeos {
12
13 namespace {
14 // 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.
15 const int kMaximumUnlockAttempts = 3;
16 base::TimeDelta kStrongAuthTimeout = base::TimeDelta::FromHours(24);
17 } // namespace
18
19 bool IsPinAvailable(PinStorage* storage) {
20 return storage->HasPin() &&
21 storage->UnlockAttemptCount() < kMaximumUnlockAttempts &&
22 storage->TimeSinceLastStrongAuth() < kStrongAuthTimeout;
23 }
24
25 bool IsValidPin(PinStorage* storage, const std::string& raw_pin) {
26 if (!IsPinAvailable(storage))
27 return false;
28
29 storage->AddUnlockAttempt();
30
31 Key key(raw_pin);
32 key.Transform(Key::KEY_TYPE_SALTED_PBKDF2_AES256_1234, storage->pin_salt());
33 return key.GetSecret() == storage->pin_secret();
34 }
stevenjb 2016/05/16 16:33:34 These both look like they should be PinStorage mem
jdufault 2016/05/16 22:08:47 Done.
35
36 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698