Test session should continue with no keybox am: 75b87c7f59 am: 78d0b73964

Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/16507242

Change-Id: I448766407f548908468143aa2ca2e45b8362c10d
This commit is contained in:
Fred Gylys-Colwell
2022-01-07 06:08:37 +00:00
committed by Automerger Merge Worker
3 changed files with 50 additions and 40 deletions

View File

@@ -223,14 +223,17 @@ std::string WvCdmTestBase::SignHMAC(const std::string& message,
TestCryptoSession::TestCryptoSession(metrics::CryptoMetrics* crypto_metrics)
: CryptoSession(crypto_metrics) {
// The first CryptoSession should have initialized OEMCrypto. This is right
// after that, so should tell oemcrypto to use a test keybox.
// after that, so we should tell oemcrypto to use a test keybox.
if (session_count() == 1) {
OverrideNeedKeyboxForTesting(false);
// However, if the device does not have a keybox, initialization would have
// failed. In that case we should try again.
if (!initialized()) {
// If not initialized, try again and see if we are just missing a keybox.
// Since we plan to install a test keybox, we can ignore keybox errors.
const OEMCryptoResult status = ::OEMCrypto_Initialize();
if (status != OEMCrypto_SUCCESS) return;
OverrideInitializedForTesting(true);
// Give up if we cannot initialize at all.
if (OEMCrypto_SUCCESS != OEMCrypto_Initialize()) return;
set_initialized(true);
// This was skipped in Init because initialization failed.
CacheVersion();
}
WvCdmTestBase::InstallTestRootOfTrust();
}