summaryrefslogtreecommitdiff
path: root/identity/WritableCredential.cpp
diff options
context:
space:
mode:
authorDavid Zeuthen <zeuthen@google.com>2021-03-04 16:32:43 -0500
committerDavid Zeuthen <zeuthen@google.com>2021-03-08 11:10:28 -0500
commit27407a57439a5d28e9c2735fe8422130741101f8 (patch)
tree0b26c46ee93e11167f02c62c121a0f662749fbe0 /identity/WritableCredential.cpp
parentd60ebe2e2e144d6a0f5a9e7619f4ba81fc814d57 (diff)
downloadsecurity-27407a57439a5d28e9c2735fe8422130741101f8.tar.gz
credstore: Fix several problems with credstore.
The root of the problem is that in some cases credstore would pass auth- and verification-tokens to the Identity Credential HAL without first having obtained a challenge via IIdentityCredential.createAuthChallenge(). This makes it impossible for the TA to validate the verification token for freshness. This is easily fixed by simply ensuring createAuthChallenge() is called (and the returned challenge is used in the requested verification token) whenever dealing with ACPs using user authentication. Additional issues / changes: - During Android 12 development, an use-after-free bug was introduced in Credential.cpp L120. - keystore's getTokensForCredstore() had some bugs in how to select an auth-token, in particular mixing authTokenAgeMillis (milliseconds) with time_t values (seconds) - as a result, keystore would sometimes return tokens older than what credstore requested. This wasn't actually problem because the TA would check it anyway. - we now precisely define semantics in IKeystoreService.aidl - Another potential use-after-free bug was found in Credential.cpp L767 None of the fixes for these bugs affect CTS or VTS tests. Bug: 181893400 Test: atest android.security.identity.cts on emulator Test: atest android.security.identity.cts on crosshatch (w/ Android 11 era HAL) Test: CtsVerifier's Identity Credential Authentication test crosshatch (w/ Android 11 era HAL) Change-Id: I45a3fd16eff3b6a232d8b8c88f2e3dd3619a9c03
Diffstat (limited to 'identity/WritableCredential.cpp')
-rw-r--r--identity/WritableCredential.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/identity/WritableCredential.cpp b/identity/WritableCredential.cpp
index d0688b8d..a300e514 100644
--- a/identity/WritableCredential.cpp
+++ b/identity/WritableCredential.cpp
@@ -41,15 +41,14 @@ using ::android::hardware::identity::support::chunkVector;
WritableCredential::WritableCredential(const string& dataPath, const string& credentialName,
const string& docType, bool isUpdate,
HardwareInformation hwInfo,
- sp<IWritableIdentityCredential> halBinder, int halApiVersion)
+ sp<IWritableIdentityCredential> halBinder)
: dataPath_(dataPath), credentialName_(credentialName), docType_(docType), isUpdate_(isUpdate),
- hwInfo_(std::move(hwInfo)), halBinder_(halBinder), halApiVersion_(halApiVersion) {}
+ hwInfo_(std::move(hwInfo)), halBinder_(halBinder) {}
WritableCredential::~WritableCredential() {}
-void WritableCredential::setCredentialUpdatedCallback(
- std::function<void()>&& onCredentialUpdatedCallback) {
- onCredentialUpdatedCallback_ = onCredentialUpdatedCallback;
+void WritableCredential::setCredentialToReloadWhenUpdated(sp<Credential> credential) {
+ credentialToReloadWhenUpdated_ = credential;
}
Status WritableCredential::ensureAttestationCertificateExists(const vector<uint8_t>& challenge) {
@@ -268,7 +267,10 @@ WritableCredential::personalize(const vector<AccessControlProfileParcel>& access
"Error saving credential data to disk");
}
- onCredentialUpdatedCallback_();
+ if (credentialToReloadWhenUpdated_) {
+ credentialToReloadWhenUpdated_->writableCredentialPersonalized();
+ credentialToReloadWhenUpdated_.clear();
+ }
*_aidl_return = proofOfProvisioningSignature;
return Status::ok();