CDM workarounds for OEMCrypto issues
Merge of https://widevine-internal-review.googlesource.com/#/c/10614/ from the widevine cdm repo. * b/15467844 - GenerateRSASignature returns OEMCrypto_ERROR_INVALID_CONTEXT when called with a non-NULL signature pointer and signature length of 0 (rather than OEMCrypto_ERROR_SHORT_BUFFER) * b/15989260 - OEMCrypto_DecryptCTR does not return OEMCrypto_ERROR_KEY_EXPIRED after keys have expired Also addresses * integration test updated to reflect that loading certificate errors are returned on OpenSession rather than GenerateKeyRequest * compiler warning on type casting b/15989261 Change-Id: Ib68b972651479e99b9d05de4493aac55a96c4f39
This commit is contained in:
@@ -57,6 +57,9 @@ class PolicyEngine {
|
||||
|
||||
virtual const LicenseIdentification& license_id() { return license_id_; }
|
||||
|
||||
bool IsLicenseDurationExpired(int64_t current_time);
|
||||
bool IsPlaybackDurationExpired(int64_t current_time);
|
||||
|
||||
private:
|
||||
typedef enum {
|
||||
kLicenseStateInitial,
|
||||
@@ -68,9 +71,7 @@ class PolicyEngine {
|
||||
|
||||
void Init(Clock* clock);
|
||||
|
||||
bool IsLicenseDurationExpired(int64_t current_time);
|
||||
int64_t GetLicenseDurationRemaining(int64_t current_time);
|
||||
bool IsPlaybackDurationExpired(int64_t current_time);
|
||||
int64_t GetPlaybackDurationRemaining(int64_t current_time);
|
||||
|
||||
bool IsRenewalDelayExpired(int64_t current_time);
|
||||
|
||||
@@ -278,15 +278,25 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) {
|
||||
|
||||
CdmResponseType status = crypto_session_->Decrypt(params);
|
||||
|
||||
if (NO_ERROR == status) {
|
||||
if (is_initial_decryption_) {
|
||||
policy_engine_.BeginDecryption();
|
||||
is_initial_decryption_ = false;
|
||||
}
|
||||
if (!is_usage_update_needed_) {
|
||||
is_usage_update_needed_ =
|
||||
!license_parser_.provider_session_token().empty();
|
||||
}
|
||||
switch (status) {
|
||||
case NO_ERROR:
|
||||
if (is_initial_decryption_) {
|
||||
policy_engine_.BeginDecryption();
|
||||
is_initial_decryption_ = false;
|
||||
}
|
||||
if (!is_usage_update_needed_) {
|
||||
is_usage_update_needed_ =
|
||||
!license_parser_.provider_session_token().empty();
|
||||
}
|
||||
break;
|
||||
case UNKNOWN_ERROR:
|
||||
Clock clock;
|
||||
int64_t current_time = clock.GetCurrentTime();
|
||||
if (policy_engine_.IsLicenseDurationExpired(current_time) ||
|
||||
policy_engine_.IsPlaybackDurationExpired(current_time)) {
|
||||
return NEED_KEY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return status;
|
||||
|
||||
@@ -24,6 +24,7 @@ std::string EncodeUint32(unsigned int u) {
|
||||
s.append(1, (u >> 0) & 0xFF);
|
||||
return s;
|
||||
}
|
||||
const uint32_t kRsaSignatureLength = 256;
|
||||
}
|
||||
|
||||
namespace wvcdm {
|
||||
@@ -570,6 +571,7 @@ bool CryptoSession::GenerateRsaSignature(const std::string& message,
|
||||
LOGV("GenerateRsaSignature: id=%ld", (uint32_t)oec_session_id_);
|
||||
if (!signature) return false;
|
||||
|
||||
signature->resize(kRsaSignatureLength);
|
||||
size_t length = signature->size();
|
||||
OEMCryptoResult sts = OEMCrypto_GenerateRSASignature(
|
||||
oec_session_id_, reinterpret_cast<const uint8_t*>(message.data()),
|
||||
|
||||
Reference in New Issue
Block a user