Skip to content

Commit

Permalink
Issue proftpd#1437: Implement support for Ed448 host keys, and the "c…
Browse files Browse the repository at this point in the history
…urve448-sha512" key exchange algorithm, in `mod_sftp`.
  • Loading branch information
Castaglia committed May 17, 2022
1 parent 16b7e53 commit 4635189
Show file tree
Hide file tree
Showing 13 changed files with 1,086 additions and 72 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
- Issue 1439 - SFTP "check-file" implementation computes incorrect results.
- Issue 1457 - Implement SFTPHostKeys directive for configuring the SSH host
key algorithms.
- Issue 1437 - Implement the "curve448-sha512" SSH key exchange algorithm.

1.3.8rc3 - Released 23-Apr-2022
--------------------------------
Expand Down
2 changes: 2 additions & 0 deletions RELEASE_NOTES
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ ChangeLog files.

SFTPClientMatch (Issue #1444)

SFTPKeyExchanges curve448-512 (Issue #1437)


1.3.8rc3
---------
Expand Down
22 changes: 11 additions & 11 deletions contrib/mod_sftp/auth-hostbased.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* ProFTPD - mod_sftp 'hostbased' user authentication
* Copyright (c) 2008-2020 TJ Saunders
* Copyright (c) 2008-2022 TJ Saunders
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -91,30 +91,30 @@ int sftp_auth_hostbased(struct ssh2_packet *pkt, cmd_rec *pass_cmd,
"client sent '%s' host key, FQDN %s, and remote user '%s'",
hostkey_algo, host_fqdn, host_user);

if (strncmp(hostkey_algo, "ssh-rsa", 8) == 0) {
if (strcmp(hostkey_algo, "ssh-rsa") == 0) {
pubkey_type = SFTP_KEY_RSA;

#ifdef HAVE_SHA256_OPENSSL
} else if (strncmp(hostkey_algo, "rsa-sha2-256", 13) == 0) {
#if defined(HAVE_SHA256_OPENSSL)
} else if (strcmp(hostkey_algo, "rsa-sha2-256") == 0) {
pubkey_type = SFTP_KEY_RSA_SHA256;
#endif /* HAVE_SHA256_OPENSSL */

#ifdef HAVE_SHA512_OPENSSL
} else if (strncmp(hostkey_algo, "rsa-sha2-512", 13) == 0) {
#if defined(HAVE_SHA512_OPENSSL)
} else if (strcmp(hostkey_algo, "rsa-sha2-512") == 0) {
pubkey_type = SFTP_KEY_RSA_SHA512;
#endif /* HAVE_SHA512_OPENSSL */

} else if (strncmp(hostkey_algo, "ssh-dss", 8) == 0) {
} else if (strcmp(hostkey_algo, "ssh-dss") == 0) {
pubkey_type = SFTP_KEY_DSA;

#ifdef PR_USE_OPENSSL_ECC
} else if (strncmp(hostkey_algo, "ecdsa-sha2-nistp256", 20) == 0) {
#if defined(PR_USE_OPENSSL_ECC)
} else if (strcmp(hostkey_algo, "ecdsa-sha2-nistp256") == 0) {
pubkey_type = SFTP_KEY_ECDSA_256;

} else if (strncmp(hostkey_algo, "ecdsa-sha2-nistp384", 20) == 0) {
} else if (strcmp(hostkey_algo, "ecdsa-sha2-nistp384") == 0) {
pubkey_type = SFTP_KEY_ECDSA_384;

} else if (strncmp(hostkey_algo, "ecdsa-sha2-nistp521", 20) == 0) {
} else if (strcmp(hostkey_algo, "ecdsa-sha2-nistp521") == 0) {
pubkey_type = SFTP_KEY_ECDSA_521;
#endif /* PR_USE_OPENSSL_ECC */

Expand Down
40 changes: 40 additions & 0 deletions contrib/mod_sftp/configure
Original file line number Diff line number Diff line change
Expand Up @@ -4058,6 +4058,46 @@ $as_echo "no" >&6; }
LIBS="$saved_libs"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether OpenSSL supports X448 algorithm" >&5
$as_echo_n "checking whether OpenSSL supports X448 algorithm... " >&6; }
LIBS="-lcrypto $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <openssl/evp.h>
int
main ()
{
EVP_PKEY_CTX *pctx;
pctx = EVP_PKEY_CTX_new_id(NID_X448, NULL);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
$as_echo "#define HAVE_X448_OPENSSL 1" >>confdefs.h
LIBS="$saved_libs"
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
LIBS="$saved_libs"
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
Expand Down
22 changes: 22 additions & 0 deletions contrib/mod_sftp/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,28 @@ AC_TRY_LINK(
]
)

AC_MSG_CHECKING([whether OpenSSL supports X448 algorithm])
LIBS="-lcrypto $LIBS"

AC_TRY_LINK(
[
#include <openssl/evp.h>
],
[
EVP_PKEY_CTX *pctx;
pctx = EVP_PKEY_CTX_new_id(NID_X448, NULL);
],
[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_X448_OPENSSL, 1, [OpenSSL supports X448 algorithm])
LIBS="$saved_libs"
],
[
AC_MSG_RESULT(no)
LIBS="$saved_libs"
]
)

LIBS="$saved_libs"

INCLUDES="$ac_build_addl_includes"
Expand Down
8 changes: 7 additions & 1 deletion contrib/mod_sftp/crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ static const char *hostkey_algos[] = {
#if defined(PR_USE_SODIUM)
"ssh-ed25519",
#endif /* PR_USE_SODIUM */
#if defined(HAVE_X448_OPENSSL)
"ssh-ed448",
#endif /* HAVE_X448_OPENSSL */
#if defined(PR_USE_OPENSSL_ECC)
"ecdsa-sha2-nistp256",
"ecdsa-sha2-nistp384",
Expand Down Expand Up @@ -231,7 +234,7 @@ static const char *key_exchanges[] = {
"diffie-hellman-group-exchange-sha256",
#endif
"diffie-hellman-group-exchange-sha1",
#ifdef PR_USE_OPENSSL_ECC
#if defined(PR_USE_OPENSSL_ECC)
"ecdh-sha2-nistp256",
"ecdh-sha2-nistp384",
"ecdh-sha2-nistp521",
Expand All @@ -240,6 +243,9 @@ static const char *key_exchanges[] = {
"curve25519-sha256",
"[email protected]",
#endif /* HAVE_SODIUM_H and HAVE_SHA256_OPENSSL */
#if defined(HAVE_X448_OPENSSL) && defined(HAVE_SHA512_OPENSSL)
"curve448-sha512",
#endif /* HAVE_X448_OPENSSL and HAVE_SHA512_OPENSSL */
"rsa1024-sha1",
NULL
};
Expand Down
Loading

0 comments on commit 4635189

Please sign in to comment.