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:
@@ -13,10 +13,12 @@ namespace wvcdm {
|
||||
|
||||
class ContentKeySession : public KeySession {
|
||||
public:
|
||||
ContentKeySession(CryptoSessionId oec_session_id,
|
||||
ContentKeySession(RequestedSecurityLevel security_level,
|
||||
CryptoSessionId oec_session_id,
|
||||
metrics::CryptoMetrics* metrics)
|
||||
: KeySession(metrics),
|
||||
oec_session_id_(oec_session_id),
|
||||
security_level_(security_level),
|
||||
cipher_mode_(kCipherModeCtr) {}
|
||||
~ContentKeySession() override {}
|
||||
|
||||
@@ -52,6 +54,24 @@ class ContentKeySession : public KeySession {
|
||||
const OEMCrypto_SampleDescription* samples, size_t samples_length,
|
||||
const OEMCrypto_CENCEncryptPatternDesc& pattern) override;
|
||||
|
||||
OEMCryptoResult GenericEncrypt(const std::string& in_buffer,
|
||||
const std::string& iv,
|
||||
OEMCrypto_Algorithm algorithm,
|
||||
std::string* out_buffer) override;
|
||||
|
||||
OEMCryptoResult GenericDecrypt(const std::string& in_buffer,
|
||||
const std::string& iv,
|
||||
OEMCrypto_Algorithm algorithm,
|
||||
std::string* out_buffer) override;
|
||||
|
||||
OEMCryptoResult GenericSign(const std::string& message,
|
||||
OEMCrypto_Algorithm algorithm,
|
||||
std::string* signature) override;
|
||||
|
||||
OEMCryptoResult GenericVerify(const std::string& message,
|
||||
OEMCrypto_Algorithm algorithm,
|
||||
const std::string& signature) override;
|
||||
|
||||
protected:
|
||||
virtual OEMCryptoResult LoadKeysAsLicenseType(
|
||||
const std::string& message, const std::string& signature,
|
||||
@@ -60,11 +80,19 @@ class ContentKeySession : public KeySession {
|
||||
const std::string& provider_session_token,
|
||||
const std::string& srm_requirement, OEMCrypto_LicenseType license_type);
|
||||
|
||||
OEMCryptoResult GetKeyHandle(CryptoSessionId session_id,
|
||||
const std::string& key_id,
|
||||
CdmCipherMode cipher_mode);
|
||||
|
||||
CryptoSessionId oec_session_id_;
|
||||
|
||||
private:
|
||||
RequestedSecurityLevel security_level_;
|
||||
|
||||
KeyId cached_key_id_;
|
||||
CdmCipherMode cipher_mode_;
|
||||
|
||||
std::vector<uint8_t> key_handle_;
|
||||
};
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -153,7 +153,8 @@ class CryptoSession {
|
||||
// License request/responses
|
||||
virtual CdmResponseType PrepareAndSignLicenseRequest(
|
||||
const std::string& message, std::string* core_message,
|
||||
std::string* signature);
|
||||
std::string* signature, bool& should_specify_algorithm,
|
||||
OEMCrypto_SignatureHashAlgorithm& algorithm);
|
||||
virtual CdmResponseType UseSecondaryKey(bool dual_key);
|
||||
// V16 licenses.
|
||||
virtual CdmResponseType LoadLicense(const std::string& signed_message,
|
||||
@@ -164,7 +165,8 @@ class CryptoSession {
|
||||
// Renewal request/responses
|
||||
virtual CdmResponseType PrepareAndSignRenewalRequest(
|
||||
const std::string& message, std::string* core_message,
|
||||
std::string* signature);
|
||||
std::string* signature, bool& should_specify_algorithm,
|
||||
OEMCrypto_SignatureHashAlgorithm& algorithm);
|
||||
// V16 licenses.
|
||||
virtual CdmResponseType LoadRenewal(const std::string& signed_message,
|
||||
const std::string& core_message,
|
||||
@@ -180,7 +182,8 @@ class CryptoSession {
|
||||
const std::string& session_key);
|
||||
virtual CdmResponseType PrepareAndSignProvisioningRequest(
|
||||
const std::string& message, std::string* core_message,
|
||||
std::string* signature);
|
||||
std::string* signature, bool& should_specify_algorithm,
|
||||
OEMCrypto_SignatureHashAlgorithm& algorithm);
|
||||
virtual CdmResponseType LoadProvisioning(const std::string& signed_message,
|
||||
const std::string& core_message,
|
||||
const std::string& signature,
|
||||
@@ -215,7 +218,6 @@ class CryptoSession {
|
||||
uint32_t* tier);
|
||||
|
||||
virtual bool GetSupportedCertificateTypes(SupportedCertificateTypes* support);
|
||||
virtual CdmResponseType GetRandom(size_t data_length, uint8_t* random_data);
|
||||
virtual CdmResponseType GetNumberOfOpenSessions(
|
||||
RequestedSecurityLevel security_level, size_t* count);
|
||||
virtual CdmResponseType GetMaxNumberOfSessions(
|
||||
|
||||
@@ -17,7 +17,8 @@ namespace wvcdm {
|
||||
|
||||
class EntitlementKeySession : public ContentKeySession {
|
||||
public:
|
||||
EntitlementKeySession(CryptoSessionId oec_session_id,
|
||||
EntitlementKeySession(RequestedSecurityLevel security_level,
|
||||
CryptoSessionId oec_session_id,
|
||||
metrics::CryptoMetrics* metrics);
|
||||
~EntitlementKeySession() override;
|
||||
|
||||
@@ -35,9 +36,6 @@ class EntitlementKeySession : public ContentKeySession {
|
||||
const std::vector<CryptoKey>& keys) override;
|
||||
OEMCryptoResult SelectKey(const std::string& key_id,
|
||||
CdmCipherMode cipher_mode) override;
|
||||
OEMCryptoResult Decrypt(
|
||||
const OEMCrypto_SampleDescription* samples, size_t samples_length,
|
||||
const OEMCrypto_CENCEncryptPatternDesc& pattern) override;
|
||||
|
||||
private:
|
||||
// The message is populated with the fields of the provided CryptoKey and the
|
||||
|
||||
@@ -40,6 +40,20 @@ class KeySession {
|
||||
virtual OEMCryptoResult Decrypt(
|
||||
const OEMCrypto_SampleDescription* samples, size_t samples_length,
|
||||
const OEMCrypto_CENCEncryptPatternDesc& pattern) = 0;
|
||||
virtual OEMCryptoResult GenericEncrypt(const std::string& in_buffer,
|
||||
const std::string& iv,
|
||||
OEMCrypto_Algorithm algorithm,
|
||||
std::string* out_buffer) = 0;
|
||||
virtual OEMCryptoResult GenericDecrypt(const std::string& in_buffer,
|
||||
const std::string& iv,
|
||||
OEMCrypto_Algorithm algorithm,
|
||||
std::string* out_buffer) = 0;
|
||||
virtual OEMCryptoResult GenericSign(const std::string& message,
|
||||
OEMCrypto_Algorithm algorithm,
|
||||
std::string* signature) = 0;
|
||||
virtual OEMCryptoResult GenericVerify(const std::string& message,
|
||||
OEMCrypto_Algorithm algorithm,
|
||||
const std::string& signature) = 0;
|
||||
|
||||
protected:
|
||||
metrics::CryptoMetrics* metrics_;
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// Copyright 2022 Google LLC. All Rights Reserved. This file and proprietary
|
||||
// source code may only be used and distributed under the Widevine License
|
||||
// Agreement.
|
||||
#ifndef WVCDM_CORE_LICENSE_PROTOCOL_CONVERSIONS_H_
|
||||
#define WVCDM_CORE_LICENSE_PROTOCOL_CONVERSIONS_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "OEMCryptoCENC.h"
|
||||
#include "license_protocol.pb.h"
|
||||
|
||||
namespace wvcdm {
|
||||
bool OecAlgorithmToProtoAlgorithm(
|
||||
OEMCrypto_SignatureHashAlgorithm oec_algorithm,
|
||||
video_widevine::HashAlgorithmProto& proto_algorithm);
|
||||
} // namespace wvcdm
|
||||
#endif // WVCDM_CORE_LICENSE_PROTOCOL_CONVERSIONS_H_
|
||||
@@ -73,94 +73,32 @@ OEMCryptoResult OEMCrypto_GetOEMPublicCertificate(uint8_t* public_cert,
|
||||
OEMCrypto_WatermarkingSupport OEMCrypto_GetWatermarkingSupport(
|
||||
RequestedSecurityLevel level);
|
||||
OEMCryptoResult OEMCrypto_ProductionReady(RequestedSecurityLevel level);
|
||||
|
||||
OEMCryptoResult OEMCrypto_DecryptCENC(
|
||||
RequestedSecurityLevel level, const uint8_t* key_handle,
|
||||
size_t key_handle_length, const OEMCrypto_SampleDescription* samples,
|
||||
size_t samples_length, const OEMCrypto_CENCEncryptPatternDesc* pattern);
|
||||
OEMCryptoResult OEMCrypto_Generic_Encrypt(
|
||||
RequestedSecurityLevel level, const uint8_t* key_handle,
|
||||
size_t key_handle_length, const OEMCrypto_SharedMemory* in_buffer,
|
||||
size_t in_buffer_length, const uint8_t* iv, OEMCrypto_Algorithm algorithm,
|
||||
OEMCrypto_SharedMemory* out_buffer);
|
||||
OEMCryptoResult OEMCrypto_Generic_Decrypt(
|
||||
RequestedSecurityLevel level, const uint8_t* key_handle,
|
||||
size_t key_handle_length, const OEMCrypto_SharedMemory* in_buffer,
|
||||
size_t in_buffer_length, const uint8_t* iv, OEMCrypto_Algorithm algorithm,
|
||||
OEMCrypto_SharedMemory* out_buffer);
|
||||
OEMCryptoResult OEMCrypto_Generic_Sign(
|
||||
RequestedSecurityLevel level, const uint8_t* key_handle,
|
||||
size_t key_handle_length, const OEMCrypto_SharedMemory* buffer,
|
||||
size_t buffer_length, OEMCrypto_Algorithm algorithm,
|
||||
OEMCrypto_SharedMemory* signature, size_t* signature_length);
|
||||
OEMCryptoResult OEMCrypto_Generic_Verify(
|
||||
RequestedSecurityLevel level, const uint8_t* key_handle,
|
||||
size_t key_handle_length, const OEMCrypto_SharedMemory* buffer,
|
||||
size_t buffer_length, OEMCrypto_Algorithm algorithm,
|
||||
const OEMCrypto_SharedMemory* signature, size_t signature_length);
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
/* The following functions are deprecated in OEMCrypto v13. They are defined
|
||||
* here so that core cdm code may be backwards compatible with an OEMCrypto
|
||||
* v12.
|
||||
*/
|
||||
extern "C" {
|
||||
|
||||
typedef struct { // Used for backwards compatibility.
|
||||
const uint8_t* key_id;
|
||||
size_t key_id_length;
|
||||
const uint8_t* key_data_iv;
|
||||
const uint8_t* key_data;
|
||||
size_t key_data_length;
|
||||
const uint8_t* key_control_iv;
|
||||
const uint8_t* key_control;
|
||||
} OEMCrypto_KeyObject_V10;
|
||||
|
||||
typedef struct { // Used for backwards compatibility.
|
||||
const uint8_t* key_id;
|
||||
size_t key_id_length;
|
||||
const uint8_t* key_data_iv;
|
||||
const uint8_t* key_data;
|
||||
size_t key_data_length;
|
||||
const uint8_t* key_control_iv;
|
||||
const uint8_t* key_control;
|
||||
OEMCryptoCipherMode cipher_mode;
|
||||
} OEMCrypto_KeyObject_V13;
|
||||
|
||||
typedef struct {
|
||||
const uint8_t* key_id;
|
||||
size_t key_id_length;
|
||||
const uint8_t* key_data_iv;
|
||||
const uint8_t* key_data;
|
||||
size_t key_data_length;
|
||||
const uint8_t* key_control_iv;
|
||||
const uint8_t* key_control;
|
||||
} OEMCrypto_KeyObject_V14;
|
||||
|
||||
// Backwards compatibility between v14 and v13.
|
||||
OEMCryptoResult OEMCrypto_LoadKeys_Back_Compat(
|
||||
OEMCrypto_SESSION session, const uint8_t* message, size_t message_length,
|
||||
const uint8_t* signature, size_t signature_length,
|
||||
OEMCrypto_Substring enc_mac_keys_iv, OEMCrypto_Substring enc_mac_keys,
|
||||
size_t num_keys, const OEMCrypto_KeyObject* key_array,
|
||||
OEMCrypto_Substring pst, OEMCrypto_Substring srm_restriction_data,
|
||||
OEMCrypto_LicenseType license_type, OEMCryptoCipherMode* cipher_modes);
|
||||
|
||||
OEMCryptoResult OEMCrypto_DeactivateUsageEntry_V12(const uint8_t* pst,
|
||||
size_t pst_length);
|
||||
typedef struct {
|
||||
const uint8_t* entitlement_key_id;
|
||||
size_t entitlement_key_id_length;
|
||||
const uint8_t* content_key_id;
|
||||
size_t content_key_id_length;
|
||||
const uint8_t* content_key_data_iv;
|
||||
const uint8_t* content_key_data;
|
||||
size_t content_key_data_length;
|
||||
} OEMCrypto_EntitledContentKeyObject_V14;
|
||||
|
||||
typedef struct {
|
||||
const uint8_t* key_id;
|
||||
size_t key_id_length;
|
||||
const uint8_t* key_control_iv;
|
||||
const uint8_t* key_control;
|
||||
} OEMCrypto_KeyRefreshObject_V14;
|
||||
|
||||
OEMCryptoResult OEMCrypto_LoadKeys_V14(
|
||||
OEMCrypto_SESSION session, const uint8_t* message, size_t message_length,
|
||||
const uint8_t* signature, size_t signature_length,
|
||||
const uint8_t* enc_mac_keys_iv, const uint8_t* enc_mac_keys,
|
||||
size_t num_keys, const OEMCrypto_KeyObject_V14* key_array,
|
||||
const uint8_t* pst, size_t pst_length, const uint8_t* srm_requirement,
|
||||
OEMCrypto_LicenseType license_type);
|
||||
|
||||
OEMCryptoResult OEMCrypto_LoadEntitledContentKeys_V14(
|
||||
OEMCrypto_SESSION session, size_t num_keys,
|
||||
const OEMCrypto_EntitledContentKeyObject_V14* key_array);
|
||||
|
||||
OEMCryptoResult OEMCrypto_RefreshKeys_V14(
|
||||
OEMCrypto_SESSION session, const uint8_t* message, size_t message_length,
|
||||
const uint8_t* signature, size_t signature_length, size_t num_keys,
|
||||
const OEMCrypto_KeyRefreshObject_V14* key_array);
|
||||
|
||||
OEMCryptoResult OEMCrypto_CopyBuffer_V14(
|
||||
const uint8_t* data_addr, size_t data_length,
|
||||
OEMCrypto_DestBufferDesc* out_buffer_descriptor, uint8_t subsample_flags);
|
||||
|
||||
} // extern "C"
|
||||
|
||||
#endif // WVCDM_CORE_OEMCRYPTO_ADAPTER_H_
|
||||
|
||||
@@ -51,6 +51,7 @@ constexpr uint32_t RESOURCE_RATING_TIER_MAX = RESOURCE_RATING_TIER_VERY_HIGH;
|
||||
|
||||
// OEMCrypto features by version
|
||||
constexpr uint32_t OEM_CRYPTO_API_VERSION_SUPPORTS_RESOURCE_RATING_TIER = 15;
|
||||
constexpr uint32_t OEM_CRYPTO_API_VERSION_SUPPORTS_PROV40_CORE_MESSAGE = 18;
|
||||
|
||||
constexpr char SESSION_ID_PREFIX[] = "sid";
|
||||
constexpr char ATSC_KEY_SET_ID_PREFIX[] = "atscksid";
|
||||
|
||||
@@ -444,8 +444,15 @@ enum CdmResponseEnum : int32_t {
|
||||
PROVISIONING_4_FAILED_TO_STORE_OEM_CERTIFICATE = 384,
|
||||
PROVISIONING_4_FAILED_TO_STORE_DRM_CERTIFICATE = 385,
|
||||
PROVISIONING_4_FAILED_TO_INITIALIZE_DEVICE_FILES_3 = 386,
|
||||
GET_SIGNATURE_HASH_ALGORITHM_ERROR_1 = 387,
|
||||
GET_SIGNATURE_HASH_ALGORITHM_ERROR_2 = 388,
|
||||
GET_SIGNATURE_HASH_ALGORITHM_ERROR_3 = 389,
|
||||
UNSUPPORTED_SIGNATURE_HASH_ALGORITHM_1 = 390,
|
||||
UNSUPPORTED_SIGNATURE_HASH_ALGORITHM_2 = 391,
|
||||
UNSUPPORTED_SIGNATURE_HASH_ALGORITHM_3 = 392,
|
||||
UNSUPPORTED_SIGNATURE_HASH_ALGORITHM_4 = 393,
|
||||
// Don't forget to add new values to
|
||||
// * core/test/test_printers.cpp.
|
||||
// * core/src/wv_cdm_types.cpp
|
||||
// * android/include/mapErrors-inl.h
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user