aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Bottomley <James.Bottomley@HansenPartnership.com>2023-11-28 18:05:38 -0500
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2023-11-28 18:11:02 -0500
commit2ca1b46b68dc7b8ab8a42e315d49857a2c0a868d (patch)
tree4c70ea95dc28b960d2e911bf8726c6e32c60b7de
parent36b4d7d447593831d3addf358a5921ec8947b1f1 (diff)
downloadopenssl_tpm2_engine-2ca1b46b68dc7b8ab8a42e315d49857a2c0a868d.tar.gz
tpm2-common: fix encrypted secret size
It's been reported that the ASN.1 representation of the encrypted secret is always two bytes too big and zero padded at the end. This is because the written parameter isn't reset to zero when the secret was Marshalled and is in fact left at 2 from a previous use. Fix by initializing to zero before marshalling. Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
-rw-r--r--src/libcommon/tpm2-common.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/libcommon/tpm2-common.c b/src/libcommon/tpm2-common.c
index 71c66d2..3d70ea6 100644
--- a/src/libcommon/tpm2-common.c
+++ b/src/libcommon/tpm2-common.c
@@ -3107,6 +3107,7 @@ TPM_RC tpm2_outerwrap(EVP_PKEY *parent,
&null_2b, &null_2b, SHA256_DIGEST_LENGTH*8);
/* OK the ephermeral public point is now the encrypted secret */
size = sizeof(ephemeral_pt);
+ written = 0;
buf = enc_secret->secret;
TSS_TPM2B_ECC_POINT_Marshal(&ephemeral_pt, &written,
&buf, &size);