From git+noreply at mindrot.org Sat Aug 1 12:34:51 2026 From: git+noreply at mindrot.org (git+noreply at mindrot.org) Date: Sat, 01 Aug 2026 12:34:51 +1000 Subject: [openssh-commits] [openssh] branch master updated: Require NISTP521 in libcrypto. Message-ID: <178555169189.69650.134489021407423315@fuyu.mindrot.org> This is an automated email from the git hooks/post-receive script. dtucker pushed a commit to branch master in repository openssh. The following commit(s) were added to refs/heads/master by this push: new ec0485632 Require NISTP521 in libcrypto. ec0485632 is described below commit ec0485632885e0c533b35e5970e4b583781db83f Author: Darren Tucker AuthorDate: Sat Aug 1 12:10:40 2026 +1000 Require NISTP521 in libcrypto. Previously we supported building without NISTP521 in libcrypto since some vendors shipped without it, but this now seems uncommon. This removes that support, requiring a fully functional libcrypto. This removes another set of diffs vs upstream and should reduce the maintenance burden. ok djm@ --- configure.ac | 97 ++-------------------- kex-names.c | 2 - .../unittests/sshbuf/test_sshbuf_getput_crypto.c | 11 +-- regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c | 8 +- regress/unittests/sshkey/common.c | 4 +- ssh-ecdsa.c | 6 -- ssh-keygen.c | 5 -- sshkey.c | 12 --- 8 files changed, 11 insertions(+), 134 deletions(-) diff --git a/configure.ac b/configure.ac index d1f64cd62..c4fdd5d19 100644 --- a/configure.ac +++ b/configure.ac @@ -3300,101 +3300,16 @@ if test "x$openssl" = "xyes" ; then #include ]], [[ EC_KEY *e = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); + EC_KEY *f = EC_KEY_new_by_curve_name(NID_secp384r1); + EC_KEY *g = EC_KEY_new_by_curve_name(NID_secp521r1); + /* Also require EC_KEY_METHOD support for ECDSA PKCS#11 */ + void *h = EC_KEY_METHOD_new(NULL); const EVP_MD *m = EVP_sha256(); /* We need this too */ ]])], - [ AC_MSG_RESULT([yes]) - enable_nistp256=1 ], - [ AC_MSG_RESULT([no]) ] - ) - - AC_MSG_CHECKING([whether OpenSSL has NID_secp384r1]) - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[ - #include - #include - #include - #include - #include - #include - ]], [[ - EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp384r1); - const EVP_MD *m = EVP_sha384(); /* We need this too */ - ]])], - [ AC_MSG_RESULT([yes]) - enable_nistp384=1 ], - [ AC_MSG_RESULT([no]) ] - ) - - AC_MSG_CHECKING([whether OpenSSL has NID_secp521r1]) - AC_LINK_IFELSE( - [AC_LANG_PROGRAM([[ - #include - #include - #include - #include - #include - #include - ]], [[ - EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1); - const EVP_MD *m = EVP_sha512(); /* We need this too */ - ]])], - [ AC_MSG_RESULT([yes]) - AC_MSG_CHECKING([if OpenSSL's NID_secp521r1 is functional]) - AC_RUN_IFELSE( - [AC_LANG_PROGRAM([[ - #include - #include - #include - #include - #include - #include - #include - ]],[[ - EC_KEY *e = EC_KEY_new_by_curve_name(NID_secp521r1); - const EVP_MD *m = EVP_sha512(); /* We need this too */ - exit(e == NULL || m == NULL); - ]])], - [ AC_MSG_RESULT([yes]) - enable_nistp521=1 ], - [ AC_MSG_RESULT([no]) ], - [ AC_MSG_WARN([cross-compiling: assuming yes]) - enable_nistp521=1 ] - )], - AC_MSG_RESULT([no]) + [ AC_MSG_RESULT([yes]) ], + [ AC_MSG_ERROR([libcrypto does not have required ECC support]) ] ) - if test x$enable_nistp256 = x1 || test x$enable_nistp384 = x1 || \ - test x$enable_nistp521 = x1; then - AC_CHECK_FUNCS([EC_KEY_METHOD_new]) - else - AC_MSG_ERROR([libcrypto does not have required ECC support]) - fi - if test x$enable_nistp256 = x1; then - AC_DEFINE([OPENSSL_HAS_NISTP256], [1], - [libcrypto has NID_X9_62_prime256v1]) - else - unsupported_algorithms="$unsupported_algorithms \ - ecdsa-sha2-nistp256 \ - ecdh-sha2-nistp256 \ - ecdsa-sha2-nistp256-cert-v01 at openssh.com" - fi - if test x$enable_nistp384 = x1; then - AC_DEFINE([OPENSSL_HAS_NISTP384], [1], [libcrypto has NID_secp384r1]) - else - unsupported_algorithms="$unsupported_algorithms \ - ecdsa-sha2-nistp384 \ - ecdh-sha2-nistp384 \ - ecdsa-sha2-nistp384-cert-v01 at openssh.com" - fi - if test x$enable_nistp521 = x1; then - AC_DEFINE([OPENSSL_HAS_NISTP521], [1], [libcrypto has NID_secp521r1]) - else - unsupported_algorithms="$unsupported_algorithms \ - ecdh-sha2-nistp521 \ - ecdsa-sha2-nistp521 \ - ecdsa-sha2-nistp521-cert-v01 at openssh.com" - fi - # Check libcrypto ED25519 support AC_CHECK_FUNCS([EVP_PKEY_get_raw_public_key]) AC_CHECK_FUNCS([EVP_PKEY_get_raw_private_key]) diff --git a/kex-names.c b/kex-names.c index f9ba49b7f..7660c2edc 100644 --- a/kex-names.c +++ b/kex-names.c @@ -65,10 +65,8 @@ static const struct kexalg kexalgs[] = { NID_X9_62_prime256v1, SSH_DIGEST_SHA256, KEX_NOT_PQ }, { KEX_ECDH_SHA2_NISTP384, KEX_ECDH_SHA2, NID_secp384r1, SSH_DIGEST_SHA384, KEX_NOT_PQ }, -# ifdef OPENSSL_HAS_NISTP521 { KEX_ECDH_SHA2_NISTP521, KEX_ECDH_SHA2, NID_secp521r1, SSH_DIGEST_SHA512, KEX_NOT_PQ }, -# endif /* OPENSSL_HAS_NISTP521 */ { KEX_MLKEM768NISTP256_SHA256, KEX_KEM_MLKEM768ECDH_SHA256, NID_X9_62_prime256v1, SSH_DIGEST_SHA256, KEX_IS_PQ }, # ifdef NID_brainpoolP256r1 diff --git a/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c b/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c index 1ce2041c9..4bd4afa2b 100644 --- a/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c +++ b/regress/unittests/sshbuf/test_sshbuf_getput_crypto.c @@ -30,7 +30,9 @@ void sshbuf_getput_crypto_tests(void) { struct sshbuf *p1; - BIGNUM *bn, *bn2; + const u_char *d; + size_t s; + BIGNUM *bn, *bn2, *bn_x, *bn_y; const char *hexbn1 = "0102030405060708090a0b0c0d0e0f10"; /* This one has MSB set to test bignum2 encoding negative-avoidance */ const char *hexbn2 = "f0e0d0c0b0a0908070605040302010007fff11"; @@ -43,10 +45,6 @@ sshbuf_getput_crypto_tests(void) 0x70, 0x60, 0x50, 0x40, 0x30, 0x20, 0x10, 0x00, 0x7f, 0xff, 0x11 }; -#if defined(OPENSSL_HAS_NISTP256) - const u_char *d; - size_t s; - BIGNUM *bn_x, *bn_y; int ec256_nid = NID_X9_62_prime256v1; char *ec256_x = "0C828004839D0106AA59575216191357" "34B451459DADB586677EF9DF55784999"; @@ -65,7 +63,6 @@ sshbuf_getput_crypto_tests(void) }; EC_KEY *eck; EC_POINT *ecp; -#endif int r; #define MKBN(b, bnn) \ @@ -219,7 +216,6 @@ sshbuf_getput_crypto_tests(void) sshbuf_free(p1); TEST_DONE(); -#if defined(OPENSSL_HAS_NISTP256) TEST_START("sshbuf_put_ec"); eck = EC_KEY_new_by_curve_name(ec256_nid); ASSERT_PTR_NE(eck, NULL); @@ -271,7 +267,6 @@ sshbuf_getput_crypto_tests(void) BN_free(bn); BN_free(bn2); TEST_DONE(); -#endif } #endif /* WITH_OPENSSL */ diff --git a/regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c b/regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c index 5c53529df..9b95b60bb 100644 --- a/regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c +++ b/regress/unittests/sshbuf/test_sshbuf_getput_fuzz.c @@ -16,9 +16,7 @@ #ifdef WITH_OPENSSL #include #include -#ifdef OPENSSL_HAS_NISTP256 -# include -#endif +#include #endif #include "../test_helper/test_helper.h" @@ -33,9 +31,7 @@ attempt_parse_blob(u_char *blob, size_t len) struct sshbuf *p1; #ifdef WITH_OPENSSL BIGNUM *bn; -#if defined(OPENSSL_HAS_NISTP256) EC_KEY *eck; -#endif /* defined(OPENSSL_HAS_NISTP256) */ #endif /* WITH_OPENSSL */ u_char *s; size_t l; @@ -59,12 +55,10 @@ attempt_parse_blob(u_char *blob, size_t len) bn = NULL; ASSERT_INT_EQ(sshbuf_get_bignum2(p1, &bn), 0); BN_clear_free(bn); -# if defined(OPENSSL_HAS_NISTP256) eck = EC_KEY_new_by_curve_name(NID_X9_62_prime256v1); ASSERT_PTR_NE(eck, NULL); ASSERT_INT_EQ(sshbuf_get_eckey(p1, eck), 0); EC_KEY_free(eck); -# endif /* defined(OPENSSL_HAS_NISTP256) */ #endif /* WITH_OPENSSL */ sshbuf_free(p1); } diff --git a/regress/unittests/sshkey/common.c b/regress/unittests/sshkey/common.c index fa68e6d5b..32144beab 100644 --- a/regress/unittests/sshkey/common.c +++ b/regress/unittests/sshkey/common.c @@ -18,11 +18,9 @@ #ifdef WITH_OPENSSL #include +#include #include #include -#ifdef OPENSSL_HAS_NISTP256 -# include -#endif /* OPENSSL_HAS_NISTP256 */ #endif /* WITH_OPENSSL */ #include "openbsd-compat/openssl-compat.h" diff --git a/ssh-ecdsa.c b/ssh-ecdsa.c index 488db9c2a..54a626e3f 100644 --- a/ssh-ecdsa.c +++ b/ssh-ecdsa.c @@ -49,9 +49,7 @@ sshkey_ecdsa_fixup_group(EVP_PKEY *k) int nids[] = { NID_X9_62_prime256v1, NID_secp384r1, -#ifdef OPENSSL_HAS_NISTP521 NID_secp521r1, -#endif -1 }; int nid = -1; @@ -106,10 +104,8 @@ ssh_ecdsa_size(const struct sshkey *key) return 256; case NID_secp384r1: return 384; -#ifdef OPENSSL_HAS_NISTP521 case NID_secp521r1: return 521; -#endif default: return 0; } @@ -556,7 +552,6 @@ const struct sshkey_impl sshkey_ecdsa_nistp384_cert_impl = { /* .funcs = */ &sshkey_ecdsa_funcs, }; -#ifdef OPENSSL_HAS_NISTP521 const struct sshkey_impl sshkey_ecdsa_nistp521_impl = { /* .name = */ "ecdsa-sha2-nistp521", /* .shortname = */ "ECDSA", @@ -580,6 +575,5 @@ const struct sshkey_impl sshkey_ecdsa_nistp521_cert_impl = { /* .keybits = */ 0, /* .funcs = */ &sshkey_ecdsa_funcs, }; -#endif #endif /* WITH_OPENSSL */ diff --git a/ssh-keygen.c b/ssh-keygen.c index fef27300e..e3a12bf39 100644 --- a/ssh-keygen.c +++ b/ssh-keygen.c @@ -206,13 +206,8 @@ type_bits_valid(int type, const char *name, uint32_t *bitsp) break; case KEY_ECDSA: if (sshkey_ecdsa_bits_to_nid(*bitsp) == -1) -#ifdef OPENSSL_HAS_NISTP521 fatal("Invalid ECDSA key length: valid lengths are " "256, 384 or 521 bits"); -#else - fatal("Invalid ECDSA key length: valid lengths are " - "256 or 384 bits"); -#endif } #endif } diff --git a/sshkey.c b/sshkey.c index 41a06dc34..a590529a0 100644 --- a/sshkey.c +++ b/sshkey.c @@ -105,10 +105,8 @@ extern const struct sshkey_impl sshkey_ecdsa_nistp256_impl; extern const struct sshkey_impl sshkey_ecdsa_nistp256_cert_impl; extern const struct sshkey_impl sshkey_ecdsa_nistp384_impl; extern const struct sshkey_impl sshkey_ecdsa_nistp384_cert_impl; -# ifdef OPENSSL_HAS_NISTP521 extern const struct sshkey_impl sshkey_ecdsa_nistp521_impl; extern const struct sshkey_impl sshkey_ecdsa_nistp521_cert_impl; -# endif /* OPENSSL_HAS_NISTP521 */ extern const struct sshkey_impl sshkey_rsa_impl; extern const struct sshkey_impl sshkey_rsa_cert_impl; extern const struct sshkey_impl sshkey_rsa_sha256_impl; @@ -133,10 +131,8 @@ const struct sshkey_impl * const keyimpls[] = { &sshkey_ecdsa_nistp256_cert_impl, &sshkey_ecdsa_nistp384_impl, &sshkey_ecdsa_nistp384_cert_impl, -# ifdef OPENSSL_HAS_NISTP521 &sshkey_ecdsa_nistp521_impl, &sshkey_ecdsa_nistp521_cert_impl, -# endif /* OPENSSL_HAS_NISTP521 */ # ifdef ENABLE_SK &sshkey_ecdsa_sk_impl, &sshkey_ecdsa_sk_cert_impl, @@ -575,10 +571,8 @@ sshkey_curve_name_to_nid(const char *name) return NID_X9_62_prime256v1; else if (strcmp(name, "nistp384") == 0) return NID_secp384r1; -# ifdef OPENSSL_HAS_NISTP521 else if (strcmp(name, "nistp521") == 0) return NID_secp521r1; -# endif /* OPENSSL_HAS_NISTP521 */ else return -1; } @@ -591,10 +585,8 @@ sshkey_curve_nid_to_bits(int nid) return 256; case NID_secp384r1: return 384; -# ifdef OPENSSL_HAS_NISTP521 case NID_secp521r1: return 521; -# endif /* OPENSSL_HAS_NISTP521 */ default: return 0; } @@ -608,10 +600,8 @@ sshkey_ecdsa_bits_to_nid(int bits) return NID_X9_62_prime256v1; case 384: return NID_secp384r1; -# ifdef OPENSSL_HAS_NISTP521 case 521: return NID_secp521r1; -# endif /* OPENSSL_HAS_NISTP521 */ default: return -1; } @@ -625,10 +615,8 @@ sshkey_curve_nid_to_name(int nid) return "nistp256"; case NID_secp384r1: return "nistp384"; -# ifdef OPENSSL_HAS_NISTP521 case NID_secp521r1: return "nistp521"; -# endif /* OPENSSL_HAS_NISTP521 */ default: return NULL; } -- To stop receiving notification emails like this one, please contact djm at mindrot.org.