Allow running tests without test keybox.

[ CDM CL http://go/wvgerrit/156286 ]

Local test scripts can now run the CDM unit tests without using a test
keybox / test RSA key by setting an environment variable:

  DISABLE_TEST_KEYBOX=yes

The default behavior will continue to be that the unit tests will load
a test keybox / test RSA key.

This is to enable testing different provisioning features when the
device uses keyboxes for its ROT.  Provisioning methods like 3.0 and
4.0 were never forcibly required to load a test ROT.

This is change is required for the ability to test ECC-enabled
keyboxes.

Bug: 135283522
Test: run_x86_64_tests and build_and_run_all_unit_tests.sh
Change-Id: I2a85be541deec3f60ab8fa82452a4d4cafaed339
This commit is contained in:
Alex Dale
2022-08-19 18:45:33 -07:00
parent 6bc69d5005
commit 458f4f68c4
2 changed files with 55 additions and 5 deletions

View File

@@ -103,12 +103,28 @@ class WvCdmTestBaseWithEngine : public WvCdmTestBase {
TestCdmEngine cdm_engine_;
};
struct TestCryptoSessionConfig {
// Disables newly created TestCryptoSession instances from installing
// a test keybox.
bool disable_test_keybox = false;
};
class TestCryptoSession : public CryptoSession {
public:
explicit TestCryptoSession(metrics::CryptoMetrics* crypto_metrics);
TestCryptoSession(metrics::CryptoMetrics* crypto_metrics,
const TestCryptoSessionConfig* config);
// This intercepts nonce flood errors, which is useful for tests that request
// many nonces and are not time critical.
CdmResponseType GenerateNonce(uint32_t* nonce) override;
private:
// Called once when TestCryptoSession is constructed.
void MaybeInstallTestKeybox();
bool IsTestKeyboxNeeded();
// An un-owned pointer to the config.
const TestCryptoSessionConfig* const config_ = nullptr;
};
// Given a PSSH data structure, this makes a PSSH string for use in