Kaydet (Commit) fcf365f3 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

generate the certificate verification data as part of the build

Change-Id: I30186f76302e7666c833933b059931e8b1b7b78c
üst a5204fe5
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_CustomTarget_CustomTarget,onlineupdate/generated))
onlineupdate_INC := $(call gb_CustomTarget_get_workdir,onlineupdate/generated)/onlineupdate
$(onlineupdate_INC)/primaryCert.h : \
$(SRCDIR)/onlineupdate/source/update/updater/gen_cert_header.py
$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,,1)
mkdir -p $(dir $@)
$(call gb_ExternalExecutable_get_command,python) $(SRCDIR)/onlineupdate/source/update/updater/gen_cert_header.py "primaryCertData" /lo/users/moggi/NSSDBDir/master-daily.der > $(onlineupdate_INC)/primaryCert.h #"$(UPDATE_CONFIG)"
$(onlineupdate_INC)/secondaryCert.h : \
$(SRCDIR)/onlineupdate/source/update/updater/gen_cert_header.py
$(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),build,,1)
mkdir -p $(dir $@)
$(call gb_ExternalExecutable_get_command,python) $(SRCDIR)/onlineupdate/source/update/updater/gen_cert_header.py "secondaryCertData" /lo/users/moggi/NSSDBDir/master-daily.der > $(onlineupdate_INC)/secondaryCert.h #"$(UPDATE_CONFIG)"
$(call gb_CustomTarget_get_target,onlineupdate/generated) : \
$(onlineupdate_INC)/primaryCert.h \
$(onlineupdate_INC)/secondaryCert.h \
# vim: set noet sw=4 ts=4:
......@@ -16,6 +16,8 @@ $(eval $(call gb_Executable_set_include,updater,\
$$(INCLUDE) \
))
$(eval $(call gb_Executable_use_custom_headers,updater,onlineupdate/generated))
$(eval $(call gb_Executable_use_static_libraries,updater,\
libmar \
updatehelper \
......
......@@ -21,6 +21,7 @@ $(eval $(call gb_Module_add_targets,onlineupdate,\
Executable_mar \
Executable_updater \
Executable_mbsdiff \
CustomTarget_generated \
))
endif
......
......@@ -20,8 +20,8 @@
#ifdef TEST_UPDATER
#include "../xpcshellCert.h"
#else
#include "primaryCert.h"
#include "secondaryCert.h"
#include "onlineupdate/primaryCert.h"
#include "onlineupdate/secondaryCert.h"
#endif
#endif
......
#!/usr/bin/env python
#!/usr/bin/env python3
import sys
import binascii
def file_byte_generator(filename, block_size = 512):
with open(filename, "rb") as f:
while True:
block = f.read(block_size)
if block:
for byte in block:
yield byte
else:
break
def file_byte_generator(filename):
with open(filename, "rb") as f:
block = f.read()
return block
def create_header(array_name, in_filename):
hexified = ["0x" + binascii.hexlify(byte) for byte in file_byte_generator(in_filename)]
print("const uint8_t " + array_name + "[] = {")
print(", ".join(hexified))
print("};")
return 0
hexified = ["0x" + binascii.hexlify(bytes([inp])).decode('ascii') for inp in file_byte_generator(in_filename)]
print("const uint8_t " + array_name + "[] = {")
print(", ".join(hexified))
print("};")
return 0
if __name__ == '__main__':
if len(sys.argv) < 3:
print('ERROR: usage: gen_cert_header.py array_name in_filename')
sys.exit(1);
sys.exit(create_header(sys.argv[1], sys.argv[2]))
if len(sys.argv) < 3:
print('ERROR: usage: gen_cert_header.py array_name in_filename')
sys.exit(1);
sys.exit(create_header(sys.argv[1], sys.argv[2]))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment