Skip to content

Commit 487efc6

Browse files
dgarskedanielinux
authored andcommitted
Improvements for portability using older gcc 4.8.2. Make sure wolfboot.h includes the wolfBoot_verify_* API's. Fixed issue with parsing headers when #include is # include.
1 parent 77ede65 commit 487efc6

File tree

5 files changed

+41
-8
lines changed

5 files changed

+41
-8
lines changed

docs/Renesas.md

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Platforms Supported:
1717
All of the Renesas examples support using e2Studio.
1818
The Renesas RX parts support using wolfBoot Makefile's with the rx-elf-gcc cross-compiler and example .config files.
1919

20-
### Security Key Management Tool (SKMT) Key Wrapping
20+
## Security Key Management Tool (SKMT) Key Wrapping
2121

2222
1) Setup a Renesas KeyWrap account and do the PGP key exchange.
2323
https://dlm.renesas.com/keywrap
@@ -34,7 +34,7 @@ Use GPG4Win and the Sign/Encrypt option. Sign with your own GPG key and encrypt
3434
It will use the Hidden Root Key (HRK) that both Renesas and the RX TSIP have pre-provisioned from Renesas Factory.
3535
Result is `sample.key_enc.key`. Example: `00000001 6CCB9A1C 8AA58883 B1CB02DE 6C37DA60 54FB94E2 06EAE720 4D9CCF4C 6EEB288C`
3636

37-
### RX TSIP
37+
## RX TSIP
3838

3939
1) Build key tools for Renesas
4040

@@ -164,11 +164,24 @@ Output image(s) successfully created.
164164
Download files to flash using Renesas flash programmer.
165165

166166

167-
#### RX TSIP Benchmarks
167+
### RX TSIP Benchmarks
168168

169169
| Hardware | Clock | Algorithm | RX TSIP | Debug | Release (-Os) | Release (-O2) |
170170
| -------- | ------ | ----------------- | -------- | -------- | ------------- | ------------- |
171171
| RX72N | 240MHz | ECDSA Verify P384 | 17.26 ms | 1570 ms | 441 ms | 313 ms |
172172
| RX72N | 240MHz | ECDSA Verify P256 | 2.73 ms | 469 ms | 135 ms | 107 ms |
173173
| RX65N | 120MHz | ECDSA Verify P384 | 18.57 ms | 4213 ms | 2179 ms | 1831 ms |
174174
| RX65N | 120MHz | ECDSA Verify P256 | 2.95 ms | 1208 ms | 602 ms | 517 ms |
175+
176+
177+
## RX Production Protection (recommendations)
178+
179+
1) Lockdown external serial programmer `SPCC.SPE = 0`
180+
2) Flash Access Window Setting Register (FAW)
181+
* BTFLG: Start-up Area Select FAW.BTFLG (1=FFFF E000h to FFFF FFFFh, 0=FFFF C000h to FFFF DFFFh)
182+
* FSPR - FAW.FSPR Access Window Protection (0=protections enabled) Once changed to 0 cannot be reset.
183+
3) ROM Code Protection Register `ROMCODE.CODE[31:0]`
184+
* 0000 0000h: ROM code protection enabled (ROM code protection 1)
185+
* 0000 0001h: ROM code protection enabled (ROM code protection 2)
186+
* Other than above: ROM code protection disabled
187+
4) Options Trusted Memory (TM) Enable `TMEF.TMEF[2:0] = b000` - prevents reading of blocks 8 and 9 (see 59.17 Trusted Memory) - Location for keys or code that should not be read

