Generate a unique license request ID
The request ID was set to a fixed value, which caused license requests to be rejected by the YT server with TOO_MANY_STREAMS_PER_VIDEO The request ID is now a combination of a randomly generated value and a rolling index. This is based off a fix by gmorgan@ on the eureka branch #98fa6e5e. Merge of https://widevine-internal-review.googlesource.com/#/c/8496/ from the widevine cdm repo. b/12018697 Change-Id: I6c05fea885d46aea53a07235c3e5ac65a6971eaf
This commit is contained in:
@@ -94,6 +94,9 @@ class CryptoSession {
|
|||||||
|
|
||||||
KeyId key_id_;
|
KeyId key_id_;
|
||||||
|
|
||||||
|
uint64_t request_id_base_;
|
||||||
|
static uint64_t request_id_index_;
|
||||||
|
|
||||||
CORE_DISALLOW_COPY_AND_ASSIGN(CryptoSession);
|
CORE_DISALLOW_COPY_AND_ASSIGN(CryptoSession);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -31,11 +31,13 @@ namespace wvcdm {
|
|||||||
Lock CryptoSession::crypto_lock_;
|
Lock CryptoSession::crypto_lock_;
|
||||||
bool CryptoSession::initialized_ = false;
|
bool CryptoSession::initialized_ = false;
|
||||||
int CryptoSession::session_count_ = 0;
|
int CryptoSession::session_count_ = 0;
|
||||||
|
uint64_t CryptoSession::request_id_index_ = 0;
|
||||||
|
|
||||||
CryptoSession::CryptoSession()
|
CryptoSession::CryptoSession()
|
||||||
: open_(false),
|
: open_(false),
|
||||||
is_destination_buffer_type_valid_(false),
|
is_destination_buffer_type_valid_(false),
|
||||||
requested_security_level_(kLevelDefault) {
|
requested_security_level_(kLevelDefault),
|
||||||
|
request_id_base_(0) {
|
||||||
Init();
|
Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -227,7 +229,12 @@ CdmResponseType CryptoSession::Open(SecurityLevel requested_security_level) {
|
|||||||
} else if (OEMCrypto_ERROR_TOO_MANY_SESSIONS == sts) {
|
} else if (OEMCrypto_ERROR_TOO_MANY_SESSIONS == sts) {
|
||||||
return INSUFFICIENT_CRYPTO_RESOURCES;
|
return INSUFFICIENT_CRYPTO_RESOURCES;
|
||||||
}
|
}
|
||||||
return open_ ? NO_ERROR : UNKNOWN_ERROR;
|
if (!open_) return UNKNOWN_ERROR;
|
||||||
|
|
||||||
|
OEMCrypto_GetRandom(reinterpret_cast<uint8_t*>(&request_id_base_),
|
||||||
|
sizeof(request_id_base_));
|
||||||
|
++request_id_index_;
|
||||||
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CryptoSession::Close() {
|
void CryptoSession::Close() {
|
||||||
@@ -243,8 +250,10 @@ void CryptoSession::Close() {
|
|||||||
void CryptoSession::GenerateRequestId(std::string& req_id_str) {
|
void CryptoSession::GenerateRequestId(std::string& req_id_str) {
|
||||||
LOGV("CryptoSession::GenerateRequestId: Lock");
|
LOGV("CryptoSession::GenerateRequestId: Lock");
|
||||||
AutoLock auto_lock(crypto_lock_);
|
AutoLock auto_lock(crypto_lock_);
|
||||||
// TODO(gmorgan): Get unique ID from OEMCrypto
|
req_id_str = HexEncode(reinterpret_cast<uint8_t*>(&request_id_base_),
|
||||||
req_id_str.assign("987654321");
|
sizeof(request_id_base_)) +
|
||||||
|
HexEncode(reinterpret_cast<uint8_t*>(&request_id_index_),
|
||||||
|
sizeof(request_id_index_));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CryptoSession::PrepareRequest(const std::string& message,
|
bool CryptoSession::PrepareRequest(const std::string& message,
|
||||||
@@ -275,8 +284,9 @@ bool CryptoSession::PrepareRenewalRequest(const std::string& message,
|
|||||||
AutoLock auto_lock(crypto_lock_);
|
AutoLock auto_lock(crypto_lock_);
|
||||||
|
|
||||||
if (!signature) {
|
if (!signature) {
|
||||||
LOGE("CryptoSession::PrepareRenewalRequest : No output destination "
|
LOGE(
|
||||||
"provided.");
|
"CryptoSession::PrepareRenewalRequest : No output destination "
|
||||||
|
"provided.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,8 +316,9 @@ void CryptoSession::GenerateMacContext(const std::string& input_context,
|
|||||||
void CryptoSession::GenerateEncryptContext(const std::string& input_context,
|
void CryptoSession::GenerateEncryptContext(const std::string& input_context,
|
||||||
std::string* deriv_context) {
|
std::string* deriv_context) {
|
||||||
if (!deriv_context) {
|
if (!deriv_context) {
|
||||||
LOGE("CryptoSession::GenerateEncryptContext : No output destination "
|
LOGE(
|
||||||
"provided.");
|
"CryptoSession::GenerateEncryptContext : No output destination "
|
||||||
|
"provided.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user