// Copyright 2024 Google LLC. All Rights Reserved. This file and proprietary // source code may only be used and distributed under the Widevine // License Agreement. // This tool extracts BCC by calling OEMCrypto APIs and generates a CSR file in // JSON format, which can be handled by CE CDM wv_upload_tool.py. #include #include #include #include #include #include #include "OEMCryptoCENC.h" #include "string_conversions.h" #include "wv_factory_extractor.h" namespace { // Make and Model for system ID resolution. const std::string kDeviceMake = "widevine_test"; const std::string kDeviceModel = "prov4"; // Informative fields. const std::string kDeviceArchitecture = "x86_64"; const std::string kDeviceName = "prov40 test client"; const std::string kDeviceProduct = "prov40 test"; const std::string kDeviceBuildInfo = "prov40 test build"; // == Primary == bool OutputBccRecord(const std::string& path, const std::string& record) { std::cout << "Writing BCC record to file " << path << std::endl; std::cout << record << std::endl; std::ofstream out(path); if (out) out << record; if (out.bad()) { std::cerr << "Failed to write BCC record to file " << path << std::endl; return false; } return true; } } // namespace int main(int argc, char** argv) { if (argc != 2) { std::cerr << "Usage: " << argv[0] << " " << std::endl; return 1; } const std::string bcc_path = argv[1]; widevine::ClientInfo client_info; client_info.company_name = kDeviceMake; client_info.arch_name = kDeviceArchitecture; client_info.device_name = kDeviceName; client_info.model_name = kDeviceModel; client_info.product_name = kDeviceProduct; client_info.build_info = kDeviceBuildInfo; auto extractor = widevine::WidevineFactoryExtractor::Create(client_info); if (extractor == nullptr) { std::cerr << "Failed to create WidevineFactoryExtractor" << std::endl; return 1; } std::string bcc_record; widevine::Status status = extractor->GenerateUploadRequest(bcc_record); if (status != widevine::Status::kSuccess) { std::cerr << "Fail to generate BCC record: " << status << std::endl; return 1; } if (!OutputBccRecord(bcc_path, bcc_record)) { std::cerr << "Failed to output BCC record" << std::endl; return 1; } return 0; }