ext4crypt: change to upgrade key if export fails

Add support to upgrade key when export fails with KEY_REQUIRES_UPGRADE.

Ported from
https://source.codeaurora.org/quic/la/platform/system/vold/commit/?h=LA.UM.7.9.r1-06100-sm6150.0&id=85c46eaacc60290db5e71380d89eb4d99ed67995

Change-Id: Ic64be8ade00c0b0d014370ecc9341b1ecc9b0d7a
This commit is contained in:
Peter Cai
2019-09-01 19:34:09 +02:00
committed by big biff
parent 90edd2e867
commit 05cd3f8616
3 changed files with 27 additions and 9 deletions
+4 -4
View File
@@ -142,7 +142,7 @@ bool Keymaster::generateKey(const km::AuthorizationSet& inParams, std::string* k
return true;
}
bool Keymaster::exportKey(km::KeyFormat format, KeyBuffer& kmKey, const std::string& clientId,
km::ErrorCode Keymaster::exportKey(km::KeyFormat format, KeyBuffer& kmKey, const std::string& clientId,
const std::string& appData, std::string* key) {
auto kmKeyBlob = km::support::blob2hidlVec(std::string(kmKey.data(), kmKey.size()));
auto emptyAssign = NULL;
@@ -159,13 +159,13 @@ bool Keymaster::exportKey(km::KeyFormat format, KeyBuffer& kmKey, const std::str
auto error = mDevice->exportKey(format, kmKeyBlob, kmClientId, kmAppData, hidlCb);
if (!error.isOk()) {
LOG(ERROR) << "export_key failed: " << error.description();
return false;
return km::ErrorCode::UNKNOWN_ERROR;
}
if (km_error != km::ErrorCode::OK) {
LOG(ERROR) << "export_key failed, code " << int32_t(km_error);
return false;
return km_error;
}
return true;
return km::ErrorCode::OK;
}
bool Keymaster::deleteKey(const std::string& key) {