diff options
author | David Zeuthen <zeuthen@google.com> | 2020-04-27 15:24:55 -0400 |
---|---|---|
committer | David Zeuthen <zeuthen@google.com> | 2020-04-27 16:03:36 -0400 |
commit | 602753593ee0bf881edd9aa4fbad01d23dd16158 (patch) | |
tree | cb65aad892341fbd3eadbd23c258ee3e3b890bb4 /identity | |
parent | d2115c9876d2e6c3abca6e38ca77044d3b888d1d (diff) | |
download | platform_hardware_interfaces-602753593ee0bf881edd9aa4fbad01d23dd16158.tar.gz platform_hardware_interfaces-602753593ee0bf881edd9aa4fbad01d23dd16158.tar.bz2 platform_hardware_interfaces-602753593ee0bf881edd9aa4fbad01d23dd16158.zip |
Identity Credential: Restrict AccessControlProfile identifiers to 32.
In order to implement Identity Credential on resource-restricted
secure hardware, we need to limit the number of possible
AccessControlProfile in a credential. A limit of 32 means that such
hardware only need to devote four bytes of RAM for a bitmask with
information about which profiles are authorized.
Document this, add new VTS test, and update the default
implementation.
Bug: 155100967
Test: atest android.security.identity.cts
Test: atest VtsHalIdentityTargetTest
Merged-In: Ia4f2ee0013b330561df744e0595f298a0d156122
Change-Id: I2dd672447bedfa9407bf1044e6261af26fd137f9
Diffstat (limited to 'identity')
3 files changed, 42 insertions, 1 deletions
diff --git a/identity/aidl/android/hardware/identity/IWritableIdentityCredential.aidl b/identity/aidl/android/hardware/identity/IWritableIdentityCredential.aidl index 9673821b82..07486e6001 100644 --- a/identity/aidl/android/hardware/identity/IWritableIdentityCredential.aidl +++ b/identity/aidl/android/hardware/identity/IWritableIdentityCredential.aidl @@ -140,7 +140,8 @@ interface IWritableIdentityCredential { * with STATUS_INVALID_DATA. * * @param id a numeric identifier that must be unique within the context of a Credential and may - * be used to reference the profile. If this is not satisfied the call fails with + * be used to reference the profile. This id must be non-negative and less than 32 (allowing + * for a total of 32 profiles). If this is not satisfied the call fails with * STATUS_INVALID_DATA. * * @param readerCertificate if non-empty, specifies a single X.509 certificate (not a chain of diff --git a/identity/aidl/default/WritableIdentityCredential.cpp b/identity/aidl/default/WritableIdentityCredential.cpp index 553a3d832b..52cd49600f 100644 --- a/identity/aidl/default/WritableIdentityCredential.cpp +++ b/identity/aidl/default/WritableIdentityCredential.cpp @@ -143,6 +143,12 @@ ndk::ScopedAStatus WritableIdentityCredential::addAccessControlProfile( } accessControlProfileIds_.insert(id); + if (id < 0 || id >= 32) { + return ndk::ScopedAStatus(AStatus_fromServiceSpecificErrorWithMessage( + IIdentityCredentialStore::STATUS_INVALID_DATA, + "Access Control Profile id must be non-negative and less than 32")); + } + // Spec requires if |userAuthenticationRequired| is false, then |timeoutMillis| must also // be zero. if (!userAuthenticationRequired && timeoutMillis != 0) { diff --git a/identity/aidl/vts/VtsIWritableIdentityCredentialTests.cpp b/identity/aidl/vts/VtsIWritableIdentityCredentialTests.cpp index 56b30af9a4..b68fbb54f1 100644 --- a/identity/aidl/vts/VtsIWritableIdentityCredentialTests.cpp +++ b/identity/aidl/vts/VtsIWritableIdentityCredentialTests.cpp @@ -641,6 +641,40 @@ TEST_P(IdentityCredentialTests, verifyInterleavingEntryNameSpaceOrderingFails) { EXPECT_EQ(IIdentityCredentialStore::STATUS_INVALID_DATA, result.serviceSpecificErrorCode()); } +TEST_P(IdentityCredentialTests, verifyAccessControlProfileIdOutOfRange) { + sp<IWritableIdentityCredential> writableCredential; + ASSERT_TRUE(test_utils::SetupWritableCredential(writableCredential, credentialStore_)); + + const vector<int32_t> entryCounts = {1}; + Status result = writableCredential->startPersonalization(1, entryCounts); + ASSERT_TRUE(result.isOk()) << result.exceptionCode() << "; " << result.exceptionMessage() + << endl; + + SecureAccessControlProfile profile; + + // This should fail because the id is >= 32 + result = writableCredential->addAccessControlProfile(32, // id + {}, // readerCertificate + false, // userAuthenticationRequired + 0, // timeoutMillis + 42, // secureUserId + &profile); + ASSERT_FALSE(result.isOk()) << result.exceptionCode() << "; " << result.exceptionMessage(); + ASSERT_EQ(binder::Status::EX_SERVICE_SPECIFIC, result.exceptionCode()); + ASSERT_EQ(IIdentityCredentialStore::STATUS_INVALID_DATA, result.serviceSpecificErrorCode()); + + // This should fail because the id is < 0 + result = writableCredential->addAccessControlProfile(-1, // id + {}, // readerCertificate + false, // userAuthenticationRequired + 0, // timeoutMillis + 42, // secureUserId + &profile); + ASSERT_FALSE(result.isOk()) << result.exceptionCode() << "; " << result.exceptionMessage(); + ASSERT_EQ(binder::Status::EX_SERVICE_SPECIFIC, result.exceptionCode()); + ASSERT_EQ(IIdentityCredentialStore::STATUS_INVALID_DATA, result.serviceSpecificErrorCode()); +} + INSTANTIATE_TEST_SUITE_P( Identity, IdentityCredentialTests, testing::ValuesIn(android::getAidlHalInstanceNames(IIdentityCredentialStore::descriptor)), |