mirror of https://github.com/wolfSSL/wolfTPM.git
Fix `TPM2_ParsePublic` size argument.
parent
bd682553ac
commit
d5872221ba
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue