Fix `TPM2_ParsePublic` size argument.

pull/419/head
David Garske 2025-05-30 17:59:57 -07:00
parent bd682553ac
commit d5872221ba
4 changed files with 3 additions and 10 deletions

View File

@ -221,7 +221,7 @@ int TPM2_NVRAM_Read_Example(void* userCtx, int argc, char *argv[])
/* Necessary for storing the publicArea with the correct encoding */
rc = TPM2_ParsePublic(&keyBlob.pub, pubAreaBuffer,
(word32)sizeof(pubAreaBuffer), &pubAreaSize);
readSize, &pubAreaSize);
if (rc != TPM_RC_SUCCESS) {
printf("Decoding of PublicArea failed. Unable to extract correctly.\n");
goto exit;

View File

@ -216,7 +216,7 @@ int readKeyBlob(const char* filename, WOLFTPM2_KEYBLOB* key)
/* Decode the byte stream into a publicArea structure ready for use */
rc = TPM2_ParsePublic(&key->pub, pubAreaBuffer,
(word32)sizeof(pubAreaBuffer), &pubAreaSize);
sizeof(UINT16) + key->pub.size, &pubAreaSize);
if (rc != TPM_RC_SUCCESS) {
goto exit;
}

View File

@ -6465,13 +6465,6 @@ int TPM2_ParsePublic(TPM2B_PUBLIC* pub, byte* buf, word32 size, int* sizeUsed)
if (buf == NULL || pub == NULL || sizeUsed == NULL)
return BAD_FUNC_ARG;
if (size < sizeof(TPM2B_PUBLIC)) {
#ifdef DEBUG_WOLFTPM
printf("Insufficient buffer size for TPM2B_PUBLIC operations\n");
#endif
return TPM_RC_FAILURE;
}
/* Prepare temporary buffer */
packet.buf = buf;
packet.pos = 0;

View File

@ -481,7 +481,7 @@ int wolfTPM2_SetKeyBlobFromBuffer(WOLFTPM2_KEYBLOB* key, byte *buffer,
/* Decode the byte stream into a publicArea structure ready for use */
rc = TPM2_ParsePublic(&key->pub, pubAreaBuffer,
(word32)sizeof(pubAreaBuffer), &pubAreaSize);
(word32)(sizeof(UINT16) + key->pub.size), &pubAreaSize);
if (rc != TPM_RC_SUCCESS) {
return rc;
}