sign the esp images as well
parent
234a514b46
commit
df7f90f6fc
|
@ -61,7 +61,7 @@ obj/$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/main.$(PROJ_NAME).o
|
|||
# hack
|
||||
$(CC) -Wl,--section-start,.isr_vector=0x8004000 $(CFLAGS) -o obj/$(PROJ_NAME).elf $^
|
||||
$(OBJCOPY) -v -O binary obj/$(PROJ_NAME).elf obj/code.bin
|
||||
../crypto/sign.py obj/code.bin $@ $(CERT)
|
||||
SETLEN=1 ../crypto/sign.py obj/code.bin $@ $(CERT)
|
||||
|
||||
obj/bootstub.$(PROJ_NAME).bin: obj/$(STARTUP_FILE).o obj/bootstub.$(PROJ_NAME).o obj/sha.o obj/rsa.o
|
||||
$(CC) $(CFLAGS) -o obj/bootstub.$(PROJ_NAME).elf $^
|
||||
|
|
|
@ -6,6 +6,8 @@ LDFLAGS = -Teagle.app.v6.ld
|
|||
OBJCP = xtensa-lx106-elf-objcopy
|
||||
SDK_BASE = esp-open-sdk/ESP8266_NONOS_SDK_V1.5.4_16_05_20
|
||||
|
||||
CERT = ../certs/debugesp
|
||||
|
||||
flash: user1.bin
|
||||
#./tools/esptool.py write_flash 0 $(SDK_BASE)/bin/boot_v1.5.bin 0x01000 user1.bin 0x81000 user2.bin 0x3FE000 $(SDK_BASE)/bin/blank.bin
|
||||
./tools/esptool.py write_flash 0 $(SDK_BASE)/bin/boot_v1.5.bin 0x01000 user1.bin 0x3FE000 $(SDK_BASE)/bin/blank.bin
|
||||
|
@ -30,7 +32,7 @@ user1.bin: proxy.o tcp_ota.o st_ota.o elm327.o webserver.o ../crypto/sha.c ../cr
|
|||
$(OBJCP) --only-section .irom0.text -O binary a.out eagle.app.v6.irom0text.bin
|
||||
COMPILE=gcc python ./esp-open-sdk/ESP8266_NONOS_SDK_V1.5.4_16_05_20/tools/gen_appbin.py a.out 2 0 32 4 0
|
||||
rm -f eagle.app.v6.*.bin
|
||||
mv eagle.app.flash.bin $@
|
||||
../crypto/sign.py eagle.app.flash.bin $@ $(CERT)
|
||||
|
||||
user2.bin: proxy.o tcp_ota.o st_ota.o elm327.o webserver.o ../crypto/sha.c ../crypto/rsa.c
|
||||
$(CC) $(CFLAGS) $^ -o a.out -L$(SDK_BASE)/ld -T$(SDK_BASE)/ld/eagle.app.v6.new.1024.app2.ld $(LDLIBS)
|
||||
|
@ -40,7 +42,7 @@ user2.bin: proxy.o tcp_ota.o st_ota.o elm327.o webserver.o ../crypto/sha.c ../cr
|
|||
$(OBJCP) --only-section .irom0.text -O binary a.out eagle.app.v6.irom0text.bin
|
||||
COMPILE=gcc python ./esp-open-sdk/ESP8266_NONOS_SDK_V1.5.4_16_05_20/tools/gen_appbin.py a.out 2 0 32 4 0
|
||||
rm -f eagle.app.v6.*.bin
|
||||
mv eagle.app.flash.bin $@
|
||||
../crypto/sign.py eagle.app.flash.bin $@ $(CERT)
|
||||
|
||||
ota: user1.bin user2.bin
|
||||
./tools/tcp_flash.py 192.168.0.10 user1.bin user2.bin
|
||||
|
|
|
@ -13,9 +13,13 @@ with open(sys.argv[1]) as f:
|
|||
print "signing", len(dat), "bytes"
|
||||
|
||||
with open(sys.argv[2], "wb") as f:
|
||||
x = struct.pack("I", len(dat)) + dat[4:]
|
||||
# mock signature of dat[4:]
|
||||
dd = hashlib.sha1(dat[4:]).digest()
|
||||
if os.getenv("SETLEN") is not None:
|
||||
x = struct.pack("I", len(dat)) + dat[4:]
|
||||
# mock signature of dat[4:]
|
||||
dd = hashlib.sha1(dat[4:]).digest()
|
||||
else:
|
||||
x = dat
|
||||
dd = hashlib.sha1(dat).digest()
|
||||
dd = "\x00\x01" + "\xff"*0x69 + "\x00" + dd
|
||||
rsa_out = pow(int(dd.encode("hex"), 16), rsa.d, rsa.n)
|
||||
sig = (hex(rsa_out)[2:-1].rjust(0x100, '0')).decode("hex")
|
||||
|
|
Loading…
Reference in New Issue