Skip to content

Commit 9403c71

Browse files
committed
Update mechanism implemented, ed25519 signing tool changed
1 parent 6b3dfe2 commit 9403c71

7 files changed

Lines changed: 579 additions & 53 deletions

File tree

Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ tools/ed25519/ed25519_sign:
8888
ed25519.der: tools/ed25519/ed25519_sign
8989
tools/ed25519/ed25519_keygen src/ed25519_pub_key.c
9090

91-
9291
factory.bin: $(BOOT_IMG) wolfboot-align.bin tools/ed25519/ed25519_sign ed25519.der
9392
tools/ed25519/ed25519_sign $(BOOT_IMG) ed25519.der 1
9493
cat wolfboot-align.bin $(BOOT_IMG).v1.signed > $@

include/image.h

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#ifndef IMAGE_H
2+
#define IMAGE_H
3+
#include <stdint.h>
4+
#include <target.h>
5+
6+
#define IMAGE_HEADER_SIZE 256
7+
#define IMAGE_HEADER_OFFSET (2 * sizeof(uint32_t))
8+
9+
#define WOLFBOOT_MAGIC 0x464C4F57 /* WOLF */
10+
#define WOLFBOOT_MAGIC_TRAIL 0x544F4F42 /* BOOT */
11+
12+
#define HDR_END 0x00
13+
#define HDR_VERSION 0x01
14+
#define HDR_TIMESTAMP 0x02
15+
#define HDR_SHA256 0x03
16+
#define HDR_PUBKEY 0x10
17+
#define HDR_SIGNATURE 0x20
18+
#define HDR_PADDING 0xFF
19+
20+
#define PART_BOOT 0
21+
#define PART_UPDATE 1
22+
#define PART_SWAP 2
23+
24+
#define IMG_STATE_NEW 0xFF
25+
#define IMG_STATE_UPDATING 0x70
26+
#define IMG_STATE_TESTING 0x10
27+
#define IMG_STATE_SUCCESS 0x00
28+
29+
#define SECT_FLAG_NEW 0x0F
30+
#define SECT_FLAG_SWAPPING 0x07
31+
#define SECT_FLAG_BACKUP 0x03
32+
#define SECT_FLAG_UPDATED 0x00
33+
34+
35+
struct wolfBoot_image {
36+
uint8_t *hdr;
37+
uint8_t *trailer;
38+
int hdr_ok;
39+
int signature_ok;
40+
int sha_ok;
41+
uint8_t *fw_base;
42+
uint32_t fw_size;
43+
uint8_t part;
44+
};
45+
46+
47+
int wolfBoot_open_image(struct wolfBoot_image *img, uint8_t part);
48+
int wolfBoot_verify_integrity(struct wolfBoot_image *img);
49+
int wolfBoot_verify_authenticity(struct wolfBoot_image *img);
50+
int wolfBoot_set_partition_state(uint8_t part, uint8_t newst);
51+
int wolfBoot_set_sector_flag(uint8_t part, uint8_t sector, uint8_t newflag);
52+
int wolfBoot_get_partition_state(uint8_t part, uint8_t *st);
53+
int wolfBoot_get_sector_flag(uint8_t part, uint8_t sector, uint8_t *flag);
54+
int wolfBoot_copy(uint32_t src, uint32_t dst, uint32_t size);
55+
void wolfBoot_erase_partition(uint8_t part);
56+
void wolfBoot_update_trigger(void);
57+
void wolfBoot_success(void);
58+
59+
#endif /* IMAGE_H */

include/loader.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#ifndef LOADER_H
2+
#define LOADER_H
3+
4+
#if defined(WOLFBOOT_SIGN_EC256)
5+
extern const unsigned char ecdsa_pub_key[];
6+
extern unsigned int ecdsa_pub_key_len;
7+
# define KEY_BUFFER ecdsa_pub_key
8+
# define KEY_LEN ecdsa_pub_key_len
9+
# define IMAGE_SIGNATURE_SIZE (72)
10+
#elif defined(WOLFBOOT_SIGN_ED25519)
11+
extern const unsigned char ed25519_pub_key[];
12+
extern unsigned int ed25519_pub_key_len;
13+
# define KEY_BUFFER ed25519_pub_key
14+
# define KEY_LEN ed25519_pub_key_len
15+
# define IMAGE_SIGNATURE_SIZE (64)
16+
#else
17+
# error "No public key available for given signing algorithm."
18+
#endif /* Algorithm selection */
19+
20+
21+
#endif /* LOADER_H */

0 commit comments

Comments
 (0)