mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-11-12 18:49:07 +00:00
tools: add fake signing to binctl, add make sign target
This commit is contained in:
parent
fdef0575b1
commit
35e404bd38
4
Makefile
4
Makefile
@ -32,6 +32,10 @@ binctl:
|
||||
./tools/binctl micropython/firmware/vendorheader.bin
|
||||
./tools/binctl micropython/firmware/build/firmware.bin
|
||||
|
||||
sign:
|
||||
./tools/binctl micropython/loader/build/loader.bin -s
|
||||
./tools/binctl micropython/firmware/build/firmware.bin -s
|
||||
|
||||
## emulator commands:
|
||||
|
||||
run: ## run unix port
|
||||
|
@ -66,6 +66,7 @@ OBJ_FW += $(addprefix $(BUILD_FW)/, \
|
||||
extmod/modtrezorui/font_robotomono_regular_20.o \
|
||||
trezorhal/common.o \
|
||||
trezorhal/image.o \
|
||||
trezorhal/touch.o \
|
||||
trezorhal/stm32_it.o \
|
||||
trezorhal/stm32_system.o \
|
||||
trezorhal/hal/stm32f4xx_hal_sram.o \
|
||||
|
@ -5,6 +5,7 @@
|
||||
#include "common.h"
|
||||
#include "display.h"
|
||||
#include "image.h"
|
||||
#include "touch.h"
|
||||
|
||||
#define LOADER_FGCOLOR 0xFFFF
|
||||
#define LOADER_BGCOLOR 0x0000
|
||||
@ -85,11 +86,18 @@ void check_and_jump(void)
|
||||
}
|
||||
}
|
||||
|
||||
void mainloop(void)
|
||||
{
|
||||
__fatal_error("touch detected - launch aborted");
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
SCB->VTOR = LOADER_START + HEADER_SIZE;
|
||||
periph_init();
|
||||
|
||||
touch_init();
|
||||
|
||||
display_init();
|
||||
display_clear();
|
||||
display_backlight(255);
|
||||
@ -98,7 +106,11 @@ int main(void)
|
||||
LOADER_PRINTLN("=============");
|
||||
LOADER_PRINTLN("starting loader");
|
||||
|
||||
check_and_jump();
|
||||
if (touch_read() != 0) {
|
||||
mainloop();
|
||||
} else {
|
||||
check_and_jump();
|
||||
}
|
||||
|
||||
__fatal_error("halt");
|
||||
|
||||
|
16
tools/binctl
16
tools/binctl
@ -7,10 +7,14 @@ import pyblake2
|
||||
|
||||
|
||||
def get_sig(data):
|
||||
print('Enter index : ', end='')
|
||||
idx = int(input())
|
||||
print('Enter privkey : ', end='')
|
||||
seckey = binascii.unhexlify(input())
|
||||
if False:
|
||||
print('Enter index : ', end='')
|
||||
idx = int(input())
|
||||
print('Enter privkey : ', end='')
|
||||
seckey = binascii.unhexlify(input())
|
||||
else:
|
||||
idx = 1
|
||||
seckey = binascii.unhexlify('4141414141414141414141414141414141414141414141414141414141414141')
|
||||
signkey = ed25519.SigningKey(seckey)
|
||||
digest = pyblake2.blake2s(data).digest()
|
||||
sigmask = 1 << (idx - 1)
|
||||
@ -206,13 +210,13 @@ def main():
|
||||
fn = sys.argv[1]
|
||||
sign = len(sys.argv) > 2 and sys.argv[2] == '-s'
|
||||
b = binopen(fn)
|
||||
b.print()
|
||||
if sign:
|
||||
print()
|
||||
b.sign()
|
||||
print()
|
||||
b.print()
|
||||
b.write(fn)
|
||||
else:
|
||||
b.print()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
Loading…
Reference in New Issue
Block a user