Merge "Removing Non-HIDL Widevine DRM Plugin for Android"

This commit is contained in:
TreeHugger Robot
2021-11-11 22:56:30 +00:00
committed by Android (Google) Code Review
27 changed files with 2 additions and 5634 deletions

View File

@@ -96,7 +96,7 @@ cc_defaults {
relative_install_path: "hw",
include_dirs: [
"vendor/widevine/libwvdrmengine/include_hidl",
"vendor/widevine/libwvdrmengine/mediadrm/include",
"vendor/widevine/libwvdrmengine/mediadrm/include_hidl",
"vendor/widevine/libwvdrmengine/oemcrypto/include",
],
header_libs: ["libstagefright_foundation_headers"],
@@ -274,68 +274,6 @@ cc_library_static {
}
// ----------------------------------------------------------------------------
// Builds libwvdrmengine.so
//
cc_library_shared {
name: "libwvdrmengine",
srcs: [
"src/WVCDMSingleton.cpp",
"src/WVCreatePluginFactories.cpp",
"src/WVCryptoFactory.cpp",
"src/WVDrmFactory.cpp",
"src/WVUUID.cpp",
],
include_dirs: [
"frameworks/av/include",
"frameworks/native/include",
"vendor/widevine/libwvdrmengine/cdm/core/include",
"vendor/widevine/libwvdrmengine/cdm/metrics/include",
"vendor/widevine/libwvdrmengine/cdm/util/include",
"vendor/widevine/libwvdrmengine/cdm/include",
"vendor/widevine/libwvdrmengine/include",
"vendor/widevine/libwvdrmengine/mediacrypto/include",
"vendor/widevine/libwvdrmengine/mediadrm/include",
"vendor/widevine/libwvdrmengine/oemcrypto/include",
],
static_libs: [
"libcdm",
"libcdm_protos",
"libcdm_utils",
"libjsmn",
"libwvdrmcryptoplugin",
"libwvdrmdrmplugin",
"libwvlevel3",
"libwv_odk",
],
shared_libs: [
"libbase",
"libcrypto",
"libdl",
"libhidlbase",
"liblog",
"libprotobuf-cpp-lite",
"libstagefright_foundation",
"libutils",
],
header_libs: [
"libutils_headers",
"libstagefright_headers",
],
relative_install_path: "mediadrm",
owner: "widevine",
proprietary: true,
}
// ----------------------------------------------------------------------------
// Builds libwvhidl.so
//
@@ -361,9 +299,7 @@ cc_library_shared {
"vendor/widevine/libwvdrmengine/include_hidl",
"vendor/widevine/libwvdrmengine/include",
"vendor/widevine/libwvdrmengine/mediacrypto/include_hidl",
"vendor/widevine/libwvdrmengine/mediacrypto/include",
"vendor/widevine/libwvdrmengine/mediadrm/include_hidl",
"vendor/widevine/libwvdrmengine/mediadrm/include",
"vendor/widevine/libwvdrmengine/oemcrypto/include",
],

View File

@@ -50,11 +50,8 @@ WV_TEST_TARGETS="base64_test \
initialization_data_unittest \
keybox_ota_test \
libwvdrmdrmplugin_hidl_test \
libwvdrmdrmplugin_test \
libwvdrmengine_hidl_test \
libwvdrmengine_test \
libwvdrmmediacrypto_hidl_test \
libwvdrmmediacrypto_test \
license_keys_unittest \
license_unittest \
metrics_collections_unittest \

View File

@@ -1,18 +0,0 @@
//
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
#ifndef WV_CREATE_PLUGIN_FACTORIES_H_
#define WV_CREATE_PLUGIN_FACTORIES_H_
#include "media/drm/DrmAPI.h"
#include "media/hardware/CryptoAPI.h"
extern "C" {
android::DrmFactory* createDrmFactory();
android::CryptoFactory* createCryptoFactory();
}
#endif // WV_CREATE_PLUGIN_FACTORIES_H_

View File

@@ -1,33 +0,0 @@
//
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
#ifndef WV_CRYPTO_FACTORY_H_
#define WV_CRYPTO_FACTORY_H_
#include "media/hardware/CryptoAPI.h"
#include "media/stagefright/foundation/ABase.h"
#include "utils/Errors.h"
namespace wvdrm {
class WVCryptoFactory : public android::CryptoFactory {
public:
WVCryptoFactory() {}
virtual ~WVCryptoFactory() {}
virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]) const;
virtual android::status_t createPlugin(const uint8_t uuid[16],
const void* data, size_t size,
android::CryptoPlugin** plugin);
private:
DISALLOW_EVIL_CONSTRUCTORS(WVCryptoFactory);
};
} // namespace wvdrm
#endif // WV_CRYPTO_FACTORY_H_

View File

@@ -1,37 +0,0 @@
//
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
#ifndef WV_DRM_FACTORY_H_
#define WV_DRM_FACTORY_H_
#include "media/drm/DrmAPI.h"
#include "media/stagefright/foundation/ABase.h"
#include "utils/Errors.h"
#include "WVGenericCryptoInterface.h"
namespace wvdrm {
class WVDrmFactory : public android::DrmFactory {
public:
WVDrmFactory() {}
virtual ~WVDrmFactory() {}
virtual bool isCryptoSchemeSupported(const uint8_t uuid[16]);
virtual bool isContentTypeSupported(const android::String8 &initDataType);
virtual android::status_t createDrmPlugin(const uint8_t uuid[16],
android::DrmPlugin** plugin);
private:
DISALLOW_EVIL_CONSTRUCTORS(WVDrmFactory);
static WVGenericCryptoInterface sOemCryptoInterface;
};
} // namespace wvdrm
#endif // WV_DRM_FACTORY_H_

View File

