<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<html lang="en">
<head>
<meta content="text/html; charset=US-ASCII" http-equiv="Content-Type">
<title>
GitLab
</title>


<style>img {
max-width: 100%; height: auto;
}
</style>
</head>
<body>
<div class="content">

<p style="color: #777777;">
<a href="https://gitlab.com/dwmw2">David Woodhouse</a>
commented:
</p>
<div style="">
<p dir="auto">There is some confusion around the allocation of the <code>tpm2_info_st</code>. You allocate two, fill one, free the good one. This makes it work for TLSv1.2 for me:</p>
<pre class="code highlight js-syntax-highlight plaintext" lang="plaintext" v-pre="true"><code><span id="LC1" class="line" lang="plaintext">diff --git a/lib/tpm2.c b/lib/tpm2.c</span>
<span id="LC2" class="line" lang="plaintext">index f16374e292..09c0072bb9 100644</span>
<span id="LC3" class="line" lang="plaintext">--- a/lib/tpm2.c</span>
<span id="LC4" class="line" lang="plaintext">+++ b/lib/tpm2.c</span>
<span id="LC5" class="line" lang="plaintext">@@ -251,7 +251,7 @@ int _gnutls_load_tpm2_key(gnutls_privkey_t pkey, const gnutls_datum_t *fdata)</span>
<span id="LC6" class="line" lang="plaintext"> </span>
<span id="LC7" class="line" lang="plaintext">  out_tpmkey:</span>
<span id="LC8" class="line" lang="plaintext">       asn1_delete_structure(&tpmkey);</span>
<span id="LC9" class="line" lang="plaintext">-      release_tpm2_ctx(info);</span>
<span id="LC10" class="line" lang="plaintext">+//   release_tpm2_ctx(info);</span>
<span id="LC11" class="line" lang="plaintext">  out_asn1:</span>
<span id="LC12" class="line" lang="plaintext">      free(asn1.data);</span>
<span id="LC13" class="line" lang="plaintext">      return ret;</span>
<span id="LC14" class="line" lang="plaintext">diff --git a/lib/tpm2_esys.c b/lib/tpm2_esys.c</span>
<span id="LC15" class="line" lang="plaintext">index 26a927def3..7046518371 100644</span>
<span id="LC16" class="line" lang="plaintext">--- a/lib/tpm2_esys.c</span>
<span id="LC17" class="line" lang="plaintext">+++ b/lib/tpm2_esys.c</span>
<span id="LC18" class="line" lang="plaintext">@@ -284,7 +284,7 @@ static int init_tpm2_key(ESYS_CONTEXT **ctx, ESYS_TR *keyHandle,</span>
<span id="LC19" class="line" lang="plaintext">                      gnutls_assert();</span>
<span id="LC20" class="line" lang="plaintext">                      goto error;</span>
<span id="LC21" class="line" lang="plaintext">              }</span>
<span id="LC22" class="line" lang="plaintext">-     } else {</span>
<span id="LC23" class="line" lang="plaintext">+     } else { printf("PArent %x at %p not generated?\n", info->parent, info);</span>
<span id="LC24" class="line" lang="plaintext">              r = Esys_TR_FromTPMPublic(*ctx, info->parent,</span>
<span id="LC25" class="line" lang="plaintext">                                        ESYS_TR_NONE, ESYS_TR_NONE, ESYS_TR_NONE, &parentHandle);</span>
<span id="LC26" class="line" lang="plaintext">              if (r) {</span>
<span id="LC27" class="line" lang="plaintext">@@ -534,12 +534,14 @@ int install_tpm2_key(struct tpm2_info_st *info, gnutls_privkey_t pkey,</span>
<span id="LC28" class="line" lang="plaintext">              return GNUTLS_E_TPM_ERROR;</span>
<span id="LC29" class="line" lang="plaintext">      }</span>
<span id="LC30" class="line" lang="plaintext"> </span>
<span id="LC31" class="line" lang="plaintext">+#if 0</span>
<span id="LC32" class="line" lang="plaintext">      info = calloc(1, sizeof(*info));</span>
<span id="LC33" class="line" lang="plaintext">      if (!info)</span>
<span id="LC34" class="line" lang="plaintext">              return GNUTLS_E_MEMORY_ERROR;</span>
<span id="LC35" class="line" lang="plaintext">+#endif</span>
<span id="LC36" class="line" lang="plaintext"> </span>
<span id="LC37" class="line" lang="plaintext">      info->parent = parent;</span>
<span id="LC38" class="line" lang="plaintext">-</span>
<span id="LC39" class="line" lang="plaintext">+     printf("parent %x in info at %p\n", info->parent, info);</span>
<span id="LC40" class="line" lang="plaintext">      r = Tss2_MU_TPM2B_PRIVATE_Unmarshal(privdata->data, privdata->size, NULL,</span>
<span id="LC41" class="line" lang="plaintext">                                          &info->priv);</span>
<span id="LC42" class="line" lang="plaintext">      if (r) {</span></code></pre>
<p dir="auto">TLSv1.3 gives me:
<code>|<1>| The hash size used in signature (20) is less than the expected (32)</code></p>
</div>


</div>
<div class="footer" style="margin-top: 10px;">
<p style="font-size: small; color: #777;">

<br>
Reply to this email directly or <a href="https://gitlab.com/gnutls/gnutls/issues/594#note_201929152">view it on GitLab</a>.
<br>
You're receiving this email because of your account on gitlab.com.
If you'd like to receive fewer emails, you can
<a href="https://gitlab.com/sent_notifications/ac1fa25ba942f5dcbb36b0afeccf0aa2/unsubscribe">unsubscribe</a>
from this thread or
adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Issue","url":"https://gitlab.com/gnutls/gnutls/issues/594#note_201929152"}}</script>


</p>
</div>
</body>
</html>