Encryption: try wrapped key if the first time decryption fails

Change-Id: I108b7aeea41c6b85c851f40c1c4a7e25012e2463
This commit is contained in:
bigbiff bigbiff
2019-08-27 20:50:31 -04:00
parent 05cd3f8616
commit 0be03b3217
3 changed files with 13 additions and 6 deletions

View File

@@ -177,12 +177,12 @@ bool getEphemeralWrappedKey(km::KeyFormat format, KeyBuffer& kmKey, KeyBuffer* k
return true;
}
if (ret != km::ErrorCode::KEY_REQUIRES_UPGRADE) return false;
LOG(DEBUG) << "Upgrading key";
LOG(DEBUG) << "Upgrading key" << std::endl;
std::string kmKeyStr(reinterpret_cast<const char*>(kmKey.data()), kmKey.size());
std::string newKey;
if (!keymaster.upgradeKey(kmKeyStr, km::AuthorizationSet(), &newKey)) return false;
memcpy(reinterpret_cast<void*>(kmKey.data()), newKey.c_str(), kmKey.size());
LOG(INFO) << "Key upgraded";
LOG(INFO) << "Key upgraded" << std::endl;
export_again = true;
}
//Should never come here