Source release 19.5.0

This commit is contained in:
Cong Lin
2025-04-02 10:27:18 -07:00
parent 4407acee62
commit f7ec4fdeff
295 changed files with 32196 additions and 21748 deletions

View File

@@ -1,10 +1,51 @@
Instructions:
1. Write the main function or modify the example main function in example_main.cpp
2. To compile the example_main:
clang++ *.cpp ../common/src/*.cpp ../../util/src/string_conversions.cpp -ldl -rdynamic -I../../util/include -I../../oemcrypto/include -I../common/include -o example_main.out
Widevine Factory Extraction Tool
This tool extracts the BCC and generates the Certificate Signing Request (CSR)
needed to be uploaded for Prov4 device registration.
CSR extraction instructions:
1. Prepare the example_main.cpp file:
- Write or modify the main() function in example_main.cpp according to your
needs.
- Ensure that all required fields in the client_info structure are filled in
correctly. Refer to the comments within the main() function in
example_main.cpp for detailed instructions and field descriptions.
2. Compile:
- Option 1: Command-line compilation
- Under the directory factory_upload_tool/ce, run:
clang++ *.cpp ../common/src/*.cpp ../../util/src/string_conversions.cpp -ldl -rdynamic -I../../util/include -I../../oemcrypto/include -I../common/include -o wv_factory_extractor
This command compiles all .cpp files into an executable named
wv_factory_extractor in current directory.
- Option 2: Using the provided Makefile
- Under the directory factory_upload_tool/ce, run:
`make all`
- To enable the BCC validator, compile with:
`make USE_VALIDATOR=y all`
Note that the BCC validator takes dependency of `cppbor` and
`boringssl` library from `third_party` directory.
- The compiled executable will be located in the out/wv_factory_extractor
directory under the CDM root directory.
3. Specify the location of liboemcrypto.so:
export LIBOEMCRYPTO_PATH=/path/to/liboemcrypto.so
4. Run the main program to extract the BCC and save it to a file.
./example_main.out > csr.bin
5. Upload the csr.bin with the following command. cred.json is the OAuth 2.0 client credentials obtained via Google cloud platform.
python3 upload.py --credentials=cred.json --org-name={your organization name} --json-csr=csr.bin
- Replacing /path/to/ with the actual path to the liboemcrypto.so file:
export LIBOEMCRYPTO_PATH=/path/to/liboemcrypto.so
4. Run the wv_factory_extractor tool:
- To output the CSR to a file ready for uploading, under the output
directory, run
`./wv_factory_extractor > csr.json`
- To run BCC validation and view the results in console output, run
`./wv_factory_extractor --validate`
- If BCC validator is enabled at compile time, it will print the parsed BCC
and the validation results.
Uploading instructions:
1. Upload the `csr.json` file:
- Upload the `csr.json` file using the following command:
python3 upload.py --credentials=cred.json --org-name={your organization name} --json-csr=csr.json
- Replace cred.json with the path to your OAuth 2.0 client credentials
file. You can obtain this file through the Google Cloud Platform.
- Replace {your organization name} with the name of your organization.

View File

@@ -7,14 +7,16 @@
#include "log.h"
#include "wv_factory_extractor.h"
int main() {
int main(int argc, char* argv[]) {
widevine::ClientInfo client_info;
client_info.company_name = "";
client_info.arch_name = "";
client_info.device_name = "";
client_info.model_name = "";
client_info.product_name = "";
client_info.build_info = "";
// REQUIRED: Replace with your own values.
// client_info.company_name = "<company_name>";
// client_info.arch_name = "<arch_name>";
// client_info.device_name = "<device_name>";
// client_info.model_name = "<model_name>";
// client_info.product_name = "<product_name>";
// client_info.build_info = "<build_info>";
auto extractor = widevine::WidevineFactoryExtractor::Create(client_info);
if (extractor == nullptr) {
@@ -29,5 +31,22 @@ int main() {
return 2;
}
std::cout << request << std::endl;
for (int i = 1; i < argc; ++i) {
std::string arg = argv[i];
if (arg == "--validate" || arg == "-v") {
#ifdef USE_VALIDATOR
std::string validation_out;
status = extractor->ValidateBcc(validation_out);
if (status != widevine::Status::kSuccess) {
LOGE("Fail to run validation: %d", status);
return 2;
}
std::cout << "\n--BCC VALIDATION--" << std::endl;
std::cout << validation_out << std::endl;
#endif
break;
}
}
return 0;
}
}

View File

@@ -4,6 +4,11 @@
#include "wv_factory_extractor.h"
#ifdef USE_VALIDATOR
# include "bcc_validator.h"
# include "cbor_validator.h"
#endif
#include "log.h"
#include "properties.h"
#include "properties_ce.h"
@@ -67,23 +72,30 @@ std::unique_ptr<WidevineFactoryExtractor> WidevineFactoryExtractor::Create(
new WidevineFactoryExtractor());
}
Status WidevineFactoryExtractor::InitializeCryptoInterface() {
std::string oemcrypto_path;
if (!wvcdm::Properties::GetOEMCryptoPath(&oemcrypto_path)) {
LOGE("Failed to get OEMCrypto path.");
return kOEMCryptoError;
}
LOGI("OEMCrypto path is %s", oemcrypto_path.c_str());
crypto_interface_ = std::make_unique<OEMCryptoInterface>();
if (!crypto_interface_->Init(oemcrypto_path)) {
LOGE("Failed to initialize OEMCrypto interface.");
crypto_interface_.reset(nullptr);
return kOEMCryptoError;
}
return kSuccess;
}
Status WidevineFactoryExtractor::GenerateUploadRequest(std::string& request) {
if (crypto_interface_ == nullptr) {
std::string oemcrypto_path;
if (!wvcdm::Properties::GetOEMCryptoPath(&oemcrypto_path)) {
LOGE("Failed to get OEMCrypto path.");
return kOEMCryptoError;
}
LOGI("OEMCrypto path is %s", oemcrypto_path.c_str());
crypto_interface_ = std::make_unique<OEMCryptoInterface>();
if (!crypto_interface_->Init(oemcrypto_path)) {
LOGE("Failed to initialize OEMCrypto interface.");
crypto_interface_.reset(nullptr);
return kOEMCryptoError;
Status status = InitializeCryptoInterface();
if (status != kSuccess) {
return status;
}
}
std::vector<uint8_t> bcc;
OEMCryptoResult result = crypto_interface_->GetBcc(bcc);
if (result != OEMCrypto_SUCCESS) {
@@ -113,4 +125,39 @@ Status WidevineFactoryExtractor::GenerateUploadRequest(std::string& request) {
return kSuccess;
}
#ifdef USE_VALIDATOR
Status WidevineFactoryExtractor::ValidateBcc(std::string& out) {
if (crypto_interface_ == nullptr) {
Status status = InitializeCryptoInterface();
if (status != kSuccess) {
return status;
}
}
std::vector<uint8_t> bcc;
OEMCryptoResult result = crypto_interface_->GetBcc(bcc);
if (result != OEMCrypto_SUCCESS) {
LOGE("Failed to get BCC.");
return kOEMCryptoError;
}
wvoec::util::BccValidator validator;
wvoec::util::CborMessageStatus sts = validator.Parse(bcc);
if (sts != wvoec::util::kCborParseOk) {
out = "BCC is not a valid CBOR message. Stop validating.\n";
} else {
sts = validator.Validate();
out = validator.GetFormattedMessage();
if (sts == wvoec::util::kCborValidateOk) {
out += "\nValidation OK.";
} else {
out += "\nValidation results:";
for (auto& msg : validator.GetValidateMessages()) {
out += "\n" + wvoec::util::CborMessageStatusToString(msg.first) + ": " +
msg.second.c_str();
}
}
}
return kSuccess;
}
#endif
} // namespace widevine

View File

@@ -60,8 +60,13 @@ class WidevineFactoryExtractor {
Status GenerateUploadRequest(std::string& request);
#ifdef USE_VALIDATOR
Status ValidateBcc(std::string& out);
#endif
private:
WidevineFactoryExtractor() = default;
Status InitializeCryptoInterface();
std::unique_ptr<OEMCryptoInterface> crypto_interface_;
};