Skip to content

Commit

Permalink
esys: remove trailing zeros in auth value.
Browse files Browse the repository at this point in the history
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 <juergen_repp@web.de>
  • Loading branch information
JuergenReppSIT committed Jul 18, 2023
1 parent dcec28b commit 9ef067d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/tss2-esys/esys_tr.c
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,12 @@ Esys_TR_SetAuth(ESYS_CONTEXT * esys_context, ESYS_TR esys_handle,
name_alg = esys_object->rsrc.misc.rsrc_nv_pub.nvPublic.nameAlg;
}
esys_object->auth = *authValue;

/* Remove trailing zeroes */
while (esys_object->auth.size > 0 &&
esys_object->auth.buffer[esys_object->auth.size - 1] == 0) {
esys_object->auth.size -= 1;

This comment has been minimized.

Copy link
@williamcroberts

williamcroberts Jul 18, 2023

esys_object->auth.size--;
}

This comment has been minimized.

Copy link
@williamcroberts

williamcroberts Jul 18, 2023

This needs to be done after the hashing, as a valid hash can end with a 0 byte.

/* Adapt auth value to hash for large auth values. */
if (name_alg != TPM2_ALG_NULL) {
r = iesys_hash_long_auth_values(&esys_context->crypto_backend,
Expand Down

0 comments on commit 9ef067d

Please sign in to comment.