Skip to content

Commit 412e4d9

Browse files
committed
Added optional WOLFBOOT_TPM_KEYSTORE_AUTH for build-time NV auth.
1 parent 6bfc594 commit 412e4d9

File tree

5 files changed

+13
-5
lines changed

5 files changed

+13
-5
lines changed

.github/workflows/test-build-sim-tpm.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ on:
1616
rot-args:
1717
required: false
1818
type: string
19+
authstr:
20+
required: false
21+
type: string
1922

2023
jobs:
2124

@@ -52,15 +55,15 @@ jobs:
5255
5356
- name: Build wolfboot
5457
run: |
55-
make ${{inputs.make-args}}
58+
make ${{inputs.make-args}} WOLFBOOT_TPM_KEYSTORE_AUTH="${{inputs.authstr}}"
5659
5760
- name: Build TPM tools
5861
run: |
5962
make tpmtools
6063
6164
- name: Write TPM ROT to TPM
6265
run: |
63-
./tools/tpm/rot -write ${{inputs.rot-args}}
66+
./tools/tpm/rot -write ${{inputs.rot-args}} -auth="${{inputs.authstr}}"
6467
6568
- name: Run wolfBoot
6669
run: |

.github/workflows/test-tpm.yml

+3
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ jobs:
6464
arch: host
6565
config-file: ./config/examples/sim-tpm-keystore.config
6666
make-args: SIGN=ECC256 HASH=SHA256
67+
authstr: TestAuth
6768

6869
sim_tpm_keystore_ecc384:
6970
uses: ./.github/workflows/test-build-sim-tpm.yml
@@ -72,10 +73,12 @@ jobs:
7273
config-file: ./config/examples/sim-tpm-keystore.config
7374
make-args: SIGN=ECC384 HASH=SHA384
7475
rot-args: -sha384
76+
authstr: TestAuth
7577

7678
sim_tpm_keystore_rsa2048:
7779
uses: ./.github/workflows/test-build-sim-tpm.yml
7880
with:
7981
arch: host
8082
config-file: ./config/examples/sim-tpm-keystore.config
8183
make-args: SIGN=RSA2048 HASH=SHA256
84+
authstr: TestAuth

config/examples/sim-tpm-keystore.config

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ WOLFBOOT_FIXED_PARTITIONS=1
2020
# Use NV for TPM based Root of Trust
2121
WOLFBOOT_TPM_KEYSTORE?=1
2222
WOLFBOOT_TPM_KEYSTORE_NV_INDEX?=0x01400200
23+
#WOLFBOOT_TPM_KEYSTORE_AUTH?=TestAuth
2324

2425
# TPM Logging
2526
#CFLAGS_EXTRA+=-DDEBUG_WOLFTPM

options.mk

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ifeq ($(WOLFBOOT_TPM_KEYSTORE),1)
1212
WOLFTPM:=1
1313
CFLAGS+=-DWOLFBOOT_TPM_KEYSTORE
1414
CFLAGS+=-DWOLFBOOT_TPM_KEYSTORE_NV_INDEX=$(WOLFBOOT_TPM_KEYSTORE_NV_INDEX)
15+
CFLAGS+=-DWOLFBOOT_TPM_KEYSTORE_AUTH='"$(WOLFBOOT_TPM_KEYSTORE_AUTH)"'
1516
endif
1617
endif
1718

src/image.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1269,9 +1269,9 @@ static int keyslot_id_by_sha(const uint8_t *hint)
12691269
XMEMSET(&nv, 0, sizeof(nv));
12701270
nv.handle.hndl = WOLFBOOT_TPM_KEYSTORE_NV_INDEX;
12711271

1272-
#if 0 /* TODO: Add auth */
1273-
nv.handle.auth.size = sizeof(authBuf);
1274-
XMEMCPY(nv.handle.auth.buffer, authBuf, sizeof(authBuf));
1272+
#ifdef WOLFBOOT_TPM_KEYSTORE_AUTH
1273+
nv.handle.auth.size = (UINT16)strlen(WOLFBOOT_TPM_KEYSTORE_AUTH);
1274+
memcpy(nv.handle.auth.buffer, WOLFBOOT_TPM_KEYSTORE_AUTH, nv.handle.auth.size);
12751275
#endif
12761276

12771277
rc = wolfTPM2_NVReadAuth(&wolftpm_dev, &nv, WOLFBOOT_TPM_KEYSTORE_NV_INDEX,

0 commit comments

Comments
 (0)