Pick widevine oemcrypto-v18 change
No-Typo-Check: From a third party header file Bug: 260918793 Test: unit tests Test: atp v2/widevine-eng/drm_compliance Change-Id: I36effd6a10a99bdb2399ab1f4a0fad026d607c70
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
#include <string>
|
||||
|
||||
#include "cdm_engine.h"
|
||||
#include "cdm_random.h"
|
||||
#include "clock.h"
|
||||
#include "crypto_wrapped_key.h"
|
||||
#include "file_store.h"
|
||||
@@ -306,10 +307,16 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
|
||||
std::string fake_message("empty message");
|
||||
std::string core_message;
|
||||
std::string license_request_signature;
|
||||
bool should_specify_algorithm;
|
||||
OEMCrypto_SignatureHashAlgorithm algorithm = OEMCrypto_SHA1;
|
||||
uint32_t nonce;
|
||||
// Sign a fake message so that OEMCrypto will start the rental clock. The
|
||||
// signature and generated core message are ignored.
|
||||
result = crypto_session_->GenerateNonce(&nonce);
|
||||
if (result != NO_ERROR) return result;
|
||||
result = crypto_session_->PrepareAndSignLicenseRequest(
|
||||
fake_message, &core_message, &license_request_signature);
|
||||
fake_message, &core_message, &license_request_signature,
|
||||
should_specify_algorithm, algorithm);
|
||||
if (result != NO_ERROR) return result;
|
||||
}
|
||||
|
||||
@@ -888,15 +895,14 @@ bool CdmSession::GenerateKeySetId(bool atsc_mode_enabled,
|
||||
CdmKeySetId* key_set_id) {
|
||||
RETURN_FALSE_IF_NULL(key_set_id);
|
||||
|
||||
std::vector<uint8_t> random_data(
|
||||
(kKeySetIdLength - sizeof(KEY_SET_ID_PREFIX)) / 2, 0);
|
||||
|
||||
while (key_set_id->empty()) {
|
||||
if (crypto_session_->GetRandom(random_data.size(), &random_data[0]) !=
|
||||
NO_ERROR) {
|
||||
constexpr size_t random_size =
|
||||
(kKeySetIdLength - sizeof(KEY_SET_ID_PREFIX)) / 2;
|
||||
std::string random_data = wvutil::CdmRandom::RandomData(random_size);
|
||||
if (random_data.size() != random_size) {
|
||||
LOGE("Error generating random id.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (atsc_mode_enabled)
|
||||
*key_set_id = ATSC_KEY_SET_ID_PREFIX + wvutil::b2a_hex(random_data);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user