Skip to content

Commit 4b97568

Browse files
committed
wolfBoot TPM improvements:
* Added TPM SPI wait state support and debug logging. * Added platform auth ownership (change platform password to random value before boot). * Added parameter encryption support. * Removed the TPM hashing feature (not practical). * Fixed RSA with wolfTPM build. * Fixed cleanup wolfTPM objects on make clean. * Start of TPM based root of trust.
1 parent 7638bfb commit 4b97568

File tree

6 files changed

+248
-145
lines changed

6 files changed

+248
-145
lines changed

Makefile

+4-4
Original file line numberDiff line numberDiff line change
@@ -241,10 +241,10 @@ src/keystore.c: $(PRIVATE_KEY)
241241
keys: $(PRIVATE_KEY)
242242

243243
clean:
244-
$(Q)rm -f src/*.o hal/*.o hal/spi/*.o lib/wolfssl/wolfcrypt/src/*.o test-app/*.o
245-
$(Q)rm -f *.bin *.elf wolfboot.map test-update.rom *.hex $(LSCRIPT)
246-
$(Q)rm -f src/x86/*.o $(MACHINE_OBJ) $(MAIN_TARGET)
247-
$(Q)rm -f lib/wolfTPM/src/*.o
244+
$(Q)rm -f src/*.o hal/*.o hal/spi/*.o test-app/*.o src/x86/*.o
245+
$(Q)rm -f lib/wolfssl/wolfcrypt/src/*.o lib/wolfTPM/src/*.o
246+
$(Q)rm -f wolfboot.bin wolfboot.elf wolfboot.map test-update.rom wolfboot.hex
247+
$(Q)rm -f $(MACHINE_OBJ) $(MAIN_TARGET) $(LSCRIPT)
248248
$(Q)$(MAKE) -C test-app -s clean
249249
$(Q)$(MAKE) -C tools/check_config -s clean
250250
$(Q)$(MAKE) -C stage1 -s clean

include/user_settings.h

+34-18
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ extern int tolower(int c);
129129

130130
#ifdef WOLFBOOT_SIGN_RSA2048
131131
# define RSA_LOW_MEM
132-
# define WOLFSSL_RSA_VERIFY_INLINE
133-
# define WOLFSSL_RSA_VERIFY_ONLY
132+
# ifndef WOLFBOOT_TPM
133+
# define WOLFSSL_RSA_VERIFY_INLINE
134+
# define WOLFSSL_RSA_VERIFY_ONLY
135+
# endif
134136
# define WC_NO_RSA_OAEP
135137
# define FP_MAX_BITS (2048 * 2)
136138
/* sp math */
@@ -223,12 +225,35 @@ extern int tolower(int c);
223225
# define NO_PWDBASED
224226
#endif
225227

226-
/* Disables - For minimum wolfCrypt build */
227-
#ifndef WOLFBOOT_TPM
228-
# if !defined(ENCRYPT_WITH_AES128) && !defined(ENCRYPT_WITH_AES256)
229-
# define NO_AES
230-
# endif
231-
# define NO_HMAC
228+
#ifdef WOLFBOOT_TPM
229+
/* Enable AES CFB (parameter encryption) and HMAC (for KDF) */
230+
#define WOLFSSL_AES_CFB
231+
232+
#ifdef WOLFTPM_MMIO
233+
/* IO callback it above TIS and includes Address and if read/write */
234+
#define WOLFTPM_ADV_IO
235+
#endif
236+
237+
/* add delay */
238+
#if !defined(XTPM_WAIT) && defined(WOLFTPM_MMIO)
239+
void delay(int msec);
240+
#define XTPM_WAIT() delay(1000);
241+
#endif
242+
#ifndef XTPM_WAIT
243+
#define XTPM_WAIT() /* no delay */
244+
#endif
245+
246+
/* TPM remap printf */
247+
#if defined(DEBUG_WOLFTPM) && !defined(ARCH_SIM)
248+
#include "printf.h"
249+
#define printf wolfBoot_printf
250+
#endif
251+
#else
252+
/* Disables - For minimum wolfCrypt build */
253+
#if !defined(ENCRYPT_WITH_AES128) && !defined(ENCRYPT_WITH_AES256)
254+
#define NO_AES
255+
#endif
256+
#define NO_HMAC
232257
#endif
233258

234259
#define NO_CMAC
@@ -258,6 +283,7 @@ extern int tolower(int c);
258283
#define WOLFSSL_NO_SOCK
259284
#define WOLFSSL_IGNORE_FILE_WARN
260285
#define NO_ERROR_STRINGS
286+
#define NO_AES_CBC
261287

262288
#define BENCH_EMBEDDED
263289
#define NO_CRYPT_TEST
@@ -289,14 +315,4 @@ extern int tolower(int c);
289315
# define WOLFSSL_SMALL_STACK
290316
#endif
291317

292-
293-
#ifdef WOLFTPM_MMIO
294-
void delay(int msec);
295-
#define XTPM_WAIT() delay(1000);
296-
#define DEBUG_WOLFTPM
297-
#define WOLFTPM_ADV_IO
298-
void uart_printf(const char* fmt, ...);
299-
#define XPRINTF uart_printf
300-
#endif
301-
302318
#endif /* !H_USER_SETTINGS_ */

options.mk

+4-3
Original file line numberDiff line numberDiff line change
@@ -438,15 +438,16 @@ ifeq ($(WOLFTPM),1)
438438
-D"MAX_SESSION_NUM=2" -D"MAX_DIGEST_BUFFER=973" \
439439
-D"WOLFTPM_SMALL_STACK"
440440
CFLAGS+=-D"WOLFTPM_AUTODETECT"
441-
# Use TPM for hashing (slow)
442-
#CFLAGS+=-D"WOLFBOOT_HASH_TPM"
443441
ifneq ($(SPI_FLASH),1)
444442
# don't use spi if we're using simulator
443+
ifeq ($(TARGET),sim)
444+
SIM_TPM=1
445+
endif
445446
ifeq ($(SIM_TPM),1)
446447
CFLAGS+=-DWOLFTPM_SWTPM -DTPM_TIMEOUT_TRIES=0
447448
OBJS+=./lib/wolfTPM/src/tpm2_swtpm.o
448-
# Use memory-mapped WOLFTPM on x86-64
449449
else
450+
# Use memory-mapped WOLFTPM on x86-64
450451
ifeq ($(ARCH),x86_64)
451452
CFLAGS+=-DWOLFTPM_MMIO -DWOLFTPM_EXAMPLE_HAL -DWOLFTPM_INCLUDE_IO_FILE
452453
OBJS+=./lib/wolfTPM/hal/tpm_io_mmio.o

0 commit comments

Comments
 (0)