Package: 1138361
Followup-For: Bug #1138361
X-Debbugs-Cc: [email protected]
Control: tags -1 patch ftbfs

The attached patch fixes the build issue with OpenSSL 4.0.


-- System Information:
Debian Release: trixie/sid
  APT prefers noble-updates
  APT policy: (500, 'noble-updates'), (500, 'noble-security'), (500, 'noble'), 
(100, 'noble-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 6.8.0-117-generic (SMP w/12 CPU threads; PREEMPT)
Kernel taint flags: TAINT_WARN
Locale: LANG=en_GB.UTF-8, LC_CTYPE=en_GB.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
>From d78579230c5ba86b17649aff8f2bc58a88ad88b4 Mon Sep 17 00:00:00 2001
From: Simo Sorce <[email protected]>
Date: Fri, 17 Apr 2026 16:13:18 -0400
Subject: [PATCH] Use ASN1 getters instead of direct struct access

This updates the code to interact correctly with modern OpenSSL versions
(4.0+) where these structures are opaque, ensuring API compatibility and
preventing build errors.

Co-authored-by: Gemini <[email protected]>
Signed-off-by: Simo Sorce <[email protected]>
Origin: upstream, 
https://github.com/tpm2-software/tpm2-tools/commit/d78579230c5ba86b17649aff8f2bc58a88ad88b4
Bug-Ubuntu: https://bugs.launchpad.net/bugs/2154909
Bug-Debian: https://bugs.debian.org/1138361
---
 lib/object.c       | 9 ++++-----
 lib/tpm2_convert.c | 8 ++++----
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/lib/object.c b/lib/object.c
index 1d6cd42cc..17bf77a4a 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -1,4 +1,3 @@
-
 #include <stdio.h>
 
 #include "files.h"
@@ -251,21 +250,21 @@ tool_rc tpm2_util_object_fetch_priv_pub_from_tpk(const 
char *objectstr,
         goto ret;
     }
 
-    int pub_len = tpk->pubkey->length;
-    int priv_len = tpk->privkey->length;
+    int pub_len = ASN1_STRING_length(tpk->pubkey);
+    int priv_len = ASN1_STRING_length(tpk->privkey);
     if (pub_len < 1 || priv_len < 1) {
         LOG_ERR("Error deserializing TSS Privkey Object");
         goto ret;
     }
 
-    rc = Tss2_MU_TPM2B_PUBLIC_Unmarshal(tpk->pubkey->data, pub_len,
+    rc = Tss2_MU_TPM2B_PUBLIC_Unmarshal(ASN1_STRING_get0_data(tpk->pubkey), 
pub_len,
         NULL, pub);
     if (rc != tool_rc_success) {
         LOG_ERR("Error deserializing public portion of object");
         goto ret;
     }
 
-    rc = Tss2_MU_TPM2B_PRIVATE_Unmarshal(tpk->privkey->data, priv_len,
+    rc = Tss2_MU_TPM2B_PRIVATE_Unmarshal(ASN1_STRING_get0_data(tpk->privkey), 
priv_len,
         NULL, priv);
     if (rc != tool_rc_success) {
         LOG_ERR("Error deserializing private portion of object");
diff --git a/lib/tpm2_convert.c b/lib/tpm2_convert.c
index 6c975dd7f..96979647e 100644
--- a/lib/tpm2_convert.c
+++ b/lib/tpm2_convert.c
@@ -501,8 +501,8 @@ static bool pop_ecdsa(const char *path, 
TPMS_SIGNATURE_ECDSA *ecdsa) {
         LOG_ERR("oom");
         return false;
     }
-    memcpy(R->buffer, r->data, r->length);
-    R->size = r->length;
+    memcpy(R->buffer, ASN1_STRING_get0_data(r), ASN1_STRING_length(r));
+    R->size = ASN1_STRING_length(r);
     ASN1_INTEGER_free(r);
 
     /*
@@ -514,8 +514,8 @@ static bool pop_ecdsa(const char *path, 
TPMS_SIGNATURE_ECDSA *ecdsa) {
         LOG_ERR("oom");
         return false;
     }
-    memcpy(S->buffer, s->data, s->length);
-    S->size = s->length;
+    memcpy(S->buffer, ASN1_STRING_get0_data(s), ASN1_STRING_length(s));
+    S->size = ASN1_STRING_length(s);
     ASN1_INTEGER_free(s);
 
     return true;

Reply via email to