-
Notifications
You must be signed in to change notification settings - Fork 99
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for OTP Flash as trust anchor for keystore #449
Conversation
@@ -200,7 +200,7 @@ const char Keystore_API[] = | |||
"uint32_t keystore_get_mask(int id)\n" | |||
"{\n" | |||
" if (id >= keystore_num_pubkeys())\n" | |||
" return -1;\n" | |||
" return 0;\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looked like a bug in the generated software keystore, a mask with all "1" being returned for an invalid slot. Spotted while writing the API for the OTP trust anchor.
53ff0ad
to
268f187
Compare
+ added non-secure area at boot for OTP to read trust anchor if OTP feature is enabled.
Tested provisioning on a new STM32H563. OTP keystore working as expected. Ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Builds good. Changes look good. Curious your thoughts on how best to test.
tools/keytools/otp/Makefile
Outdated
@$(OBJCOPY) -O binary $(^) $(@) | ||
|
||
otp-keystore-primer.elf: $(PRI_KS_OBJS) | ||
@$(CC) -o otp-keystore-primer.elf $(LDFLAGS) $(CFLAGS) $(PRI_KS_OBJS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might consider the V=1 logic and $(Q)
logic.
Got a warning about missing entry symbol _start
. Still built fine, but is the default entry at 0x8000 really okay?
% make clean && make
arm-none-eabi-gcc -D"__WOLFBOOT" -Werror -Wextra -Wno-array-bounds -mthumb -mlittle-endian -mthumb-interwork -DARCH_ARM -Ihal -mcpu=cortex-m33 -DCORTEX_M33 -mcmse -DWOLFCRYPT_SECURE_MODE -DWOLFSSL_SP_ASM -DWOLFSSL_SP_ARM_CORTEX_M_ASM -DTZEN -DARCH_FLASH_OFFSET=0x08000000 -DWOLFBOOT_DUALBOOT -DWOLFBOOT_ORIGIN=0x0C000000 -DBOOTLOADER_PARTITION_SIZE= -DWOLFBOOT_ARCH_ARM -DTARGET_stm32h5 -D"FLASH_OTP_KEYSTORE" -D"WOLFBOOT_SIGN_ECC256" -D"FILL_BYTE=0xFF" -D"DUALBANK_SWAP=1" -D"NVM_FLASH_WRITEONCE" -Os -D"WOLFBOOT_NO_MPU" -DWOLFBOOT_VERSION=1 -DSECURE_PKCS11 -DWOLFSSL_PKCS11_RW_TOKENS -DCK_CALLABLE="__attribute__((cmse_nonsecure_entry))" -Ilib/wolfPKCS11 -DWP11_HASH_PIN_COST=3 -D"WOLFBOOT_HASH_SHA256" -DIMAGE_HEADER_SIZE=256 "-Wstack-usage=16688" -I"." -I"include/" -I"lib/wolfssl" -Wno-array-bounds -D"WOLFSSL_USER_SETTINGS" -D"WOLFTPM_USER_SETTINGS" -D"PLATFORM_stm32h5" -Wall -Wextra -Wno-main -ffreestanding -Wno-unused -nostartfiles -ffunction-sections -fdata-sections -fomit-frame-pointer -mthumb -mlittle-endian -mthumb-interwork -mcpu=cortex-m33 -Wl,-gc-sections -Wl,-Map=wolfboot.map -ffreestanding -nostartfiles tools/keytools/otp/otp-keystore-primer.c -o tools/keytools/otp/otp-keystore-primer
/usr/local/Cellar/gcc-arm-none-eabi/20200630/bin/../lib/gcc/arm-none-eabi/9.3.1/../../../../arm-none-eabi/bin/ld: warning: cannot find entry symbol _start; defaulting to 0000000000008000
[CC-ARM] hal/stm32h5.o
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was an actual issue with otp-keystore-primer build, not selecting the right linker script
include/wolfboot/wolfboot.h
Outdated
@@ -175,6 +175,10 @@ extern "C" { | |||
#endif | |||
#endif | |||
|
|||
#endif | |||
|
|||
#if defined __WOLFBOOT || defined __FLASH_OTP_PRIMER |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe use defined(__WOLFBOOT) ||
with parenthesis for consistency?
include/otp_keystore.h
Outdated
|
||
#define OTP_HDR_SIZE 16 | ||
|
||
struct __attribute__((packed)) wolfBoot_otp_hdr { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eventually I'd like to see our use of PACKED come from a macro, so it's not just GCC.
#if (defined(__IAR_SYSTEMS_ICC__) && (__IAR_SYSTEMS_ICC__ > 8)) || \
defined(__GNUC__)
#define WOLFBOOT_PACK __attribute__ ((packed))
#else
#define WOLFBOOT_PACK
#endif
+ separate object for hal in otp-keystore-primer
Goals:
keygen
tool generates a one-time provisioning mechanism(re)based on PR #400