Skip to content

Commit 626beaf

Browse files
committed
Fixes for native_test with ST33 and TPM2_GetRandom2.
1 parent f983525 commit 626beaf

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

examples/native/native_test.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ int TPM2_Native_TestArgs(void* userCtx, int argc, char *argv[])
331331
#if defined(WOLFTPM_ST33) || defined(WOLFTPM_AUTODETECT)
332332
if (TPM2_GetVendorID() == TPM_VENDOR_STM) {
333333
XMEMSET(&cmdIn.getRand, 0, sizeof(cmdIn.getRand));
334-
i = (int)sizeof(cmdOut.getRand2.randomBytes);
334+
i = (int)sizeof(cmdOut.getRand2.randomBytes.buffer);
335335
if (i > (MAX_RESPONSE_SIZE-(int)sizeof(UINT16))) {
336336
i = (MAX_RESPONSE_SIZE-(int)sizeof(UINT16));
337337
}
@@ -361,7 +361,7 @@ int TPM2_Native_TestArgs(void* userCtx, int argc, char *argv[])
361361
/* the getRand and getRand2 have same return size header in cmdOut union */
362362
if (cmdOut.getRand.randomBytes.size != i) {
363363
printf("TPM2_GetRandom length mismatch %d != %d\n",
364-
cmdOut.getRand.randomBytes.size, MAX_RNG_REQ_SIZE);
364+
cmdOut.getRand.randomBytes.size, i);
365365
goto exit;
366366
}
367367
printf("TPM2_GetRandom: Got %d bytes\n", cmdOut.getRand.randomBytes.size);
@@ -371,7 +371,7 @@ int TPM2_Native_TestArgs(void* userCtx, int argc, char *argv[])
371371

372372
/* Stir Random */
373373
XMEMSET(&cmdIn.stirRand, 0, sizeof(cmdIn.stirRand));
374-
cmdIn.stirRand.inData.size = cmdOut.getRand.randomBytes.size;
374+
cmdIn.stirRand.inData.size = MAX_RNG_REQ_SIZE;
375375
XMEMCPY(cmdIn.stirRand.inData.buffer,
376376
cmdOut.getRand.randomBytes.buffer, cmdIn.stirRand.inData.size);
377377
rc = TPM2_StirRandom(&cmdIn.stirRand);

0 commit comments

Comments
 (0)