@@ -1,630 +0,0 @@
//
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
#ifndef WV_MAP_ERRORS_H_
#define WV_MAP_ERRORS_H_
#include "media/stagefright/MediaErrors.h"
#include "utils/Errors.h"
#include "wv_cdm_types.h"
#include "WVErrors.h"
namespace wvdrm {
static android::status_t mapCdmResponseType(wvcdm::CdmResponseType res) {
switch (res) {
// Android return codes.
// This first group is for "android::OK".
case wvcdm::NO_ERROR:
case wvcdm::KEY_ADDED:
case wvcdm::KEY_MESSAGE:
case wvcdm::KEY_CANCELED:
// KEY_ADDED, KEY_MESSAGE, and KEY_CANCELLED are all alternative
// success messages for certain CDM methods instead of NO_ERROR.
return android::OK;
// The remaining android::* are alphabetically ordered based on the first
// case condition in the group.
case wvcdm::ANALOG_OUTPUT_ERROR:
case wvcdm::INSUFFICIENT_OUTPUT_PROTECTION:
case wvcdm::KEY_PROHIBITED_FOR_SECURITY_LEVEL:
return android::ERROR_DRM_INSUFFICIENT_OUTPUT_PROTECTION;
case wvcdm::DECRYPT_ERROR:
case wvcdm::SECURE_BUFFER_REQUIRED:
return android::ERROR_DRM_CANNOT_HANDLE;
case wvcdm::DECRYPT_NOT_READY:
case wvcdm::KEY_NOT_FOUND_IN_SESSION:
case wvcdm::NEED_KEY:
case wvcdm::NO_MATCHING_ENTITLEMENT_KEY:
case wvcdm::NO_CONTENT_KEY_3:
return android::ERROR_DRM_NO_LICENSE;
case wvcdm::DEVICE_REVOKED:
return android::ERROR_DRM_DEVICE_REVOKED;
case wvcdm::INSUFFICIENT_CRYPTO_RESOURCES:
return android::ERROR_DRM_RESOURCE_BUSY;
case wvcdm::NEED_PROVISIONING:
return android::ERROR_DRM_NOT_PROVISIONED;
case wvcdm::RELEASE_USAGE_INFO_FAILED:
case wvcdm::RELEASE_USAGE_INFO_ERROR:
return android::ERROR_DRM_TAMPER_DETECTED;
case wvcdm::SESSION_NOT_FOUND_1:
case wvcdm::SESSION_NOT_FOUND_2:
case wvcdm::SESSION_NOT_FOUND_3:
case wvcdm::SESSION_NOT_FOUND_4:
case wvcdm::SESSION_NOT_FOUND_5:
case wvcdm::SESSION_NOT_FOUND_6:
case wvcdm::SESSION_NOT_FOUND_7:
case wvcdm::SESSION_NOT_FOUND_8:
case wvcdm::SESSION_NOT_FOUND_9:
case wvcdm::SESSION_NOT_FOUND_10:
case wvcdm::SESSION_NOT_FOUND_18:
case wvcdm::SESSION_NOT_FOUND_19:
case wvcdm::SESSION_NOT_FOUND_20:
case wvcdm::SESSION_NOT_FOUND_21:
case wvcdm::SESSION_NOT_FOUND_22:
case wvcdm::SESSION_NOT_FOUND_23:
case wvcdm::SESSION_NOT_FOUND_FOR_DECRYPT:
return android::ERROR_DRM_SESSION_NOT_OPENED;
case wvcdm::UNKNOWN_ERROR:
return android::ERROR_DRM_UNKNOWN;
// WV return codes.
// Alphabetically ordered based on the case condition.
case wvcdm::ADD_KEY_ERROR:
return kAddKeyError;
case wvcdm::CANNOT_DECRYPT_ZERO_SAMPLES:
return kCannotDecryptZeroSamples;
case wvcdm::CANNOT_DECRYPT_ZERO_SUBSAMPLES:
return kCannotDecryptZeroSubsamples;
case wvcdm::CENC_INIT_DATA_UNAVAILABLE:
return kCencInitDataUnavailable;
case wvcdm::CERT_PROVISIONING_EMPTY_SERVICE_CERTIFICATE:
return kCertProvisioningEmptyServiceCertificate;
case wvcdm::CERT_PROVISIONING_GET_KEYBOX_ERROR_1:
return kCertProvisioningGetKeyboxError1;
case wvcdm::CERT_PROVISIONING_INVALID_CERT_TYPE:
return kCertProvisioningInvalidCertType;
case wvcdm::CERT_PROVISIONING_NONCE_GENERATION_ERROR:
return kCertProvisioningRequestNonceGenerationError;
case wvcdm::CERT_PROVISIONING_REQUEST_ERROR_1:
return kCertProvisioningRequestError1;
case wvcdm::CERT_PROVISIONING_REQUEST_ERROR_4:
return kCertProvisioningRequestError4;
case wvcdm::CERT_PROVISIONING_RESPONSE_ERROR_1:
return kCertProvisioningResponseError1;
case wvcdm::CERT_PROVISIONING_RESPONSE_ERROR_2:
return kCertProvisioningResponseError2;
case wvcdm::CERT_PROVISIONING_RESPONSE_ERROR_3:
return kCertProvisioningResponseError3;
case wvcdm::CERT_PROVISIONING_RESPONSE_ERROR_4:
return kCertProvisioningResponseError4;
case wvcdm::CERT_PROVISIONING_RESPONSE_ERROR_7:
return kCertProvisioningResponseError7;
case wvcdm::CERT_PROVISIONING_RESPONSE_ERROR_8:
return kCertProvisioningResponseError8;
case wvcdm::CERT_PROVISIONING_RESPONSE_ERROR_9:
return kCertProvisioningResponseError9;
case wvcdm::CERT_PROVISIONING_RESPONSE_ERROR_10:
return kCertProvisioningResponseError10;
case wvcdm::CLIENT_IDENTIFICATION_TOKEN_ERROR_1:
return kClientIdentificationTokenError1;
case wvcdm::CLIENT_ID_AES_ENCRYPT_ERROR:
return kClientIdAesEncryptError;
case wvcdm::CLIENT_ID_AES_INIT_ERROR:
return kClientIdAesInitError;
case wvcdm::CLIENT_ID_GENERATE_RANDOM_ERROR:
return kClientIdGenerateRandomError;
case wvcdm::CLIENT_ID_RSA_ENCRYPT_ERROR:
return kClientIdRsaEncryptError;
case wvcdm::CLIENT_ID_RSA_INIT_ERROR:
return kClientIdRsaInitError;
case wvcdm::CLIENT_TOKEN_NOT_SET:
return kClientTokenNotSet;
case wvcdm::COPY_OLD_USAGE_ENTRY_UNKNOWN_ERROR:
return kCopyOldUsageEntryUnknownError;
case wvcdm::CORE_MESSAGE_NOT_FOUND:
return kCoreMessageNotFound;
case wvcdm::CREATE_USAGE_ENTRY_UNKNOWN_ERROR:
return kCreateUsageEntryUnknownError;
case wvcdm::CREATE_USAGE_TABLE_ERROR:
return kCreateUsageTableError;
case wvcdm::DELETE_USAGE_ERROR_1:
return kDeleteUsageError1;
case wvcdm::DELETE_USAGE_ERROR_2:
return kDeleteUsageError2;
case wvcdm::DELETE_USAGE_ERROR_3:
return kDeleteUsageError3;
case wvcdm::DEVICE_CANNOT_REPROVISION:
return kDeviceCannotReprovision;
case wvcdm::DEVICE_CERTIFICATE_ERROR_1:
return kDeviceCertificateError1;
case wvcdm::DEVICE_CERTIFICATE_ERROR_2:
return kDeviceCertificateError2;
case wvcdm::DEVICE_CERTIFICATE_ERROR_3:
return kDeviceCertificateError3;
case wvcdm::DEVICE_CERTIFICATE_ERROR_4:
return kDeviceCertificateError4;
case wvcdm::DUPLICATE_SESSION_ID_SPECIFIED:
return kDuplicateSessionIdSpecified;
case wvcdm::EMPTY_KEYSET_ID:
return kEmptyKeySetId;
case wvcdm::EMPTY_KEYSET_ID_ENG_1:
return kEmptyKeySetIdEng1;
case wvcdm::EMPTY_KEYSET_ID_ENG_2:
return kEmptyKeySetIdEng2;
case wvcdm::EMPTY_KEYSET_ID_ENG_3:
return kEmptyKeySetIdEng3;
case wvcdm::EMPTY_KEYSET_ID_ENG_4:
return kEmptyKeySetIdEng4;
case wvcdm::EMPTY_KEYSET_ID_ENG_5:
return kEmptyKeySetIdEng5;
case wvcdm::EMPTY_KEY_DATA_1:
return kEmptyKeyData1;
case wvcdm::EMPTY_KEY_DATA_2:
return kEmptyKeyData2;
case wvcdm::EMPTY_LICENSE_RENEWAL:
return kEmptyLicenseRenewal;
case wvcdm::EMPTY_LICENSE_REQUEST:
return kEmptyLicenseRequest;
case wvcdm::EMPTY_LICENSE_REQUEST_2:
return kEmptyLicenseRequest2;
case wvcdm::EMPTY_LICENSE_REQUEST_3:
return kEmptyLicenseRequest3;
case wvcdm::EMPTY_LICENSE_RESPONSE_1:
return kEmptyLicenseResponse1;
case wvcdm::EMPTY_LICENSE_RESPONSE_2:
return kEmptyLicenseResponse2;
case wvcdm::EMPTY_LICENSE_RESPONSE_3:
return kEmptyLicenseResponse3;
case wvcdm::EMPTY_LICENSE_RESPONSE_4:
return kEmptyLicenseResponse4;
case wvcdm::EMPTY_PROVISIONING_CERTIFICATE_1:
return kEmptyProvisioningCertificate1;
case wvcdm::EMPTY_PROVISIONING_CERTIFICATE_2:
return kEmptyProvisioningCertificate2;
case wvcdm::EMPTY_PROVISIONING_RESPONSE:
return kEmptyProvisioningResponse;
case wvcdm::EMPTY_RESPONSE_ERROR_1:
return kEmptyResponseError1;
case wvcdm::EMPTY_SESSION_ID:
return kEmptySessionId;
case wvcdm::GENERATE_DERIVED_KEYS_ERROR:
return kGenerateDerivedKeysError;
case wvcdm::GENERATE_USAGE_REPORT_ERROR:
return kGenerateUsageReportError;
case wvcdm::GET_DECRYPT_HASH_ERROR:
return kGetDecryptHashError;
case wvcdm::GET_LICENSE_ERROR:
case wvcdm::KEYSET_ID_NOT_FOUND_4:
// There is a sub-error code that distinguishes the two.
return kGetLicenseError;
case wvcdm::GET_PROVISIONING_METHOD_ERROR:
return kGetProvisioningError;
case wvcdm::GET_RELEASED_LICENSE_ERROR:
return kGetReleasedLicenseError;
case wvcdm::GET_USAGE_INFO_ERROR_1:
return kGetUsageInfoError1;
case wvcdm::GET_USAGE_INFO_ERROR_2:
return kGetUsageInfoError2;
case wvcdm::GET_USAGE_INFO_ERROR_3:
return kGetUsageInfoError3;
case wvcdm::GET_USAGE_INFO_ERROR_4:
return kGetUsageInfoError4;
case wvcdm::INCORRECT_CRYPTO_MODE:
return kIncorrectCryptoMode;
case wvcdm::INCORRECT_USAGE_SUPPORT_TYPE_1:
return kIncorrectUsageSupportType1;
case wvcdm::INCORRECT_USAGE_SUPPORT_TYPE_2:
return kIncorrectUsageSupportType2;
case wvcdm::INIT_DATA_NOT_FOUND:
return kInitDataNotFound;
case wvcdm::INVALID_DECRYPT_HASH_FORMAT:
return kInvalidDecryptHashFormat;
case wvcdm::INVALID_DECRYPT_PARAMETERS_ENG_1:
return kInvalidDecryptParametersEng1;
case wvcdm::INVALID_DECRYPT_PARAMETERS_ENG_2:
return kInvalidDecryptParametersEng2;
case wvcdm::INVALID_DECRYPT_PARAMETERS_ENG_3:
return kInvalidDecryptParametersEng3;
case wvcdm::INVALID_DECRYPT_PARAMETERS_ENG_4:
return kInvalidDecryptParametersEng4;
case wvcdm::INVALID_DEVICE_CERTIFICATE_TYPE:
return kInvalidDeviceCertificateType;
case wvcdm::INVALID_IV_SIZE:
return kInvalidIvSize;
case wvcdm::INVALID_KEY_SYSTEM:
return kInvalidKeySystem;
case wvcdm::INVALID_LICENSE_REQUEST_TYPE_1:
return kInvalidLicenseRequestType1;
case wvcdm::INVALID_LICENSE_REQUEST_TYPE_2:
return kInvalidLicenseRequestType2;
case wvcdm::INVALID_LICENSE_RESPONSE:
return kInvalidLicenseResponse;
case wvcdm::INVALID_LICENSE_TYPE:
return kInvalidLicenseType;
case wvcdm::INVALID_LICENSE_TYPE_2:
return kInvalidLicenseType2;
case wvcdm::INVALID_PARAMETERS_ENG_5:
return kInvalidParametersEng5;
case wvcdm::INVALID_PARAMETERS_ENG_13:
return kInvalidParametersEng13;
case wvcdm::INVALID_PARAMETERS_ENG_14:
return kInvalidParametersEng14;
case wvcdm::INVALID_PARAMETERS_ENG_15:
return kInvalidParametersEng15;
case wvcdm::INVALID_PARAMETERS_ENG_16:
return kInvalidParametersEng16;
case wvcdm::INVALID_PARAMETERS_ENG_22:
return kInvalidParametersEng22;
case wvcdm::INVALID_PARAMETERS_ENG_23:
return kInvalidParametersEng23;
case wvcdm::INVALID_PARAMETERS_ENG_24:
return kInvalidParametersEng24;
case wvcdm::INVALID_PARAMETERS_LIC_1:
return kInvalidParametersLic1;
case wvcdm::INVALID_PARAMETERS_LIC_2:
return kInvalidParametersLic2;
case wvcdm::INVALID_PARAMETERS_LIC_3:
return kInvalidParametersLic3;
case wvcdm::INVALID_PARAMETERS_LIC_4:
return kInvalidParametersLic4;
case wvcdm::INVALID_PARAMETERS_LIC_6:
return kInvalidParametersLic6;
case wvcdm::INVALID_PARAMETERS_LIC_7:
return kInvalidParametersLic7;
case wvcdm::INVALID_PROVISIONING_PARAMETERS_1:
return kInvalidProvisioningParam1;
case wvcdm::INVALID_PROVISIONING_PARAMETERS_2:
return kInvalidProvisioningParam2;
case wvcdm::INVALID_PROVISIONING_REQUEST_PARAM_1:
return kInvalidProvisioningReqParam1;
case wvcdm::INVALID_PROVISIONING_REQUEST_PARAM_2:
return kInvalidProvisioningReqParam2;
case wvcdm::INVALID_QUERY_KEY:
return kInvalidQueryKey;
case wvcdm::INVALID_SESSION_1:
return kInvalidSession1;
case wvcdm::INVALID_SESSION_2:
return kInvalidSession2;
case wvcdm::INVALID_SESSION_ID:
return kInvalidSessionId;
case wvcdm::INVALID_USAGE_ENTRY_NUMBER_MODIFICATION:
return kInvalidUsageEntryNumberModification;
case wvcdm::KEYSET_ID_NOT_FOUND_1:
return kKeySetIdNotFound1;
case wvcdm::KEYSET_ID_NOT_FOUND_2:
return kKeySetIdNotFound2;
case wvcdm::KEYSET_ID_NOT_FOUND_3:
return kKeySetIdNotFound3;
case wvcdm::KEY_CONFLICT_1:
return kKeyConflict1;
case wvcdm::KEY_ERROR:
// KEY_ERROR is used by the CDM to mean just about any kind of error, not
// just license errors, so it is mapped to the generic response.
return kErrorCDMGeneric;
case wvcdm::KEY_NOT_FOUND_1:
return kKeyNotFound1;
case wvcdm::KEY_NOT_FOUND_2:
return kKeyNotFound2;
case wvcdm::KEY_NOT_FOUND_3:
return kKeyNotFound3;
case wvcdm::KEY_NOT_FOUND_4:
return kKeyNotFound4;
case wvcdm::KEY_NOT_FOUND_5:
return kKeyNotFound5;
case wvcdm::KEY_NOT_FOUND_6:
return kKeyNotFound6;
case wvcdm::KEY_REQUEST_ERROR_1:
return kKeyRequestError1;
case wvcdm::KEY_SIZE_ERROR_1:
return kKeySizeError1;
case wvcdm::KEY_SIZE_ERROR_2:
return kKeySizeError2;
case wvcdm::LICENSE_ID_NOT_FOUND:
return kLicenseIdNotFound;
case wvcdm::LICENSE_PARSER_INIT_ERROR:
return kLicenseParserInitError;
case wvcdm::LICENSE_PARSER_NOT_INITIALIZED_1:
return kLicenseParserNotInitialized1;
case wvcdm::LICENSE_PARSER_NOT_INITIALIZED_2:
return kLicenseParserNotInitialized2;
case wvcdm::LICENSE_PARSER_NOT_INITIALIZED_3:
return kLicenseParserNotInitialized3;
case wvcdm::LICENSE_PARSER_NOT_INITIALIZED_4:
return kLicenseParserNotInitialized4;
case wvcdm::LICENSE_RENEWAL_NONCE_GENERATION_ERROR:
return kLicenseRenewalNonceGenerationError;
case wvcdm::LICENSE_RENEWAL_PROHIBITED:
return kLicenseRenewalProhibited;
case wvcdm::LICENSE_REQUEST_NONCE_GENERATION_ERROR:
return kLicenseRequestNonceGenerationError;
case wvcdm::LICENSE_REQUEST_SERVICE_CERTIFICATE_GENERATION_ERROR:
return kLicenseRequestServiceCertificateGenerationError;
case wvcdm::LICENSE_RESPONSE_NOT_SIGNED:
return kLicenseResponseNotSigned;
case wvcdm::LICENSE_RESPONSE_PARSE_ERROR_1:
return kLicenseResponseParseError1;
case wvcdm::LICENSE_RESPONSE_PARSE_ERROR_2:
return kLicenseResponseParseError2;
case wvcdm::LICENSE_RESPONSE_PARSE_ERROR_3:
return kLicenseResponseParseError3;
case wvcdm::LICENSE_RESPONSE_PARSE_ERROR_4:
return kLicenseResponseParseError4;
case wvcdm::LICENSE_RESPONSE_PARSE_ERROR_5:
return kLicenseResponseParseError5;
case wvcdm::LICENSE_USAGE_ENTRY_MISSING:
return kLicenseUsageEntryMissing;
case wvcdm::LIST_LICENSE_ERROR_1:
return kListLicenseError1;
case wvcdm::LIST_LICENSE_ERROR_2:
return kListLicenseError2;
case wvcdm::LIST_USAGE_ERROR_1:
return kListUsageError1;
case wvcdm::LIST_USAGE_ERROR_2:
return kListUsageError2;
case wvcdm::LOAD_ENTITLED_CONTENT_KEYS_ERROR:
return kLoadEntitledContentKeysError;
case wvcdm::LOAD_KEY_ERROR:
return kLoadKeyError;
case wvcdm::LOAD_LICENSE_ERROR:
return kLoadLicenseError;
case wvcdm::LOAD_PROVISIONING_ERROR:
return kLoadProvisioningError;
case wvcdm::LOAD_RENEWAL_ERROR:
return kLoadRenewalError;
case wvcdm::LOAD_SYSTEM_ID_ERROR:
return kLoadSystemIdError;
case wvcdm::LOAD_USAGE_ENTRY_GENERATION_SKEW:
return kLoadUsageEntryGenerationSkew;
case wvcdm::LOAD_USAGE_ENTRY_INVALID_SESSION:
return kLoadUsageEntryInvalidSession;
case wvcdm::LOAD_USAGE_ENTRY_SIGNATURE_FAILURE:
return kLoadUsageEntrySignatureFailure;
case wvcdm::LOAD_USAGE_ENTRY_UNKNOWN_ERROR:
return kLoadUsageEntryUnknownError;
case wvcdm::LOAD_USAGE_HEADER_BAD_MAGIC:
return kLoadUsageHeaderBadMagic;
case wvcdm::LOAD_USAGE_HEADER_GENERATION_SKEW:
return kLoadUsageHeaderGenerationSkew;
case wvcdm::LOAD_USAGE_HEADER_SIGNATURE_FAILURE:
return kLoadUsageHeaderSignatureFailure;
case wvcdm::LOAD_USAGE_HEADER_UNKNOWN_ERROR:
return kLoadUsageHeaderUnknownError;
case wvcdm::LOAD_USAGE_INFO_FILE_ERROR:
return kLoadUsageInfoFileError;
case wvcdm::LOAD_USAGE_INFO_MISSING:
return kLoadUsageInfoMissing;
case wvcdm::MOVE_USAGE_ENTRY_DESTINATION_IN_USE:
return kMoveUsageEntryDestinationInUse;
case wvcdm::MOVE_USAGE_ENTRY_UNKNOWN_ERROR:
return kMoveUsageEntryUnknownError;
case wvcdm::NOT_AN_ENTITLEMENT_SESSION:
return kNotAnEntitlementSession;
case wvcdm::NOT_INITIALIZED_ERROR:
return kNotInitializedError;
case wvcdm::NO_CONTENT_KEY:
return kNoContentKey;
case wvcdm::NO_CONTENT_KEY_2:
return kNoContentKey2;
case wvcdm::NO_DEVICE_KEY_1:
return kNoDeviceKey1;
case wvcdm::NO_SRM_VERSION:
return kNoSrmVersion;
case wvcdm::NO_USAGE_ENTRIES:
return kNoUsageEntries;
case wvcdm::OFFLINE_LICENSE_PROHIBITED:
return kOfflineLicenseProhibited;
case wvcdm::OKP_ALREADY_PROVISIONED:
return kOkpAlreadyProvisioned;
case wvcdm::PARAMETER_NULL:
return kParameterNull;
case wvcdm::PARSE_OKP_RESPONSE_ERROR:
return kParseOkpResponseError;
case wvcdm::PARSE_REQUEST_ERROR_1:
return kParseRequestError1;
case wvcdm::PARSE_REQUEST_ERROR_2:
return kParseRequestError2;
case wvcdm::PARSE_RESPONSE_ERROR_1:
return kParseResponseError1;
case wvcdm::PARSE_RESPONSE_ERROR_2:
return kParseResponseError2;
case wvcdm::PARSE_RESPONSE_ERROR_3:
return kParseResponseError3;
case wvcdm::PARSE_RESPONSE_ERROR_4:
return kParseResponseError4;
case wvcdm::PARSE_SERVICE_CERTIFICATE_ERROR:
return kParseServiceCertificateError;
case wvcdm::PREPARE_CENC_CONTENT_ID_FAILED:
return kPrepareCencContentIdFailed;
case wvcdm::PREPARE_WEBM_CONTENT_ID_FAILED:
return kPrepareWebmContentIdFailed;
case wvcdm::PRIVACY_MODE_ERROR_1:
return kPrivacyModeError1;
case wvcdm::PRIVACY_MODE_ERROR_2:
return kPrivacyModeError2;
case wvcdm::PRIVACY_MODE_ERROR_3:
return kPrivacyModeError3;
case wvcdm::PROVISIONING_NOT_ALLOWED_FOR_ATSC:
return kProvisioningNotAllowedForAtsc;
case wvcdm::REFRESH_KEYS_ERROR:
return kRefreshKeysError;
case wvcdm::REINIT_ERROR:
return kReinitError;
case wvcdm::RELEASE_KEY_ERROR:
return kReleaseKeyError;
case wvcdm::RELEASE_KEY_REQUEST_ERROR:
return kReleaseKeyRequestError;
case wvcdm::RELEASE_LICENSE_ERROR_1:
return kReleaseLicenseError1;
case wvcdm::RELEASE_LICENSE_ERROR_2:
return kReleaseLicenseError2;
case wvcdm::REMOVE_ALL_USAGE_INFO_ERROR_1:
return kRemoveAllUsageInfoError1;
case wvcdm::REMOVE_ALL_USAGE_INFO_ERROR_2:
return kRemoveAllUsageInfoError2;
case wvcdm::REMOVE_ALL_USAGE_INFO_ERROR_5:
return kRemoveAllUsageInfoError5;
case wvcdm::REMOVE_ALL_USAGE_INFO_ERROR_6:
return kRemoveAllUsageInfoError6;
case wvcdm::REMOVE_ALL_USAGE_INFO_ERROR_7:
return kRemoveAllUsageInfoError7;
case wvcdm::REMOVE_USAGE_INFO_ERROR_1:
return kRemoveUsageInfoError1;
case wvcdm::REMOVE_USAGE_INFO_ERROR_2:
return kRemoveUsageInfoError2;
case wvcdm::REMOVE_USAGE_INFO_ERROR_3:
return kRemoveUsageInfoError3;
case wvcdm::RENEW_KEY_ERROR_1:
return kRenewKeyError1;
case wvcdm::RENEW_KEY_ERROR_2:
return kRenewKeyError2;
case wvcdm::RESTORE_OFFLINE_LICENSE_ERROR_2:
return kRestoreOfflineLicenseError2;
case wvcdm::RESTORE_OFFLINE_LICENSE_ERROR_3:
return kRestoreOfflineLicenseError3;
case wvcdm::SAMPLE_AND_SUBSAMPLE_SIZE_MISMATCH:
return kSampleAndSubsampleSizeMismatch;
case wvcdm::SESSION_FILE_HANDLE_INIT_ERROR:
return kSessionFileHandleInitError;
case wvcdm::SESSION_KEYS_NOT_FOUND:
return kSessionKeysNotFound;
case wvcdm::SESSION_KEYS_NOT_FOUND_2:
return kSessionKeysNotFound2;
case wvcdm::SESSION_NOT_FOUND_11:
return kSessionNotFound11;
case wvcdm::SESSION_NOT_FOUND_12:
return kSessionNotFound12;
case wvcdm::SESSION_NOT_FOUND_13:
return kSessionNotFound13;
case wvcdm::SESSION_NOT_FOUND_14:
return kSessionNotFound14;
case wvcdm::SESSION_NOT_FOUND_15:
return kSessionNotFound15;
case wvcdm::SESSION_NOT_FOUND_16:
return kSessionNotFound16;
case wvcdm::SET_DECRYPT_HASH_ERROR:
return kSetDecryptHashError;
case wvcdm::SHRINK_USAGE_TABLE_HEADER_ENTRY_IN_USE:
return kShrinkUsageTableHeaderEntryInUse;
case wvcdm::SHRINK_USAGE_TABLE_HEADER_UNKNOWN_ERROR:
return kShrinkUsageTableHeaderUnknownError;
case wvcdm::SIGNATURE_NOT_FOUND:
return kSignatureNotFound;
case wvcdm::SIGNATURE_NOT_FOUND_2:
return kSignatureNotFound2;
case wvcdm::STORAGE_PROHIBITED:
return kStorageProhibited;
case wvcdm::STORE_LICENSE_ERROR_1:
return kStoreLicenseError1;
case wvcdm::STORE_LICENSE_ERROR_2:
return kStoreLicenseError2;
case wvcdm::STORE_USAGE_INFO_ERROR:
return kStoreUsageInfoError;
case wvcdm::UNEXPECTED_EMPTY_USAGE_ENTRY:
return kUnexpectedEmptyUsageEntry;
case wvcdm::UNKNOWN_SELECT_KEY_ERROR_1:
return kUnknownSelectKeyError1;
case wvcdm::UNKNOWN_SELECT_KEY_ERROR_2:
return kUnknownSelectKeyError2;
case wvcdm::UNPROVISION_ERROR_1:
return kUnprovisioningError1;
case wvcdm::UNPROVISION_ERROR_2:
return kUnprovisioningError2;
case wvcdm::UNPROVISION_ERROR_3:
return kUnprovisioningError3;
case wvcdm::UNPROVISION_ERROR_4:
return kUnprovisioningError4;
case wvcdm::UNSUPPORTED_INIT_DATA:
return kUnsupportedInitData;
case wvcdm::UNSUPPORTED_INIT_DATA_FORMAT:
return kUnsupportedInitDataFormat;
case wvcdm::UPDATE_USAGE_ENTRY_UNKNOWN_ERROR:
return kUpdateUsageEntryUnknownError;
case wvcdm::USAGE_ENTRY_NUMBER_MISMATCH:
return kUsageEntryNumberMismatch;
case wvcdm::USAGE_ENTRY_ALREADY_LOADED:
return kUsageEntryAlreadyLoaded;
case wvcdm::USAGE_GET_ENTRY_RETRIEVE_INVALID_STORAGE_TYPE:
return kUsageGetEntryRetrieveInvalidStorageType;
case wvcdm::USAGE_GET_ENTRY_RETRIEVE_LICENSE_FAILED:
return kUsageGetEntryRetrieveLicenseFailed;
case wvcdm::USAGE_GET_ENTRY_RETRIEVE_USAGE_INFO_FAILED:
return kUsageGetEntryRetrieveUsageInfoFailed;
case wvcdm::USAGE_INFORMATION_SUPPORT_FAILED:
return kUsageInformationSupportFailed;
case wvcdm::USAGE_INFO_NOT_FOUND:
return kUsageInfoNotFound;
case wvcdm::USAGE_INVALID_LOAD_ENTRY:
return kUsageInvalidLoadEntry;
case wvcdm::USAGE_INVALID_NEW_ENTRY:
return kUsageInvalidNewEntry;
case wvcdm::USAGE_INVALID_PARAMETERS_1:
return kUsageInvalidParameters1;
case wvcdm::USAGE_INVALID_PARAMETERS_2:
return kUsageInvalidParameters2;
case wvcdm::USAGE_STORE_ENTRY_RETRIEVE_INVALID_STORAGE_TYPE:
return kUsageStoreEntryRetrieveInvalidStorageType;
case wvcdm::USAGE_STORE_ENTRY_RETRIEVE_LICENSE_FAILED:
return kUsageStoreEntryRetrieveLicenseFailed;
case wvcdm::USAGE_STORE_ENTRY_RETRIEVE_USAGE_INFO_FAILED:
return kUsageStoreEntryRetrieveUsageInfoFailed;
case wvcdm::USAGE_STORE_LICENSE_FAILED:
return kUsageStoreLicenseFailed;
case wvcdm::USAGE_STORE_USAGE_INFO_FAILED:
return kUsageStoreUsageInfoFailed;
case wvcdm::USAGE_SUPPORT_GET_API_FAILED:
return kUsageSupportGetApiFailed;
case wvcdm::WEBM_INIT_DATA_UNAVAILABLE:
return kWebmInitDataUnavailable;
// This error is only returned in API 29 by the hidl service.
// It should never be used in the legacy plugin.
// It is mapped here to clear the compiler warning.
case wvcdm::GET_OFFLINE_LICENSE_STATE_ERROR_1:
case wvcdm::GET_OFFLINE_LICENSE_STATE_ERROR_2:
case wvcdm::REMOVE_OFFLINE_LICENSE_ERROR_1:
case wvcdm::REMOVE_OFFLINE_LICENSE_ERROR_2:
case wvcdm::OUTPUT_TOO_LARGE_ERROR:
case wvcdm::SESSION_LOST_STATE_ERROR:
case wvcdm::GENERATE_DERIVED_KEYS_ERROR_2:
case wvcdm::LOAD_DEVICE_RSA_KEY_ERROR:
case wvcdm::NONCE_GENERATION_ERROR:
case wvcdm::GENERATE_SIGNATURE_ERROR:
case wvcdm::UNKNOWN_CLIENT_TOKEN_TYPE:
case wvcdm::DEACTIVATE_USAGE_ENTRY_ERROR:
case wvcdm::SYSTEM_INVALIDATED_ERROR:
case wvcdm::OPEN_CRYPTO_SESSION_ERROR:
case wvcdm::LOAD_SRM_ERROR:
case wvcdm::RANDOM_GENERATION_ERROR:
case wvcdm::CRYPTO_SESSION_NOT_INITIALIZED:
case wvcdm::GET_DEVICE_ID_ERROR:
case wvcdm::GET_TOKEN_FROM_OEM_CERT_ERROR:
case wvcdm::CRYPTO_SESSION_NOT_OPEN:
case wvcdm::GET_TOKEN_FROM_KEYBOX_ERROR:
case wvcdm::KEYBOX_TOKEN_TOO_SHORT:
case wvcdm::EXTRACT_SYSTEM_ID_FROM_OEM_CERT_ERROR:
case wvcdm::RSA_SIGNATURE_GENERATION_ERROR:
case wvcdm::GET_HDCP_CAPABILITY_FAILED:
case wvcdm::GET_NUMBER_OF_OPEN_SESSIONS_ERROR:
case wvcdm::GET_MAX_NUMBER_OF_OPEN_SESSIONS_ERROR:
case wvcdm::NOT_IMPLEMENTED_ERROR:
case wvcdm::GET_SRM_VERSION_ERROR:
case wvcdm::REWRAP_DEVICE_RSA_KEY_ERROR:
case wvcdm::SERVICE_CERTIFICATE_PROVIDER_ID_EMPTY:
case wvcdm::INVALID_SRM_LIST:
return android::ERROR_DRM_UNKNOWN;
}
// Return here instead of as a default case so that the compiler will warn
// us if we forget to include an enum member in the switch statement.
return android::UNKNOWN_ERROR;
}
static inline bool isCdmResponseTypeSuccess(wvcdm::CdmResponseType res) {
return mapCdmResponseType(res) == android::OK;
}
} // namespace wvdrm
#endif // WV_MAP_ERRORS_H_

