Re: [PATCH 1/1] create_tpm2_key: correct size of public area

James Bottomley
 

On Thu, 2018-11-15 at 08:39 +0100, Fredrik Ternerot wrote:
On Wed, Oct 31, 2018 at 13:54:52 +0100, Fredrik Ternerot wrote:
TPM2B_PUBLIC.size should be the size of TPM2B_PUBLIC.publicArea and
not
the size of TPM2B_PUBLIC itself.

Signed-off-by: Fredrik Ternerot <fredrikt@...>
---
create_tpm2_key.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/create_tpm2_key.c b/create_tpm2_key.c
index 0be8e43..41b738e 100644
--- a/create_tpm2_key.c
+++ b/create_tpm2_key.c
@@ -414,7 +414,7 @@ TPM_RC openssl_to_tpm_public_rsa(TPMT_PUBLIC
*pub, EVP_PKEY *pkey)
TPM_RC openssl_to_tpm_public(TPM2B_PUBLIC *pub, EVP_PKEY *pkey)
{
TPMT_PUBLIC *tpub = &pub->publicArea;
- pub->size = sizeof(*pub);
+ pub->size = sizeof(*tpub);

switch (EVP_PKEY_type(EVP_PKEY_id(pkey))) {
case EVP_PKEY_RSA:
--
2.11.0
Hi James,

I can not find this in the next branch. Would you mind take this in?
Actually, the whole line is wrong (or at least irrelevant) and should
probably be removed: the size of all named TPM2Bs is calculated on
marshal so while we deal with the unmarshalled publicArea, the value
has no meaning at all and will be ignored in the marshalled structure.

James

Join openssl-tpm2-engine@groups.io to automatically receive all group messages.