mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-12-24 18:22:19 +03:00
25f35c7d0e
This new FW is build on the same codebasse than the actual InfiniTime. Only the display task is different (this allows to remove lvgl from the recovery fw, which is very heavy). CMake builds and docker have been modified accordingly. Note than the fw is converted into an image and then into a DFU in the cmake build (previously, it was only done in the
46 lines
1.7 KiB
Python
46 lines
1.7 KiB
Python
"""General key class."""
|
|
|
|
import sys
|
|
|
|
AUTOGEN_MESSAGE = "/* Autogenerated by imgtool.py, do not edit. */"
|
|
|
|
class KeyClass(object):
|
|
def _emit(self, header, trailer, encoded_bytes, indent, file=sys.stdout, len_format=None):
|
|
print(AUTOGEN_MESSAGE, file=file)
|
|
print(header, end='', file=file)
|
|
for count, b in enumerate(encoded_bytes):
|
|
if count % 8 == 0:
|
|
print("\n" + indent, end='', file=file)
|
|
else:
|
|
print(" ", end='', file=file)
|
|
print("0x{:02x},".format(b), end='', file=file)
|
|
print("\n" + trailer, file=file)
|
|
if len_format is not None:
|
|
print(len_format.format(len(encoded_bytes)), file=file)
|
|
|
|
def emit_c_public(self, file=sys.stdout):
|
|
self._emit(
|
|
header="const unsigned char {}_pub_key[] = {{".format(self.shortname()),
|
|
trailer="};",
|
|
encoded_bytes=self.get_public_bytes(),
|
|
indent=" ",
|
|
len_format="const unsigned int {}_pub_key_len = {{}};".format(self.shortname()),
|
|
file=file)
|
|
|
|
def emit_rust_public(self, file=sys.stdout):
|
|
self._emit(
|
|
header="static {}_PUB_KEY: &'static [u8] = &[".format(self.shortname().upper()),
|
|
trailer="];",
|
|
encoded_bytes=self.get_public_bytes(),
|
|
indent=" ",
|
|
file=file)
|
|
|
|
def emit_private(self, minimal, file=sys.stdout):
|
|
self._emit(
|
|
header="const unsigned char enc_priv_key[] = {",
|
|
trailer="};",
|
|
encoded_bytes=self.get_private_bytes(minimal),
|
|
indent=" ",
|
|
len_format="const unsigned int enc_priv_key_len = {};",
|
|
file=file)
|