Skip to content

Commit 2826f70

Browse files
dgarskedanielinux
authored andcommitted
Improve documentation for new custom TLV.
1 parent e366924 commit 2826f70

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

docs/Signing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ Provides a PCR mask and digest to be signed and included in the header. The sign
185185
Provides a value to be set with a custom tag
186186

187187
* `--custom-tlv tag len val`: Adds a TLV entry to the manifest header, corresponding
188-
to the type identified by `tag`, with lenght `len` bytes, and assigns the value `val`.
188+
to the type identified by `tag`, with length `len` bytes, and assigns the value `val`.
189189
Values can be decimal or hex numbers (prefixed by '0x'). The tag is a 16-bit number.
190190
Valid tags are in the range between 0x0030 and 0xFEFE.
191191

docs/firmware_image.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ application. This corresponds to the first partition in the flash memory.
99
Multiple firmware images can be created this way, and stored in two different partitions. The bootloader
1010
will take care of moving the selected firmware to the first (BOOT) partition before chain-loading the image.
1111

12-
Due to the presence of an image header, the entry point of the application has a fixed additional offset
12+
Due to the presence of an image header, the entry point of the application has a fixed additional offset
1313
of 256B from the beginning of the flash partition.
1414

1515
## Firmware image header
@@ -26,7 +26,7 @@ chain-loading the firmware the interrupt continue to work properly after the boo
2626

2727
### Image header: Tags
2828

29-
The **image header** is prepended with a single 4-byte magic number, followed by a 4-byte field indicating the
29+
The **image header** is prepended with a single 4-byte magic number, followed by a 4-byte field indicating the
3030
firmware image size (excluding the header). All numbers in the header are stored in Little-endian format.
3131

3232
The two fixed fields are followed by one or more tags. Each TAG is structured as follows:
@@ -46,7 +46,7 @@ Each **Type** has a different meaning, and integrate information about the firmw
4646
- A 'firmware signature' Tag (type: 0x0020, size: 64 Bytes) used to validate the signature stored with the firmware against a known public key
4747
- A 'firmware type' Tag (type: 0x0030, size: 2 Bytes) used to identify the type of firmware, and the authentication mechanism in use.
4848

49-
A 'public key hint digest' tag is transmitted in the header (type: 0x10, size:32 Bytes). This tag contains the SHA digest of the public key used
49+
A 'public key hint digest' tag is transmitted in the header (type: 0x10, size:32 Bytes). This tag contains the SHA digest of the public key used
5050
by the signing tool. The bootloader may use this field to locate the correct public key in case of multiple keys available.
5151

5252
wolfBoot will, in all cases, refuse to boot an image that cannot be verified and authenticated using the built-in digital signature authentication mechanism.
@@ -77,17 +77,18 @@ The output image `test-app/image_v4_signed.bin` will contain the custom field wi
7777
From the bootloader code, we can then retrieve the value of the custom field using the `wolfBoot_find_header` function:
7878

7979
```c
80-
uint32_t custom_code34_field;
81-
const uint16_t custom_code34_field_size = 4;
82-
const uint16_t custom_code34_tag = 0x34;
83-
int size;
84-
85-
size = wolfBoot_find_header(0x34, &custom_code34_field, sizeof(custom_code34_value));
86-
if (size != custom_code34_field_size) {
80+
uint32_t value;
81+
uint8_t* ptr = NULL;
82+
uint16_t tlv = 0x34;
83+
uint8_t* imageHdr = (uint8_t*)WOLFBOOT_PARTITION_BOOT_ADDRESS; /* WOLFBOOT_PARTITION_UPDATE_ADDRESS */
84+
uint16_t size = wolfBoot_find_header(imageHdr, tlv, &ptr);
85+
if (size != sizeof(uint32_t) || ptr == NULL) {
8786
/* Error: the field is not present or has the wrong size */
8887
}
8988

90-
/* From here, the value 0xAABBCCDD is stored in custom_code34_value */
89+
/* From here, the value 0xAABBCCDD is at ptr */
90+
memcpy(&value, ptr, size);
91+
printf("TLV 0x%x=0x%x\n", tlv, value);
9192
```
9293
9394
### Image signing tool

0 commit comments

Comments
 (0)