Unit Test Updates for v13
Merge from widevine of http://go/wvgerrit/23042 This updates unit tests to account for key control block changes for OEMCrypto v13. There are two new bits, restricting SRM version and restricting analog output. The verification string is also updated. Part of this is to include some simple unit tests for the SRM functions. b/33815454 b/28955520 Change-Id: I7cc2ce508688fded2b67fc2a4379c7a8d59d8d22
This commit is contained in:
@@ -131,6 +131,24 @@ TEST_F(OEMCryptoClientTest, CheckHDCPCapability) {
|
||||
HDCPCapabilityAsString(maximum));
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoClientTest, CheckSRMCapabilityV13) {
|
||||
// This just tests some trivial functionality of the SRM update functions.
|
||||
bool supported = OEMCrypto_IsSRMUpdateSupported();
|
||||
printf(" Update SRM Supported: %s.\n",
|
||||
supported ? "true" : "false");
|
||||
uint16_t version = 0;
|
||||
OEMCryptoResult current_result = OEMCrypto_GetCurrentSRMVersion(&version);
|
||||
if (current_result == OEMCrypto_SUCCESS) {
|
||||
printf(" Current SRM Version: %d.\n", version);
|
||||
EXPECT_NE(OEMCrypto_SUCCESS, OEMCrypto_GetCurrentSRMVersion(NULL));
|
||||
} else {
|
||||
EXPECT_EQ(OEMCrypto_ERROR_NOT_IMPLEMENTED, current_result);
|
||||
}
|
||||
vector<uint8_t> bad_srm(42);
|
||||
RAND_pseudo_bytes(&bad_srm[0], bad_srm.size());
|
||||
EXPECT_NE(OEMCrypto_SUCCESS, OEMCrypto_LoadSRM(&bad_srm[0], bad_srm.size()));
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoClientTest, CheckMaxNumberOfSessionsAPI10) {
|
||||
size_t sessions_count;
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS,
|
||||
@@ -1153,7 +1171,8 @@ TEST_P(SessionTestAlternateVerification, LoadKeys) {
|
||||
ASSERT_NE(OEMCrypto_SUCCESS, sts);
|
||||
} else {
|
||||
// Otherwise, LoadKeys should succeed.
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts)
|
||||
<< "LoadKeys failed for key control block kc" << target_api_;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1161,7 +1180,7 @@ TEST_P(SessionTestAlternateVerification, LoadKeys) {
|
||||
// the current API + 2. We use +2 because we want to test at least 1
|
||||
// future API, and the ::testing::Range is not inclusive.
|
||||
INSTANTIATE_TEST_CASE_P(TestAll, SessionTestAlternateVerification,
|
||||
Range(8, 12 + 2));
|
||||
Range(8, 13 + 2));
|
||||
|
||||
TEST_F(OEMCryptoSessionTests, LoadKeysBadSignature) {
|
||||
Session s;
|
||||
@@ -2104,6 +2123,18 @@ TEST_F(OEMCryptoSessionTests, DecryptSecureToClear) {
|
||||
s.TestDecryptCTR(true, OEMCrypto_ERROR_UNKNOWN_FAILURE));
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoSessionTests, DecryptNoAnalogToClear) {
|
||||
Session s;
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
|
||||
kDuration, wvoec_mock::kControlDisableAnalogOutput, 0));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys());
|
||||
ASSERT_NO_FATAL_FAILURE(
|
||||
s.TestDecryptCTR(true, OEMCrypto_ERROR_ANALOG_OUTPUT));
|
||||
}
|
||||
|
||||
TEST_F(OEMCryptoSessionTests, KeyDuration) {
|
||||
Session s;
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
|
||||
Reference in New Issue
Block a user