View File

@@ -11,56 +11,6 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------
// Builds libwvdrmcryptoplugin
//
// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE
// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE
// DEPENDING ON IT IN YOUR PROJECT. ***
package {
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "vendor_widevine_license"
// to get the below license kinds:
// legacy_by_exception_only (by exception only)
default_applicable_licenses: ["vendor_widevine_license"],
}
cc_library_static {
name: "libwvdrmcryptoplugin",
srcs: ["src/WVCryptoPlugin.cpp"],
include_dirs: [
"frameworks/av/include",
"frameworks/native/include",
"vendor/widevine/libwvdrmengine/cdm/core/include",
"vendor/widevine/libwvdrmengine/cdm/include",
"vendor/widevine/libwvdrmengine/cdm/metrics/include",
"vendor/widevine/libwvdrmengine/cdm/util/include",
"vendor/widevine/libwvdrmengine/include",
"vendor/widevine/libwvdrmengine/mediacrypto/include",
"vendor/widevine/libwvdrmengine/oemcrypto/include",
],
header_libs: [
"libstagefright_headers",
"libstagefright_foundation_headers",
"libutils_headers",
],
static_libs: ["libcdm_protos"],
shared_libs: [
"libcrypto",
"liblog",
],
proprietary: true,
}
// -----------------------------------------------------------------------------
// Builds libwvdrmcryptoplugin_hidl
//
@@ -76,10 +26,9 @@ cc_library_static {
"vendor/widevine/libwvdrmengine/cdm/include",
"vendor/widevine/libwvdrmengine/cdm/metrics/include",
"vendor/widevine/libwvdrmengine/cdm/util/include",
"vendor/widevine/libwvdrmengine/include_hidl",
"vendor/widevine/libwvdrmengine/include_hidl",
"vendor/widevine/libwvdrmengine/include",
"vendor/widevine/libwvdrmengine/mediacrypto/include_hidl",
"vendor/widevine/libwvdrmengine/mediacrypto/include",
"vendor/widevine/libwvdrmengine/oemcrypto/include",
],

