From 071bc6e3d987921cb47fb905665d10e8890c3607 Mon Sep 17 00:00:00 2001 From: Chris Eager Date: Thu, 1 Oct 2026 10:52:07 -0400 Subject: [PATCH] Update getSigAlgs to handle algorithms without combined NID Motivation: Some algorithms, such as Ed25519, have no combined signature and hash NID, causing them to be returned as NID_undef, and thus unusable to callers. Modifications: Fall back to `psign` if `psignhash` is undefined Result: | Code point | TLS name | Before | After | |------------|-----------------------|-------------|-----------------| | `0x0807` | `ed25519` | `undefined` | `ED25519` | | `0x0808` | `ed448` | `undefined` | `ED448` | | `0x0804` | `rsa_pss_rsae_sha256` | `undefined` | `rsassaPss` | | `0x0805` | `rsa_pss_rsae_sha384` | `undefined` | `rsassaPss` | | `0x0806` | `rsa_pss_rsae_sha512` | `undefined` | `rsassaPss` | | `0x0809` | `rsa_pss_pss_sha256` | `undefined` | `rsassaPss` | | `0x080a` | `rsa_pss_pss_sha384` | `undefined` | `rsassaPss` | | `0x080b` | `rsa_pss_pss_sha512` | `undefined` | `rsassaPss` | | `0x0302` | `dsa_sha224` | `undefined` | `dsaEncryption` | | `0x0502` | `dsa_sha384` | `undefined` | `dsaEncryption` | | `0x0602` | `dsa_sha512` | `undefined` | `dsaEncryption` | --- .../src/main/java/io/netty/internal/tcnative/SSL.java | 3 ++- openssl-dynamic/src/main/c/ssl.c | 8 +++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/openssl-classes/src/main/java/io/netty/internal/tcnative/SSL.java b/openssl-classes/src/main/java/io/netty/internal/tcnative/SSL.java index f28df2b61..f6a6dc631 100644 --- a/openssl-classes/src/main/java/io/netty/internal/tcnative/SSL.java +++ b/openssl-classes/src/main/java/io/netty/internal/tcnative/SSL.java @@ -876,7 +876,8 @@ public static void setKeyMaterialServerSide(long ssl, long chain, long key) thro /** * Return the signature algorithms that the remote peer supports or {@code null} if none are supported. * See man SSL_get_sigalgs for more details. - * The returned names are generated using {@code OBJ_nid2ln} with the {@code psignhash} as parameter. + * The returned names are generated using {@code OBJ_nid2ln} with the {@code psignhash} as parameter, or with + * {@code psign} if there is no {@code psignhash} (for example for Ed25519). * * @param ssl the SSL instance (SSL *) * @return the signature algorithms or {@code null}. diff --git a/openssl-dynamic/src/main/c/ssl.c b/openssl-dynamic/src/main/c/ssl.c index 3aec22371..59a894f92 100644 --- a/openssl-dynamic/src/main/c/ssl.c +++ b/openssl-dynamic/src/main/c/ssl.c @@ -2704,6 +2704,7 @@ TCN_IMPLEMENT_CALL(jobjectArray, SSL, getSigAlgs)(TCN_STDARGS, jlong ssl) { #if OPENSSL_VERSION_NUMBER >= 0x10002000L || defined(__GNUC__) || defined(__GNUG__) int i; int nsig; + int psign; int psignhash; jobjectArray array = NULL; jstring algString = NULL; @@ -2718,7 +2719,12 @@ TCN_IMPLEMENT_CALL(jobjectArray, SSL, getSigAlgs)(TCN_STDARGS, jlong ssl) { } for (i = 0; i < nsig; i++) { - SSL_get_sigalgs(ssl_, i, NULL, NULL, &psignhash, NULL, NULL); + SSL_get_sigalgs(ssl_, i, &psign, NULL, &psignhash, NULL, NULL); + if (psignhash == NID_undef) { + // Some algorithms, such as Ed25519, Ed448 and RSA-PSS, have no combined signature and hash NID. + // Use the signature NID so we return their name rather than "undefined". + psignhash = psign; + } if ((algString = (*e)->NewStringUTF(e, OBJ_nid2ln(psignhash))) == NULL) { // something is wrong we should better just return here return NULL;