Skip to content

pkey: fix compilation with OpenSSL 4.1 - #183

Merged
moritzbuhl merged 1 commit into
tpm2-software:masterfrom
moritzbuhl:mbuhl-182
Sep 10, 2026
Merged

moritzbuhl merged 1 commit into
tpm2-software:masterfrom
moritzbuhl:mbuhl-182

Conversation

@moritzbuhl

Copy link
Copy Markdown
Member

Avoid deprecated OpenSSL functions, add fallback defines for older versions:
src/tpm2-provider-pkey.c:91:5: error: 'ASN1_STRING_set' is deprecated: Since OpenSSL 4.1; use ASN1_STRING_set1_data() or ASN1_STRING_set1_string() [-Werror,-Wdeprecated-declarations]
src/tpm2-provider-pkey.c:165:41: error: 'ASN1_STRING_length' is deprecated: Since OpenSSL 4.1; use ASN1_STRING_get_length()
[-Werror,-Wdeprecated-declarations]

Add missing header:
src/tpm2-provider-pkey.c:32:1: error: call to undeclared function 'ERR_raise'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

Addresses #182

Comment thread src/tpm2-provider-pkey.c Outdated
#include "tpm2-provider-pkey.h"

#if OPENSSL_VERSION_NUMBER >= 0x40100000
#define TPM2_ASN1_STRING_length(x) ASN1_STRING_get_length(x)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend to use macro names aligned with the new api; i.e. "TPM2_ASN1_STRING_set_length" and "TPM2_ASN1_STRING_set1_data"

Also, do we have a CI job running OpenSSL 4.1 for testing this ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are testing against the following branches: openssl-3.0, openssl-3.5, master
master will become 4.1 and to my understanding it should be a LTS release that is worth adding to our CI.

I'll rename the macros.

Avoid deprecated OpenSSL functions, add fallback defines for older
versions:
src/tpm2-provider-pkey.c:91:5: error: 'ASN1_STRING_set' is deprecated:
Since OpenSSL 4.1; use ASN1_STRING_set1_data() or ASN1_STRING_set1_string()
[-Werror,-Wdeprecated-declarations]
src/tpm2-provider-pkey.c:165:41: error: 'ASN1_STRING_length' is deprecated:
Since OpenSSL 4.1; use ASN1_STRING_get_length()
[-Werror,-Wdeprecated-declarations]

Add missing header:
src/tpm2-provider-pkey.c:32:1: error: call to undeclared function 'ERR_raise';
ISO C99 and later do not support implicit function declarations
[-Wimplicit-function-declaration]

Signed-off-by: Moritz Buhl <moritz.buhl@infineon.com>
@moritzbuhl
moritzbuhl merged commit 9cc4cbe into tpm2-software:master Sep 10, 2026
6 checks passed
@moritzbuhl
moritzbuhl deleted the mbuhl-182 branch September 10, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants