Assorted Key Session Code Cleanup
Merge from Widevine repo of http://go/wvgerrit/53202 and Merge from Widevine repo of http://go/wvgerrit/53624 This change contains a variety of small tweaks to the ContentKeySession and EntitlementKeySession classes that were discovered while fixing b/78652567. There should be no change in behavior from this patch. The fixes are: 1) Added missing headers and removed unnecessary headers. 2) Removed the unused keys_ member from EntitlementKeySession. 3) Renamed ContentKeySession's protected member function so that it is not an overload of the public LoadKeys() function. This makes it clearer what EntitlementKeySession::LoadKeys() is doing. 4) Added missing "virtual" and "OVERRIDE" keywords. 5) Added missing copyright headers. 6) Ran clang-format with Google style. 7) Correct missing OVERRIDE keywords. Test: tested as part of http://go/ag/4674759 Change-Id: Icb0af886d7d3eb097b5dffbb716be6ac28f0916d
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
|
||||
#include "content_key_session.h"
|
||||
#include "crypto_key.h"
|
||||
#include "crypto_session.h"
|
||||
@@ -65,9 +69,9 @@ OEMCryptoResult ContentKeySession::LoadKeys(
|
||||
const std::vector<CryptoKey>& keys,
|
||||
const std::string& provider_session_token, CdmCipherMode* cipher_mode,
|
||||
const std::string& srm_requirement) {
|
||||
return LoadKeys(message, signature, mac_key_iv, mac_key, keys,
|
||||
provider_session_token, cipher_mode, srm_requirement,
|
||||
OEMCrypto_ContentLicense);
|
||||
return LoadKeysAsLicenseType(message, signature, mac_key_iv, mac_key, keys,
|
||||
provider_session_token, cipher_mode,
|
||||
srm_requirement, OEMCrypto_ContentLicense);
|
||||
}
|
||||
|
||||
// Select Key for ContentKeySession
|
||||
@@ -87,9 +91,9 @@ OEMCryptoResult ContentKeySession::SelectKey(const std::string& key_id,
|
||||
reinterpret_cast<const uint8_t*>(cached_key_id_.data());
|
||||
|
||||
OEMCryptoResult sts;
|
||||
M_TIME(sts = OEMCrypto_SelectKey(
|
||||
oec_session_id_, key_id_string, cached_key_id_.size(),
|
||||
ToOEMCryptoCipherMode(cipher_mode)),
|
||||
M_TIME(sts = OEMCrypto_SelectKey(oec_session_id_, key_id_string,
|
||||
cached_key_id_.size(),
|
||||
ToOEMCryptoCipherMode(cipher_mode)),
|
||||
metrics_, oemcrypto_select_key_, sts);
|
||||
|
||||
if (OEMCrypto_SUCCESS != sts) {
|
||||
@@ -113,7 +117,7 @@ OEMCryptoResult ContentKeySession::Decrypt(
|
||||
return sts;
|
||||
}
|
||||
|
||||
OEMCryptoResult ContentKeySession::LoadKeys(
|
||||
OEMCryptoResult ContentKeySession::LoadKeysAsLicenseType(
|
||||
const std::string& message, const std::string& signature,
|
||||
const std::string& mac_key_iv, const std::string& mac_key,
|
||||
const std::vector<CryptoKey>& keys,
|
||||
@@ -127,7 +131,7 @@ OEMCryptoResult ContentKeySession::LoadKeys(
|
||||
enc_mac_key = msg + GetOffset(message, mac_key);
|
||||
enc_mac_key_iv = msg + GetOffset(message, mac_key_iv);
|
||||
} else {
|
||||
LOGV("ContentKeySession::LoadKeys: enc_mac_key not set");
|
||||
LOGV("enc_mac_key not set");
|
||||
}
|
||||
std::vector<OEMCrypto_KeyObject_V13> load_keys(keys.size());
|
||||
for (size_t i = 0; i < keys.size(); ++i) {
|
||||
@@ -164,7 +168,7 @@ OEMCryptoResult ContentKeySession::LoadKeys(
|
||||
srm_req = const_cast<uint8_t*>(msg) + GetOffset(message, srm_requirement);
|
||||
}
|
||||
|
||||
LOGV("LoadKeys: id=%ld", (uint32_t)oec_session_id_);
|
||||
LOGV("id=%ld", (uint32_t)oec_session_id_);
|
||||
OEMCryptoResult sts;
|
||||
M_TIME(
|
||||
sts = ::OEMCrypto_LoadKeys_Back_Compat(
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine Master
|
||||
// License Agreement.
|
||||
|
||||
#include "entitlement_key_session.h"
|
||||
|
||||
#include "crypto_key.h"
|
||||
@@ -13,8 +17,9 @@ OEMCryptoResult EntitlementKeySession::LoadKeys(
|
||||
const std::vector<CryptoKey>& keys,
|
||||
const std::string& provider_session_token, CdmCipherMode* cipher_mode,
|
||||
const std::string& srm_requirement) {
|
||||
keys_.resize(keys.size());
|
||||
return ContentKeySession::LoadKeys(
|
||||
// Call our superclass's LoadKeysAsLicenseType(), but set the license type to
|
||||
// OEMCrypto_EntitlementLicense.
|
||||
return ContentKeySession::LoadKeysAsLicenseType(
|
||||
message, signature, mac_key_iv, mac_key, keys, provider_session_token,
|
||||
cipher_mode, srm_requirement, OEMCrypto_EntitlementLicense);
|
||||
}
|
||||
@@ -51,4 +56,4 @@ OEMCryptoResult EntitlementKeySession::LoadEntitledContentKeys(
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
} // namespace wvcdm
|
||||
|
||||
Reference in New Issue
Block a user