From 9e9285fce4627d0255f6149a263b3878da149885 Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 19 Jan 2024 09:53:43 -0800 Subject: [PATCH 1/2] Fix build error with missing `wc_RsaKeyToPublicDer_ex`. --- src/tpm2_wrap.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/tpm2_wrap.c b/src/tpm2_wrap.c index 9973e443..f785200c 100644 --- a/src/tpm2_wrap.c +++ b/src/tpm2_wrap.c @@ -2772,7 +2772,11 @@ int wolfTPM2_ExportPublicKeyBuffer(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* tpmKey, #endif } else if (tpmKey->pub.publicArea.type == TPM_ALG_RSA) { - #ifndef NO_RSA + /* RSA public key export only enabled with: + * cert gen, key gen or openssl extra */ + #if !defined(NO_RSA) && \ + (defined(WOLFSSL_CERT_GEN) || defined(OPENSSL_EXTRA) || \ + defined(WOLFSSL_KEY_GEN)) rc = wc_InitRsaKey(&key.rsa, NULL); if (rc == 0) { /* load public portion of key into wolf RSA Key */ From 9f243d39bb667304fb4b08a696c13f5b86dff0dc Mon Sep 17 00:00:00 2001 From: David Garske Date: Fri, 19 Jan 2024 13:26:19 -0800 Subject: [PATCH 2/2] Improve the ECC macro checks for `wc_EccPublicKeyToDer`. --- src/tpm2_wrap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/tpm2_wrap.c b/src/tpm2_wrap.c index f785200c..779b18a5 100644 --- a/src/tpm2_wrap.c +++ b/src/tpm2_wrap.c @@ -2751,7 +2751,8 @@ int wolfTPM2_ExportPublicKeyBuffer(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* tpmKey, /* determine the type of key in WOLFTPM2_KEY */ if (tpmKey->pub.publicArea.type == TPM_ALG_ECC) { - #ifdef HAVE_ECC + #if defined(HAVE_ECC) && \ + defined(HAVE_ECC_KEY_IMPORT) && defined(HAVE_ECC_KEY_EXPORT) rc = wc_ecc_init(&key.ecc); if (rc == 0) { /* load public portion of key into wolf ECC Key */