Source release 19.6.0
GitOrigin-RevId: 13a33e34413c19da1bfe76abcc66be519c9ac9d1
This commit is contained in:
200
factory_upload_tool/ce/Makefile
Normal file
200
factory_upload_tool/ce/Makefile
Normal file
@@ -0,0 +1,200 @@
|
||||
#
|
||||
# Copyright 2024 Google LLC. All Rights Reserved. This file and proprietary
|
||||
# source code may only be used and distributed under the Widevine
|
||||
# License Agreement.
|
||||
#
|
||||
CDM_DIR ?= $(shell pwd)/../..
|
||||
|
||||
# CROSS_COMPILE: prefix for cross compilers, e.g. arm-none-gnueabihf-
|
||||
cc ?= $(CROSS_COMPILE)gcc
|
||||
cxx ?= $(CROSS_COMPILE)g++
|
||||
ARCH ?= 64
|
||||
IS_ARM ?= 0
|
||||
|
||||
project := wv_factory_extractor
|
||||
srcdir := $(shell realpath --relative-to=$(CURDIR) $(CDM_DIR))
|
||||
output = $(project)
|
||||
|
||||
# Place outputs in $CDM_DIR/out/wv_factory_extractor/
|
||||
default_build_dir := $(CDM_DIR)/out/$(project)
|
||||
# Check if OUT_DIR is set and not empty
|
||||
ifeq ($(strip $(OUT_DIR)),)
|
||||
builddir := $(default_build_dir)/
|
||||
else
|
||||
builddir := $(OUT_DIR)/
|
||||
endif
|
||||
|
||||
# All file locations are relative to the $CDM_DIR path.
|
||||
REPO_TOP :=
|
||||
|
||||
# Path to the modified example_main file used by tests
|
||||
MODIFIED_MAIN_SRC := example_main_modified.cpp
|
||||
|
||||
# Conditionally add the source file based on its existence
|
||||
ifneq ($(wildcard $(MODIFIED_MAIN_SRC)),)
|
||||
extractor_sources += $(REPO_TOP)/factory_upload_tool/ce/$MODIFIED_MAIN_SRC
|
||||
$(info Using modified source for tests)
|
||||
else
|
||||
extractor_sources += $(REPO_TOP)/factory_upload_tool/ce/example_main.cpp
|
||||
endif
|
||||
|
||||
# other sources
|
||||
extractor_sources += \
|
||||
$(REPO_TOP)/factory_upload_tool/ce/log.cpp \
|
||||
$(REPO_TOP)/factory_upload_tool/ce/properties_ce.cpp \
|
||||
$(REPO_TOP)/factory_upload_tool/ce/wv_factory_extractor.cpp \
|
||||
$(REPO_TOP)/util/src/string_conversions.cpp \
|
||||
$(REPO_TOP)/factory_upload_tool/common/src/WidevineOemcryptoInterface.cpp \
|
||||
|
||||
extractor_includes := \
|
||||
$(REPO_TOP)/factory_upload_tool/common/include \
|
||||
$(REPO_TOP)/oemcrypto/include \
|
||||
$(REPO_TOP)/util/include
|
||||
|
||||
srcs := $(extractor_sources)
|
||||
incs := $(extractor_includes)
|
||||
|
||||
ifdef USE_VALIDATOR
|
||||
oemcrypto_util_dir := $(REPO_TOP)/oemcrypto/util
|
||||
|
||||
validator_sources := \
|
||||
$(oemcrypto_util_dir)/src/bcc_validator.cpp \
|
||||
$(oemcrypto_util_dir)/src/cbor_validator.cpp \
|
||||
$(oemcrypto_util_dir)/src/device_info_validator.cpp \
|
||||
$(oemcrypto_util_dir)/src/prov4_validation_helper.cpp \
|
||||
$(oemcrypto_util_dir)/src/cmac.cpp \
|
||||
$(oemcrypto_util_dir)/src/oemcrypto_drm_key.cpp \
|
||||
$(oemcrypto_util_dir)/src/oemcrypto_ecc_key.cpp \
|
||||
$(oemcrypto_util_dir)/src/oemcrypto_key_deriver.cpp \
|
||||
$(oemcrypto_util_dir)/src/oemcrypto_oem_cert.cpp \
|
||||
$(oemcrypto_util_dir)/src/oemcrypto_rsa_key.cpp \
|
||||
$(oemcrypto_util_dir)/src/signed_csr_payload_validator.cpp \
|
||||
$(oemcrypto_util_dir)/src/wvcrc.cpp
|
||||
|
||||
validator_includes := \
|
||||
$(oemcrypto_util_dir)/include
|
||||
|
||||
cppbor_dir := $(REPO_TOP)/third_party/libcppbor
|
||||
|
||||
cppbor_sources += \
|
||||
$(cppbor_dir)/src/cppbor.cpp \
|
||||
$(cppbor_dir)/src/cppbor_parse.cpp
|
||||
|
||||
cppbor_includes += \
|
||||
$(cppbor_dir)/include \
|
||||
$(cppbor_dir)/include/cppbor
|
||||
|
||||
include $(CDM_DIR)/third_party/boringssl/kit/sources.mk
|
||||
boringssl_sources_raw += $(crypto_sources)
|
||||
ifeq ($(ARCH), 64)
|
||||
ifneq ($(IS_ARM), 0)
|
||||
boringssl_sources_raw += $(linux_aarch64_sources)
|
||||
else
|
||||
boringssl_sources_raw += $(linux_x86_64_sources)
|
||||
endif
|
||||
else ifeq ($(ARCH), 32)
|
||||
ifneq ($(IS_ARM), 0)
|
||||
boringssl_sources_raw += $(linux_arm_sources)
|
||||
else
|
||||
boringssl_sources_raw += $(linux_x86_sources)
|
||||
endif
|
||||
else
|
||||
$(error No known value for ARCH; assembly not included for BoringSSL)
|
||||
endif
|
||||
|
||||
boringssl_dir := $(REPO_TOP)/third_party/boringssl
|
||||
|
||||
boringssl_sources += \
|
||||
$(addprefix $(boringssl_dir)/kit/, $(boringssl_sources_raw))
|
||||
|
||||
boringssl_includes += \
|
||||
$(boringssl_dir)/kit/src/include
|
||||
|
||||
srcs += \
|
||||
$(validator_sources) \
|
||||
$(cppbor_sources) \
|
||||
$(boringssl_sources)
|
||||
|
||||
incs += \
|
||||
$(validator_includes) \
|
||||
$(cppbor_includes) \
|
||||
$(boringssl_includes)
|
||||
endif
|
||||
|
||||
# flags
|
||||
cflags += \
|
||||
-Wall \
|
||||
-Werror \
|
||||
-fPIC \
|
||||
-fsanitize=address \
|
||||
$(addprefix -I, $(includes))
|
||||
|
||||
cflags_c += \
|
||||
$(cflags) \
|
||||
-std=c11 \
|
||||
-D_POSIX_C_SOURCE=200809L \
|
||||
-fno-inline
|
||||
|
||||
cppflags += \
|
||||
$(cflags)
|
||||
|
||||
ifdef USE_VALIDATOR
|
||||
cppflags += -DUSE_VALIDATOR
|
||||
endif
|
||||
|
||||
ldflags = \
|
||||
-ldl \
|
||||
-rdynamic \
|
||||
-fsanitize=address \
|
||||
|
||||
# make rules
|
||||
ifneq ($V,1)
|
||||
q := @
|
||||
cmd-echo := true
|
||||
cmd-echo-silent := echo
|
||||
else
|
||||
q :=
|
||||
cmd-echo := echo
|
||||
cmd-echo-silent := true
|
||||
endif
|
||||
|
||||
ssrc := $(patsubst %.S, %.o, $(filter %.S, $(srcs)))
|
||||
csrc := $(patsubst %.c, %.o, $(filter %.c, $(srcs)))
|
||||
cppsrc := $(patsubst %.cpp, %.o, $(filter %.cpp, $(srcs)))
|
||||
ccsrc := $(patsubst %.cc, %.o, $(filter %.cc, $(srcs)))
|
||||
objs := $(sort $(addprefix $(builddir), $(csrc) $(cppsrc) $(ccsrc) $(ssrc)))
|
||||
|
||||
includes := $(addprefix $(srcdir), $(incs)) $(global-incs)
|
||||
|
||||
.PHONY: all
|
||||
all: $(builddir)$(output)
|
||||
|
||||
$(builddir)$(output): $(objs)
|
||||
@$(cmd-echo-silent) ' LD $@'
|
||||
${q}$(cxx) -o $@ $(objs) $(ldflags)
|
||||
|
||||
$(builddir)%.o: $(srcdir)%.c
|
||||
${q}mkdir -p $(shell dirname $@)
|
||||
@$(cmd-echo-silent) ' CC $@'
|
||||
${q}$(cc) $(cflags_c) -c $< -o $@
|
||||
|
||||
$(builddir)%.o: $(srcdir)%.cc
|
||||
${q}mkdir -p $(shell dirname $@)
|
||||
@$(cmd-echo-silent) ' CPP $@'
|
||||
${q}$(cxx) $(cppflags) -c $< -o $@
|
||||
|
||||
$(builddir)%.o: $(srcdir)%.cpp
|
||||
${q}mkdir -p $(shell dirname $@)
|
||||
@$(cmd-echo-silent) ' CPP $@'
|
||||
$(cxx) $(cppflags) -c $< -o $@
|
||||
|
||||
$(builddir)%.o: $(srcdir)%.S
|
||||
${q}mkdir -p $(shell dirname $@)
|
||||
@$(cmd-echo-silent) ' CC $@'
|
||||
${q}$(cc) $(cflags_c) -c $< -o $@
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
@$(cmd-echo-silent) ' CLEAN $(builddir)'
|
||||
${q}rm -f $(objs) $(output)
|
||||
@if [ -d $(builddir) ]; then rm -r $(builddir); fi
|
||||
@@ -71,6 +71,16 @@ bool Properties::GetBuildInfo(std::string* build_info) {
|
||||
return GetValue(client_info_.build_info, build_info);
|
||||
}
|
||||
|
||||
// static
|
||||
bool Properties::GetPlatform(std::string* /* platform */) {
|
||||
return false; // No attempt for upload tool.
|
||||
}
|
||||
|
||||
// static
|
||||
bool Properties::GetFormFactor(std::string* /* form_factor */) {
|
||||
return false; // No attempt for upload tool.
|
||||
}
|
||||
|
||||
// static
|
||||
bool Properties::GetOEMCryptoPath(std::string* path) {
|
||||
if (path == nullptr) return false;
|
||||
|
||||
@@ -130,9 +130,13 @@ def parse_args():
|
||||
Returns:
|
||||
An argparse.Namespace object populated with the arguments.
|
||||
"""
|
||||
parser = argparse.ArgumentParser(description='Widevine BCC Batch Upload/Check Tool')
|
||||
parser = argparse.ArgumentParser(
|
||||
description='Widevine BCC Batch Upload/Check Tool'
|
||||
)
|
||||
|
||||
parser.add_argument("--version", action="version", version="20240822") #yyyymmdd
|
||||
parser.add_argument(
|
||||
'--version', action='version', version='20240822'
|
||||
) # yyyymmdd
|
||||
|
||||
parser.add_argument(
|
||||
'--json-csr',
|
||||
@@ -200,6 +204,7 @@ def parse_json_csrs(filename, batches):
|
||||
batches: Output dict containing a mapping from json dumped device metadata
|
||||
to BCCs.
|
||||
"""
|
||||
base_filename = os.path.basename(filename)
|
||||
line_count = 0
|
||||
for line in open(filename):
|
||||
line_count = line_count + 1
|
||||
@@ -210,7 +215,10 @@ def parse_json_csrs(filename, batches):
|
||||
die(f'{e.msg} {filename}:{line_count}, char {e.pos}')
|
||||
|
||||
try:
|
||||
bcc = {'boot_certificate_chain': obj['bcc']}
|
||||
bcc = {
|
||||
'boot_certificate_chain': obj['bcc'],
|
||||
'name': f'{base_filename}#{line_count}',
|
||||
}
|
||||
device_metadata = json.dumps({
|
||||
'company': obj['company'],
|
||||
'architecture': obj['architecture'],
|
||||
@@ -227,7 +235,7 @@ def parse_json_csrs(filename, batches):
|
||||
die(f'Invalid object at {filename}:{line_count}, missing {e}')
|
||||
|
||||
if line_count == 0:
|
||||
die('Empty BCC file!')
|
||||
die('Empty BCC file!')
|
||||
|
||||
|
||||
def format_request_body(args, device_metadata, bccs):
|
||||
@@ -481,6 +489,7 @@ def batch_action_single_attempt(args, path, body):
|
||||
eprint('Failed with unexpected response:')
|
||||
eprint(response_body)
|
||||
|
||||
|
||||
def main():
|
||||
args = parse_args()
|
||||
if args.dryrun:
|
||||
|
||||
Reference in New Issue
Block a user