include/image.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,6 @@ int wolfBoot_open_image_external(struct wolfBoot_image* img, uint8_t part, uint8
833833
int wolfBoot_open_image_address(struct wolfBoot_image* img, uint8_t* image);
834834
int wolfBoot_verify_integrity(struct wolfBoot_image *img);
835835
int wolfBoot_verify_authenticity(struct wolfBoot_image *img);
836-
int wolfBoot_get_partition_state(uint8_t part, uint8_t *st);
837836
int wolfBoot_set_partition_state(uint8_t part, uint8_t newst);
838837
int wolfBoot_get_update_sector_flag(uint16_t sector, uint8_t *flag);
839838
int wolfBoot_set_update_sector_flag(uint16_t sector, uint8_t newflag);

include/user_settings.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@
3737
#define WOLFSSL_USER_MUTEX /* avoid wc_port.c wc_InitAndAllocMutex */
3838
#define WOLFCRYPT_ONLY
3939
#define SIZEOF_LONG_LONG 8
40+
#define HAVE_EMPTY_AGGREGATES 0
41+
#define HAVE_ANONYMOUS_INLINE_AGGREGATES 0
4042

4143
/* Stdlib Types */
4244
#define CTYPE_USER /* don't let wolfCrypt types.h include ctype.h */
@@ -533,6 +535,7 @@ extern int tolower(int c);
533535

534536
#ifdef WOLFBOOT_ENABLE_WOLFHSM_CLIENT
535537
# define WOLF_CRYPTO_CB
538+
# undef HAVE_ANONYMOUS_INLINE_AGGREGATES
536539
# define HAVE_ANONYMOUS_INLINE_AGGREGATES 1
537540
# define WOLFSSL_KEY_GEN
538541
#endif /* WOLFBOOT_ENABLE_WOLFHSM_CLIENT */

include/wolfboot/wolfboot.h

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,11 @@ extern "C" {
164164

165165
/* Hashing configuration */
166166
#if defined(WOLFBOOT_HASH_SHA256)
167-
# include "wolfssl/wolfcrypt/sha256.h"
167+
#include "wolfssl/wolfcrypt/settings.h"
168+
#include "wolfssl/wolfcrypt/visibility.h"
169+
#include "wolfssl/wolfcrypt/wc_port.h"
170+
#include "wolfssl/wolfcrypt/types.h"
171+
#include "wolfssl/wolfcrypt/sha256.h"
168172
# ifndef WOLFBOOT_SHA_BLOCK_SIZE
169173
# define WOLFBOOT_SHA_BLOCK_SIZE (256)
170174
# endif
@@ -179,7 +183,11 @@ extern "C" {
179183
typedef wc_Sha256 wolfBoot_hash_t;
180184
# define HDR_HASH HDR_SHA256
181185
#elif defined(WOLFBOOT_HASH_SHA384)
182-
# include "wolfssl/wolfcrypt/sha512.h"
186+
#include "wolfssl/wolfcrypt/settings.h"
187+
#include "wolfssl/wolfcrypt/visibility.h"
188+
#include "wolfssl/wolfcrypt/wc_port.h"
189+
#include "wolfssl/wolfcrypt/types.h"
190+
#include "wolfssl/wolfcrypt/sha512.h"
183191
# ifndef WOLFBOOT_SHA_BLOCK_SIZE
184192
# define WOLFBOOT_SHA_BLOCK_SIZE (256)
185193
# endif
@@ -194,7 +202,11 @@ extern "C" {
194202
typedef wc_Sha384 wolfBoot_hash_t;
195203
# define HDR_HASH HDR_SHA384
196204
#elif defined(WOLFBOOT_HASH_SHA3_384)
197-
# include "wolfssl/wolfcrypt/sha3.h"
205+
#include "wolfssl/wolfcrypt/settings.h"
206+
#include "wolfssl/wolfcrypt/visibility.h"
207+
#include "wolfssl/wolfcrypt/wc_port.h"
208+
#include "wolfssl/wolfcrypt/types.h"
209+
#include "wolfssl/wolfcrypt/sha3.h"
198210
# ifndef WOLFBOOT_SHA_BLOCK_SIZE
199211
# define WOLFBOOT_SHA_BLOCK_SIZE (128)
200212
# endif
@@ -326,6 +338,12 @@ extern "C" {
326338
#define FLASH_WORD_ERASED 0x00000000UL
327339
#endif
328340

341+
#ifdef __WOLFBOOT
342+
/* include after PART_* are defined */
343+
/* for wolfBoot_verify_integrity and wolfBoot_verify_authenticity */
344+
#include "image.h"
345+
#endif
346+
329347
void wolfBoot_update_trigger(void);
330348
void wolfBoot_success(void);
331349
uint32_t wolfBoot_image_size(uint8_t *image);

src/delta.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ struct BLOCK_HDR_PACKED block_hdr {
4343
#define BLOCK_HDR_SIZE (sizeof (struct block_hdr))
4444

4545
#if defined(EXT_ENCRYPTED) && defined(__WOLFBOOT)
46-
#include "encrypt.h"
46+
#include "image.h"
4747
#define ext_flash_check_write ext_flash_encrypt_write
4848
#define ext_flash_check_read ext_flash_decrypt_read
4949
#elif defined(__WOLFBOOT)

0 commit comments

Comments
 (0)