Adjust nonce for v15 servers am: 7f347cd59f am: 940a771969
Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/12173751 Change-Id: I67ed1d76737d81d039b603d85b18977845f20007
This commit is contained in:
committed by
Automerger Merge Worker
commit
08fe6b1690
@@ -176,6 +176,9 @@ class CdmLicense {
|
|||||||
// HandleKeyResponse
|
// HandleKeyResponse
|
||||||
VersionInfo latest_service_version_;
|
VersionInfo latest_service_version_;
|
||||||
|
|
||||||
|
// The nonce used in the original license request.
|
||||||
|
uint32_t license_nonce_;
|
||||||
|
|
||||||
#if defined(UNIT_TEST)
|
#if defined(UNIT_TEST)
|
||||||
friend class CdmLicenseTestPeer;
|
friend class CdmLicenseTestPeer;
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -237,6 +237,7 @@ bool CdmLicense::Init(const std::string& client_token,
|
|||||||
crypto_session_ = session;
|
crypto_session_ = session;
|
||||||
policy_engine_ = policy_engine;
|
policy_engine_ = policy_engine;
|
||||||
use_privacy_mode_ = use_privacy_mode;
|
use_privacy_mode_ = use_privacy_mode;
|
||||||
|
license_nonce_ = 0;
|
||||||
initialized_ = true;
|
initialized_ = true;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -313,8 +314,7 @@ CdmResponseType CdmLicense::PrepareKeyRequest(
|
|||||||
|
|
||||||
// Get/set the nonce. This value will be reflected in the Key Control Block
|
// Get/set the nonce. This value will be reflected in the Key Control Block
|
||||||
// of the license response.
|
// of the license response.
|
||||||
uint32_t nonce;
|
status = crypto_session_->GenerateNonce(&license_nonce_);
|
||||||
status = crypto_session_->GenerateNonce(&nonce);
|
|
||||||
|
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case NO_ERROR:
|
case NO_ERROR:
|
||||||
@@ -325,7 +325,7 @@ CdmResponseType CdmLicense::PrepareKeyRequest(
|
|||||||
default:
|
default:
|
||||||
return LICENSE_REQUEST_NONCE_GENERATION_ERROR;
|
return LICENSE_REQUEST_NONCE_GENERATION_ERROR;
|
||||||
}
|
}
|
||||||
license_request.set_key_control_nonce(nonce);
|
license_request.set_key_control_nonce(license_nonce_);
|
||||||
license_request.set_protocol_version(video_widevine::VERSION_2_1);
|
license_request.set_protocol_version(video_widevine::VERSION_2_1);
|
||||||
|
|
||||||
// License request is complete. Serialize it.
|
// License request is complete. Serialize it.
|
||||||
@@ -460,11 +460,11 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
|||||||
LOGW("Unknown API Version");
|
LOGW("Unknown API Version");
|
||||||
api_version = 15;
|
api_version = 15;
|
||||||
}
|
}
|
||||||
uint32_t nonce = 0;
|
|
||||||
if (api_version < 16) {
|
if (api_version < 16) {
|
||||||
// For a pre-v16 license, get/set the nonce. This value will be reflected
|
// For a pre-v16 license, get/set the nonce. This value will be reflected
|
||||||
// in the Key Control Block of the license response.
|
// in the Key Control Block of the license response.
|
||||||
const CdmResponseType status = crypto_session_->GenerateNonce(&nonce);
|
const CdmResponseType status =
|
||||||
|
crypto_session_->GenerateNonce(&license_nonce_);
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case NO_ERROR:
|
case NO_ERROR:
|
||||||
break;
|
break;
|
||||||
@@ -475,7 +475,7 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
|||||||
return LICENSE_RENEWAL_NONCE_GENERATION_ERROR;
|
return LICENSE_RENEWAL_NONCE_GENERATION_ERROR;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
license_request.set_key_control_nonce(nonce);
|
license_request.set_key_control_nonce(license_nonce_);
|
||||||
license_request.set_protocol_version(video_widevine::VERSION_2_1);
|
license_request.set_protocol_version(video_widevine::VERSION_2_1);
|
||||||
|
|
||||||
// License request is complete. Serialize it.
|
// License request is complete. Serialize it.
|
||||||
@@ -810,6 +810,13 @@ CdmResponseType CdmLicense::RestoreOfflineLicense(
|
|||||||
}
|
}
|
||||||
|
|
||||||
key_request_ = signed_request.msg();
|
key_request_ = signed_request.msg();
|
||||||
|
LicenseRequest original_license_request;
|
||||||
|
if (!original_license_request.ParseFromString(key_request_)) {
|
||||||
|
LOGW("Could not parse original request.");
|
||||||
|
} else {
|
||||||
|
license_nonce_ = original_license_request.key_control_nonce();
|
||||||
|
}
|
||||||
|
|
||||||
CdmResponseType sts = HandleKeyResponse(license_response);
|
CdmResponseType sts = HandleKeyResponse(license_response);
|
||||||
|
|
||||||
if (sts != KEY_ADDED) return sts;
|
if (sts != KEY_ADDED) return sts;
|
||||||
|
|||||||
Reference in New Issue
Block a user