diff options
-rw-r--r-- | security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp | 57 |
1 files changed, 26 insertions, 31 deletions
diff --git a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp index ebea8b27a8..41d47eee8c 100644 --- a/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp +++ b/security/keymint/aidl/vts/functional/KeyMintAidlTestBase.cpp @@ -1751,38 +1751,33 @@ bool verify_attestation_record(int32_t aidl_version, // EXPECT_EQ(security_level, att_keymint_security_level); EXPECT_EQ(security_level, att_attestation_security_level); - // TODO(b/136282179): When running under VTS-on-GSI the TEE-backed - // keymint implementation will report YYYYMM dates instead of YYYYMMDD - // for the BOOT_PATCH_LEVEL. - if (avb_verification_enabled()) { - for (int i = 0; i < att_hw_enforced.size(); i++) { - if (att_hw_enforced[i].tag == TAG_BOOT_PATCHLEVEL || - att_hw_enforced[i].tag == TAG_VENDOR_PATCHLEVEL) { - std::string date = - std::to_string(att_hw_enforced[i].value.get<KeyParameterValue::integer>()); - - // strptime seems to require delimiters, but the tag value will - // be YYYYMMDD - if (date.size() != 8) { - ADD_FAILURE() << "Tag " << att_hw_enforced[i].tag - << " with invalid format (not YYYYMMDD): " << date; - return false; - } - date.insert(6, "-"); - date.insert(4, "-"); - struct tm time; - strptime(date.c_str(), "%Y-%m-%d", &time); - - // Day of the month (0-31) - EXPECT_GE(time.tm_mday, 0); - EXPECT_LT(time.tm_mday, 32); - // Months since Jan (0-11) - EXPECT_GE(time.tm_mon, 0); - EXPECT_LT(time.tm_mon, 12); - // Years since 1900 - EXPECT_GT(time.tm_year, 110); - EXPECT_LT(time.tm_year, 200); + for (int i = 0; i < att_hw_enforced.size(); i++) { + if (att_hw_enforced[i].tag == TAG_BOOT_PATCHLEVEL || + att_hw_enforced[i].tag == TAG_VENDOR_PATCHLEVEL) { + std::string date = + std::to_string(att_hw_enforced[i].value.get<KeyParameterValue::integer>()); + + // strptime seems to require delimiters, but the tag value will + // be YYYYMMDD + if (date.size() != 8) { + ADD_FAILURE() << "Tag " << att_hw_enforced[i].tag + << " with invalid format (not YYYYMMDD): " << date; + return false; } + date.insert(6, "-"); + date.insert(4, "-"); + struct tm time; + strptime(date.c_str(), "%Y-%m-%d", &time); + + // Day of the month (0-31) + EXPECT_GE(time.tm_mday, 0); + EXPECT_LT(time.tm_mday, 32); + // Months since Jan (0-11) + EXPECT_GE(time.tm_mon, 0); + EXPECT_LT(time.tm_mon, 12); + // Years since 1900 + EXPECT_GT(time.tm_year, 110); + EXPECT_LT(time.tm_year, 200); } } |