mirror of https://github.com/wolfSSL/wolfBoot.git
Merge pull request #171 from danielinux/delta-sign-align
commit
2b1f402ffb
|
@ -10,7 +10,7 @@ endif
|
|||
ifeq ($(SIGN),NONE)
|
||||
SIGN_OPTIONS+=--no-sign
|
||||
PRIVATE_KEY=
|
||||
STACK_USAGE=1024
|
||||
STACK_USAGE=1180
|
||||
CFLAGS+=-DWOLFBOOT_NO_SIGN
|
||||
endif
|
||||
|
||||
|
@ -57,7 +57,7 @@ ifeq ($(SIGN),ED25519)
|
|||
./lib/wolfssl/wolfcrypt/src/fe_low_mem.o
|
||||
PUBLIC_KEY_OBJS=./src/ed25519_pub_key.o
|
||||
CFLAGS+=-D"WOLFBOOT_SIGN_ED25519"
|
||||
STACK_USAGE?=1024
|
||||
STACK_USAGE?=1180
|
||||
endif
|
||||
|
||||
ifeq ($(SIGN),ED448)
|
||||
|
|
|
@ -448,10 +448,17 @@ static int make_header_ex(int is_diff, uint8_t *pubkey, uint32_t pubkey_sz, cons
|
|||
&image_type);
|
||||
|
||||
if (is_diff) {
|
||||
/* Append pad bytes, so fields are 4-byte aligned */
|
||||
while ((header_idx % 4) != 0)
|
||||
header_idx++;
|
||||
header_append_tag(header, &header_idx, HDR_IMG_DELTA_BASE, 4,
|
||||
&delta_base_version);
|
||||
header_append_tag(header, &header_idx, HDR_IMG_DELTA_SIZE, 2,
|
||||
&patch_len);
|
||||
|
||||
/* Append pad bytes, so fields are 4-byte aligned */
|
||||
while ((header_idx % 4) != 0)
|
||||
header_idx++;
|
||||
header_append_tag(header, &header_idx, HDR_IMG_DELTA_INVERSE, 4,
|
||||
&patch_inv_off);
|
||||
header_append_tag(header, &header_idx, HDR_IMG_DELTA_INVERSE_SIZE, 2,
|
||||
|
|
|
@ -90,8 +90,8 @@ def make_header(image_file, fw_version, extra_fields=[]):
|
|||
header += struct.pack('<L', fw_version)
|
||||
|
||||
# Four pad bytes, so timestamp is aligned
|
||||
header += struct.pack('BB', 0xFF, 0xFF)
|
||||
header += struct.pack('BB', 0xFF, 0xFF)
|
||||
header += struct.pack('BB', HDR_PADDING, HDR_PADDING)
|
||||
header += struct.pack('BB', HDR_PADDING, HDR_PADDING)
|
||||
|
||||
# Timestamp field
|
||||
header += struct.pack('<HH', HDR_TIMESTAMP, HDR_TIMESTAMP_LEN)
|
||||
|
@ -123,13 +123,20 @@ def make_header(image_file, fw_version, extra_fields=[]):
|
|||
for t in extra_fields:
|
||||
tag = t[0]
|
||||
sz = t[1]
|
||||
if sz == 4:
|
||||
while (len(header) % 4) != 0:
|
||||
header += struct.pack('B', HDR_PADDING)
|
||||
elif sz == 8:
|
||||
while (len(header) % 8) != 4:
|
||||
header += struct.pack('B', HDR_PADDING)
|
||||
|
||||
payload = t[2]
|
||||
header += struct.pack('<HH', tag, sz)
|
||||
header += payload
|
||||
|
||||
# Pad bytes. Sha-3 field requires 8-byte alignment
|
||||
while (len(header) % 8) != 4:
|
||||
header += struct.pack('B', 0xFF)
|
||||
header += struct.pack('B', HDR_PADDING)
|
||||
|
||||
print("Calculating %s digest..." % hash_algo)
|
||||
|
||||
|
@ -462,7 +469,7 @@ outfile = open(output_image_file, 'wb')
|
|||
outfile.write(header)
|
||||
sz = len(header)
|
||||
while sz < WOLFBOOT_HEADER_SIZE:
|
||||
outfile.write(struct.pack('B',0xFF))
|
||||
outfile.write(struct.pack('B',HDR_PADDING))
|
||||
sz += 1
|
||||
infile = open(image_file, 'rb')
|
||||
while True:
|
||||
|
@ -505,7 +512,7 @@ if (delta):
|
|||
outfile.write(header)
|
||||
sz = len(header)
|
||||
while sz < WOLFBOOT_HEADER_SIZE:
|
||||
outfile.write(struct.pack('B', 0xFF))
|
||||
outfile.write(struct.pack('B', HDR_PADDING))
|
||||
sz += 1
|
||||
infile = open(tmp_outfile, 'rb')
|
||||
while True:
|
||||
|
|
Loading…
Reference in New Issue