Skip to content

Commit 570acb1

Browse files
authored
Merge pull request #493 from dgarske/fixes_20260424
Fix for FwCmd_StirRandom with custom hardware rand generate
2 parents ebaeb7a + 3fd6758 commit 570acb1

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/fwtpm/fwtpm_command.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,11 +901,18 @@ static TPM_RC FwCmd_StirRandom(FWTPM_CTX* ctx, TPM2_Packet* cmd, int cmdSize,
901901
printf("fwTPM: StirRandom(%d bytes)\n", inDataSize);
902902
#endif
903903

904-
/* Reseed the DRBG with the caller-provided additional input */
904+
/* Reseed the Hash DRBG with the caller-provided additional input.
905+
* When the port uses CUSTOM_RAND_GENERATE_BLOCK (HW RNG) or the
906+
* Hash DRBG is not compiled in, there is nothing to reseed -
907+
* treat as a no-op, which is TCG-compliant for HW-RNG-backed TPMs. */
908+
#if defined(HAVE_HASHDRBG) && !defined(CUSTOM_RAND_GENERATE_BLOCK)
905909
rc = wc_RNG_DRBG_Reseed(&ctx->rng, cmd->buf + cmd->pos, inDataSize);
906910
if (rc != 0) {
907911
rc = TPM_RC_FAILURE;
908912
}
913+
#else
914+
(void)inDataSize;
915+
#endif
909916
}
910917

911918
if (rc == 0) {

0 commit comments

Comments
 (0)