View File

@@ -1,57 +0,0 @@
//
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
#ifndef WV_CRYPTO_PLUGIN_H_
#define WV_CRYPTO_PLUGIN_H_
#include <stdint.h>
#include "utils/StrongPointer.h"
#include "utils/Vector.h"
#include "media/hardware/CryptoAPI.h"
#include "media/stagefright/foundation/ABase.h"
#include "media/stagefright/foundation/AString.h"
#include "wv_content_decryption_module.h"
namespace wvdrm {
class WVCryptoPlugin : public android::CryptoPlugin {
public:
WVCryptoPlugin(const void* data, size_t size,
const android::sp<wvcdm::WvContentDecryptionModule>& cdm);
virtual ~WVCryptoPlugin() {}
virtual bool requiresSecureDecoderComponent(const char* mime) const;
virtual void notifyResolution(uint32_t width, uint32_t height);
virtual android::status_t setMediaDrmSession(
const android::Vector<uint8_t>& sessionId);
virtual ssize_t decrypt(bool secure, const uint8_t key[16],
const uint8_t iv[16], Mode mode, const Pattern &pattern,
const void* srcPtr,
const SubSample* subSamples, size_t numSubSamples,
void* dstPtr, android::AString* errorDetailMsg);
private:
DISALLOW_EVIL_CONSTRUCTORS(WVCryptoPlugin);
android::sp<wvcdm::WvContentDecryptionModule> const mCDM;
bool mTestMode;
wvcdm::CdmSessionId mSessionId;
wvcdm::CdmSessionId configureTestMode(const void* data, size_t size);
android::status_t attemptDecrypt(
const wvcdm::CdmDecryptionParametersV16& params,
bool haveEncryptedSubsamples, android::AString* errorDetailMsg);
};
} // namespace wvdrm
#endif // WV_CRYPTO_PLUGIN_H_

View File

@@ -1,261 +0,0 @@
//
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
//#define LOG_NDEBUG 0
#define LOG_TAG "WVCdm"
#include <utils/Log.h>
#include "WVCryptoPlugin.h"
#include <algorithm>
#include <endian.h>
#include <iterator>
#include <string.h>
#include <string>
#include <vector>
#include "mapErrors-inl.h"
#include "media/stagefright/MediaErrors.h"
#include "OEMCryptoCENC.h"
#include "openssl/sha.h"
#include "utils/Errors.h"
#include "utils/String8.h"
#include "wv_cdm_constants.h"
#include "WVErrors.h"
namespace wvdrm {
using namespace android;
using namespace std;
using namespace wvcdm;
WVCryptoPlugin::WVCryptoPlugin(const void* data, size_t size,
const sp<WvContentDecryptionModule>& cdm)
: mCDM(cdm),
mTestMode(false),
mSessionId(configureTestMode(data, size)) {}
CdmSessionId WVCryptoPlugin::configureTestMode(const void* data, size_t size) {
CdmSessionId sessionId;
if (data != NULL) {
sessionId.assign(static_cast<const char *>(data), size);
size_t index = sessionId.find("test_mode");
if (index != string::npos) {
sessionId = sessionId.substr(0, index);
mTestMode = true;
}
}
if (!mCDM->IsOpenSession(sessionId)) {
sessionId.clear();
}
return sessionId;
}
bool WVCryptoPlugin::requiresSecureDecoderComponent(const char* mime) const {
if (!strncasecmp(mime, "video/", 6)) {
// Type is video, so query CDM to see if we require a secure decoder.
CdmQueryMap status;
CdmResponseType res = mCDM->QuerySessionStatus(mSessionId, &status);
if (!isCdmResponseTypeSuccess(res)) {
ALOGE("Error querying CDM status: %u", res);
return false;
}
return status[QUERY_KEY_SECURITY_LEVEL] == QUERY_VALUE_SECURITY_LEVEL_L1;
} else {
// Type is not video, so never require a secure decoder.
return false;
}
}
void WVCryptoPlugin::notifyResolution(uint32_t width, uint32_t height) {
mCDM->NotifyResolution(mSessionId, width, height);
}
status_t WVCryptoPlugin::setMediaDrmSession(const Vector<uint8_t>& sessionId) {
CdmSessionId cdmSessionId(reinterpret_cast<const char *>(sessionId.array()),
sessionId.size());
if (sessionId.size() == 0) {
return android::BAD_VALUE;
}
if (!mCDM->IsOpenSession(cdmSessionId)) {
return android::ERROR_DRM_SESSION_NOT_OPENED;
} else {
mSessionId = cdmSessionId;
return android::NO_ERROR;
}
}
// Returns negative values for error code and positive values for the size of
// decrypted data. In theory, the output size can be larger than the input
// size, but in practice this should never happen for AES-CTR.
ssize_t WVCryptoPlugin::decrypt(bool secure, const uint8_t key[KEY_ID_SIZE],
const uint8_t iv[KEY_IV_SIZE], Mode mode,
const Pattern& pattern, const void* srcPtr,
const SubSample* subSamples,
size_t numSubSamples, void* dstPtr,
AString* errorDetailMsg) {
if (mode != kMode_Unencrypted &&
mode != kMode_AES_CTR &&
mode != kMode_AES_CBC) {
errorDetailMsg->setTo(
"The requested encryption mode is not supported by Widevine CDM.");
return kErrorUnsupportedCrypto;
} else if (mode == kMode_AES_CTR &&
(pattern.mEncryptBlocks != 0 || pattern.mSkipBlocks != 0)) {
errorDetailMsg->setTo(
"The 'cens' schema is not supported by Widevine CDM.");
return kErrorUnsupportedCrypto;
}
// Convert parameters to the form the CDM wishes to consume them in.
const KeyId keyId(reinterpret_cast<const char*>(key), KEY_ID_SIZE);
vector<uint8_t> ivVector(iv, iv + KEY_IV_SIZE);
const uint8_t* const source = static_cast<const uint8_t*>(srcPtr);
uint8_t* const dest = static_cast<uint8_t*>(dstPtr);
// Set up the decrypt params
CdmDecryptionParametersV16 params;
params.key_id = keyId;
params.is_secure = secure;
if (mode == kMode_AES_CTR) {
params.cipher_mode = kCipherModeCtr;
} else if (mode == kMode_AES_CBC) {
params.cipher_mode = kCipherModeCbc;
}
params.pattern.encrypt_blocks = pattern.mEncryptBlocks;
params.pattern.skip_blocks = pattern.mSkipBlocks;
// Set up the sample
// Android's API only supports one at a time
params.samples.emplace_back();
CdmDecryptionSample& sample = params.samples.back();
sample.encrypt_buffer = source;
sample.decrypt_buffer = dest;
sample.decrypt_buffer_offset = 0;
sample.iv = ivVector;
// Set up the subsamples
// We abuse std::transform() here to also do some side-effects: Tallying the
// total size of the sample and checking if any of the data is protected.
size_t totalSize = 0;
bool hasProtectedData = false;
sample.subsamples.reserve(numSubSamples);
std::transform(subSamples, subSamples + numSubSamples,
std::back_inserter(sample.subsamples),
[&](const SubSample& subSample) -> CdmDecryptionSubsample {
totalSize +=
subSample.mNumBytesOfClearData + subSample.mNumBytesOfEncryptedData;
hasProtectedData |= subSample.mNumBytesOfEncryptedData > 0;
return CdmDecryptionSubsample(subSample.mNumBytesOfClearData,
subSample.mNumBytesOfEncryptedData);
});
sample.encrypt_buffer_length = totalSize;
sample.decrypt_buffer_size = totalSize;
if (mode == kMode_Unencrypted && hasProtectedData) {
errorDetailMsg->setTo("Protected ranges found in allegedly clear data.");
return kErrorExpectedUnencrypted;
}
// Decrypt
status_t res = attemptDecrypt(params, hasProtectedData, errorDetailMsg);
if (res != android::OK) {
return res;
}
// In test mode, we return an error that causes a detailed error
// message string containing a SHA256 hash of the decrypted data
// to get passed to the java app via CryptoException. The test app
// can then use the hash to verify that decryption was successful.
if (mTestMode) {
if (secure) {
// can't access data in secure mode
errorDetailMsg->setTo("secure");
} else {
SHA256_CTX ctx;
uint8_t digest[SHA256_DIGEST_LENGTH];
SHA256_Init(&ctx);
SHA256_Update(&ctx, dstPtr, totalSize);
SHA256_Final(digest, &ctx);
String8 buf;
for (size_t i = 0; i < sizeof(digest); i++) {
buf.appendFormat("%02x", digest[i]);
}
errorDetailMsg->setTo(buf.string());
}
return kErrorTestMode;
}
return static_cast<ssize_t>(totalSize);
}
status_t WVCryptoPlugin::attemptDecrypt(
const CdmDecryptionParametersV16& params, bool hasProtectedData,
AString* errorDetailMsg) {
CdmResponseType res = mCDM->DecryptV16(mSessionId, hasProtectedData,
params);
if (isCdmResponseTypeSuccess(res)) {
return android::OK;
} else {
ALOGE("Decrypt error in session %s during a sample %s protected data: %d",
mSessionId.c_str(),
hasProtectedData ? "with" : "without",
res);
bool actionableError = true;
switch (res) {
case wvcdm::INSUFFICIENT_CRYPTO_RESOURCES:
errorDetailMsg->setTo(
"Error decrypting data: insufficient crypto resources");
break;
case wvcdm::NEED_KEY:
case wvcdm::KEY_NOT_FOUND_IN_SESSION:
errorDetailMsg->setTo(
"Error decrypting data: requested key has not been loaded");
break;
case wvcdm::DECRYPT_NOT_READY:
errorDetailMsg->setTo(
"Error decrypting data: license validity period is in the future");
break;
case wvcdm::SESSION_NOT_FOUND_FOR_DECRYPT:
errorDetailMsg->setTo(
"Error decrypting data: session not found, possibly reclaimed");
break;
case wvcdm::DECRYPT_ERROR:
errorDetailMsg->setTo(
"Error decrypting data: unspecified error");
break;
case wvcdm::INSUFFICIENT_OUTPUT_PROTECTION:
case wvcdm::ANALOG_OUTPUT_ERROR:
errorDetailMsg->setTo(
"Error decrypting data: insufficient output protection");
break;
case wvcdm::KEY_PROHIBITED_FOR_SECURITY_LEVEL:
errorDetailMsg->setTo(
"Error decrypting data: key prohibited for security level");
break;
default:
actionableError = false;
break;
}
if (actionableError) {
// This error is actionable by the app and should be passed up.
return mapCdmResponseType(res);
} else {
// Swallow the specifics of other errors to obscure decrypt internals.
return kErrorCDMGeneric;
}
}
}
} // namespace wvdrm

View File

