Source release 18.5.0

This commit is contained in:
Matt Feddersen
2024-03-28 19:15:22 -07:00
parent b2c35151ad
commit 28ec8548c6
109 changed files with 3623 additions and 1012 deletions

View File

@@ -180,6 +180,11 @@ class CdmEngine {
virtual CdmResponseType QueryOemCryptoSessionId(
const CdmSessionId& session_id, CdmQueryMap* query_response);
// Query Signed CSR payload for Prov 4 device
virtual CdmResponseType QueryDeviceSignedCsrPayload(
const std::string& challenge, const std::string& device_info,
std::string* query_response);
// Generate and return a valid provisioning request.
virtual CdmResponseType GetProvisioningRequest(
CdmCertificateType cert_type, const std::string& cert_authority,

View File

@@ -265,6 +265,8 @@ class CdmSession {
bool HasRootOfTrustBeenRenewed();
CdmResponseType ResetCryptoSession();
// These setters are for testing only. Takes ownership of the pointers.
void set_license_parser(CdmLicense* license_parser);
void set_crypto_session(CryptoSession* crypto_session);
@@ -340,8 +342,9 @@ class CdmSession {
bool has_license_been_loaded_ = false;
bool has_license_been_restored_ = false;
bool mock_license_parser_in_use_;
bool mock_policy_engine_in_use_;
bool mock_crypto_session_in_use_ = false;
bool mock_license_parser_in_use_ = false;
bool mock_policy_engine_in_use_ = false;
CORE_DISALLOW_COPY_AND_ASSIGN(CdmSession);
};

View File

@@ -73,6 +73,9 @@ class CertificateProvisioning {
static void GetProvisioningServerUrl(std::string* default_url);
private:
#if defined(UNIT_TEST)
friend class CertificateProvisioningTest;
#endif
CdmResponseType GetProvisioningRequestInternal(
wvutil::FileSystem* file_system,
RequestedSecurityLevel requested_security_level,
@@ -82,7 +85,8 @@ class CertificateProvisioning {
CdmResponseType GetProvisioning40RequestInternal(
wvutil::FileSystem* file_system, const std::string& origin,
const std::string& spoid, CdmProvisioningRequest* request,
std::string* default_url);
std::string* default_url, CdmCertificateType cert_type,
const std::string& cert_authority);
CdmResponseType FillEncryptedClientId(
const std::string& client_token,
video_widevine::ProvisioningRequest& provisioning_request,
@@ -93,7 +97,14 @@ class CertificateProvisioning {
video_widevine::ProvisioningRequest& provisioning_request,
const ServiceCertificate& service_certificate);
CdmResponseType HandleProvisioning40Response(
wvutil::FileSystem* file_system, const std::string& response_message);
wvutil::FileSystem* file_system,
const video_widevine::SignedProvisioningMessage& signed_message,
std::string* cert, std::string* wrapped_key);
// Assign the cert type for provisioning request
// Required by Cast cert provisioning flow
CdmResponseType CertTypeAssign(
video_widevine::ProvisioningRequest& provisioning_request,
CdmCertificateType cert_type, const std::string& cert_authority);
CdmResponseType SetSpoidParameter(
const std::string& origin, const std::string& spoid,
@@ -120,6 +131,8 @@ class CertificateProvisioning {
std::string provisioning_40_wrapped_private_key_;
// Key type of the generated key pair in provisioning 4.
CryptoWrappedKey::Type provisioning_40_key_type_;
// Store the last provisioning request message
std::string provisioning_request_message_;
CORE_DISALLOW_COPY_AND_ASSIGN(CertificateProvisioning);
};

View File

@@ -50,9 +50,10 @@ class ContentKeySession : public KeySession {
CdmCipherMode cipher_mode) override;
// Decrypt for ContentKeySession
OEMCryptoResult Decrypt(
const OEMCrypto_SampleDescription* samples, size_t samples_length,
const OEMCrypto_CENCEncryptPatternDesc& pattern) override;
OEMCryptoResult Decrypt(const OEMCrypto_SampleDescription* samples,
size_t samples_length,
const OEMCrypto_CENCEncryptPatternDesc& pattern,
bool is_any_subsample_protected) override;
OEMCryptoResult GenericEncrypt(const std::string& in_buffer,
const std::string& iv,

View File

@@ -69,6 +69,8 @@ class CryptoSession {
static CryptoSession* MakeCryptoSession(
metrics::CryptoMetrics* crypto_metrics);
static const char* HdcpCapabilityToString(HdcpCapability hdcp_level);
virtual ~CryptoSession();
// This method will try to terminate OEMCrypto if |session_size_| is 0.
@@ -103,6 +105,9 @@ class CryptoSession {
// Only valid for OEM certificate-based based devices.
virtual CdmResponseType GetTokenFromOemCert(
RequestedSecurityLevel requested_security_level, std::string* oem_cert);
// Retrieves the embedded public certificate from OEMCrypto.
// Only valid for L3 devices with embedded (baked-in) certificates.
virtual CdmResponseType GetTokenFromEmbeddedCertificate(std::string* token);
// The overloaded methods with |requested_level| may be called
// without a preceding call to Open. The other method must call Open first.
@@ -194,6 +199,13 @@ class CryptoSession {
std::string* additional_signature);
virtual CdmResponseType GetBootCertificateChain(
std::string* bcc, std::string* additional_signature);
virtual CdmResponseType GetDeviceInformation(
RequestedSecurityLevel requested_security_level,
std::string* device_info);
virtual CdmResponseType GetDeviceSignedCsrPayload(
RequestedSecurityLevel requested_security_level,
const std::string& challenge, const std::string& device_info,
std::string* signed_csr_payload);
virtual CdmResponseType GenerateCertificateKeyPair(
std::string* public_key, std::string* public_key_signature,
std::string* wrapped_private_key, CryptoWrappedKey::Type* key_type);
@@ -411,18 +423,22 @@ class CryptoSession {
OEMCryptoResult DecryptMultipleSamples(
const std::vector<OEMCrypto_SampleDescription>& samples,
CdmCipherMode cipher_mode,
const OEMCrypto_CENCEncryptPatternDesc& pattern);
OEMCryptoResult DecryptSample(
const OEMCrypto_SampleDescription& sample, CdmCipherMode cipher_mode,
const OEMCrypto_CENCEncryptPatternDesc& pattern);
OEMCryptoResult LegacyDecrypt(
const OEMCrypto_SampleDescription& sample, CdmCipherMode cipher_mode,
const OEMCrypto_CENCEncryptPatternDesc& pattern);
const OEMCrypto_CENCEncryptPatternDesc& pattern,
bool is_any_subsample_protected);
OEMCryptoResult DecryptSample(const OEMCrypto_SampleDescription& sample,
CdmCipherMode cipher_mode,
const OEMCrypto_CENCEncryptPatternDesc& pattern,
bool is_any_subsample_protected);
OEMCryptoResult LegacyDecrypt(const OEMCrypto_SampleDescription& sample,
CdmCipherMode cipher_mode,
const OEMCrypto_CENCEncryptPatternDesc& pattern,
bool is_any_subsample_protected);
OEMCryptoResult LegacyCopyBufferInChunks(
const OEMCrypto_SampleDescription& sample, size_t max_chunk_size);
OEMCryptoResult LegacyDecryptInChunks(
const OEMCrypto_SampleDescription& sample, CdmCipherMode cipher_mode,
const OEMCrypto_CENCEncryptPatternDesc& pattern, size_t max_chunk_size);
const OEMCrypto_CENCEncryptPatternDesc& pattern, size_t max_chunk_size,
bool is_any_subsample_protected);
// These methods should be used to take the various CryptoSession mutexes in
// preference to taking the mutexes directly.
@@ -545,6 +561,9 @@ class CryptoSession {
// same error code in sequence of each other. A value of
// OEMCrypto_SUCCESS indicates that no error have yet occurred.
OEMCryptoResult last_decrypt_error_ = OEMCrypto_SUCCESS;
// Similar to |last_decrypt_error_|, but intended for calls to
// SelectKey().
OEMCryptoResult last_select_key_error_ = OEMCrypto_SUCCESS;
// In order to avoid creating a deadlock if instantiation needs to take any
// of the CryptoSession static mutexes, |factory_| is protected by its own

View File

@@ -39,7 +39,8 @@ class KeySession {
CdmCipherMode cipher_mode) = 0;
virtual OEMCryptoResult Decrypt(
const OEMCrypto_SampleDescription* samples, size_t samples_length,
const OEMCrypto_CENCEncryptPatternDesc& pattern) = 0;
const OEMCrypto_CENCEncryptPatternDesc& pattern,
bool is_any_subsample_protected) = 0;
virtual OEMCryptoResult GenericEncrypt(const std::string& in_buffer,
const std::string& iv,
OEMCrypto_Algorithm algorithm,

View File

@@ -90,6 +90,15 @@ class CdmLicense {
const CdmKeyResponse& license_response,
std::string* provider_session_token);
// Testing only. Caller retains ownership of pointers.
void set_crypto_session(CryptoSession* crypto_session) {
crypto_session_ = crypto_session;
}
void set_policy_engine(PolicyEngine* policy_engine) {
policy_engine_ = policy_engine;
}
private:
CdmResponseType HandleKeyErrorResponse(
const video_widevine::SignedMessage& signed_message);
@@ -129,8 +138,8 @@ class CdmLicense {
bool SetTypeAndId(CdmLicenseType license_type, const std::string& request_id,
T* content_id);
CryptoSession* crypto_session_;
PolicyEngine* policy_engine_;
CryptoSession* crypto_session_ = nullptr;
PolicyEngine* policy_engine_ = nullptr;
std::string server_url_;
std::string client_token_;
const CdmSessionId session_id_;

View File

@@ -161,6 +161,8 @@ class LicenseKeyStatus {
bool meets_security_level_constraints_ = true;
CdmKeyAllowedUsage allowed_usage_;
CryptoSession::HdcpCapability default_hdcp_level_ = HDCP_NONE;
CryptoSession::HdcpCapability last_reported_device_hdcp_level_ = HDCP_NONE;
CryptoSession::HdcpCapability last_reported_license_hdcp_level_ = HDCP_NONE;
ConstraintList constraints_;
CORE_DISALLOW_COPY_AND_ASSIGN(LicenseKeyStatus);

View File

@@ -106,6 +106,8 @@ class PolicyEngine {
virtual const LicenseIdentification& license_id() { return license_id_; }
WvCdmEventListener* event_listener() { return event_listener_; }
bool GetSecondsSinceStarted(int64_t* seconds_since_started);
bool GetSecondsSinceLastPlayed(int64_t* seconds_since_started);
@@ -131,6 +133,11 @@ class PolicyEngine {
return license_keys_->MeetsConstraints(key_id);
}
// Testing only. Caller retains ownership.
void set_crypto_session(CryptoSession* crypto_session) {
crypto_session_ = crypto_session;
}
private:
friend class PolicyEngineTest;
friend class PolicyEngineConstraintsTest;

View File

@@ -37,7 +37,7 @@ class AesCbcKey {
~AesCbcKey();
bool Init(const std::string& key);
bool Encrypt(const std::string& in, std::string* out, std::string* iv);
bool Encrypt(const std::string& in, const std::string& iv, std::string* out);
private:
std::string key_;

View File

@@ -124,6 +124,7 @@ static const std::string QUERY_KEY_PRODUCTION_READY = "ProductionReady";
// Internal query key. Should not be exposed to Android apps.
static const std::string QUERY_KEY_DEBUG_BOOT_CERTIFICATE_CHAIN =
"DebugBootCertificateChain";
static const std::string QUERY_KEY_DEVICE_INFORMATION = "DeviceInformation";
static const std::string QUERY_VALUE_TRUE = "True";
static const std::string QUERY_VALUE_FALSE = "False";
@@ -139,16 +140,16 @@ static const std::string QUERY_VALUE_SECURITY_LEVEL_UNKNOWN = "Unknown";
static const std::string QUERY_VALUE_SECURITY_LEVEL_DEFAULT = "Default";
static const std::string QUERY_VALUE_HDCP_NO_DIGITAL_OUTPUT = "Disconnected";
static const std::string QUERY_VALUE_HDCP_NONE = "Unprotected";
static const std::string QUERY_VALUE_HDCP_V1 = "HDCP-1.x";
static const std::string QUERY_VALUE_HDCP_V2_0 = "HDCP-2.0";
static const std::string QUERY_VALUE_HDCP_V2_1 = "HDCP-2.1";
static const std::string QUERY_VALUE_HDCP_V2_2 = "HDCP-2.2";
static const std::string QUERY_VALUE_HDCP_V2_3 = "HDCP-2.3";
static const std::string QUERY_VALUE_HDCP_V1_X = "HDCP-1.x";
static const std::string QUERY_VALUE_HDCP_V1_0 = "HDCP-1.0";
static const std::string QUERY_VALUE_HDCP_V1_1 = "HDCP-1.1";
static const std::string QUERY_VALUE_HDCP_V1_2 = "HDCP-1.2";
static const std::string QUERY_VALUE_HDCP_V1_3 = "HDCP-1.3";
static const std::string QUERY_VALUE_HDCP_V1_4 = "HDCP-1.4";
static const std::string QUERY_VALUE_HDCP_V2_0 = "HDCP-2.0";
static const std::string QUERY_VALUE_HDCP_V2_1 = "HDCP-2.1";
static const std::string QUERY_VALUE_HDCP_V2_2 = "HDCP-2.2";
static const std::string QUERY_VALUE_HDCP_V2_3 = "HDCP-2.3";
static const std::string QUERY_VALUE_HDCP_LEVEL_UNKNOWN = "HDCP-LevelUnknown";
static const std::string QUERY_VALUE_DRM_CERTIFICATE = "DrmCertificate";
static const std::string QUERY_VALUE_KEYBOX = "Keybox";

View File

@@ -461,6 +461,9 @@ enum CdmResponseEnum : int32_t {
STORE_ATSC_LICENSE_ERROR = 395,
SESSION_NOT_FOUND_GENERIC_CRYPTO = 396,
SESSION_NOT_FOUND_24 = 397,
GET_DEVICE_INFORMATION_ERROR = 398,
GET_DEVICE_SIGNED_CSR_PAYLOAD_ERROR = 399,
GET_TOKEN_FROM_EMBEDDED_CERT_ERROR = 400,
// Don't forget to add new values to
// * core/src/wv_cdm_types.cpp
// * android/include/mapErrors-inl.h
@@ -604,6 +607,9 @@ enum CdmClientTokenType : int32_t {
kClientTokenOemCert,
kClientTokenUninitialized,
kClientTokenBootCertChain,
// For use by internal L3 CDMs supporting individualization of embedded
// drm certificates.
kClientTokenDrmCertificateReprovisioning,
};
// kNonSecureUsageSupport - TEE does not provide any support for usage
@@ -942,6 +948,8 @@ const char* IdToString(const std::string& id);
// provided as string pointers.
const char* IdPtrToString(const std::string* id);
const char* BoolToString(bool value);
// Logging utilities for OEMCrypto types.
const char* OemCryptoResultToString(OEMCryptoResult result);
} // namespace wvcdm