mirror of
https://github.com/Evolution-X/hardware_interfaces
synced 2026-02-01 16:50:18 +00:00
Merge "KeyMint VTS: fix 3DES key sizes" am: 4862e3f6f3 am: 9f4239423d
Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1699808 Change-Id: I158c42c5e92a864e91a1594b4a07884b991d63f4
This commit is contained in:
@@ -3329,7 +3329,7 @@ TEST_P(ImportKeyTest, TripleDesSuccess) {
|
|||||||
*/
|
*/
|
||||||
TEST_P(ImportKeyTest, TripleDesFailure) {
|
TEST_P(ImportKeyTest, TripleDesFailure) {
|
||||||
string key = hex2str("a49d7564199e97cb529d2c9d97bf2f98d35edf57ba1f7358");
|
string key = hex2str("a49d7564199e97cb529d2c9d97bf2f98d35edf57ba1f7358");
|
||||||
uint32_t bitlen = key.size() * 8;
|
uint32_t bitlen = key.size() * 7;
|
||||||
for (uint32_t key_size : {bitlen - 1, bitlen + 1, bitlen - 8, bitlen + 8}) {
|
for (uint32_t key_size : {bitlen - 1, bitlen + 1, bitlen - 8, bitlen + 8}) {
|
||||||
// Explicit key size doesn't match that of the provided key.
|
// Explicit key size doesn't match that of the provided key.
|
||||||
auto result = ImportKey(AuthorizationSetBuilder()
|
auto result = ImportKey(AuthorizationSetBuilder()
|
||||||
@@ -3343,19 +3343,19 @@ TEST_P(ImportKeyTest, TripleDesFailure) {
|
|||||||
<< "unexpected result: " << result;
|
<< "unexpected result: " << result;
|
||||||
}
|
}
|
||||||
// Explicit key size matches that of the provided key, but it's not a valid size.
|
// Explicit key size matches that of the provided key, but it's not a valid size.
|
||||||
string long_key = hex2str("a49d7564199e97cb529d2c9d97bf2f98d35edf57ba1f7358");
|
string long_key = hex2str("a49d7564199e97cb529d2c9d97bf2f98d35edf57ba1f735800");
|
||||||
ASSERT_EQ(ErrorCode::UNSUPPORTED_KEY_SIZE,
|
ASSERT_EQ(ErrorCode::UNSUPPORTED_KEY_SIZE,
|
||||||
ImportKey(AuthorizationSetBuilder()
|
ImportKey(AuthorizationSetBuilder()
|
||||||
.Authorization(TAG_NO_AUTH_REQUIRED)
|
.Authorization(TAG_NO_AUTH_REQUIRED)
|
||||||
.TripleDesEncryptionKey(long_key.size() * 8)
|
.TripleDesEncryptionKey(long_key.size() * 7)
|
||||||
.EcbMode()
|
.EcbMode()
|
||||||
.Padding(PaddingMode::PKCS7),
|
.Padding(PaddingMode::PKCS7),
|
||||||
KeyFormat::RAW, long_key));
|
KeyFormat::RAW, long_key));
|
||||||
string short_key = hex2str("a49d7564199e97cb529d2c9d97bf2f98d35edf57ba1f7358");
|
string short_key = hex2str("a49d7564199e97cb529d2c9d97bf2f98d35edf57ba1f73");
|
||||||
ASSERT_EQ(ErrorCode::UNSUPPORTED_KEY_SIZE,
|
ASSERT_EQ(ErrorCode::UNSUPPORTED_KEY_SIZE,
|
||||||
ImportKey(AuthorizationSetBuilder()
|
ImportKey(AuthorizationSetBuilder()
|
||||||
.Authorization(TAG_NO_AUTH_REQUIRED)
|
.Authorization(TAG_NO_AUTH_REQUIRED)
|
||||||
.TripleDesEncryptionKey(short_key.size() * 8)
|
.TripleDesEncryptionKey(short_key.size() * 7)
|
||||||
.EcbMode()
|
.EcbMode()
|
||||||
.Padding(PaddingMode::PKCS7),
|
.Padding(PaddingMode::PKCS7),
|
||||||
KeyFormat::RAW, short_key));
|
KeyFormat::RAW, short_key));
|
||||||
|
|||||||
Reference in New Issue
Block a user