Remove OEMCrypto_InitializeDecryptHash
Merge from Widevine repo of http://go/wvgerrit/68464 The Full Decrypt Path Testing design has changed to remove OEMCrypto_InitializeDecryptHash. This CL updates the unit tests and reference code. Bug: 120795057 Test: unit tests Change-Id: Iee28fa9034dc21cee81c5b894c192e260375eeee
This commit is contained in:
committed by
Srujan Gaddam
parent
f42038d89a
commit
9c95e4caae
@@ -1721,21 +1721,27 @@ INSTANTIATE_TEST_CASE_P(TestRefreshEachKeys, SessionTestRefreshKeyTest,
|
||||
|
||||
// If the license does not allow a hash, then we should not compute one.
|
||||
TEST_F(OEMCryptoSessionTests, HashForbiddenAPI15) {
|
||||
uint32_t hash_type = OEMCrypto_SupportsDecryptHash();
|
||||
// If hash is not supported, or is vendor defined, don't try to test it.
|
||||
if (hash_type != OEMCrypto_CRC_Clear_Buffer) return;
|
||||
Session s;
|
||||
ASSERT_NO_FATAL_FAILURE(s.open());
|
||||
ASSERT_NO_FATAL_FAILURE(InstallTestSessionKeys(&s));
|
||||
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(kDuration, 0, 0));
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys());
|
||||
// Either failure, or not supported is allowed.
|
||||
ASSERT_NE(OEMCrypto_SUCCESS, OEMCrypto_InitializeDecryptHash(s.session_id()));
|
||||
ASSERT_EQ(
|
||||
OEMCrypto_SUCCESS,
|
||||
OEMCrypto_SelectKey(s.session_id(), s.license().keys[0].key_id,
|
||||
s.license().keys[0].key_id_length,
|
||||
OEMCrypto_CipherMode_CTR));
|
||||
// Still not allowed.
|
||||
ASSERT_NE(OEMCrypto_SUCCESS, OEMCrypto_InitializeDecryptHash(s.session_id()));
|
||||
uint32_t frame_number = 1;
|
||||
uint32_t hash = 42;
|
||||
// It is OK to set the hash before loading the keys
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS,
|
||||
OEMCrypto_SetDecryptHash(s.session_id(), frame_number,
|
||||
reinterpret_cast<const uint8_t*>(&hash),
|
||||
sizeof(hash)));
|
||||
// It is OK to select the key and decrypt.
|
||||
ASSERT_NO_FATAL_FAILURE(s.TestDecryptCTR());
|
||||
// But the error code should be bad.
|
||||
ASSERT_EQ(OEMCrypto_ERROR_UNKNOWN_FAILURE,
|
||||
OEMCrypto_GetHashErrorCode(s.session_id(), &frame_number));
|
||||
}
|
||||
|
||||
//
|
||||
@@ -1944,14 +1950,18 @@ class OEMCryptoSessionTestsDecryptTests
|
||||
s.license().keys[0].cipher_mode = cipher_mode_;
|
||||
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
|
||||
ASSERT_NO_FATAL_FAILURE(s.LoadTestKeys());
|
||||
if (global_features.supports_crc) {
|
||||
uint32_t hash =
|
||||
wvcrc32(unencryptedData.data(), unencryptedData.size());
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS,
|
||||
OEMCrypto_SetDecryptHash(
|
||||
s.session_id(), 1, reinterpret_cast<const uint8_t*>(&hash),
|
||||
sizeof(hash)));
|
||||
}
|
||||
sts = OEMCrypto_SelectKey(s.session_id(), s.license().keys[0].key_id,
|
||||
s.license().keys[0].key_id_length,
|
||||
cipher_mode_);
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS, sts);
|
||||
if (global_features.supports_crc) {
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS,
|
||||
OEMCrypto_InitializeDecryptHash(s.session_id()));
|
||||
}
|
||||
// We decrypt each subsample.
|
||||
vector<uint8_t> output_buffer(total_size_ + 16, 0xaa);
|
||||
const uint8_t *input_buffer = NULL;
|
||||
@@ -2021,12 +2031,6 @@ class OEMCryptoSessionTestsDecryptTests
|
||||
output_buffer.resize(total_size_);
|
||||
EXPECT_EQ(unencryptedData, output_buffer);
|
||||
if (global_features.supports_crc) {
|
||||
uint32_t hash =
|
||||
wvoec::wvcrc32(unencryptedData.data(), unencryptedData.size());
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS,
|
||||
OEMCrypto_SetDecryptHash(
|
||||
s.session_id(), 1, reinterpret_cast<const uint8_t*>(&hash),
|
||||
sizeof(hash)));
|
||||
uint32_t frame;
|
||||
ASSERT_EQ(OEMCrypto_SUCCESS,
|
||||
OEMCrypto_GetHashErrorCode(s.session_id(), &frame));
|
||||
|
||||
Reference in New Issue
Block a user