Skip to content

Commit 44788c1

Browse files
committed
Peer review fixes
1 parent 92854c5 commit 44788c1

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

hal/tpm_io_mmio.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
#ifdef WOLFTPM_INCLUDE_IO_FILE
3838
#ifdef WOLFTPM_MMIO
3939

40-
#ifndef MIMO_BASE_ADDRESS
41-
#define MIMO_BASE_ADDRESS 0xFE000000u
40+
#ifndef MMIO_BASE_ADDRESS
41+
#define MMIO_BASE_ADDRESS 0xFE000000u
4242
#endif
4343

4444
#ifndef WOLFTPM_ADV_IO
@@ -108,14 +108,14 @@ int TPM2_IoCb_Mmio(TPM2_CTX *ctx, int isRead, word32 addr, byte* buf, word16 siz
108108
return TPM_RC_FAILURE;
109109
}
110110

111-
effectiveAddr = MIMO_BASE_ADDRESS + addr;
111+
effectiveAddr = MMIO_BASE_ADDRESS + addr;
112112

113113
/* FIFO registers use the same address for every access
114114
* (hardware auto-increments internally).
115-
* Non-FIFO registers need the address advanced for multi-byte access.
116-
* TPM_DATA_FIFO offset=0x0024, TPM_XDATA_FIFO offset=0x0083 */
115+
* Non-FIFO registers need the address advanced for multi-byte access. */
117116
regOffset = addr & 0x0FFFu;
118-
isFifo = (regOffset == 0x0024u || regOffset == 0x0083u);
117+
isFifo = (regOffset == TPM_TIS_DATA_FIFO_OFFSET ||
118+
regOffset == TPM_TIS_XDATA_FIFO_OFFSET);
119119

120120
/* IO for 32-bit aligned */
121121
for (i = 0; ((size_t)size - i) >= sizeof(word32); i += sizeof(word32)) {

src/tpm2_tis.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ enum tpm_tis_status {
8484
#define TPM_INT_STATUS(l) (TPM_BASE_ADDRESS | 0x0010u | ((l) << 12u))
8585
#define TPM_STS(l) (TPM_BASE_ADDRESS | 0x0018u | ((l) << 12u))
8686
#define TPM_BURST_COUNT(l) (TPM_BASE_ADDRESS | 0x0019u | ((l) << 12u))
87-
#define TPM_DATA_FIFO(l) (TPM_BASE_ADDRESS | 0x0024u | ((l) << 12u))
88-
#define TPM_XDATA_FIFO(l) (TPM_BASE_ADDRESS | 0x0083u | ((l) << 12u))
87+
#define TPM_DATA_FIFO(l) (TPM_BASE_ADDRESS | TPM_TIS_DATA_FIFO_OFFSET | ((l) << 12u))
88+
#define TPM_XDATA_FIFO(l) (TPM_BASE_ADDRESS | TPM_TIS_XDATA_FIFO_OFFSET | ((l) << 12u))
8989

9090

9191
/* this option enables named semaphore protection on TIS commands for protected

src/tpm2_wrap.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4471,7 +4471,7 @@ int wolfTPM2_VerifyHash(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* key,
44714471
}
44724472
else if (pub->type == TPM_ALG_RSA) {
44734473
hashAlg = pub->parameters.rsaDetail.scheme.details.anySig.hashAlg;
4474-
if (hashAlg == TPM_ALG_NULL || hashAlg == 0)
4474+
if (hashAlg == TPM_ALG_NULL || hashAlg == TPM_ALG_ERROR)
44754475
hashAlg = TPM_ALG_SHA256;
44764476
}
44774477
}
@@ -4688,6 +4688,7 @@ int wolfTPM2_ECDHEGenZ(WOLFTPM2_DEV* dev, WOLFTPM2_KEY* parentKey,
46884688
printf("TPM2_ZGen_2Phase failed %d: %s\n", rc,
46894689
wolfTPM2_GetRCString(rc));
46904690
#endif
4691+
TPM2_ForceZero(&outZGen2Ph, sizeof(outZGen2Ph));
46914692
return rc;
46924693
}
46934694

wolftpm/tpm2_tis.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141

4242
#define TPM_TIS_READY_MASK 0x01
4343

44+
/* TIS register offsets (without base address or locality) */
45+
#define TPM_TIS_DATA_FIFO_OFFSET 0x0024u
46+
#define TPM_TIS_XDATA_FIFO_OFFSET 0x0083u
47+
4448
/* Typically only 0-2 wait states are required */
4549
#ifndef TPM_TIS_MAX_WAIT
4650
#define TPM_TIS_MAX_WAIT 3

0 commit comments

Comments
 (0)