@@ -1,67 +1,4 @@
LOCAL_PATH := $(call my-dir)
# -----------------------------------------------------------------------------
# Builds libwvdrmmediacrypto_test
#
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
legacy_src/WVCryptoPlugin_test.cpp \
LOCAL_C_INCLUDES := \
frameworks/av/include \
frameworks/native/include \
vendor/widevine/libwvdrmengine/cdm/core/include \
vendor/widevine/libwvdrmengine/cdm/include \
vendor/widevine/libwvdrmengine/cdm/metrics/include \
vendor/widevine/libwvdrmengine/cdm/util/include \
vendor/widevine/libwvdrmengine/mediacrypto/include \
vendor/widevine/libwvdrmengine/oemcrypto/include \
LOCAL_STATIC_LIBRARIES := \
libcdm \
libcdm_protos \
libcdm_utils \
libjsmn \
libgmock \
libgmock_main \
libgtest \
libwvlevel3 \
libwvdrmcryptoplugin \
libwv_odk \
LOCAL_SHARED_LIBRARIES := \
libbase \
libcrypto \
libcutils \
libdl \
libhidlbase \
liblog \
libprotobuf-cpp-lite \
libstagefright_foundation \
libutils \
LOCAL_C_INCLUDES += \
external/protobuf/src \
LOCAL_MODULE := libwvdrmmediacrypto_test
LOCAL_LICENSE_KINDS := legacy_by_exception_only
LOCAL_LICENSE_CONDITIONS := by_exception_only
LOCAL_MODULE_TAGS := tests
LOCAL_MODULE_OWNER := widevine
LOCAL_PROPRIETARY_MODULE := true
# When built, explicitly put it in the DATA/nativetest directory.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
ifneq ($(TARGET_ENABLE_MEDIADRM_64), true)
LOCAL_MODULE_TARGET_ARCH := arm x86 mips
endif
include $(BUILD_EXECUTABLE)
# -----------------------------------------------------------------------------
# Builds libwvdrmmediacrypto_hidl_test
#
@@ -79,7 +16,6 @@ LOCAL_C_INCLUDES := \
vendor/widevine/libwvdrmengine/cdm/util/include \
vendor/widevine/libwvdrmengine/include_hidl \
vendor/widevine/libwvdrmengine/mediacrypto/include_hidl \
vendor/widevine/libwvdrmengine/mediacrypto/include \
vendor/widevine/libwvdrmengine/oemcrypto/include \
LOCAL_STATIC_LIBRARIES := \

View File

@@ -1,430 +0,0 @@
//
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
#include <stdio.h>
#include <string>
#include <vector>
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "media/stagefright/foundation/ABase.h"
#include "media/stagefright/foundation/AString.h"
#include "media/stagefright/MediaErrors.h"
#include "OEMCryptoCENC.h"
#include "wv_cdm_constants.h"
#include "wv_cdm_types.h"
#include "wv_content_decryption_module.h"
#include "WVCryptoPlugin.h"
using namespace android;
using namespace std;
using namespace testing;
using namespace wvcdm;
using namespace wvdrm;
namespace {
constexpr ssize_t kErrorUnsupportedCrypto = ERROR_DRM_VENDOR_MIN + 2;
}
class MockCDM : public WvContentDecryptionModule {
public:
MOCK_METHOD1(IsOpenSession, bool(const CdmSessionId&));
MOCK_METHOD3(DecryptV16, CdmResponseType(const CdmSessionId&, bool,
const CdmDecryptionParametersV16&));
MOCK_METHOD2(QuerySessionStatus, CdmResponseType(const CdmSessionId&,
CdmQueryMap*));
};
class WVCryptoPluginTest : public Test {
protected:
static const uint32_t kSessionIdSize = 16;
uint8_t sessionId[kSessionIdSize];
virtual void SetUp() {
FILE* fp = fopen("/dev/urandom", "r");
fread(sessionId, sizeof(uint8_t), kSessionIdSize, fp);
fclose(fp);
// Set default CdmResponseType value for gMock
DefaultValue<CdmResponseType>::Set(wvcdm::NO_ERROR);
}
};
TEST_F(WVCryptoPluginTest, CorrectlyReportsSecureBuffers) {
android::sp<StrictMock<MockCDM>> cdm = new StrictMock<MockCDM>();
CdmQueryMap l1Map;
l1Map[QUERY_KEY_SECURITY_LEVEL] = QUERY_VALUE_SECURITY_LEVEL_L1;
CdmQueryMap l3Map;
l3Map[QUERY_KEY_SECURITY_LEVEL] = QUERY_VALUE_SECURITY_LEVEL_L3;
// Provide the expected behavior for IsOpenSession
EXPECT_CALL(*cdm, IsOpenSession(_))
.WillRepeatedly(Return(true));
// Specify the expected calls to QuerySessionStatus
EXPECT_CALL(*cdm, QuerySessionStatus(_, _))
.WillOnce(DoAll(SetArgPointee<1>(l1Map),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<1>(l3Map),
Return(wvcdm::NO_ERROR)));
WVCryptoPlugin plugin(sessionId, kSessionIdSize, cdm.get());
EXPECT_TRUE(plugin.requiresSecureDecoderComponent("video/mp4")) <<
"WVCryptoPlugin incorrectly allows an insecure video decoder on L1";
EXPECT_FALSE(plugin.requiresSecureDecoderComponent("video/mp4")) <<
"WVCryptoPlugin incorrectly expects a secure video decoder on L3";
EXPECT_FALSE(plugin.requiresSecureDecoderComponent("audio/aac")) <<
"WVCryptoPlugin incorrectly expects a secure audio decoder";
}
// TODO(b/28295739):
// Add New MediaCrypto Unit Tests for CBC & Pattern Mode in cdmPatternDesc.
// Predicate that validates that the fields of a passed-in
// CdmDecryptionParametersV16 match the values it was given at construction
// time.
//
// This could be done with a huge pile of gMock matchers, but it is ugly and
// unmaintainable, particularly once you get into validating the subsamples. The
// logic here is complex enough to warrant a custom matcher for this one test.
class CDPMatcher {
public:
CDPMatcher(const uint8_t* keyId, bool isSecure, CryptoPlugin::Mode cipherMode,
const CryptoPlugin::Pattern& pattern,
const uint8_t* input, size_t inputLength,
const uint8_t* output, size_t outputLength, const uint8_t* iv,
const CryptoPlugin::SubSample* subsamples,
size_t subsamplesLength)
: mKeyId(keyId, keyId + KEY_ID_SIZE), mIsSecure(isSecure),
mCipherMode(cipherMode), mPattern(pattern), mInput(input),
mInputLength(inputLength), mOutput(output), mOutputLength(outputLength),
mIv(iv, iv + KEY_IV_SIZE),
mSubsamples(subsamples, subsamples + subsamplesLength) {}
bool operator()(const CdmDecryptionParametersV16& params) const {
if (mCipherMode == CryptoPlugin::kMode_AES_CTR &&
params.cipher_mode != kCipherModeCtr) {
return false;
} else if (mCipherMode == CryptoPlugin::kMode_AES_CBC &&
params.cipher_mode != kCipherModeCbc) {
return false;
}
if (params.key_id != mKeyId ||
params.is_secure != mIsSecure ||
params.pattern.encrypt_blocks != mPattern.mEncryptBlocks ||
params.pattern.skip_blocks != mPattern.mSkipBlocks ||
params.samples.size() != 1) {
return false;
}
const CdmDecryptionSample& sample = params.samples[0];
if (sample.encrypt_buffer != mInput ||
sample.encrypt_buffer_length != mInputLength ||
sample.decrypt_buffer != mOutput ||
sample.decrypt_buffer_size != mOutputLength ||
sample.decrypt_buffer_offset != 0 ||
sample.iv != mIv ||
sample.subsamples.size() != mSubsamples.size()) {
return false;
}
for (size_t i = 0; i < mSubsamples.size(); ++i) {
const CryptoPlugin::SubSample& androidSubsample = mSubsamples[i];
const CdmDecryptionSubsample& cdmSubsample = sample.subsamples[i];
if (cdmSubsample.clear_bytes != androidSubsample.mNumBytesOfClearData||
cdmSubsample.protected_bytes != androidSubsample.mNumBytesOfEncryptedData) {
return false;
}
}
return true;
}
private:
const KeyId mKeyId;
const bool mIsSecure;
const CryptoPlugin::Mode mCipherMode;
const CryptoPlugin::Pattern mPattern;
const uint8_t* const mInput;
const size_t mInputLength;
const uint8_t* const mOutput;
const size_t mOutputLength;
const std::vector<uint8_t> mIv;
const std::vector<CryptoPlugin::SubSample> mSubsamples;
};
TEST_F(WVCryptoPluginTest, AttemptsToDecrypt) {
android::sp<StrictMock<MockCDM>> cdm = new StrictMock<MockCDM>();
constexpr size_t kSubSampleCount = 6;
CryptoPlugin::SubSample subSamples[kSubSampleCount];
memset(subSamples, 0, sizeof(subSamples));
subSamples[0].mNumBytesOfEncryptedData = 16;
subSamples[1].mNumBytesOfClearData = 16;
subSamples[1].mNumBytesOfEncryptedData = 16;
subSamples[2].mNumBytesOfEncryptedData = 8;
subSamples[3].mNumBytesOfClearData = 29;
subSamples[3].mNumBytesOfEncryptedData = 24;
subSamples[4].mNumBytesOfEncryptedData = 60;
subSamples[5].mNumBytesOfEncryptedData = 16;
uint8_t keyId[KEY_ID_SIZE];
uint8_t iv[KEY_IV_SIZE];
constexpr size_t kDataSize = 185;
uint8_t inputData[kDataSize];
uint8_t outputData[kDataSize];
FILE* fp = fopen("/dev/urandom", "r");
fread(keyId, sizeof(uint8_t), KEY_ID_SIZE, fp);
fread(iv, sizeof(uint8_t), KEY_IV_SIZE, fp);
fread(inputData, sizeof(uint8_t), kDataSize, fp);
fclose(fp);
android::CryptoPlugin::Pattern noPattern = { 0, 0 };
// Provide the expected behavior for IsOpenSession
EXPECT_CALL(*cdm, IsOpenSession(_))
.WillRepeatedly(Return(true));
// Specify the expected calls to Decrypt
CDPMatcher paramsMatcher(keyId, false, CryptoPlugin::kMode_AES_CTR, noPattern,
inputData, kDataSize, outputData, kDataSize, iv,
subSamples, kSubSampleCount);
EXPECT_CALL(*cdm, DecryptV16(ElementsAreArray(sessionId, kSessionIdSize),
true,
Truly(paramsMatcher)))
.Times(1);
WVCryptoPlugin plugin(sessionId, kSessionIdSize, cdm.get());
AString errorDetailMessage;
ssize_t res = plugin.decrypt(false, keyId, iv, CryptoPlugin::kMode_AES_CTR,
noPattern, inputData, subSamples,
kSubSampleCount, outputData,
&errorDetailMessage);
EXPECT_EQ(static_cast<ssize_t>(kDataSize), res) <<
"WVCryptoPlugin decrypted the wrong number of bytes";
EXPECT_EQ(0u, errorDetailMessage.size()) <<
"WVCryptoPlugin reported a detailed error message.";
}
TEST_F(WVCryptoPluginTest, RejectsCens) {
android::sp<StrictMock<MockCDM>> cdm = new StrictMock<MockCDM>();
constexpr size_t kSubSampleCount = 2;
CryptoPlugin::SubSample subSamples[kSubSampleCount];
memset(subSamples, 0, sizeof(subSamples));
subSamples[0].mNumBytesOfEncryptedData = 16;
subSamples[1].mNumBytesOfClearData = 16;
subSamples[1].mNumBytesOfEncryptedData = 16;
uint8_t keyId[KEY_ID_SIZE];
uint8_t iv[KEY_IV_SIZE];
constexpr size_t kDataSize = 48;
uint8_t inputData[kDataSize];
uint8_t outputData[kDataSize];
FILE* fp = fopen("/dev/urandom", "r");
fread(keyId, sizeof(uint8_t), KEY_ID_SIZE, fp);
fread(iv, sizeof(uint8_t), KEY_IV_SIZE, fp);
fread(inputData, sizeof(uint8_t), kDataSize, fp);
fclose(fp);
android::CryptoPlugin::Pattern recommendedPattern = { 1, 9 };
// Provide the expected behavior for IsOpenSession
EXPECT_CALL(*cdm, IsOpenSession(_))
.WillRepeatedly(Return(true));
// Refuse calls to Decrypt
EXPECT_CALL(*cdm, DecryptV16(_, _, _))
.Times(0);
WVCryptoPlugin plugin(sessionId, kSessionIdSize, cdm.get());
AString errorDetailMessage;
ssize_t res = plugin.decrypt(false, keyId, iv, CryptoPlugin::kMode_AES_CTR,
recommendedPattern, inputData, subSamples,
kSubSampleCount, outputData,
&errorDetailMessage);
EXPECT_EQ(res, kErrorUnsupportedCrypto) <<
"WVCryptoPlugin did not return an error for 'cens'.";
EXPECT_NE(errorDetailMessage.size(), 0u) <<
"WVCryptoPlugin did not report a detailed error message for 'cens'.";
}
TEST_F(WVCryptoPluginTest, CommunicatesSecureBufferRequest) {
android::sp<StrictMock<MockCDM>> cdm = new StrictMock<MockCDM>();
uint8_t keyId[KEY_ID_SIZE];
uint8_t iv[KEY_IV_SIZE];
static const size_t kDataSize = 32;
uint8_t in[kDataSize];
uint8_t out[kDataSize];
FILE* fp = fopen("/dev/urandom", "r");
fread(keyId, sizeof(uint8_t), KEY_ID_SIZE, fp);
fread(iv, sizeof(uint8_t), KEY_IV_SIZE, fp);
fread(in, sizeof(uint8_t), kDataSize, fp);
fclose(fp);
static const uint32_t kSubSampleCount = 1;
CryptoPlugin::SubSample subSamples[kSubSampleCount];
memset(subSamples, 0, sizeof(subSamples));
subSamples[0].mNumBytesOfClearData = 16;
subSamples[0].mNumBytesOfEncryptedData = 16;
// Provide the expected behavior for IsOpenSession
EXPECT_CALL(*cdm, IsOpenSession(_))
.WillRepeatedly(Return(true));
// Specify the expected calls to Decrypt
{
InSequence calls;
typedef CdmDecryptionParametersV16 CDP;
EXPECT_CALL(*cdm, DecryptV16(_, _, Field(&CDP::is_secure, false)))
.Times(1);
EXPECT_CALL(*cdm, DecryptV16(_, _, Field(&CDP::is_secure, true)))
.Times(1);
}
WVCryptoPlugin plugin(sessionId, kSessionIdSize, cdm.get());
android::CryptoPlugin::Pattern noPattern = { 0, 0 };
AString errorDetailMessage;
ssize_t res = plugin.decrypt(false, keyId, iv, CryptoPlugin::kMode_AES_CTR,
noPattern, in, subSamples, kSubSampleCount,
out, &errorDetailMessage);
ASSERT_GE(res, 0) <<
"WVCryptoPlugin returned an error";
EXPECT_EQ(0u, errorDetailMessage.size()) <<
"WVCryptoPlugin reported a detailed error message.";
res = plugin.decrypt(true, keyId, iv, CryptoPlugin::kMode_AES_CTR,
noPattern, in, subSamples, kSubSampleCount, out,
&errorDetailMessage);
ASSERT_GE(res, 0) <<
"WVCryptoPlugin returned an error";
EXPECT_EQ(0u, errorDetailMessage.size()) <<
"WVCryptoPlugin reported a detailed error message.";
}
TEST_F(WVCryptoPluginTest, AllowsSessionIdChanges) {
android::sp<StrictMock<MockCDM>> cdm = new StrictMock<MockCDM>();
uint8_t keyId[KEY_ID_SIZE];
uint8_t iv[KEY_IV_SIZE];
uint8_t sessionId2[kSessionIdSize];
static const size_t kDataSize = 32;
uint8_t in[kDataSize];
uint8_t out[kDataSize];
FILE* fp = fopen("/dev/urandom", "r");
fread(keyId, sizeof(uint8_t), KEY_ID_SIZE, fp);
fread(iv, sizeof(uint8_t), KEY_IV_SIZE, fp);
fread(sessionId2, sizeof(uint8_t), kSessionIdSize, fp);
fread(in, sizeof(uint8_t), kDataSize, fp);
fclose(fp);
static const uint32_t kSubSampleCount = 1;
CryptoPlugin::SubSample subSamples[kSubSampleCount];
memset(subSamples, 0, sizeof(subSamples));
subSamples[0].mNumBytesOfClearData = 16;
subSamples[0].mNumBytesOfEncryptedData = 16;
Vector<uint8_t> sessionIdVector;
sessionIdVector.appendArray(sessionId, kSessionIdSize);
Vector<uint8_t> sessionId2Vector;
sessionId2Vector.appendArray(sessionId2, kSessionIdSize);
// Provide the expected behavior for IsOpenSession
EXPECT_CALL(*cdm, IsOpenSession(_))
.WillRepeatedly(Return(true));
// Specify the expected calls to Decrypt
{
InSequence calls;
EXPECT_CALL(*cdm,
DecryptV16(ElementsAreArray(sessionId, kSessionIdSize), _, _))
.Times(1);
EXPECT_CALL(*cdm,
DecryptV16(ElementsAreArray(sessionId2, kSessionIdSize), _, _))
.Times(1);
}
uint8_t blank[1]; // Some compilers will not accept 0.
WVCryptoPlugin plugin(blank, 0, cdm.get());
android::CryptoPlugin::Pattern noPattern = { 0, 0 };
AString errorDetailMessage;
ssize_t res;
res = plugin.setMediaDrmSession(sessionIdVector);
EXPECT_EQ(android::NO_ERROR, res);
res = plugin.decrypt(false, keyId, iv, CryptoPlugin::kMode_AES_CTR,
noPattern, in, subSamples, kSubSampleCount, out,
&errorDetailMessage);
EXPECT_GE(res, 0) <<
"WVCryptoPlugin returned an error";
EXPECT_EQ(0u, errorDetailMessage.size()) <<
"WVCryptoPlugin reported a detailed error message.";
res = plugin.setMediaDrmSession(sessionId2Vector);
EXPECT_EQ(android::NO_ERROR, res);
res = plugin.decrypt(false, keyId, iv, CryptoPlugin::kMode_AES_CTR,
noPattern, in, subSamples, kSubSampleCount, out,
&errorDetailMessage);
EXPECT_GE(res, 0) <<
"WVCryptoPlugin returned an error";
EXPECT_EQ(0u, errorDetailMessage.size()) <<
"WVCryptoPlugin reported a detailed error message.";
}
TEST_F(WVCryptoPluginTest, DisallowsUnopenedSessionIdChanges) {
android::sp<StrictMock<MockCDM>> cdm = new StrictMock<MockCDM>();
uint8_t blank[1]; // Some compilers will not accept 0.
Vector<uint8_t> sessionIdVector;
sessionIdVector.appendArray(sessionId, kSessionIdSize);
// Specify the expected calls to IsOpenSession
{
InSequence calls;
EXPECT_CALL(*cdm, IsOpenSession(ElementsAreArray(blank, 0)))
.WillOnce(Return(false));
EXPECT_CALL(*cdm, IsOpenSession(ElementsAreArray(sessionId, kSessionIdSize)))
.WillOnce(Return(false))
.WillOnce(Return(true));
}
WVCryptoPlugin plugin(blank, 0, cdm.get());
ssize_t res;
res = plugin.setMediaDrmSession(sessionIdVector);
EXPECT_EQ(android::ERROR_DRM_SESSION_NOT_OPENED, res);
res = plugin.setMediaDrmSession(sessionIdVector);
EXPECT_EQ(android::NO_ERROR, res);
}

