Skip to content

Commit 9ef067d

Browse files
esys: remove trailing zeros in auth value.
Esys_TR_SetAuth doesn't remove trailing zeros, but when the TPM calculates an HMAC, the trailing zeros are removed. Fixes: tpm2-software#2664 Signed-off-by: Juergen Repp <[email protected]>
1 parent dcec28b commit 9ef067d

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/tss2-esys/esys_tr.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,12 @@ Esys_TR_SetAuth(ESYS_CONTEXT * esys_context, ESYS_TR esys_handle,
481481
name_alg = esys_object->rsrc.misc.rsrc_nv_pub.nvPublic.nameAlg;
482482
}
483483
esys_object->auth = *authValue;
484+
485+
/* Remove trailing zeroes */
486+
while (esys_object->auth.size > 0 &&
487+
esys_object->auth.buffer[esys_object->auth.size - 1] == 0) {
488+
esys_object->auth.size -= 1;
489+
}
484490
/* Adapt auth value to hash for large auth values. */
485491
if (name_alg != TPM2_ALG_NULL) {
486492
r = iesys_hash_long_auth_values(&esys_context->crypto_backend,

0 commit comments

Comments
 (0)