trousers: copy memory in secure way (part 2)
Create tpm_rqu_build_checked to check the size of buffer not to
overflow.
And replace all tpm_rqu_build with this regex rule:
replace this:
tpm_rqu_build\((TPM_ORD([^,)]|\n)*),(([^,)]|\n)*),(([^,)]|\n)*),(([^)]|\n)*)\)
to this:
tpm_rqu_build_checked($1,$3, TSS_TPM_TXBLOB_SIZE,$5,$7)
BUG=chromium:1020667
TEST=Build ok.
TEST=CQ
TEST=manually enroll and login on chell
TEST=run trousers testsuite and had same result before/after this CL.
Change-Id: I2355989b25fb3eeef79f131b1be987d039d5c013
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/trousers/+/2407933
Tested-by: joe Chou <yich@google.com>
Commit-Queue: joe Chou <yich@google.com>
Reviewed-by: Leo Lai <cylai@google.com>
Reviewed-by: Andrey Pronin <apronin@chromium.org>
diff --git a/src/include/tcs_utils.h b/src/include/tcs_utils.h
index 0f0f4ce..a425c9b 100644
--- a/src/include/tcs_utils.h
+++ b/src/include/tcs_utils.h
@@ -263,7 +263,9 @@
char platform_get_runlevel();
TSS_RESULT tpm_rsp_parse(TPM_COMMAND_CODE, BYTE *, UINT32, ...);
+TSS_RESULT tpm_rqu_build_internal(TPM_COMMAND_CODE, UINT64 *, BYTE *, va_list);
TSS_RESULT tpm_rqu_build(TPM_COMMAND_CODE, UINT64 *, BYTE *, ...);
+TSS_RESULT tpm_rqu_build_checked(TPM_COMMAND_CODE, UINT64 *, UINT64, BYTE *, ...);
TSS_RESULT tpm_preload_check(TCS_CONTEXT_HANDLE, TPM_COMMAND_CODE ordinal, ...);
TSS_RESULT getKeyByCacheEntry(struct key_disk_cache *, BYTE *, UINT16 *);
TSS_RESULT add_cache_entry(TCS_CONTEXT_HANDLE, BYTE *, TCS_KEY_HANDLE, TPM_KEY_HANDLE, TCS_KEY_HANDLE *);
diff --git a/src/tcs/tcs_pbg.c b/src/tcs/tcs_pbg.c
index 2400fd8..89e478f 100644
--- a/src/tcs/tcs_pbg.c
+++ b/src/tcs/tcs_pbg.c
@@ -924,19 +924,60 @@
return result;
}
-/* XXX optimize these cases by always passing in lengths for blobs, no more "20 byte values" */
TSS_RESULT
tpm_rqu_build(TPM_COMMAND_CODE ordinal, UINT64 *outOffset, BYTE *out_blob, ...)
{
+ va_list ap;
+ TSS_RESULT result;
+ va_start(ap, out_blob);
+ result = tpm_rqu_build_internal(ordinal, outOffset,out_blob, ap);
+ va_end(ap);
+ return result;
+}
+
+TSS_RESULT
+tpm_rqu_build_checked(TPM_COMMAND_CODE ordinal, UINT64 *outOffset, UINT64 maxOffset, BYTE *out_blob, ...)
+{
+ va_list ap;
+ TSS_RESULT result;
+ UINT64 tempOffset = *outOffset;
+
+ va_start(ap, out_blob);
+ result = tpm_rqu_build_internal(ordinal, &tempOffset, NULL, ap);
+ va_end(ap);
+ if (result)
+ {
+ return result;
+ }
+
+ if (tempOffset > maxOffset)
+ {
+ return TCSERR(TSS_E_BAD_PARAMETER);
+ }
+
+ va_start(ap, out_blob);
+ result = tpm_rqu_build_internal(ordinal, outOffset, out_blob, ap);
+ va_end(ap);
+
+ if (tempOffset != *outOffset)
+ {
+ return TCSERR(TSS_E_INTERNAL_ERROR);
+ }
+
+ return result;
+}
+
+/* XXX optimize these cases by always passing in lengths for blobs, no more "20 byte values" */
+TSS_RESULT
+tpm_rqu_build_internal(TPM_COMMAND_CODE ordinal, UINT64 *outOffset, BYTE *out_blob, va_list ap)
+{
TSS_RESULT result = TSS_SUCCESS;
UINT64 blob_size;
- va_list ap;
DBG_ASSERT(ordinal);
DBG_ASSERT(outOffset);
- DBG_ASSERT(out_blob);
-
- va_start(ap, out_blob);
+ /* |out_blob| could be set to NULL in order to calculate the output size, */
+ /* so don't make assertion to its value. */
switch (ordinal) {
#ifdef TSS_BUILD_DELEGATION
@@ -948,7 +989,6 @@
BYTE *digest1 = va_arg(ap, BYTE *);
UINT32 in_len1 = va_arg(ap, UINT32);
BYTE *in_blob1 = va_arg(ap, BYTE *);
- va_end(ap);
if (!digest1 || !in_blob1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -974,7 +1014,6 @@
BYTE *in_blob1 = va_arg(ap, BYTE *);
BYTE *digest1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!in_len1 || !in_blob1 || !digest1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1002,7 +1041,6 @@
BYTE *in_blob1 = va_arg(ap, BYTE *);
BYTE *digest1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!keyslot1 || !in_len1 || !in_blob1 || !digest1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1034,7 +1072,6 @@
BYTE *in_blob1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
*outOffset += TSS_TPM_TXBLOB_HDR_LEN;
if (keyslot1)
@@ -1073,7 +1110,6 @@
BYTE *in_blob2 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!in_blob1 || !in_blob2 || !auth2) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1109,7 +1145,6 @@
BYTE *in_blob1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!digest1 || !in_blob1 || !auth1 || !auth2) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1143,7 +1178,6 @@
blob1 = va_arg(ap, BYTE *);
auth1 = va_arg(ap, TPM_AUTH *);
auth2 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!dig1 || !dig2 || !blob1 || !auth2) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1177,7 +1211,6 @@
UINT32 in_len1 = va_arg(ap, UINT32);
BYTE *in_blob1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!in_blob1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1209,7 +1242,6 @@
UINT32 j = va_arg(ap, UINT32);
UINT32 k = va_arg(ap, UINT32);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
*outOffset += TSS_TPM_TXBLOB_HDR_LEN;
LoadBlob_UINT32(outOffset, i, out_blob);
@@ -1230,7 +1262,6 @@
BYTE *digest1 = va_arg(ap, BYTE *);
UINT32 in_len1 = va_arg(ap, UINT32);
BYTE *in_blob1 = va_arg(ap, BYTE *);
- va_end(ap);
if (!digest1 || !in_blob1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1254,7 +1285,6 @@
BYTE *in_blob1 = va_arg(ap, BYTE *);
TSS_BOOL in_bool1 = va_arg(ap, int);
BYTE *digest2 = va_arg(ap, BYTE *);
- va_end(ap);
if (!digest1 || !in_blob1 || !digest2) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1275,7 +1305,6 @@
case TPM_ORD_RevokeTrust:
{
BYTE *digest1 = va_arg(ap, BYTE *);
- va_end(ap);
if (!digest1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1298,7 +1327,6 @@
UINT32 in_len1 = va_arg(ap, UINT32);
BYTE *in_blob1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!digest1 || !in_blob1 || !auth1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1327,7 +1355,6 @@
UINT32 in_len2 = va_arg(ap, UINT32);
BYTE *in_blob2 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!keySlot1 || !in_blob1 || !auth1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1358,7 +1385,6 @@
UINT32 in_len2 = va_arg(ap, UINT32);
BYTE *in_blob2 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!keySlot1 || !in_blob1 || !in_blob2) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1389,7 +1415,6 @@
BYTE *digest1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!keySlot1 || !keySlot2 || !digest1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1427,7 +1452,6 @@
UINT32 in_len1 = va_arg(ap, UINT32);
BYTE *in_blob1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (in_len1 && !in_blob1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1460,7 +1484,6 @@
UINT32 in_len2 = va_arg(ap, UINT32);
BYTE *in_blob2 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
blob_size = in_len1 + in_len2 + TPM_DIGEST_SIZE + sizeof(TPM_AUTH);
if (blob_size > TSS_TPM_TXBLOB_SIZE) {
@@ -1495,7 +1518,6 @@
BYTE *in_blob1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!keySlot1 || !in_blob1 || !auth2) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1526,7 +1548,6 @@
UINT32 in_len1 = va_arg(ap, UINT32);
BYTE *in_blob1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!keySlot1 || !digest1 || !in_blob1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1558,7 +1579,6 @@
BYTE *in_blob1 = va_arg(ap, BYTE *);
TSS_BOOL* addVersion = va_arg(ap,TSS_BOOL *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!keySlot1 || !digest1 || !in_blob1 || !addVersion) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1592,7 +1612,6 @@
UINT32 in_len1 = va_arg(ap, UINT32);
BYTE *in_blob1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!keySlot1 || !digest1 || !digest2 || !in_blob1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1622,7 +1641,6 @@
UINT32 in_len2 = va_arg(ap, UINT32);
BYTE *in_blob2 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!in_blob1 || !in_blob2) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1650,7 +1668,6 @@
BYTE *digest1 = va_arg(ap, BYTE *);
BYTE *digest2 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!keySlot1 || !digest1 || !digest2) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1680,7 +1697,6 @@
{
UINT32 in_len1 = va_arg(ap, UINT32);
BYTE *in_blob1 = va_arg(ap, BYTE *);
- va_end(ap);
if (!in_blob1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1711,7 +1727,6 @@
BYTE *in_blob1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (in_len1 && !in_blob1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1745,7 +1760,6 @@
BYTE *in_blob1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
TPM_AUTH *auth2 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (in_len1 && !in_blob1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1778,7 +1792,6 @@
UINT32 in_len1 = va_arg(ap, UINT32);
BYTE *in_blob1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!in_blob1 || !auth1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1805,7 +1818,6 @@
UINT32 in_len3 = va_arg(ap, UINT32);
BYTE *in_blob3 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!in_blob1 || !in_blob2 || !in_blob3 || !auth1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1833,7 +1845,6 @@
TSS_BOOL bool1 = va_arg(ap, int);
BYTE *digest1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!digest1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1862,7 +1873,6 @@
UINT16 type1 = va_arg(ap, int);
UINT32 value1 = va_arg(ap, UINT32);
BYTE *digest1 = va_arg(ap, BYTE *);
- va_end(ap);
if (!digest1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1885,7 +1895,6 @@
BYTE *digest1 = va_arg(ap, BYTE *);
UINT16 type2 = va_arg(ap, int);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!digest1 || !auth1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1909,7 +1918,6 @@
UINT32 ord1 = va_arg(ap, UINT32);
TSS_BOOL bool1 = va_arg(ap, int);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!auth1) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -1934,7 +1942,6 @@
{
TSS_BOOL bool1 = va_arg(ap, int);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
*outOffset += TSS_TPM_TXBLOB_HDR_LEN;
LoadBlob_BOOL(outOffset, bool1, out_blob);
@@ -1966,7 +1973,6 @@
case TPM_ORD_ForceClear:
{
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
*outOffset += TSS_TPM_TXBLOB_HDR_LEN;
if (auth1) {
@@ -1994,7 +2000,6 @@
{
UINT32 i = va_arg(ap, UINT32);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
*outOffset += TSS_TPM_TXBLOB_HDR_LEN;
LoadBlob_UINT32(outOffset, i, out_blob);
@@ -2013,7 +2018,6 @@
{
BYTE *digest1 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
*outOffset += TSS_TPM_TXBLOB_HDR_LEN;
LoadBlob(outOffset, TPM_SHA1_160_HASH_LEN, out_blob, digest1);
@@ -2031,7 +2035,6 @@
case TSC_ORD_PhysicalPresence:
{
UINT16 i = va_arg(ap, int);
- va_end(ap);
*outOffset += TSS_TPM_TXBLOB_HDR_LEN;
LoadBlob_UINT16(outOffset, i, out_blob);
@@ -2050,7 +2053,6 @@
BYTE *digest2 = va_arg(ap, BYTE *);
BYTE *digest3 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!digest1 || !in_blob1 || !digest2 || !digest3) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -2082,7 +2084,6 @@
UINT32 in_len2 = va_arg(ap, UINT32);
BYTE *in_blob2 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!digest1 || !in_blob1 || !in_blob2) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -2121,7 +2122,6 @@
UINT32 in_len5 = va_arg(ap, UINT32);
BYTE *in_blob5 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!digest1 || !in_blob1 || !in_blob2 || !in_blob3 || !in_blob4 || !in_blob5) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -2165,7 +2165,6 @@
UINT32 in_len3 = va_arg(ap, UINT32);
BYTE *in_blob3 = va_arg(ap, BYTE *);
TPM_AUTH *auth1 = va_arg(ap, TPM_AUTH *);
- va_end(ap);
if (!cmkauth1 || !digest1 || !in_blob1 || !in_blob2 || !in_blob3) {
result = TCSERR(TSS_E_INTERNAL_ERROR);
@@ -2197,7 +2196,6 @@
{
UINT32 val1 = va_arg(ap, UINT32);
UINT32 val2 = va_arg(ap, UINT32);
- va_end(ap);
*outOffset += TSS_TPM_TXBLOB_HDR_LEN;
LoadBlob_UINT32(outOffset, val1, out_blob);
@@ -2229,7 +2227,6 @@
}
#endif
default:
- va_end(ap);
LogError("Unknown ordinal: 0x%x", ordinal);
break;
}
diff --git a/src/tcs/tcs_utils.c b/src/tcs/tcs_utils.c
index a10e39a..bcb1685 100644
--- a/src/tcs/tcs_utils.c
+++ b/src/tcs/tcs_utils.c
@@ -219,13 +219,14 @@
void
LoadBlob_Header(UINT16 tag, UINT32 paramSize, UINT32 ordinal, BYTE * blob)
{
-
- UINT16ToArray(tag, &blob[0]);
- LogData("Header Tag:", tag);
- UINT32ToArray(paramSize, &blob[2]);
- LogData("Header ParamSize:", paramSize);
- UINT32ToArray(ordinal, &blob[6]);
- LogData("Header Ordinal:", ordinal);
+ if (blob) {
+ UINT16ToArray(tag, &blob[0]);
+ LogData("Header Tag:", tag);
+ UINT32ToArray(paramSize, &blob[2]);
+ LogData("Header ParamSize:", paramSize);
+ UINT32ToArray(ordinal, &blob[6]);
+ LogData("Header Ordinal:", ordinal);
+ }
#if 0
LogInfo("Blob's TPM Ordinal: 0x%x", ordinal);
#endif
diff --git a/src/tcs/tcsi_admin.c b/src/tcs/tcsi_admin.c
index e946c6a..790a7ff 100644
--- a/src/tcs/tcsi_admin.c
+++ b/src/tcs/tcsi_admin.c
@@ -39,7 +39,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_SetOwnerInstall, &offset, txBlob, state, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_SetOwnerInstall, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, state, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -66,7 +66,7 @@
if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_OwnerSetDisable, &offset, txBlob, disableState,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_OwnerSetDisable, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, disableState,
ownerAuth)))
goto done;
@@ -99,7 +99,7 @@
if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_DisableOwnerClear, &offset, txBlob, ownerAuth)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_DisableOwnerClear, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, ownerAuth)))
goto done;
if ((result = req_mgr_submit_req(txBlob)))
@@ -127,7 +127,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_ForceClear, &offset, txBlob, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_ForceClear, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -150,7 +150,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_DisableForceClear, &offset, txBlob, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_DisableForceClear, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -203,7 +203,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_PhysicalDisable, &offset, txBlob, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_PhysicalDisable, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -227,7 +227,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_PhysicalEnable, &offset, txBlob, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_PhysicalEnable, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -252,7 +252,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_PhysicalSetDeactivated, &offset, txBlob, state, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_PhysicalSetDeactivated, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, state, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -275,7 +275,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_SetTempDeactivated, &offset, txBlob, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_SetTempDeactivated, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -306,7 +306,7 @@
return result;
}
- if ((result = tpm_rqu_build(TPM_ORD_SetTempDeactivated, &offset, txBlob, operatorAuth)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_SetTempDeactivated, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, operatorAuth)))
goto done;
if ((result = req_mgr_submit_req(txBlob)))
@@ -351,7 +351,7 @@
goto done;
}
- if ((result = tpm_rqu_build(TPM_ORD_FieldUpgrade, &offset, txBlob, dataInSize, dataIn,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_FieldUpgrade, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, dataInSize, dataIn,
ownerAuth, NULL)))
return result;
@@ -398,7 +398,7 @@
goto done;
}
- if ((result = tpm_rqu_build(TPM_ORD_SetRedirection, &offset, txBlob, keySlot, c1, c2,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_SetRedirection, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, keySlot, c1, c2,
privAuth)))
goto done;
@@ -432,7 +432,7 @@
if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_ResetLockValue, &offset, txBlob, ownerAuth)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_ResetLockValue, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, ownerAuth)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -456,7 +456,7 @@
TSS_RESULT result;
BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
- if ((result = tpm_rqu_build(TPM_ORD_FlushSpecific, &offset, txBlob, tpmResHandle,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_FlushSpecific, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, tpmResHandle,
resourceType)))
return result;
diff --git a/src/tcs/tcsi_aik.c b/src/tcs/tcsi_aik.c
index 8915d13..d49ec50 100644
--- a/src/tcs/tcsi_aik.c
+++ b/src/tcs/tcsi_aik.c
@@ -65,7 +65,7 @@
goto done;
offset = 0;
- if ((result = tpm_rqu_build(TPM_ORD_MakeIdentity, &offset, txBlob, identityAuth.authdata,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_MakeIdentity, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, identityAuth.authdata,
IDLabel_PrivCAHash.digest, idKeyInfoSize, idKeyInfo, pSrkAuth,
pOwnerAuth)))
goto done;
@@ -126,7 +126,7 @@
goto done;
offset = 0;
- if ((result = tpm_rqu_build(TPM_ORD_ActivateIdentity, &offset, txBlob, keySlot, blobSize,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_ActivateIdentity, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, keySlot, blobSize,
blob, idKeyAuth, ownerAuth)))
goto done;
@@ -204,7 +204,7 @@
goto done;
offset = 0;
- if ((result = tpm_rqu_build(TPM_ORD_MakeIdentity, &offset, txBlob, identityAuth.authdata,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_MakeIdentity, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, identityAuth.authdata,
IDLabel_PrivCAHash.digest, idKeyInfoSize, idKeyInfo, pSrkAuth,
pOwnerAuth)))
goto done;
diff --git a/src/tcs/tcsi_audit.c b/src/tcs/tcsi_audit.c
index 1832f19..eebe94f 100644
--- a/src/tcs/tcsi_audit.c
+++ b/src/tcs/tcsi_audit.c
@@ -38,7 +38,7 @@
if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_SetOrdinalAuditStatus, &offset, txBlob, ulOrdinal,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_SetOrdinalAuditStatus, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, ulOrdinal,
bAuditState, ownerAuth)))
goto done;
@@ -80,7 +80,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_GetAuditDigest, &offset, txBlob, startOrdinal, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_GetAuditDigest, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, startOrdinal, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -136,7 +136,7 @@
if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_GetAuditDigestSigned, &offset, txBlob, keySlot,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_GetAuditDigestSigned, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, keySlot,
closeAudit, antiReplay.nonce, privAuth)))
goto done;
diff --git a/src/tcs/tcsi_auth.c b/src/tcs/tcsi_auth.c
index ec4a11e..a62ee71 100644
--- a/src/tcs/tcsi_auth.c
+++ b/src/tcs/tcsi_auth.c
@@ -42,7 +42,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_OIAP, &offset, txBlob, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_OIAP, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -75,7 +75,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_OSAP, &offset, txBlob, entityType, entityValue,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_OSAP, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, entityType, entityValue,
nonceOddOSAP.nonce)))
return result;
@@ -100,7 +100,7 @@
TSS_RESULT result;
BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
- if ((result = tpm_rqu_build(TPM_ORD_Terminate_Handle, &offset, txBlob, handle, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_Terminate_Handle, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, handle, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
diff --git a/src/tcs/tcsi_bind.c b/src/tcs/tcsi_bind.c
index 7c9fb46..412711c 100644
--- a/src/tcs/tcsi_bind.c
+++ b/src/tcs/tcsi_bind.c
@@ -58,7 +58,7 @@
if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_UnBind, &offset, txBlob, keySlot, inDataSize, inData,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_UnBind, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, keySlot, inDataSize, inData,
privAuth, NULL)))
return result;
diff --git a/src/tcs/tcsi_caps_tpm.c b/src/tcs/tcsi_caps_tpm.c
index b600fe0..b15b091 100644
--- a/src/tcs/tcsi_caps_tpm.c
+++ b/src/tcs/tcsi_caps_tpm.c
@@ -42,7 +42,7 @@
LogDebug("Entering Get Cap");
- if ((result = tpm_rqu_build(TPM_ORD_GetCapability, &offset, txBlob, capArea, subCapSize,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_GetCapability, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, capArea, subCapSize,
subCap, NULL)))
return result;
@@ -78,7 +78,7 @@
if ((result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_GetCapabilityOwner, &offset, txBlob, pOwnerAuth)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_GetCapabilityOwner, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, pOwnerAuth)))
goto done;
if ((result = req_mgr_submit_req(txBlob)))
@@ -117,7 +117,7 @@
(result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_SetCapability, &offset, txBlob, capArea, subCapSize,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_SetCapability, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, capArea, subCapSize,
subCap, valueSize, value, pOwnerAuth)))
return result;
diff --git a/src/tcs/tcsi_certify.c b/src/tcs/tcsi_certify.c
index 8fae84e..b3994d3 100644
--- a/src/tcs/tcsi_certify.c
+++ b/src/tcs/tcsi_certify.c
@@ -71,7 +71,7 @@
if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_CertifyKey, &offset, txBlob, certKeySlot, keySlot,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_CertifyKey, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, certKeySlot, keySlot,
antiReplay.nonce, certAuth, keyAuth)))
goto done;
diff --git a/src/tcs/tcsi_changeauth.c b/src/tcs/tcsi_changeauth.c
index 59329ea..cccbf80 100644
--- a/src/tcs/tcsi_changeauth.c
+++ b/src/tcs/tcsi_changeauth.c
@@ -60,7 +60,7 @@
if ((result = ensureKeyIsLoaded(contextHandle, parentHandle, &keySlot)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_ChangeAuth, &offset, txBlob, keySlot, protocolID,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_ChangeAuth, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, keySlot, protocolID,
newAuth.authdata, entityType, encDataSize, encData, ownerAuth,
entityAuth)))
goto done;
@@ -121,7 +121,7 @@
if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_ChangeAuthOwner, &offset, txBlob, protocolID,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_ChangeAuthOwner, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, protocolID,
newAuth.authdata, entityType, ownerAuth)))
goto done;
diff --git a/src/tcs/tcsi_cmk.c b/src/tcs/tcsi_cmk.c
index 3f83133..ca93363 100644
--- a/src/tcs/tcsi_cmk.c
+++ b/src/tcs/tcsi_cmk.c
@@ -37,7 +37,7 @@
if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_CMK_SetRestrictions, &offset, txBlob,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_CMK_SetRestrictions, &offset, TSS_TPM_TXBLOB_SIZE, txBlob,
Restriction, ownerAuth)))
goto done;
@@ -77,7 +77,7 @@
if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_CMK_ApproveMA, &offset, txBlob,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_CMK_ApproveMA, &offset, TSS_TPM_TXBLOB_SIZE, txBlob,
&migAuthorityDigest, ownerAuth)))
goto done;
@@ -133,7 +133,7 @@
}
}
- if ((result = tpm_rqu_build(TPM_ORD_CMK_CreateKey, &offset, txBlob,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_CMK_CreateKey, &offset, TSS_TPM_TXBLOB_SIZE, txBlob,
parentSlot, &KeyUsageAuth, *keyDataSize, *prgbKeyData,
&MigAuthApproval, &MigAuthorityDigest, pAuth))) {
free(*prgbKeyData);
@@ -181,7 +181,7 @@
if ((result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_CMK_CreateTicket, &offset, txBlob,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_CMK_CreateTicket, &offset, TSS_TPM_TXBLOB_SIZE, txBlob,
PublicVerifyKeySize, PublicVerifyKey, &SignedData,
SigValueSize, SigValue, pOwnerAuth)))
goto done;
@@ -243,7 +243,7 @@
return result;
}
- if ((result = tpm_rqu_build(TPM_ORD_CMK_CreateBlob, &offset, txBlob,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_CMK_CreateBlob, &offset, TSS_TPM_TXBLOB_SIZE, txBlob,
parentSlot, migrationType, MigrationKeyAuthSize,
MigrationKeyAuth, &PubSourceKeyDigest, msaListSize, msaList,
restrictTicketSize, restrictTicket, sigTicketSize, sigTicket,
@@ -301,7 +301,7 @@
return result;
}
- if ((result = tpm_rqu_build(TPM_ORD_CMK_ConvertMigration, &offset, txBlob,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_CMK_ConvertMigration, &offset, TSS_TPM_TXBLOB_SIZE, txBlob,
parentSlot, &restrictTicket, &sigTicket,
keyDataSize, prgbKeyData, msaListSize, msaList,
randomSize, random, parentAuth)))
diff --git a/src/tcs/tcsi_counter.c b/src/tcs/tcsi_counter.c
index edba088..b5a8a82 100644
--- a/src/tcs/tcsi_counter.c
+++ b/src/tcs/tcsi_counter.c
@@ -37,7 +37,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_ReadCounter, &offset, txBlob, idCounter, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_ReadCounter, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, idCounter, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -82,7 +82,7 @@
if ((result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_CreateCounter, &offset, txBlob, CounterAuth.authdata,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_CreateCounter, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, CounterAuth.authdata,
LabelSize, pLabel, pOwnerAuth)))
return result;
@@ -120,7 +120,7 @@
if ((result = auth_mgr_check(hContext, &pCounterAuth->AuthHandle)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_IncrementCounter, &offset, txBlob, idCounter,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_IncrementCounter, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, idCounter,
pCounterAuth)))
return result;
@@ -156,7 +156,7 @@
if ((result = auth_mgr_check(hContext, &pCounterAuth->AuthHandle)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_ReleaseCounter, &offset, txBlob, idCounter,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_ReleaseCounter, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, idCounter,
pCounterAuth)))
return result;
@@ -191,7 +191,7 @@
if ((result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_ReleaseCounterOwner, &offset, txBlob, idCounter,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_ReleaseCounterOwner, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, idCounter,
pOwnerAuth)))
return result;
diff --git a/src/tcs/tcsi_daa.c b/src/tcs/tcsi_daa.c
index 293f4b3..8f66360 100644
--- a/src/tcs/tcsi_daa.c
+++ b/src/tcs/tcsi_daa.c
@@ -72,7 +72,7 @@
LogDebug("load Header: ordinal: %X (oldOffset=%" PRIu64 ")", TPM_ORD_DAA_Join, offset);
LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, offset, TPM_ORD_DAA_Join, txBlob);
#else
- if ((result = tpm_rqu_build(TPM_ORD_DAA_Join, &offset, txBlob, handle, stage, inputSize0,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_DAA_Join, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, handle, stage, inputSize0,
inputData0, inputSize1, inputData1, ownerAuth)))
goto done;
#endif
@@ -154,7 +154,7 @@
LogDebug("load Header: ordinal: %X (oldOffset=%" PRIu64 ")", TPM_ORD_DAA_Sign, offset);
LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, offset, TPM_ORD_DAA_Sign, txBlob);
#else
- if ((result = tpm_rqu_build(TPM_ORD_DAA_Sign, &offset, txBlob, handle, stage, inputSize0,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_DAA_Sign, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, handle, stage, inputSize0,
inputData0, inputSize1, inputData1, ownerAuth)))
goto done;
#endif
diff --git a/src/tcs/tcsi_delegate.c b/src/tcs/tcsi_delegate.c
index 27d1edf..f45a5d1 100644
--- a/src/tcs/tcsi_delegate.c
+++ b/src/tcs/tcsi_delegate.c
@@ -44,7 +44,7 @@
return result;
}
- if ((result = tpm_rqu_build(TPM_ORD_Delegate_Manage, &offset, txBlob, familyID, opFlag,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_Delegate_Manage, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, familyID, opFlag,
opDataSize, opData, ownerAuth)))
goto done;
@@ -94,7 +94,7 @@
if ((result = ensureKeyIsLoaded(hContext, hKey, &keySlot)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_Delegate_CreateKeyDelegation, &offset, txBlob, keySlot,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_Delegate_CreateKeyDelegation, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, keySlot,
publicInfoSize, publicInfo, encDelAuth, keyAuth)))
goto done;
@@ -140,7 +140,7 @@
return result;
}
- if ((result = tpm_rqu_build(TPM_ORD_Delegate_CreateOwnerDelegation, &offset, txBlob,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_Delegate_CreateOwnerDelegation, &offset, TSS_TPM_TXBLOB_SIZE, txBlob,
increment, publicInfoSize, publicInfo, encDelAuth, ownerAuth)))
goto done;
@@ -183,7 +183,7 @@
return result;
}
- if ((result = tpm_rqu_build(TPM_ORD_Delegate_LoadOwnerDelegation, &offset, txBlob, index,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_Delegate_LoadOwnerDelegation, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, index,
blobSize, blob, ownerAuth)))
goto done;
@@ -221,7 +221,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_Delegate_ReadTable, &offset, txBlob, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_Delegate_ReadTable, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -262,7 +262,7 @@
return result;
}
- if ((result = tpm_rqu_build(TPM_ORD_Delegate_UpdateVerification, &offset, txBlob, inputSize,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_Delegate_UpdateVerification, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, inputSize,
inputSize, input, ownerAuth, NULL)))
goto done;
@@ -298,7 +298,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_Delegate_VerifyDelegation, &offset, txBlob,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_Delegate_VerifyDelegation, &offset, TSS_TPM_TXBLOB_SIZE, txBlob,
delegateSize, delegateSize, delegate, NULL, NULL)))
return result;
@@ -344,7 +344,7 @@
goto done;
}
- if ((result = tpm_rqu_build(TPM_ORD_DSAP, &offset, txBlob, entityType, tpmKeyHandle,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_DSAP, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, entityType, tpmKeyHandle,
nonceOddDSAP, entityValueSize, entityValue)))
return result;
diff --git a/src/tcs/tcsi_dir.c b/src/tcs/tcsi_dir.c
index 9d5030a..a754b9a 100644
--- a/src/tcs/tcsi_dir.c
+++ b/src/tcs/tcsi_dir.c
@@ -49,7 +49,7 @@
goto done;
}
- if ((result = tpm_rqu_build(TPM_ORD_DirWriteAuth, &offset, txBlob, dirIndex,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_DirWriteAuth, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, dirIndex,
TPM_DIGEST_SIZE, newContents.digest, ownerAuth, NULL)))
goto done;
@@ -87,7 +87,7 @@
if (dirIndex > tpm_metrics.num_dirs)
return TCSERR(TSS_E_BAD_PARAMETER);
- if ((result = tpm_rqu_build(TPM_ORD_DirRead, &offset, txBlob, dirIndex, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_DirRead, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, dirIndex, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
diff --git a/src/tcs/tcsi_ek.c b/src/tcs/tcsi_ek.c
index 34388da..11f6f9d 100644
--- a/src/tcs/tcsi_ek.c
+++ b/src/tcs/tcsi_ek.c
@@ -43,7 +43,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_CreateEndorsementKeyPair, &offset, txBlob,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_CreateEndorsementKeyPair, &offset, TSS_TPM_TXBLOB_SIZE, txBlob,
antiReplay.nonce, endorsementKeyInfoSize,
endorsementKeyInfo)))
return result;
@@ -77,7 +77,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_ReadPubek, &offset, txBlob, TPM_NONCE_SIZE,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_ReadPubek, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, TPM_NONCE_SIZE,
antiReplay.nonce)))
return result;
@@ -110,7 +110,7 @@
if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_DisablePubekRead, &offset, txBlob, ownerAuth)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_DisablePubekRead, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, ownerAuth)))
goto done;
if ((result = req_mgr_submit_req(txBlob)))
@@ -144,7 +144,7 @@
if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_OwnerReadPubek, &offset, txBlob, ownerAuth)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_OwnerReadPubek, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, ownerAuth)))
goto done;
if ((result = req_mgr_submit_req(txBlob)))
@@ -181,7 +181,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_CreateRevocableEK, &offset, txBlob,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_CreateRevocableEK, &offset, TSS_TPM_TXBLOB_SIZE, txBlob,
antiReplay.nonce, endorsementKeyInfoSize,
endorsementKeyInfo, genResetAuth, eKResetAuth->digest)))
return result;
@@ -212,7 +212,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_RevokeTrust, &offset, txBlob, EKResetAuth.digest)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_RevokeTrust, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, EKResetAuth.digest)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
diff --git a/src/tcs/tcsi_key.c b/src/tcs/tcsi_key.c
index 07ee4f9..7d7a26a 100644
--- a/src/tcs/tcsi_key.c
+++ b/src/tcs/tcsi_key.c
@@ -204,7 +204,7 @@
goto done;
}
- if ((result = tpm_rqu_build(TPM_ORD_CreateWrapKey, &offset, txBlob, parentSlot,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_CreateWrapKey, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, parentSlot,
KeyUsageAuth.authdata, KeyMigrationAuth.authdata, keyInfoSize,
keyInfo, pAuth)))
goto done;
@@ -255,7 +255,7 @@
}
LogDebug("GetPubKey: handle: 0x%x, slot: 0x%x", hKey, keySlot);
- if ((result = tpm_rqu_build(TPM_ORD_GetPubKey, &offset, txBlob, keySlot, pAuth)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_GetPubKey, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, keySlot, pAuth)))
goto done;
if ((result = req_mgr_submit_req(txBlob)))
@@ -300,7 +300,7 @@
if ((result = auth_mgr_check(hContext, &pOwnerAuth->AuthHandle)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_OwnerReadInternalPub, &offset, txBlob, hKey,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_OwnerReadInternalPub, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, hKey,
pOwnerAuth)))
goto done;
@@ -356,7 +356,7 @@
goto done;
}
- if ((result = tpm_rqu_build(TPM_ORD_KeyControlOwner, &offset, txBlob, hTpmKey,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_KeyControlOwner, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, hTpmKey,
ulPubKeyLength, rgbPubKey, attribName, attribValue,
pOwnerAuth))) {
LogDebugFn("rqu build failed");
diff --git a/src/tcs/tcsi_maint.c b/src/tcs/tcsi_maint.c
index fea756d..e213e22 100644
--- a/src/tcs/tcsi_maint.c
+++ b/src/tcs/tcsi_maint.c
@@ -48,7 +48,7 @@
if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_CreateMaintenanceArchive, &offset, txBlob,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_CreateMaintenanceArchive, &offset, TSS_TPM_TXBLOB_SIZE, txBlob,
generateRandom, ownerAuth)))
goto done;
@@ -87,7 +87,7 @@
if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_LoadMaintenanceArchive, &offset, txBlob, dataInSize,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_LoadMaintenanceArchive, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, dataInSize,
dataInSize, dataIn, ownerAuth, NULL)))
return result;
@@ -120,7 +120,7 @@
if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_KillMaintenanceFeature, &offset, txBlob, ownerAuth)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_KillMaintenanceFeature, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, ownerAuth)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -151,7 +151,7 @@
LogDebug("Entering Load Manu Maint Pub");
- if ((result = tpm_rqu_build(TPM_ORD_LoadManuMaintPub, &offset, txBlob, TPM_NONCE_SIZE,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_LoadManuMaintPub, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, TPM_NONCE_SIZE,
antiReplay.nonce, PubKeySize, PubKey, NULL)))
return result;
@@ -179,7 +179,7 @@
LogDebug("Entering Read Manu Maint Pub");
- if ((result = tpm_rqu_build(TPM_ORD_ReadManuMaintPub, &offset, txBlob, TPM_NONCE_SIZE,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_ReadManuMaintPub, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, TPM_NONCE_SIZE,
antiReplay.nonce)))
return result;
diff --git a/src/tcs/tcsi_migration.c b/src/tcs/tcsi_migration.c
index 8467f02..975097e 100644
--- a/src/tcs/tcsi_migration.c
+++ b/src/tcs/tcsi_migration.c
@@ -78,7 +78,7 @@
break;
}
- if ((result = tpm_rqu_build(TPM_ORD_CreateMigrationBlob, &offset, txBlob, keyHandle,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_CreateMigrationBlob, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, keyHandle,
migrationType, MigrationKeyAuthSize, MigrationKeyAuth,
encDataSize, encData, parentAuth, entityAuth)))
return result;
@@ -129,7 +129,7 @@
if ((result = ensureKeyIsLoaded(hContext, parentHandle, &keySlot)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_ConvertMigrationBlob, &offset, txBlob, keySlot,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_ConvertMigrationBlob, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, keySlot,
inDataSize, inData, randomSize, random, parentAuth)))
return result;
@@ -196,7 +196,7 @@
break;
}
- if ((result = tpm_rqu_build(TPM_ORD_AuthorizeMigrationKey, &offset, txBlob, migrateScheme,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_AuthorizeMigrationKey, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, migrateScheme,
MigrationKeySize, MigrationKey, ownerAuth)))
return result;
diff --git a/src/tcs/tcsi_nv.c b/src/tcs/tcsi_nv.c
index 1c867ea..b5a8401 100644
--- a/src/tcs/tcsi_nv.c
+++ b/src/tcs/tcsi_nv.c
@@ -47,7 +47,7 @@
goto done;
}
- if ((result = tpm_rqu_build(TPM_ORD_NV_DefineSpace, &offset, txBlob, cPubInfoSize, pPubInfo,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_NV_DefineSpace, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, cPubInfoSize, pPubInfo,
TPM_ENCAUTH_SIZE, encAuth.authdata, pAuth)))
return result;
@@ -87,7 +87,7 @@
goto done;
}
- if ((result = tpm_rqu_build(TPM_ORD_NV_WriteValue, &off_set, txBlob, hNVStore, offset,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_NV_WriteValue, &off_set, TSS_TPM_TXBLOB_SIZE, txBlob, hNVStore, offset,
ulDataLength, rgbDataToWrite, privAuth)))
return result;
@@ -125,7 +125,7 @@
if ((result = auth_mgr_check(hContext, &NVAuth->AuthHandle)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_NV_WriteValueAuth, &off_set, txBlob, hNVStore, offset,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_NV_WriteValueAuth, &off_set, TSS_TPM_TXBLOB_SIZE, txBlob, hNVStore, offset,
ulDataLength, rgbDataToWrite, NVAuth)))
return result;
@@ -166,7 +166,7 @@
goto done;
}
- if ((result = tpm_rqu_build(TPM_ORD_NV_ReadValue, &off_set, txBlob, hNVStore, offset,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_NV_ReadValue, &off_set, TSS_TPM_TXBLOB_SIZE, txBlob, hNVStore, offset,
*pulDataLength, privAuth)))
return result;
@@ -205,7 +205,7 @@
if ((NVAuth != NULL) && (result = auth_mgr_check(hContext, &NVAuth->AuthHandle)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_NV_ReadValueAuth, &off_set, txBlob, hNVStore, offset,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_NV_ReadValueAuth, &off_set, TSS_TPM_TXBLOB_SIZE, txBlob, hNVStore, offset,
*pulDataLength, NVAuth)))
return result;
diff --git a/src/tcs/tcsi_oper.c b/src/tcs/tcsi_oper.c
index eee6c76..7f0434c 100644
--- a/src/tcs/tcsi_oper.c
+++ b/src/tcs/tcsi_oper.c
@@ -33,7 +33,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_SetOperatorAuth, &offset, txBlob, TPM_AUTHDATA_SIZE,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_SetOperatorAuth, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, TPM_AUTHDATA_SIZE,
operatorAuth->authdata)))
return result;
diff --git a/src/tcs/tcsi_own.c b/src/tcs/tcsi_own.c
index 5f9ad27..6b4a2d1 100644
--- a/src/tcs/tcsi_own.c
+++ b/src/tcs/tcsi_own.c
@@ -61,7 +61,7 @@
LogDebug("auth data usage is %.2X", oldAuthDataUsage);
offset = 0;
- if ((result = tpm_rqu_build(TPM_ORD_TakeOwnership, &offset, txBlob, protocolID,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_TakeOwnership, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, protocolID,
encOwnerAuthSize, encOwnerAuth, encSrkAuthSize, encSrkAuth,
srkInfoSize, srkInfo, ownerAuth)))
return result;
@@ -170,7 +170,7 @@
if ((result = auth_mgr_check(hContext, &ownerAuth->AuthHandle)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_OwnerClear, &offset, txBlob, ownerAuth)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_OwnerClear, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, ownerAuth)))
goto done;
if ((result = req_mgr_submit_req(txBlob)))
diff --git a/src/tcs/tcsi_pcr.c b/src/tcs/tcsi_pcr.c
index 2cb97e3..0f8fa29 100644
--- a/src/tcs/tcsi_pcr.c
+++ b/src/tcs/tcsi_pcr.c
@@ -59,7 +59,7 @@
return TCSERR(TSS_E_FAIL);
}
- if ((result = tpm_rqu_build(TPM_ORD_Extend, &offset, txBlob, pcrNum, TPM_DIGEST_SIZE,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_Extend, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, pcrNum, TPM_DIGEST_SIZE,
inDigest.digest, NULL, NULL)))
return result;
@@ -93,7 +93,7 @@
if (pcrNum >= tpm_metrics.num_pcrs)
return TCSERR(TSS_E_BAD_PARAMETER);
- if ((result = tpm_rqu_build(TPM_ORD_PcrRead, &offset, txBlob, pcrNum, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_PcrRead, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, pcrNum, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -122,7 +122,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_PCR_Reset, &offset, txBlob, pcrDataSizeIn, pcrDataIn)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_PCR_Reset, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, pcrDataSizeIn, pcrDataIn)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
diff --git a/src/tcs/tcsi_quote.c b/src/tcs/tcsi_quote.c
index 632b0cc..6399bf8 100644
--- a/src/tcs/tcsi_quote.c
+++ b/src/tcs/tcsi_quote.c
@@ -61,7 +61,7 @@
if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_Quote, &offset, txBlob, keySlot, antiReplay.nonce,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_Quote, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, keySlot, antiReplay.nonce,
pcrDataSizeIn, pcrDataIn, privAuth)))
goto done;
diff --git a/src/tcs/tcsi_quote2.c b/src/tcs/tcsi_quote2.c
index 0ced27f..6972618 100644
--- a/src/tcs/tcsi_quote2.c
+++ b/src/tcs/tcsi_quote2.c
@@ -65,7 +65,7 @@
if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_Quote2, &offset, txBlob, keySlot, antiReplay.nonce,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_Quote2, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, keySlot, antiReplay.nonce,
pcrDataSizeIn, pcrDataIn, &addVersion, privAuth)))
goto done;
diff --git a/src/tcs/tcsi_random.c b/src/tcs/tcsi_random.c
index 9670df4..0c6952d 100644
--- a/src/tcs/tcsi_random.c
+++ b/src/tcs/tcsi_random.c
@@ -52,7 +52,7 @@
do {
offset = 0;
- if ((result = tpm_rqu_build(TPM_ORD_GetRandom, &offset, txBlob,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_GetRandom, &offset, TSS_TPM_TXBLOB_SIZE, txBlob,
*bytesRequested - totalReturned, NULL)))
break;
@@ -133,7 +133,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_StirRandom, &offset, txBlob, inDataSize, inDataSize,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_StirRandom, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, inDataSize, inDataSize,
inData, NULL, NULL)))
return result;
diff --git a/src/tcs/tcsi_seal.c b/src/tcs/tcsi_seal.c
index bc72ecd..5a5ba0f 100644
--- a/src/tcs/tcsi_seal.c
+++ b/src/tcs/tcsi_seal.c
@@ -128,7 +128,7 @@
goto done;
}
- if ((result = tpm_rqu_build(TPM_ORD_Unseal, &offset, txBlob, keySlot, SealedDataSize,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_Unseal, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, keySlot, SealedDataSize,
SealedData, parentAuth, dataAuth)))
return result;
diff --git a/src/tcs/tcsi_selftest.c b/src/tcs/tcsi_selftest.c
index 95869bc..882ba57 100644
--- a/src/tcs/tcsi_selftest.c
+++ b/src/tcs/tcsi_selftest.c
@@ -39,7 +39,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_SelfTestFull, &offset, txBlob, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_SelfTestFull, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -80,7 +80,7 @@
if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_CertifySelfTest, &offset, txBlob, keySlot,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_CertifySelfTest, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, keySlot,
TPM_NONCE_SIZE, antiReplay.nonce, privAuth, NULL)))
return result;
@@ -112,7 +112,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_GetTestResult, &offset, txBlob, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_GetTestResult, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
diff --git a/src/tcs/tcsi_sign.c b/src/tcs/tcsi_sign.c
index 3671fb1..45bb33d 100644
--- a/src/tcs/tcsi_sign.c
+++ b/src/tcs/tcsi_sign.c
@@ -58,7 +58,7 @@
if ((result = ensureKeyIsLoaded(hContext, keyHandle, &keySlot)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_Sign, &offset, txBlob, keySlot, areaToSignSize,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_Sign, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, keySlot, areaToSignSize,
areaToSign, privAuth)))
return result;
diff --git a/src/tcs/tcsi_tick.c b/src/tcs/tcsi_tick.c
index b752e83..0ec303b 100644
--- a/src/tcs/tcsi_tick.c
+++ b/src/tcs/tcsi_tick.c
@@ -37,7 +37,7 @@
if ((result = ctx_verify_context(hContext)))
return result;
- if ((result = tpm_rqu_build(TPM_ORD_GetTicks, &offset, txBlob, NULL)))
+ if ((result = tpm_rqu_build_checked(TPM_ORD_GetTicks, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, NULL)))
return result;
if ((result = req_mgr_submit_req(txBlob)))
@@ -80,7 +80,7 @@
if ((result = ensureKeyIsLoaded(hContext, hKey, &keySlot)))
goto done;
- if ((result = tpm_rqu_build(TPM_ORD_TickStampBlob, &offset, txBlob, keySlot, antiReplay,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_TickStampBlob, &offset, TSS_TPM_TXBLOB_SIZE, txBlob, keySlot, antiReplay,
digestToStamp, privAuth)))
return result;
diff --git a/src/tcs/tcsi_transport.c b/src/tcs/tcsi_transport.c
index 2f61be2..5764fb0 100644
--- a/src/tcs/tcsi_transport.c
+++ b/src/tcs/tcsi_transport.c
@@ -142,7 +142,7 @@
TSS_RESULT result;
UINT32 paramSize, wrappedSize, val1 = 0, val2 = 0, *pVal1 = NULL, *pVal2 = NULL;
TCS_HANDLE handle1 = 0, handle2 = 0;
- UINT64 offset, wrappedOffset = 0;
+ UINT64 offset, wrappedOffset = 0, tmpOffset;
BYTE txBlob[TSS_TPM_TXBLOB_SIZE];
@@ -299,7 +299,7 @@
}
build_command:
- if ((result = tpm_rqu_build(TPM_ORD_ExecuteTransport, &wrappedOffset,
+ if ((result = tpm_rqu_build_checked(TPM_ORD_ExecuteTransport, &wrappedOffset, TSS_TPM_TXBLOB_SIZE,
&txBlob[TSS_TXBLOB_WRAPPEDCMD_OFFSET], unWrappedCommandOrdinal,
pVal1, pVal2, ulWrappedCmdParamInSize, rgbWrappedCmdParamIn,
pWrappedCmdAuth1, pWrappedCmdAuth2)))
@@ -322,6 +322,12 @@
*/
offset = TSS_TPM_TXBLOB_HDR_LEN;
/* Load wrapped command size: |wrappedCmdSize| */
+ tmpOffset = offset;
+ LoadBlob_UINT32(&tmpOffset, wrappedOffset, NULL);
+ if (tmpOffset > TSS_TPM_TXBLOB_SIZE) {
+ result = TCSERR(TSS_E_BAD_PARAMETER);
+ goto done;
+ }
LoadBlob_UINT32(&offset, wrappedOffset, txBlob);
/* offset + wrappedOffset is the position of the execute transport auth struct */
@@ -329,6 +335,12 @@
if (pTransAuth) {
/* Load the auth for the execute transport command: |AUTHet| */
+ tmpOffset = offset;
+ LoadBlob_Auth(&tmpOffset, NULL, pTransAuth);
+ if (tmpOffset > TSS_TPM_TXBLOB_SIZE) {
+ result = TCSERR(TSS_E_BAD_PARAMETER);
+ goto done;
+ }
LoadBlob_Auth(&offset, txBlob, pTransAuth);
/* Load the outer header: |TAGet|LENet|ORDet| */
LoadBlob_Header(TPM_TAG_RQU_AUTH1_COMMAND, offset, TPM_ORD_ExecuteTransport,