View File

@@ -12,55 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
// ----------------------------------------------------------------------------
// Builds libwvdrmdrmplugin
//
// *** THIS PACKAGE HAS SPECIAL LICENSING CONDITIONS. PLEASE
// CONSULT THE OWNERS AND opensource-licensing@google.com BEFORE
// DEPENDING ON IT IN YOUR PROJECT. ***
package {
// See: http://go/android-license-faq
// A large-scale-change added 'default_applicable_licenses' to import
// all of the 'license_kinds' from "vendor_widevine_license"
// to get the below license kinds:
// legacy_by_exception_only (by exception only)
default_applicable_licenses: ["vendor_widevine_license"],
}
cc_library_static {
name: "libwvdrmdrmplugin",
srcs: [
"src/WVDrmPlugin.cpp",
"src/WVGenericCryptoInterface.cpp",
],
include_dirs: [
"frameworks/av/include",
"frameworks/native/include",
"vendor/widevine/libwvdrmengine/cdm/core/include",
"vendor/widevine/libwvdrmengine/cdm/include",
"vendor/widevine/libwvdrmengine/cdm/metrics/include",
"vendor/widevine/libwvdrmengine/cdm/util/include",
"vendor/widevine/libwvdrmengine/include",
"vendor/widevine/libwvdrmengine/mediadrm/include",
"vendor/widevine/libwvdrmengine/oemcrypto/include",
],
header_libs: [
"libstagefright_headers",
"libstagefright_foundation_headers",
"libutils_headers",
],
shared_libs: ["liblog"],
static_libs: ["libcdm_protos"],
proprietary: true,
}
// ----------------------------------------------------------------------------
// Builds libwvdrmdrmplugin_hidl
//
@@ -83,7 +34,6 @@ cc_library_static {
"vendor/widevine/libwvdrmengine/include_hidl",
"vendor/widevine/libwvdrmengine/include",
"vendor/widevine/libwvdrmengine/mediadrm/include_hidl",
"vendor/widevine/libwvdrmengine/mediadrm/include",
"vendor/widevine/libwvdrmengine/oemcrypto/include",
],

View File

