Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 | |
| OLD | NEW |