diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-05-05 13:56:24 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2017-05-19 03:43:33 +0200 |
commit | fcf365f352ee4daf1dd538e64d7982faff2206d4 (patch) | |
tree | b72559f262e8b2a12dd93e858dc6b955aaf67ca7 /onlineupdate/source | |
parent | a5204fe5b3a403f25a5a2781761cd2303391cf36 (diff) |
generate the certificate verification data as part of the build
Change-Id: I30186f76302e7666c833933b059931e8b1b7b78c
Diffstat (limited to 'onlineupdate/source')
-rw-r--r-- | onlineupdate/source/update/updater/archivereader.cxx | 4 | ||||
-rwxr-xr-x | onlineupdate/source/update/updater/gen_cert_header.py | 33 |
2 files changed, 16 insertions, 21 deletions
diff --git a/onlineupdate/source/update/updater/archivereader.cxx b/onlineupdate/source/update/updater/archivereader.cxx index b0395d14094e..ec043680c27e 100644 --- a/onlineupdate/source/update/updater/archivereader.cxx +++ b/onlineupdate/source/update/updater/archivereader.cxx @@ -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 diff --git a/onlineupdate/source/update/updater/gen_cert_header.py b/onlineupdate/source/update/updater/gen_cert_header.py index 5fff9be79084..5b70758db3f2 100755 --- a/onlineupdate/source/update/updater/gen_cert_header.py +++ b/onlineupdate/source/update/updater/gen_cert_header.py @@ -1,27 +1,22 @@ -#!/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])) |