diff --git a/examples/nvram/read.c b/examples/nvram/read.c index 4ca26a7..6d9ed72 100644 --- a/examples/nvram/read.c +++ b/examples/nvram/read.c @@ -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; diff --git a/examples/tpm_test_keys.c b/examples/tpm_test_keys.c index 710e782..4aaaa49 100644 --- a/examples/tpm_test_keys.c +++ b/examples/tpm_test_keys.c @@ -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; } diff --git a/src/tpm2.c b/src/tpm2.c index bd1fcf1..bce1453 100644 --- a/src/tpm2.c +++ b/src/tpm2.c @@ -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; diff --git a/src/tpm2_wrap.c b/src/tpm2_wrap.c index c43352f..ad6e174 100644 --- a/src/tpm2_wrap.c +++ b/src/tpm2_wrap.c @@ -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; }