Regular sync.

Changes include:
1. Fix refreshkeys when handling renewal response.
2. Change ECM start detect method.
3. Fix signing key truncation.
4. Reformat C++ code.
5. Return license_id in LICENSE_CAS_READY payload.
6. Expose OEMCrypto API version in the license request.
7. Add support for newly added widevine cas ids.
8. Store content iv and encryption mode info to entitled key.
9. Upgrade ODK library to 16.4.
This commit is contained in:
huihli
2020-10-21 11:16:23 -07:00
parent 0f6db6f751
commit 2feec02df2
39 changed files with 703 additions and 546 deletions

View File

@@ -11,6 +11,7 @@
#include "cas_util.h"
#include "log.h"
static const uint32_t kExpectedOEMCryptoVersion = 16;
namespace wvcas {
@@ -53,11 +54,11 @@ void FillEntitledContentKeyObjectFromKeyData(
if (nullptr == dest) {
return;
}
std::string entitlement_key_id
(src.entitlement_key_id.begin(), src.entitlement_key_id.end());
std::string entitlement_key_id(src.entitlement_key_id.begin(),
src.entitlement_key_id.end());
std::string content_key_id(src.key_id.begin(), src.key_id.end());
std::string
content_key_data_iv(src.wrapped_key_iv.begin(), src.wrapped_key_iv.end());
std::string content_key_data_iv(src.wrapped_key_iv.begin(),
src.wrapped_key_iv.end());
std::string content_key_data(src.wrapped_key.begin(), src.wrapped_key.end());
std::string content_iv(src.content_iv.begin(), src.content_iv.end());
@@ -392,6 +393,12 @@ OEMCryptoResult CryptoInterface::OEMCrypto_RemoveEntitledKeySession(
});
}
uint32_t CryptoInterface::OEMCrypto_APIVersion() {
return lock_->WithOecReadLock("APIVersion", [&] {
return oemcrypto_interface_->OEMCrypto_APIVersion();
});
}
OEMCryptoResult CryptoInterface::create_internal(
OEMCryptoInterface* oemcrypto_interface,
std::unique_ptr<CryptoInterface>* init) {
@@ -438,9 +445,8 @@ CryptoInterface::~CryptoInterface() {
lock_->WithStaticFieldWriteLock("Terminate", [&] {
if (session_count_ > 0) {
if (--session_count_ == 0) {
lock_->WithOecWriteLock("Terminate", [&] {
oemcrypto_interface_->OEMCrypto_Terminate();
});
lock_->WithOecWriteLock(
"Terminate", [&] { oemcrypto_interface_->OEMCrypto_Terminate(); });
}
}
});
@@ -1087,6 +1093,8 @@ CasStatus CryptoSession::RefreshKeys(const std::string& message,
if (!key.key_control().empty()) {
key_object.key_control_iv.offset =
GetOffset(message, key.key_control_iv());
key_object.key_control_iv.length = key.key_control_iv().length();
key_object.key_control.offset = GetOffset(message, key.key_control());
key_object.key_control.length = key.key_control().length();
}
}
@@ -1180,4 +1188,23 @@ CasStatus CryptoSession::RemoveEntitledKeySession(
return CasStatus::OkStatus();
}
CasStatus CryptoSession::APIVersion(uint32_t* api_version) {
if (!crypto_interface_) {
return CasStatus(CasStatusCode::kCryptoSessionError,
"missing crypto interface");
}
uint32_t oemcrypto_api_version = crypto_interface_->OEMCrypto_APIVersion();
if (oemcrypto_api_version != kExpectedOEMCryptoVersion) {
std::ostringstream err_string;
err_string << "OEMCrypto_APIVersion returned: " << oemcrypto_api_version
<< ". While the correct API version should be: "
<< kExpectedOEMCryptoVersion;
return CasStatus(CasStatusCode::kOEMCryptoVersionMismatch,
err_string.str());
}
*api_version = oemcrypto_api_version;
return CasStatus::OkStatus();
}
} // namespace wvcas