@@ -1,306 +0,0 @@
//
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
#ifndef WV_DRM_PLUGIN_H_
#define WV_DRM_PLUGIN_H_
#include <stdint.h>
#include <map>
#include "cdm_client_property_set.h"
#include "cdm_identifier.h"
#include "media/drm/DrmAPI.h"
#include "media/stagefright/foundation/ABase.h"
#include "media/stagefright/foundation/AString.h"
#include "OEMCryptoCENC.h"
#include "utils/Errors.h"
#include "utils/KeyedVector.h"
#include "utils/List.h"
#include "utils/String8.h"
#include "utils/StrongPointer.h"
#include "utils/Vector.h"
#include "wv_cdm_event_listener.h"
#include "wv_content_decryption_module.h"
#include "WVGenericCryptoInterface.h"
namespace wvdrm {
using android::KeyedVector;
using android::List;
using android::status_t;
using android::String8;
using android::Vector;
using std::map;
using wvcdm::CdmIdentifier;
using wvcdm::CdmKeyStatusMap;
using wvcdm::CdmSessionId;
using wvcdm::CdmResponseType;
using wvcdm::WvContentDecryptionModule;
const OEMCrypto_Algorithm kInvalidCryptoAlgorithm =
static_cast<OEMCrypto_Algorithm>(-1);
class WVDrmPlugin : public android::DrmPlugin,
public wvcdm::WvCdmEventListener {
public:
WVDrmPlugin(const android::sp<wvcdm::WvContentDecryptionModule>& cdm,
WVGenericCryptoInterface* crypto);
virtual ~WVDrmPlugin();
virtual status_t openSession(Vector<uint8_t>& sessionId);
virtual status_t closeSession(const Vector<uint8_t>& sessionId);
virtual status_t getKeyRequest(
const Vector<uint8_t>& scope,
const Vector<uint8_t>& initData,
const String8& initDataType,
KeyType keyType,
const KeyedVector<String8, String8>& optionalParameters,
Vector<uint8_t>& request,
String8& defaultUrl,
KeyRequestType *keyRequestType);
virtual status_t provideKeyResponse(const Vector<uint8_t>& scope,
const Vector<uint8_t>& response,
Vector<uint8_t>& keySetId);
virtual status_t removeKeys(const Vector<uint8_t>& sessionId);
virtual status_t restoreKeys(const Vector<uint8_t>& sessionId,
const Vector<uint8_t>& keySetId);
virtual status_t queryKeyStatus(
const Vector<uint8_t>& sessionId,
KeyedVector<String8, String8>& infoMap) const;
virtual status_t getProvisionRequest(const String8& cert_type,
const String8& cert_authority,
Vector<uint8_t>& request,
String8& defaultUrl);
virtual status_t provideProvisionResponse(const Vector<uint8_t>& response,
Vector<uint8_t>& certificate,
Vector<uint8_t>& wrapped_key);
virtual status_t unprovisionDevice();
virtual status_t getSecureStop(const Vector<uint8_t>& ssid,
Vector<uint8_t>& secureStop);
virtual status_t getSecureStops(List<Vector<uint8_t> >& secureStops);
virtual status_t releaseAllSecureStops();
virtual status_t releaseSecureStops(const Vector<uint8_t>& ssRelease);
virtual status_t getPropertyString(const String8& name, String8& value) const;
virtual status_t getPropertyByteArray(const String8& name,
Vector<uint8_t>& value) const;
virtual status_t setPropertyString(const String8& name, const String8& value);
virtual status_t setPropertyByteArray(const String8& name,
const Vector<uint8_t>& value);
virtual status_t setCipherAlgorithm(const Vector<uint8_t>& sessionId,
const String8& algorithm);
virtual status_t setMacAlgorithm(const Vector<uint8_t>& sessionId,
const String8& algorithm);
virtual status_t encrypt(const Vector<uint8_t>& sessionId,
const Vector<uint8_t>& keyId,
const Vector<uint8_t>& input,
const Vector<uint8_t>& iv,
Vector<uint8_t>& output);
virtual status_t decrypt(const Vector<uint8_t>& sessionId,
const Vector<uint8_t>& keyId,
const Vector<uint8_t>& input,
const Vector<uint8_t>& iv,
Vector<uint8_t>& output);
virtual status_t sign(const Vector<uint8_t>& sessionId,
const Vector<uint8_t>& keyId,
const Vector<uint8_t>& message,
Vector<uint8_t>& signature);
virtual status_t verify(const Vector<uint8_t>& sessionId,
const Vector<uint8_t>& keyId,
const Vector<uint8_t>& message,
const Vector<uint8_t>& signature,
bool& match);
virtual status_t signRSA(const Vector<uint8_t>& sessionId,
const String8& algorithm,
const Vector<uint8_t>& message,
const Vector<uint8_t>& wrappedKey,
Vector<uint8_t>& signature);
virtual void OnSessionRenewalNeeded(const CdmSessionId& cdmSessionId);
virtual void OnSessionKeysChange(const CdmSessionId& cdmSessionId,
const CdmKeyStatusMap& cdmKeysStatus,
bool hasNewUsableKey);
virtual void OnExpirationUpdate(const CdmSessionId& cdmSessionId,
int64_t newExpiryTimeSeconds);
private:
DISALLOW_EVIL_CONSTRUCTORS(WVDrmPlugin);
struct CryptoSession {
public:
CryptoSession()
: mOecSessionId(-1),
mCipherAlgorithm(kInvalidCryptoAlgorithm),
mMacAlgorithm(kInvalidCryptoAlgorithm) {}
CryptoSession(OEMCrypto_SESSION sessionId)
: mOecSessionId(sessionId),
mCipherAlgorithm(kInvalidCryptoAlgorithm),
mMacAlgorithm(kInvalidCryptoAlgorithm) {}
OEMCrypto_SESSION oecSessionId() const { return mOecSessionId; }
OEMCrypto_Algorithm cipherAlgorithm() const { return mCipherAlgorithm; }
void setCipherAlgorithm(OEMCrypto_Algorithm newAlgorithm) {
mCipherAlgorithm = newAlgorithm;
}
OEMCrypto_Algorithm macAlgorithm() const { return mMacAlgorithm; }
void setMacAlgorithm(OEMCrypto_Algorithm newAlgorithm) {
mMacAlgorithm = newAlgorithm;
}
private:
OEMCrypto_SESSION mOecSessionId;
OEMCrypto_Algorithm mCipherAlgorithm;
OEMCrypto_Algorithm mMacAlgorithm;
};
class WVClientPropertySet : public wvcdm::CdmClientPropertySet {
public:
WVClientPropertySet()
: mUsePrivacyMode(false), mShareKeys(false), mSessionSharingId(0),
mUseAtscMode(false) {}
virtual ~WVClientPropertySet() {}
virtual const std::string& security_level() const {
return mSecurityLevel;
}
void set_security_level(const std::string& securityLevel) {
mSecurityLevel = securityLevel;
}
virtual bool use_privacy_mode() const {
return mUsePrivacyMode;
}
void set_use_privacy_mode(bool usePrivacyMode) {
mUsePrivacyMode = usePrivacyMode;
}
virtual const std::string& service_certificate() const {
return mServiceCertificate;
}
virtual void set_service_certificate(
const std::string& serviceCertificate) {
mServiceCertificate = serviceCertificate;
}
virtual bool is_session_sharing_enabled() const {
return mShareKeys;
}
void set_is_session_sharing_enabled(bool shareKeys) {
mShareKeys = shareKeys;
}
virtual uint32_t session_sharing_id() const {
return mSessionSharingId;
}
virtual void set_session_sharing_id(uint32_t id) {
mSessionSharingId = id;
}
virtual const std::string& app_id() const {
return mAppId;
}
void set_app_id(const std::string& appId) {
mAppId = appId;
}
virtual bool use_atsc_mode() const {
return mUseAtscMode;
}
void set_use_atsc_mode(bool useAtscMode) {
mUseAtscMode = useAtscMode;
}
private:
DISALLOW_EVIL_CONSTRUCTORS(WVClientPropertySet);
std::string mSecurityLevel;
bool mUsePrivacyMode;
std::string mServiceCertificate;
bool mShareKeys;
uint32_t mSessionSharingId;
std::string mAppId;
bool mUseAtscMode;
const std::string mEmptyString;
} mPropertySet;
android::sp<wvcdm::WvContentDecryptionModule> const mCDM;
WVGenericCryptoInterface* mCrypto;
map<CdmSessionId, CryptoSession> mCryptoSessions;
CdmIdentifier mCdmIdentifier;
std::string mProvisioningServiceCertificate;
CdmSessionId mDecryptHashSessionId;
status_t queryProperty(const std::string& property,
std::string& stringValue) const;
status_t queryProperty(wvcdm::SecurityLevel securityLevel,
const std::string& property,
std::string& stringValue) const;
status_t queryProperty(const std::string& property,
String8& string8_value) const;
status_t queryProperty(const std::string& property,
Vector<uint8_t>& vector_value) const;
status_t mapAndNotifyOfCdmResponseType(const Vector<uint8_t>& sessionId,
CdmResponseType res);
status_t mapAndNotifyOfOEMCryptoResult(const Vector<uint8_t>& sessionId,
OEMCryptoResult res);
status_t mapOEMCryptoResult(OEMCryptoResult res);
bool initDataResemblesPSSH(const Vector<uint8_t>& initData);
status_t unprovision(const CdmIdentifier& identifier);
};
} // namespace wvdrm
#endif // WV_DRM_PLUGIN_H_

View File

@@ -1,98 +0,0 @@
//
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
#ifndef WV_GENERIC_CRYPTO_INTERFACE_H_
#define WV_GENERIC_CRYPTO_INTERFACE_H_
#include <stdint.h>
#include "OEMCryptoCENC.h"
#include "media/stagefright/foundation/ABase.h"
#include "utils/Vector.h"
namespace wvdrm {
class WVGenericCryptoInterface {
public:
WVGenericCryptoInterface() {}
virtual ~WVGenericCryptoInterface() {}
virtual OEMCryptoResult selectKey(const OEMCrypto_SESSION session,
const uint8_t* key_id,
size_t key_id_length) {
return OEMCrypto_SelectKey(session, key_id, key_id_length,
OEMCrypto_CipherMode_CBC);
}
virtual OEMCryptoResult encrypt(OEMCrypto_SESSION session,
const uint8_t* in_buffer,
size_t buffer_length, const uint8_t* iv,
OEMCrypto_Algorithm algorithm,
uint8_t* out_buffer) {
return OEMCrypto_Generic_Encrypt(session, in_buffer, buffer_length, iv,
algorithm, out_buffer);
}
virtual OEMCryptoResult decrypt(OEMCrypto_SESSION session,
const uint8_t* in_buffer,
size_t buffer_length, const uint8_t* iv,
OEMCrypto_Algorithm algorithm,
uint8_t* out_buffer) {
return OEMCrypto_Generic_Decrypt(session, in_buffer, buffer_length, iv,
algorithm, out_buffer);
}
virtual OEMCryptoResult sign(OEMCrypto_SESSION session,
const uint8_t* in_buffer, size_t buffer_length,
OEMCrypto_Algorithm algorithm,
uint8_t* signature, size_t* signature_length) {
return OEMCrypto_Generic_Sign(session, in_buffer, buffer_length, algorithm,
signature, signature_length);
}
virtual OEMCryptoResult verify(OEMCrypto_SESSION session,
const uint8_t* in_buffer, size_t buffer_length,
OEMCrypto_Algorithm algorithm,
const uint8_t* signature,
size_t signature_length) {
return OEMCrypto_Generic_Verify(session, in_buffer, buffer_length,
algorithm, signature, signature_length);
}
virtual OEMCryptoResult signRSA(const uint8_t* wrapped_rsa_key,
size_t wrapped_rsa_key_length,
const uint8_t* message,
size_t message_length,
android::Vector<uint8_t>& signature,
RSA_Padding_Scheme padding_scheme);
virtual OEMCryptoResult loadDeviceRSAKey(OEMCrypto_SESSION session,
const uint8_t* wrapped_rsa_key,
size_t wrapped_rsa_key_length) {
return OEMCrypto_LoadDRMPrivateKey(session, OEMCrypto_RSA_Private_Key,
wrapped_rsa_key, wrapped_rsa_key_length);
}
virtual OEMCryptoResult generateRSASignature(
OEMCrypto_SESSION session,
const uint8_t* message,
size_t message_length,
uint8_t* signature,
size_t* signature_length,
RSA_Padding_Scheme padding_scheme) {
return OEMCrypto_GenerateRSASignature(session, message, message_length,
signature, signature_length,
padding_scheme);
}
private:
DISALLOW_EVIL_CONSTRUCTORS(WVGenericCryptoInterface);
};
} // namespace wvdrm
#endif // WV_GENERIC_CRYPTO_INTERFACE_H_

File diff suppressed because it is too large Load Diff

View File

@@ -1,51 +0,0 @@
//
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
//#define LOG_NDEBUG 0
#define LOG_TAG "WVCdm"
#include <utils/Log.h>
#include "WVGenericCryptoInterface.h"
#include "wv_cdm_constants.h"
namespace wvdrm {
using namespace android;
using namespace std;
using namespace wvcdm;
OEMCryptoResult WVGenericCryptoInterface::signRSA(const uint8_t* wrapped_rsa_key,
size_t wrapped_rsa_key_length,
const uint8_t* message,
size_t message_length,
Vector<uint8_t>& signature,
RSA_Padding_Scheme padding_scheme) {
OEMCrypto_SESSION session;
OEMCryptoResult sts = OEMCrypto_OpenSession(&session);
if (sts != OEMCrypto_SUCCESS) return sts;
sts = OEMCrypto_LoadDRMPrivateKey(session, OEMCrypto_RSA_Private_Key,
wrapped_rsa_key, wrapped_rsa_key_length);
if (sts == OEMCrypto_SUCCESS) {
size_t signatureSize = 0;
sts = OEMCrypto_GenerateRSASignature(session, message, message_length,
NULL, &signatureSize,
padding_scheme);
if (sts == OEMCrypto_SUCCESS) {
// Should be short buffer.
sts = OEMCrypto_ERROR_UNKNOWN_FAILURE;
} else if (sts == OEMCrypto_ERROR_SHORT_BUFFER) {
signature.resize(signatureSize);
sts = OEMCrypto_GenerateRSASignature(session, message, message_length,
signature.editArray(), &signatureSize,
padding_scheme);
}
}
OEMCrypto_CloseSession(session);
return sts;
}
} // namespace wvdrm

View File

@@ -1,70 +1,5 @@
LOCAL_PATH := $(call my-dir)
# -----------------------------------------------------------------------------
# Builds libwvdrmdrmplugin_test
#
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
legacy_src/WVDrmPlugin_test.cpp \
LOCAL_C_INCLUDES := \
frameworks/av/include \
frameworks/native/include \
vendor/widevine/libwvdrmengine/cdm/core/include \
vendor/widevine/libwvdrmengine/cdm/include \
vendor/widevine/libwvdrmengine/cdm/metrics/include \
vendor/widevine/libwvdrmengine/cdm/util/include \
vendor/widevine/libwvdrmengine/include \
vendor/widevine/libwvdrmengine/mediadrm/include \
vendor/widevine/libwvdrmengine/oemcrypto/include \
LOCAL_STATIC_LIBRARIES := \
libcdm \
libcdm_protos \
libcdm_utils \
libjsmn \
libgmock \
libgmock_main \
libgtest \
libwvlevel3 \
libwvdrmdrmplugin \
libwv_odk \
LOCAL_SHARED_LIBRARIES := \
libbase \
libcrypto \
libdl \
libhidlbase \
liblog \
libprotobuf-cpp-lite \
libutils \
LOCAL_HEADER_LIBRARIES := \
libstagefright_headers \
libstagefright_foundation_headers \
LOCAL_C_INCLUDES += \
external/protobuf/src \
LOCAL_MODULE := libwvdrmdrmplugin_test
LOCAL_LICENSE_KINDS := legacy_by_exception_only
LOCAL_LICENSE_CONDITIONS := by_exception_only
LOCAL_MODULE_TAGS := tests
LOCAL_MODULE_OWNER := widevine
LOCAL_PROPRIETARY_MODULE := true
# When built, explicitly put it in the DATA/nativetest directory.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
ifneq ($(TARGET_ENABLE_MEDIADRM_64), true)
LOCAL_MODULE_TARGET_ARCH := arm x86 mips
endif
include $(BUILD_EXECUTABLE)
# -----------------------------------------------------------------------------
# Builds libwvdrmdrmplugin_hidl_test
#
@@ -83,7 +18,6 @@ LOCAL_C_INCLUDES := \
vendor/widevine/libwvdrmengine/include_hidl \
vendor/widevine/libwvdrmengine/include \
vendor/widevine/libwvdrmengine/mediadrm/include_hidl \
vendor/widevine/libwvdrmengine/mediadrm/include \
vendor/widevine/libwvdrmengine/oemcrypto/include \
LOCAL_STATIC_LIBRARIES := \
@@ -156,7 +90,6 @@ LOCAL_C_INCLUDES := \
vendor/widevine/libwvdrmengine/include_hidl \
vendor/widevine/libwvdrmengine/include \
vendor/widevine/libwvdrmengine/mediadrm/include_hidl \
vendor/widevine/libwvdrmengine/mediadrm/include \
vendor/widevine/libwvdrmengine/oemcrypto/include \
LOCAL_STATIC_LIBRARIES := \

