summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <zeuthen@google.com>2023-03-10 15:11:09 -0500
committerCherrypicker Worker <android-build-cherrypicker-worker@system.gserviceaccount.com>2023-03-15 14:01:50 +0000
commit5993719991ce3d7551760dc83e9b39b18ea2bf2c (patch)
tree7e8a9778eec12614dff094a25cf9c3c328e069cd
parent333df15518a9e0d5203235f2459231d5c9da6570 (diff)
identity: VTS: allow for multiple interpretations of AuthKey validity.
Bug: 271948315 Test: atest VtsHalIdentityTargetTest (cherry picked from https://android-review.googlesource.com/q/commit:719920700e0e8c0849ef25eeaad8de2bf2442b6e) Merged-In: Iedb9caad933b0df2b190915f5cc7177e507f15b5 Change-Id: I6599499e08db91729fe6898dbfa5ecb77450d11e
-rw-r--r--identity/aidl/vts/Util.cpp20
1 files changed, 18 insertions, 2 deletions
diff --git a/identity/aidl/vts/Util.cpp b/identity/aidl/vts/Util.cpp
index 1148cb0b60..0ce63b2e2d 100644
--- a/identity/aidl/vts/Util.cpp
+++ b/identity/aidl/vts/Util.cpp
@@ -445,8 +445,24 @@ void verifyAuthKeyCertificate(const vector<uint8_t>& authKeyCertChain) {
int64_t allowDriftSecs = 10;
EXPECT_LE(-allowDriftSecs, diffSecs);
EXPECT_GE(allowDriftSecs, diffSecs);
- constexpr uint64_t kSecsInOneYear = 365 * 24 * 60 * 60;
- EXPECT_EQ(notBefore + kSecsInOneYear, notAfter);
+
+ // The AIDL spec used to call for "one year in the future (365
+ // days)" but was updated to say "current time and 31536000
+ // seconds in the future (approximately 365 days)" to clarify that
+ // this was the original intention.
+ //
+ // However a number of implementations interpreted this as a
+ // "literal year" which started causing problems in March 2023
+ // because 2024 is a leap year. Since the extra day doesn't really
+ // matter (the validity period is specified in the MSO anyway and
+ // that's what RPs use), we allow both interpretations.
+ //
+ // For simplicity, we just require that that notAfter is after
+ // 31536000 and which also covers the case if there's a leap-day
+ // and possible leap-seconds.
+ //
+ constexpr uint64_t kSecsIn365Days = 365 * 24 * 60 * 60;
+ EXPECT_LE(notBefore + kSecsIn365Days, notAfter);
}
vector<RequestNamespace> buildRequestNamespaces(const vector<TestEntryData> entries) {