// 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 "properties_ce.h" #include #include #include #include "cdm_version.h" #include "compiler_detection.h" #include "log.h" #include "properties.h" // This anonymous namespace is shared between both the widevine namespace and // wvcdm namespace objects below. namespace { bool use_secure_buffers_ = false; bool use_fifo_ = false; bool use_userspace_buffers_ = true; bool set_provisioning_messages_to_binary_ = false; std::string sandbox_id_; widevine::Cdm::SecureOutputType secure_output_type_ = widevine::Cdm::kNoSecureOutput; bool GetValue(const char* source, std::string* output) { if (!source || !output) { return false; } *output = source; return source[0] != '\0'; } constexpr char kBuildInfo[] = CLIENT_VERSION " | " CLIENT_PLATFORM " | " CLIENT_FORM_FACTOR " | " CLIENT_ARCH_NAME " | CE CDM " CDM_VERSION " | " CPU_ARCH_MESSAGE " | " LOGGING_MESSAGE " | " BUILD_FLAVOR_MESSAGE; } // namespace namespace widevine { // static void PropertiesCE::SetSecureOutputType( Cdm::SecureOutputType secure_output_type) { secure_output_type_ = secure_output_type; switch (secure_output_type) { case Cdm::kOpaqueHandle: use_secure_buffers_ = true; use_fifo_ = false; use_userspace_buffers_ = false; break; case Cdm::kDirectRender: use_secure_buffers_ = false; use_fifo_ = true; use_userspace_buffers_ = false; break; case Cdm::kNoSecureOutput: default: use_secure_buffers_ = false; use_fifo_ = false; use_userspace_buffers_ = true; break; } } // static Cdm::SecureOutputType PropertiesCE::GetSecureOutputType() { return secure_output_type_; } // static void PropertiesCE::SetProvisioningMessagesAreBinary(bool new_setting) { set_provisioning_messages_to_binary_ = new_setting; } // static void PropertiesCE::SetSandboxId(const std::string& sandbox_id) { sandbox_id_ = sandbox_id; } } // namespace widevine namespace wvcdm { // static void Properties::InitOnce() { oem_crypto_use_secure_buffers_ = use_secure_buffers_; oem_crypto_use_fifo_ = use_fifo_; oem_crypto_use_userspace_buffers_ = use_userspace_buffers_; provisioning_messages_are_binary_ = set_provisioning_messages_to_binary_; allow_service_certificate_requests_ = false; device_files_is_a_real_filesystem_ = false; allow_restore_of_offline_licenses_with_release_ = true; delay_oem_crypto_termination_ = false; session_property_set_.reset(new CdmClientPropertySetMap()); } // static bool Properties::GetCompanyName(std::string* company_name) { return GetValue(CLIENT_COMPANY_NAME, company_name); } // static bool Properties::GetModelName(std::string* model_name) { return GetValue(CLIENT_MODEL_NAME, model_name); } // static bool Properties::GetModelYear(std::string* model_year) { return GetValue(CLIENT_MODEL_YEAR, model_year); } // static bool Properties::GetArchitectureName(std::string* arch_name) { return GetValue(CLIENT_ARCH_NAME, arch_name); } // static bool Properties::GetDeviceName(std::string* device_name) { return GetValue(CLIENT_DEVICE_NAME, device_name); } // static bool Properties::GetProductName(std::string* product_name) { return GetValue(CLIENT_PRODUCT_NAME, product_name); } // static bool Properties::GetBuildInfo(std::string* build_info) { return GetValue(kBuildInfo, build_info); } // static bool Properties::GetWVCdmVersion(std::string* version) { return GetValue(CDM_VERSION, version); } // static bool Properties::GetDeviceFilesBasePath(CdmSecurityLevel, std::string* base_path) { if (base_path == nullptr) return false; // A no-op, but successful. base_path->clear(); return true; } // static bool Properties::GetFactoryKeyboxPath(std::string*) { // Unused on CE devices. return false; } // static bool Properties::GetOEMCryptoPath(std::string* path) { if (path == nullptr) return false; // Using an environment variable is useful for testing. const char* env_path = getenv("LIBOEMCRYPTO_PATH"); if (env_path) { *path = std::string(env_path); } else { *path = "liboemcrypto.so"; } return true; } // static bool Properties::GetSandboxId(std::string* sandbox_id_ptr) { if (sandbox_id_.empty() || sandbox_id_ptr == nullptr) return false; (*sandbox_id_ptr) = sandbox_id_; return true; } // static bool Properties::AlwaysUseKeySetIds() { return true; } // static bool Properties::UseProviderIdInProvisioningRequest() { return true; } } // namespace wvcdm