Update OEMCrypto calls to use substrings (addendum)

Merge from master branch of Widevine repo of http://go/wvgerrit/66076
Merge from oemcrypto-v15 branch of Widevine repo of http://go/wvgerrit/64743

http://go/wvgerrit/64083 had some refactorings that weren't completely
accurate or slightly changed the meaning of some tests. This CL is an
addendum to that CL to fix those refactorings.

Test: tested as part of http://go/ag/5501993
Bug: 115874964

Change-Id: I37766a4c34de737eb9ca94ef781805435ee30dfd
This commit is contained in:
Srujan Gaddam
2018-11-12 14:19:29 -08:00
committed by Fred Gylys-Colwell
parent 4d5e0f961b
commit b7e4b56934
2 changed files with 29 additions and 24 deletions

View File

@@ -401,7 +401,10 @@ void Session::LoadEntitledContentKeys(OEMCryptoResult expected_sts) {
reinterpret_cast<const uint8_t*>(
encrypted_entitled_message_.data() +
encrypted_entitled_key_array[i].content_key_data.offset);
memcpy(&iv[0], encrypted_content_key_data, 16);
memcpy(&iv[0],
message_ptr() +
encrypted_entitled_key_array[i].content_key_data_iv.offset,
16);
AES_cbc_encrypt(content_key_data,
const_cast<uint8_t*>(encrypted_content_key_data),
encrypted_entitled_key_array[i].content_key_data.length,

View File

@@ -1092,10 +1092,10 @@ TEST_F(OEMCryptoSessionTests, LoadKeyWithBadRange7) {
s.key_array()[2].key_control_iv.offset += s.message_size();
OEMCryptoResult sts = OEMCrypto_LoadKeys(
s.session_id(), s.message_ptr(), s.message_size(), &s.signature()[0],
s.signature().size(), s.enc_mac_keys_iv_substr(), s.enc_mac_keys_substr(),
s.num_keys(), s.key_array(), GetSubstring(), GetSubstring(),
OEMCrypto_ContentLicense);
s.session_id(), reinterpret_cast<const uint8_t*>(double_message.data()),
s.message_size(), &s.signature()[0], s.signature().size(),
s.enc_mac_keys_iv_substr(), s.enc_mac_keys_substr(), s.num_keys(),
s.key_array(), GetSubstring(), GetSubstring(), OEMCrypto_ContentLicense);
ASSERT_NE(OEMCrypto_SUCCESS, sts);
}
@@ -1327,13 +1327,12 @@ TEST_F(OEMCryptoSessionTests, LoadKeyNoKeys) {
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(kDuration, 0, 42));
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
int kNoKeys = 0;
ASSERT_NE(
OEMCrypto_SUCCESS,
OEMCrypto_LoadKeys(s.session_id(), s.message_ptr(), s.message_size(),
&s.signature()[0], s.signature().size(),
s.enc_mac_keys_iv_substr(), s.enc_mac_keys_substr(),
kNoKeys, s.key_array(), GetSubstring(), GetSubstring(),
OEMCrypto_ContentLicense));
ASSERT_NE(OEMCrypto_SUCCESS,
OEMCrypto_LoadKeys(
s.session_id(), s.message_ptr(), s.message_size(),
&s.signature()[0], s.signature().size(), GetSubstring(),
GetSubstring(), kNoKeys, s.key_array(), GetSubstring(),
GetSubstring(), OEMCrypto_ContentLicense));
}
TEST_F(OEMCryptoSessionTests, LoadKeyNoKeyWithNonce) {
@@ -1344,13 +1343,12 @@ TEST_F(OEMCryptoSessionTests, LoadKeyNoKeyWithNonce) {
s.FillSimpleMessage(0, wvoec::kControlNonceEnabled, s.get_nonce()));
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
int kNoKeys = 0;
ASSERT_NE(
OEMCrypto_SUCCESS,
OEMCrypto_LoadKeys(s.session_id(), s.message_ptr(), s.message_size(),
&s.signature()[0], s.signature().size(),
s.enc_mac_keys_iv_substr(), s.enc_mac_keys_substr(),
kNoKeys, s.key_array(), GetSubstring(), GetSubstring(),
OEMCrypto_ContentLicense));
ASSERT_NE(OEMCrypto_SUCCESS,
OEMCrypto_LoadKeys(
s.session_id(), s.message_ptr(), s.message_size(),
&s.signature()[0], s.signature().size(), GetSubstring(),
GetSubstring(), kNoKeys, s.key_array(), GetSubstring(),
GetSubstring(), OEMCrypto_ContentLicense));
}
TEST_F(OEMCryptoSessionTests, SelectKeyNotThere) {
@@ -5310,13 +5308,17 @@ TEST_P(UsageTableTestWithMAC, BadRange) {
ASSERT_NO_FATAL_FAILURE(s.FillSimpleMessage(
0, wvoec::kControlNonceOrEntry, s.get_nonce(), pst));
ASSERT_NO_FATAL_FAILURE(s.EncryptAndSign());
std::string double_message = DuplicateMessage(s.encrypted_license());
OEMCrypto_Substring wrong_pst = s.pst_substr();
wrong_pst.offset += s.message_size();
ASSERT_NE(
OEMCrypto_SUCCESS,
OEMCrypto_LoadKeys(s.session_id(), s.message_ptr(), s.message_size(),
&s.signature()[0], s.signature().size(),
s.enc_mac_keys_iv_substr(), s.enc_mac_keys_substr(),
s.num_keys(), s.key_array(), s.pst_substr(),
GetSubstring(), OEMCrypto_ContentLicense));
OEMCrypto_LoadKeys(
s.session_id(),
reinterpret_cast<const uint8_t*>(double_message.data()),
s.message_size(), &s.signature()[0], s.signature().size(),
s.enc_mac_keys_iv_substr(), s.enc_mac_keys_substr(), s.num_keys(),
s.key_array(), wrong_pst, GetSubstring(), OEMCrypto_ContentLicense));
}
TEST_F(UsageTableTest, UpdateFailsWithNullPtr) {