Skip to content

Commit edc6a26

Browse files
committed
Update wolfHSM, add associated code changes for compatibility with
key usage policies
1 parent c303129 commit edc6a26

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

.github/workflows/test-wolfhsm-simulator.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,8 @@ jobs:
111111
echo "obj 1 0xFFFF 0x0000 \"cert CA\" ../../../../../test-dummy-ca/root-cert.der" >> $tmpfile
112112
./Build/wh_posix_server.elf --type tcp --nvminit $tmpfile &
113113
else
114-
./Build/wh_posix_server.elf --type tcp --client 12 --id 255 --key ../../../../../wolfboot_signing_private_key_pub.der &
114+
# --flags=0x100 sets the WH_NVM_FLAGS_USAGE_VERIFY flag
115+
./Build/wh_posix_server.elf --type tcp --client 12 --id 255 --flags 0x100 --key ../../../../../wolfboot_signing_private_key_pub.der &
115116
fi
116117
TCP_SERVER_PID=$!
117118
echo "TCP_SERVER_PID=$TCP_SERVER_PID" >> $GITHUB_ENV

src/image.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,8 @@ static void wolfBoot_verify_signature_rsa(uint8_t key_slot,
486486
#else
487487
whKeyId hsmKeyId = WH_KEYID_ERASED;
488488
/* Cache the public key on the server */
489-
ret = wh_Client_KeyCache(&hsmClientCtx, 0, NULL, 0, pubkey, pubkey_sz,
490-
&hsmKeyId);
489+
ret = wh_Client_KeyCache(&hsmClientCtx, WH_NVM_FLAGS_USAGE_VERIFY, NULL, 0,
490+
pubkey, pubkey_sz, &hsmKeyId);
491491
if (ret != WH_ERROR_OK) {
492492
return;
493493
}
@@ -2102,18 +2102,19 @@ int wolfBoot_verify_authenticity(struct wolfBoot_image *img)
21022102
"verifying cert chain and caching leaf pubkey (using DMA)\n");
21032103
hsm_ret = wh_Client_CertVerifyDmaAndCacheLeafPubKey(
21042104
&hsmClientCtx, cert_chain, cert_chain_size, hsmNvmIdCertRootCA,
2105-
&g_certLeafKeyId, &cert_verify_result);
2105+
WH_NVM_FLAGS_USAGE_VERIFY, &g_certLeafKeyId, &cert_verify_result);
21062106
#else
21072107
wolfBoot_printf("verifying cert chain and caching leaf pubkey\n");
21082108
hsm_ret = wh_Client_CertVerifyAndCacheLeafPubKey(
21092109
&hsmClientCtx, cert_chain, cert_chain_size, hsmNvmIdCertRootCA,
2110-
&g_certLeafKeyId, &cert_verify_result);
2110+
WH_NVM_FLAGS_USAGE_VERIFY, &g_certLeafKeyId, &cert_verify_result);
21112111
#endif
21122112
#elif defined(WOLFBOOT_ENABLE_WOLFHSM_SERVER)
21132113
wolfBoot_printf("verifying cert chain and caching leaf pubkey\n");
21142114
hsm_ret = wh_Server_CertVerify(
21152115
&hsmServerCtx, cert_chain, cert_chain_size, hsmNvmIdCertRootCA,
2116-
WH_CERT_FLAGS_CACHE_LEAF_PUBKEY, &g_certLeafKeyId);
2116+
WH_CERT_FLAGS_CACHE_LEAF_PUBKEY, WH_NVM_FLAGS_USAGE_VERIFY,
2117+
&g_certLeafKeyId);
21172118
if (hsm_ret == WH_ERROR_OK) {
21182119
cert_verify_result = 0;
21192120
}

tools/scripts/tc3xx/wolfBoot-wolfHSM-keys.nvminit

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
#
33
# Key format is:
44
# key <clientId> <keyId> <access> <flags> <label> <file>
5-
key 0x1 0xFF 0xFF 0x00 "wolfBoot Pubkey" wolfboot_signing_private_key_pub.der
5+
# flags: WH_NVM_FLAGS_USAGE_VERIFY=0x100
6+
key 0x1 0xFF 0xFF 0x100 "wolfBoot Pubkey" wolfboot_signing_private_key_pub.der

0 commit comments

Comments
 (0)