F-9163 - Reject truncated public key blobs

pull/582/head
Aidan Garske 2026-08-21 13:38:23 -07:00
parent c88d1e0b80
commit 32008fce9f
1 changed files with 2 additions and 0 deletions

View File

@ -221,6 +221,7 @@ int readKeyBlob(const char* filename, WOLFTPM2_KEYBLOB* key)
if (bytes_read != sizeof(key->pub.size)) {
printf("Read %zu, expected size marker of %zu bytes\n",
bytes_read, sizeof(key->pub.size));
rc = BUFFER_E;
goto exit;
}
fileSz -= bytes_read;
@ -233,6 +234,7 @@ int readKeyBlob(const char* filename, WOLFTPM2_KEYBLOB* key)
if (bytes_read != (sizeof(UINT16) + key->pub.size)) {
printf("Read %zu, expected public blob %zu bytes\n",
bytes_read, sizeof(UINT16) + key->pub.size);
rc = BUFFER_E;
goto exit;
}
fileSz -= bytes_read; /* Reminder bytes for private key part */