Skip to content

Commit d854b28

Browse files
committed
Fixes for wolfHSM RSA with cert chain auth
1 parent 6697e50 commit d854b28

File tree

5 files changed

+34
-11
lines changed

5 files changed

+34
-11
lines changed

demo-build-offline-certs.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
make -C ../ clean CERT_CHAIN_FILE=foo
4+
5+
# build keytools
6+
make -C tools/keytools/ \
7+
HT_TRICORE_PATH=/opt/hightec/gnutri_v4.9.4.1-11fcedf-lin64 \
8+
WOLFHSM_INFINEON_TC3XX=/home/brett/workspace/wolfssl/wolfssl-repos/wolfhsm-private/infineon/tc3xx \
9+
TC3_DIR=/home/brett/workspace/wolfssl/wolfssl-repos/wolfhsm-private/infineon/tc3xx/wolfLLD-tc3xx/tc3 \
10+
WOLFBOOT_LIB_WOLFSSL=/home/brett/workspace/wolfssl/wolfssl-repos/wolfhsm-private/infineon/tc3xx/wolfssl \
11+
WOLFBOOT_LIB_WOLFHSM=/home/brett/workspace/wolfssl/wolfssl-repos/wolfhsm-private/infineon/tc3xx/wolfHSM
12+
13+
# Build wolfBoot
14+
make DEBUG_SYMBOLS=1 GCC=1 \
15+
CERT_CHAIN_FILE=$(pwd)/offline-dummy-chain/raw-chain.der \
16+
NVM_CONFIG=$(pwd)/offline-dummy-chain/custom-root.nvminit \
17+
PRIVATE_KEY=$(pwd)/offline-dummy-chain/leaf-prvkey.der \
18+
IMPORT_PUBLIC_KEY=$(pwd)/offline-dummy-chain/leaf-pubkey.der \
19+
HT_TRICORE_PATH=/opt/hightec/gnutri_v4.9.4.1-11fcedf-lin64 \
20+
WOLFHSM_INFINEON_TC3XX=/home/brett/workspace/wolfssl/wolfssl-repos/wolfhsm-private/infineon/tc3xx \
21+
TC3_DIR=/home/brett/workspace/wolfssl/wolfssl-repos/wolfhsm-private/infineon/tc3xx/wolfLLD-tc3xx/tc3 \
22+
WOLFBOOT_LIB_WOLFSSL=/home/brett/workspace/wolfssl/wolfssl-repos/wolfhsm-private/infineon/tc3xx/wolfssl \
23+
WOLFBOOT_LIB_WOLFHSM=/home/brett/workspace/wolfssl/wolfssl-repos/wolfhsm-private/infineon/tc3xx/wolfHSM
24+
25+
# Sign v2 test app
26+
IMAGE_HEADER_SIZE=4096 tools/keytools/sign --rsa2048 --cert-chain offline-dummy-chain/raw-chain.der test-app/image.bin offline-dummy-chain/leaf-prvkey.der 2
27+
28+
29+
30+
31+
Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ set -euo pipefail
55
OUT_DIR="offline-dummy-chain"
66
OUT_PATH="$(pwd)/${OUT_DIR}"
77

8-
# 1) Build keytools (same as Makefile prerequisite)
9-
make -C tools/keytools -j
10-
118
# 2) Generate signing key + keystore.c (same as Makefile rule wolfboot_signing_private_key.der)
129
# Uses RSA2048 to match your current setup. The generated keystore.c wont be used as it will
1310
# be regenerated based on the input key when building wolfBoot with `make` later

include/user_settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,7 @@ extern int tolower(int c);
587587
# define WOLFSSL_USER_IO
588588
# define WOLFSSL_SP_MUL_D
589589
# define WOLFSSL_PEM_TO_DER
590+
# define WOLFSSL_ALLOW_NO_SUITES
590591
#endif
591592

592593
#ifdef WOLFSSL_STM32_PKA

src/image.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,8 @@ static void wolfBoot_verify_signature_rsa(uint8_t key_slot,
499499
XMEMCPY(output, sig, RSA_IMAGE_SIGNATURE_SIZE);
500500
RSA_VERIFY_FN(ret, wc_RsaSSL_VerifyInline, output, RSA_IMAGE_SIGNATURE_SIZE,
501501
&digest_out, &rsa);
502-
#if !defined(WOLFBOOT_USE_WOLFHSM_PUBKEY_ID)
502+
#if defined(WOLFBOOT_ENABLE_WOLFHSM_CLIENT) && \
503+
!defined(WOLFBOOT_USE_WOLFHSM_PUBKEY_ID)
503504
/* evict the key after use, since we aren't using the RSA import API */
504505
if (WH_ERROR_OK != wh_Client_KeyEvict(&hsmClientCtx, hsmKeyId)) {
505506
return;

test-app/Makefile

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,6 @@ BOOTLOADER_PARTITION_SIZE?=$$(( $(WOLFBOOT_PARTITION_BOOT_ADDRESS) - $(ARCH_FLAS
2121
# For test-applications we should only use user_settings.h
2222
CFLAGS+=-DWOLFSSL_USER_SETTINGS -DWOLFTPM_USER_SETTINGS
2323

24-
ifeq ($(SIGN),RSA2048)
25-
IMAGE_HEADER_SIZE:=512
26-
endif
27-
28-
ifeq ($(SIGN),RSA4096)
29-
IMAGE_HEADER_SIZE:=1024
30-
endif
3124
ifeq ($(HASH),SHA256)
3225
WOLFCRYPT_OBJS+=$(WOLFBOOT_LIB_WOLFSSL)/wolfcrypt/src/sha256.o
3326
CFLAGS+=-D"WOLFBOOT_HASH_SHA256"

0 commit comments

Comments
 (0)