File diff suppressed because it is too large Load Diff

View File

@@ -112,9 +112,7 @@ adb_shell_run hidl_metrics_adapter_unittest
adb_shell_run http_socket_test
adb_shell_run initialization_data_unittest
adb_shell_run libwvdrmdrmplugin_hidl_test
adb_shell_run libwvdrmdrmplugin_test
adb_shell_run libwvdrmmediacrypto_hidl_test
adb_shell_run libwvdrmmediacrypto_test
adb_shell_run license_keys_unittest
adb_shell_run license_unittest
adb_shell_run odk_test
@@ -130,13 +128,6 @@ adb_shell_run usage_table_header_unittest
adb_shell_run value_metric_unittest
adb_shell_run wv_cdm_metrics_test
# Run the non-Treble test on non-Treble devices
if adb $SERIAL_NUM shell ls /vendor/lib/mediadrm/libwvdrmengine.so &> /dev/null ||
adb $SERIAL_NUM shell ls /vendor/lib64/mediadrm/libwvdrmengine.so &> /dev/null; then
library_path="/vendor/lib/mediadrm/:/vendor/lib64/mediadrm/"
adb_shell_run libwvdrmengine_test LD_LIBRARY_PATH=$library_path
fi
# Run the Treble test on Treble devices
if adb $SERIAL_NUM shell ls /vendor/lib/libwvhidl.so &> /dev/null ||
adb $SERIAL_NUM shell ls /vendor/lib64/libwvhidl.so &> /dev/null; then

View File

@@ -1,22 +0,0 @@
//
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
#include "WVCreatePluginFactories.h"
#include "WVCryptoFactory.h"
#include "WVDrmFactory.h"
extern "C" {
android::DrmFactory* createDrmFactory() {
return new wvdrm::WVDrmFactory();
}
android::CryptoFactory* createCryptoFactory() {
return new wvdrm::WVCryptoFactory();
}
} // extern "C"

View File

@@ -1,39 +0,0 @@
//
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
//#define LOG_NDEBUG 0
#define LOG_TAG "WVCdm"
#include <utils/Log.h>
#include "WVCryptoFactory.h"
#include <dlfcn.h>
#include "utils/Errors.h"
#include "WVCDMSingleton.h"
#include "WVCryptoPlugin.h"
#include "WVUUID.h"
namespace wvdrm {
using namespace android;
bool WVCryptoFactory::isCryptoSchemeSupported(const uint8_t uuid[16]) const {
return isWidevineUUID(uuid);
}
status_t WVCryptoFactory::createPlugin(const uint8_t uuid[16], const void* data,
size_t size, CryptoPlugin** plugin) {
if (!isCryptoSchemeSupported(uuid)) {
*plugin = NULL;
return BAD_VALUE;
}
*plugin = new WVCryptoPlugin(data, size, getCDM());
return OK;
}
} // namespace wvdrm

View File

@@ -1,46 +0,0 @@
//
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
//#define LOG_NDEBUG 0
#define LOG_TAG "WVCdm"
#include <utils/Log.h>
#include "WVDrmFactory.h"
#include "utils/Errors.h"
#include "wv_cdm_constants.h"
#include "WVCDMSingleton.h"
#include "wv_content_decryption_module.h"
#include "WVDrmPlugin.h"
#include "WVUUID.h"
namespace wvdrm {
using namespace android;
WVGenericCryptoInterface WVDrmFactory::sOemCryptoInterface;
bool WVDrmFactory::isCryptoSchemeSupported(const uint8_t uuid[16]) {
return isWidevineUUID(uuid);
}
bool WVDrmFactory::isContentTypeSupported(const String8 &initDataType) {
return wvcdm::WvContentDecryptionModule::IsSupported(initDataType.string());
}
status_t WVDrmFactory::createDrmPlugin(const uint8_t uuid[16],
DrmPlugin** plugin) {
if (!isCryptoSchemeSupported(uuid)) {
*plugin = NULL;
return BAD_VALUE;
}
*plugin = new WVDrmPlugin(getCDM(), &sOemCryptoInterface);
return OK;
}
} // namespace wvdrm

View File

@@ -1,55 +1,5 @@
LOCAL_PATH:= $(call my-dir)
# -----------------------------------------------------------------------------
# Builds libwvdrmengine_test
#
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
legacy_src/WVCreatePluginFactories_test.cpp \
legacy_src/WVCryptoFactory_test.cpp \
legacy_src/WVDrmFactory_test.cpp \
LOCAL_C_INCLUDES := \
frameworks/av/include \
frameworks/native/include \
vendor/widevine/libwvdrmengine/include \
vendor/widevine/libwvdrmengine/mediadrm/include \
vendor/widevine/libwvdrmengine/oemcrypto/include \
LOCAL_STATIC_LIBRARIES := \
libgtest \
libgtest_main \
LOCAL_SHARED_LIBRARIES := \
libcrypto \
libdl \
liblog \
libutils \
libwvdrmengine \
LOCAL_HEADER_LIBRARIES := \
libstagefright_headers \
libstagefright_foundation_headers \
LOCAL_MODULE := libwvdrmengine_test
LOCAL_LICENSE_KINDS := legacy_by_exception_only
LOCAL_LICENSE_CONDITIONS := by_exception_only
LOCAL_MODULE_TAGS := tests
LOCAL_MODULE_OWNER := widevine
LOCAL_PROPRIETARY_MODULE := true
# When built, explicitly put it in the DATA/nativetest directory.
LOCAL_MODULE_PATH := $(TARGET_OUT_DATA)/nativetest
ifneq ($(TARGET_ENABLE_MEDIADRM_64), true)
LOCAL_MODULE_TARGET_ARCH := arm x86 mips
endif
include $(BUILD_EXECUTABLE)
# -----------------------------------------------------------------------------
# Builds libwvdrmengine_hidl_test
#
@@ -66,7 +16,6 @@ LOCAL_C_INCLUDES := \
vendor/widevine/libwvdrmengine/include_hidl \
vendor/widevine/libwvdrmengine/include \
vendor/widevine/libwvdrmengine/mediadrm/include_hidl \
vendor/widevine/libwvdrmengine/mediadrm/include \
vendor/widevine/libwvdrmengine/oemcrypto/include \
LOCAL_STATIC_LIBRARIES := \

View File

@@ -1,26 +0,0 @@
//
// Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
#include "gtest/gtest.h"
#include "WVCreatePluginFactories.h"
#include <memory>
using namespace android;
TEST(CreatePluginFactoriesTest, CreatesDrmFactory) {
std::unique_ptr<DrmFactory> factory(createDrmFactory());
EXPECT_NE((DrmFactory*)NULL, factory.get()) <<
"createDrmFactory() returned null";
}
TEST(CreatePluginFactoriesTest, CreatesCryptoFactory) {
std::unique_ptr<CryptoFactory> factory(createCryptoFactory());
EXPECT_NE((CryptoFactory*)NULL, factory.get()) <<
"createCryptoFactory() returned null";
}

View File

@@ -1,44 +0,0 @@
/*
* Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
* source code may only be used and distributed under the Widevine License
* Agreement.
*/
#include "gtest/gtest.h"
#include "WVCryptoFactory.h"
#include <memory>
using namespace wvdrm;
const uint8_t kWidevineUUID[16] = {
0xED,0xEF,0x8B,0xA9,0x79,0xD6,0x4A,0xCE,
0xA3,0xC8,0x27,0xDC,0xD5,0x1D,0x21,0xED
};
const uint8_t kOldNetflixWidevineUUID[16] = {
0x29,0x70,0x1F,0xE4,0x3C,0xC7,0x4A,0x34,
0x8C,0x5B,0xAE,0x90,0xC7,0x43,0x9A,0x47
};
const uint8_t kUnknownUUID[16] = {
0x6A,0x7F,0xAA,0xB0,0x83,0xC7,0x9E,0x20,
0x08,0xBC,0xEF,0x32,0x34,0x1A,0x9A,0x26
};
TEST(WVCryptoFactoryTest, SupportsSupportedCryptoSchemes) {
std::unique_ptr<WVCryptoFactory> factory(new WVCryptoFactory());
EXPECT_TRUE(factory->isCryptoSchemeSupported(kWidevineUUID)) <<
"WVPluginFactory does not support Widevine's UUID";
EXPECT_TRUE(factory->isCryptoSchemeSupported(kOldNetflixWidevineUUID)) <<
"WVPluginFactory does not support the old Netflix Widevine UUID";
}
TEST(WVCryptoFactoryTest, DoesNotSupportUnsupportedCryptoSchemes) {
std::unique_ptr<WVCryptoFactory> factory(new WVCryptoFactory());
EXPECT_FALSE(factory->isCryptoSchemeSupported(kUnknownUUID)) <<
"WVPluginFactory incorrectly claims to support an unknown UUID";
}

View File

@@ -1,88 +0,0 @@
/*
* Copyright 2018 Google LLC. All Rights Reserved. This file and proprietary
* source code may only be used and distributed under the Widevine License
* Agreement.
*/
#include "gtest/gtest.h"
#include "WVDrmFactory.h"
using namespace wvdrm;
using namespace android;
const uint8_t kWidevineUUID[16] = {
0xED,0xEF,0x8B,0xA9,0x79,0xD6,0x4A,0xCE,
0xA3,0xC8,0x27,0xDC,0xD5,0x1D,0x21,0xED
};
const uint8_t kOldNetflixWidevineUUID[16] = {
0x29,0x70,0x1F,0xE4,0x3C,0xC7,0x4A,0x34,
0x8C,0x5B,0xAE,0x90,0xC7,0x43,0x9A,0x47
};
const uint8_t kUnknownUUID[16] = {
0x6A,0x7F,0xAA,0xB0,0x83,0xC7,0x9E,0x20,
0x08,0xBC,0xEF,0x32,0x34,0x1A,0x9A,0x26
};
TEST(WVDrmFactoryTest, SupportsSupportedCryptoSchemes) {
WVDrmFactory factory;
EXPECT_TRUE(factory.isCryptoSchemeSupported(kWidevineUUID)) <<
"WVPluginFactory does not support Widevine's UUID";
EXPECT_TRUE(factory.isCryptoSchemeSupported(kOldNetflixWidevineUUID)) <<
"WVPluginFactory does not support the old Netflix Widevine UUID";
}
TEST(WVDrmFactoryTest, DoesNotSupportUnsupportedCryptoSchemes) {
WVDrmFactory factory;
EXPECT_FALSE(factory.isCryptoSchemeSupported(kUnknownUUID)) <<
"WVPluginFactory incorrectly claims to support an unknown UUID";
}
TEST(WVDrmFactoryTest, SupportsSupportedContainerFormats) {
WVDrmFactory factory;
EXPECT_TRUE(factory.isContentTypeSupported(String8("video/mp4"))) <<
"WVPluginFactory does not support ISO-BMFF video";
EXPECT_TRUE(factory.isContentTypeSupported(String8("audio/mp4"))) <<
"WVPluginFactory does not support ISO-BMFF audio";
EXPECT_TRUE(factory.isContentTypeSupported(String8("video/webm"))) <<
"WVPluginFactory does not support WebM video";
EXPECT_TRUE(factory.isContentTypeSupported(String8("audio/webm"))) <<
"WVPluginFactory does not support WebM audio";
}
TEST(WVDrmFactoryTest, DoesNotSupportUnsupportedContainerFormats) {
WVDrmFactory factory;
// Taken from Encoding.com's list of the most common internet video MIME-types
EXPECT_FALSE(factory.isContentTypeSupported(String8("video/x-matroska"))) <<
"WVPluginFactory incorrectly claims to support Matroska";
EXPECT_FALSE(factory.isContentTypeSupported(String8("video/x-flv"))) <<
"WVPluginFactory incorrectly claims to support Flash Video";
EXPECT_FALSE(factory.isContentTypeSupported(String8("application/x-mpegURL"))) <<
"WVPluginFactory incorrectly claims to support m3u8 Indexes";
EXPECT_FALSE(factory.isContentTypeSupported(String8("video/MP2T"))) <<
"WVPluginFactory incorrectly claims to support MPEG-2 TS";
EXPECT_FALSE(factory.isContentTypeSupported(String8("video/3gpp"))) <<
"WVPluginFactory incorrectly claims to support 3GP Mobile";
EXPECT_FALSE(factory.isContentTypeSupported(String8("video/quicktime"))) <<
"WVPluginFactory incorrectly claims to support Quicktime";
EXPECT_FALSE(factory.isContentTypeSupported(String8("video/x-msvideo"))) <<
"WVPluginFactory incorrectly claims to support AVI";
EXPECT_FALSE(factory.isContentTypeSupported(String8("video/x-ms-wmv"))) <<
"WVPluginFactory incorrectly claims to support WMV";
}

View File

@@ -27,11 +27,8 @@ WIDEVINE_TEST_MAKE_TARGETS += \
http_socket_test \
initialization_data_unittest \
libwvdrmdrmplugin_hidl_test \
libwvdrmdrmplugin_test \
libwvdrmengine_hidl_test \
libwvdrmengine_test \
libwvdrmmediacrypto_hidl_test \
libwvdrmmediacrypto_test \
license_keys_unittest \
license_unittest \
odk_test \