Merge "Don't clear kesytore after 5 auth failures."
This commit is contained in:
commit
44f4d85dcf
2 changed files with 4 additions and 25 deletions
|
@ -37,7 +37,7 @@ namespace keystore {
|
|||
|
||||
UserState::UserState(uid_t userId)
|
||||
: mMasterKeyEntry(".masterkey", "user_" + std::to_string(userId), userId, /* masterkey */ true),
|
||||
mUserId(userId), mState(STATE_UNINITIALIZED), mRetry(MAX_RETRY) {}
|
||||
mUserId(userId), mState(STATE_UNINITIALIZED) {}
|
||||
|
||||
bool UserState::operator<(const UserState& rhs) const {
|
||||
return getUserId() < rhs.getUserId();
|
||||
|
@ -69,9 +69,6 @@ bool UserState::initialize() {
|
|||
|
||||
void UserState::setState(State state) {
|
||||
mState = state;
|
||||
if (mState == STATE_NO_ERROR || mState == STATE_UNINITIALIZED) {
|
||||
mRetry = MAX_RETRY;
|
||||
}
|
||||
}
|
||||
|
||||
void UserState::zeroizeMasterKeysInMemory() {
|
||||
|
@ -208,23 +205,9 @@ ResponseCode UserState::readMasterKey(const android::String8& pw) {
|
|||
}
|
||||
return response;
|
||||
}
|
||||
if (mRetry <= 0) {
|
||||
reset();
|
||||
return ResponseCode::UNINITIALIZED;
|
||||
}
|
||||
--mRetry;
|
||||
switch (mRetry) {
|
||||
case 0:
|
||||
return ResponseCode::WRONG_PASSWORD_0;
|
||||
case 1:
|
||||
return ResponseCode::WRONG_PASSWORD_1;
|
||||
case 2:
|
||||
return ResponseCode::WRONG_PASSWORD_2;
|
||||
case 3:
|
||||
return ResponseCode::WRONG_PASSWORD_3;
|
||||
default:
|
||||
return ResponseCode::WRONG_PASSWORD_3;
|
||||
}
|
||||
|
||||
LOG(ERROR) << "Invalid password presented";
|
||||
return ResponseCode::WRONG_PASSWORD_0;
|
||||
}
|
||||
|
||||
bool UserState::reset() {
|
||||
|
|
|
@ -55,8 +55,6 @@ class UserState {
|
|||
void setState(State state);
|
||||
State getState() const { return mState; }
|
||||
|
||||
int8_t getRetry() const { return mRetry; }
|
||||
|
||||
void zeroizeMasterKeysInMemory();
|
||||
bool deleteMasterKey();
|
||||
|
||||
|
@ -81,7 +79,6 @@ class UserState {
|
|||
static constexpr int MASTER_KEY_SIZE_BYTES = kAes256KeySizeBytes;
|
||||
static constexpr int MASTER_KEY_SIZE_BITS = MASTER_KEY_SIZE_BYTES * 8;
|
||||
|
||||
static constexpr int MAX_RETRY = 4;
|
||||
static constexpr size_t SALT_SIZE = 16;
|
||||
|
||||
void generateKeyFromPassword(std::vector<uint8_t>& key, const android::String8& pw,
|
||||
|
@ -94,7 +91,6 @@ class UserState {
|
|||
|
||||
uid_t mUserId;
|
||||
State mState;
|
||||
int8_t mRetry;
|
||||
|
||||
std::vector<uint8_t> mMasterKey;
|
||||
uint8_t mSalt[SALT_SIZE];
|
||||
|
|
Loading…
Reference in a new issue