mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 11:36:00 +00:00
Merge "Test that the password isn't truncated" am: 51b8d29e7e am: 1285a868db am: de4e656380
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/2151558 Change-Id: I6968cab4a02652aec7eec47fab4567953da49798 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -243,6 +243,47 @@ TEST_P(GatekeeperHidlTest, VerifySuccess) {
|
||||
ALOGI("Testing Enroll+Verify done");
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that passwords containing a NUL byte aren't truncated
|
||||
*/
|
||||
TEST_P(GatekeeperHidlTest, PasswordIsBinaryData) {
|
||||
GatekeeperResponse enrollRsp;
|
||||
GatekeeperResponse verifyRsp;
|
||||
hidl_vec<uint8_t> rightPassword = {'A', 'B', 'C', '\0', 'D', 'E', 'F'};
|
||||
hidl_vec<uint8_t> wrongPassword = {'A', 'B', 'C', '\0', '\0', '\0', '\0'};
|
||||
|
||||
ALOGI("Testing Enroll+Verify of password with embedded NUL (expected success)");
|
||||
enrollNewPassword(rightPassword, enrollRsp, true);
|
||||
verifyPassword(rightPassword, enrollRsp.data, 1, verifyRsp, true);
|
||||
|
||||
ALOGI("Testing Verify of wrong password (expected failure)");
|
||||
verifyPassword(wrongPassword, enrollRsp.data, 1, verifyRsp, false);
|
||||
|
||||
ALOGI("PasswordIsBinaryData test done");
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure that long passwords aren't truncated
|
||||
*/
|
||||
TEST_P(GatekeeperHidlTest, LongPassword) {
|
||||
GatekeeperResponse enrollRsp;
|
||||
GatekeeperResponse verifyRsp;
|
||||
hidl_vec<uint8_t> password;
|
||||
|
||||
password.resize(64); // maximum length used by Android
|
||||
memset(password.data(), 'A', password.size());
|
||||
|
||||
ALOGI("Testing Enroll+Verify of long password (expected success)");
|
||||
enrollNewPassword(password, enrollRsp, true);
|
||||
verifyPassword(password, enrollRsp.data, 1, verifyRsp, true);
|
||||
|
||||
ALOGI("Testing Verify of wrong password (expected failure)");
|
||||
password[password.size() - 1] ^= 1;
|
||||
verifyPassword(password, enrollRsp.data, 1, verifyRsp, false);
|
||||
|
||||
ALOGI("LongPassword test done");
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure we can securely update password (keep the same
|
||||
* secure user_id) if we prove we know old password
|
||||
|
||||
Reference in New Issue
Block a user