Skip to content

Commit

Permalink
Fix building with wolfTPM
Browse files Browse the repository at this point in the history
  • Loading branch information
danielinux committed Oct 28, 2024
1 parent a3ecb0d commit 549cb02
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions include/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ int wolfBot_get_dts_size(void *dts_addr);
#define wolfBoot_verify_signature_secondary wolfBoot_verify_signature_ml_dsa
#endif

#if defined(WOLFBOOT_TPM)
#undef wolfBoot_verify_signature_primary
#define wolfBoot_verify_signature_primary wolfBoot_verify_signature_tpm
#endif


#if (defined(WOLFBOOT_ARMORED) && defined(__WOLFBOOT))

Expand Down
11 changes: 9 additions & 2 deletions src/image.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ static uint8_t digest[WOLFBOOT_SHA_DIGEST_SIZE];

/* TPM based verify */
#if defined(WOLFBOOT_TPM) && defined(WOLFBOOT_TPM_VERIFY)
static void wolfBoot_verify_signature_ecc(uint8_t key_slot,
#ifdef ECC_IMAGE_SIGNATURE_SIZE
#define IMAGE_SIGNATURE_SIZE ECC_IMAGE_SIGNATURE_SIZE
#else
#define IMAGE_SIGNATURE_SIZE RSA_IMAGE_SIGNATURE_SIZE
#endif

static void wolfBoot_verify_signature_tpm(uint8_t key_slot,
struct wolfBoot_image *img, uint8_t *sig)
{
int ret = 0, verify_res = 0;
Expand All @@ -80,7 +86,8 @@ static void wolfBoot_verify_signature_ecc(uint8_t key_slot,
if (ret == 0) {
sigAlg = (alg == TPM_ALG_RSA) ? TPM_ALG_RSASSA : TPM_ALG_ECDSA;
ret = wolfTPM2_VerifyHashScheme(&wolftpm_dev, &tpmKey,
sig, ECC_IMAGE_SIGNATURE_SIZE, /* Signature */
sig, /* Signature */
IMAGE_SIGNATURE_SIZE, /* Signature size */
img->sha_hash, WOLFBOOT_SHA_DIGEST_SIZE, /* Hash */
sigAlg, WOLFBOOT_TPM_HASH_ALG);
}
Expand Down

0 comments on commit 549cb02

Please sign in to comment.