Test session should continue with no keybox
Merge from Widevine repo of http://go/wvgerrit/142149 This CL updates the TestCryptoSession so that it will recover from initializing without a keybox. This allows unit and integration tests to be run using a test keybox on a device that does not have any keybox. Bug: 210807585 Bug: 161925952 Change-Id: I8639bd733a50ae5af3a7c786347b5a06a9d783ce
This commit is contained in:
@@ -215,14 +215,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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user