Backwards Compatibility Tests
Merge from Widevine repo of http://go/wvgerrit/24241 The CL also only modifies existing tests so that they will pass with an old version of OEMCrypto, or it filters out the tests so that they do not run. This positions us so that we can more easily verify how much backwards compatibility we expect to work. bug: 35877886 Change-Id: Iadc06672d7f9cef75800662ff83389c504a3fd04
This commit is contained in:
@@ -534,22 +534,43 @@ void Session::TestDecryptCTR(bool select_key_first,
|
||||
if (expected_result == OEMCrypto_SUCCESS) { // No error.
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
|
||||
ASSERT_EQ(unencryptedData, outputBuffer);
|
||||
} else if (expected_result == OEMCrypto_ERROR_KEY_EXPIRED) {
|
||||
// Report stale keys.
|
||||
ASSERT_EQ(OEMCrypto_ERROR_KEY_EXPIRED, sts);
|
||||
} else {
|
||||
ASSERT_NO_FATAL_FAILURE(TestDecryptResult(expected_result, sts));
|
||||
ASSERT_NE(unencryptedData, outputBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void Session::TestDecryptResult(OEMCryptoResult expected_result,
|
||||
OEMCryptoResult actual_result) {
|
||||
|
||||
if (expected_result == OEMCrypto_SUCCESS) { // No error.
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, actual_result);
|
||||
} else if (expected_result == OEMCrypto_ERROR_KEY_EXPIRED &&
|
||||
global_features.api_version >= 9) {
|
||||
// Report stale keys, required in v9 and beyond.
|
||||
ASSERT_EQ(OEMCrypto_ERROR_KEY_EXPIRED, actual_result);
|
||||
} else if (expected_result == OEMCrypto_ERROR_INSUFFICIENT_HDCP) {
|
||||
// Report HDCP errors.
|
||||
ASSERT_EQ(OEMCrypto_ERROR_INSUFFICIENT_HDCP, sts);
|
||||
ASSERT_NE(unencryptedData, outputBuffer);
|
||||
ASSERT_EQ(OEMCrypto_ERROR_INSUFFICIENT_HDCP, actual_result);
|
||||
} else if (expected_result == OEMCrypto_ERROR_ANALOG_OUTPUT) {
|
||||
// Report analog errors.
|
||||
ASSERT_EQ(OEMCrypto_ERROR_ANALOG_OUTPUT, sts);
|
||||
ASSERT_NE(unencryptedData, outputBuffer);
|
||||
ASSERT_EQ(OEMCrypto_ERROR_ANALOG_OUTPUT, actual_result);
|
||||
} else {
|
||||
// OEM's can fine tune other error codes for debugging.
|
||||
ASSERT_NE(OEMCrypto_SUCCESS, sts);
|
||||
ASSERT_NE(unencryptedData, outputBuffer);
|
||||
ASSERT_NE(OEMCrypto_SUCCESS, actual_result);
|
||||
}
|
||||
}
|
||||
|
||||
void Session::TestSelectExpired(unsigned int key_index) {
|
||||
if (global_features.api_version >= 13) {
|
||||
OEMCryptoResult status =
|
||||
OEMCrypto_SelectKey(session_id(), license().keys[key_index].key_id,
|
||||
license().keys[key_index].key_id_length);
|
||||
// It is OK for SelectKey to succeed with an expired key, but if there is
|
||||
// an error, it must be OEMCrypto_ERROR_KEY_EXIRED.
|
||||
if (status != OEMCrypto_SUCCESS) {
|
||||
ASSERT_EQ(OEMCrypto_ERROR_KEY_EXPIRED, status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -985,7 +1006,10 @@ void Session::CopyAndVerifyOldEntry(const Test_PST_Report& report,
|
||||
OEMCryptoResult result = OEMCrypto_CopyOldUsageEntry(
|
||||
session_id(), reinterpret_cast<const uint8_t*>(report.pst.c_str()),
|
||||
report.pst.length());
|
||||
if (result == OEMCrypto_ERROR_NOT_IMPLEMENTED) return;
|
||||
if (result == OEMCrypto_ERROR_NOT_IMPLEMENTED) {
|
||||
cout << "WARNING: OEMCrypto CANNOT copy old usage table to new." << endl;
|
||||
return;
|
||||
}
|
||||
ASSERT_NO_FATAL_FAILURE(UpdateUsageEntry(header_buffer));
|
||||
ASSERT_NO_FATAL_FAILURE(GenerateReport(report.pst));
|
||||
ASSERT_NO_FATAL_FAILURE(VerifyPST(report));
|
||||
|
||||
Reference in New Issue
Block a user