Soften behaviour of the Compression=no/yes option

Currently Compression=no (the default) force-disables zlib algos, while
Compression=yes force-enables it. This means that mismatching options between
client and server lead to connection failure. This can easily happen if the
server has default settings but the client specifies Compression=yes.

OpenSSH treats the option as a "prefer compression" setting:
Compression=no  -> none,zlib@openssh.com,zlib (default)
Compression=yes -> zlib@openssh.com,zlib,none

This commit changes the libssh behaviour to the same as OpenSSH.

Signed-off-by: Fabian Vogt <fabian@ritter-vogt.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
This commit is contained in:
Fabian Vogt
2021-12-23 12:34:00 +01:00
committed by Jakub Jelen
parent 6f634af4fb
commit 14991ad071
4 changed files with 38 additions and 15 deletions

View File

@@ -88,7 +88,7 @@
#endif /* HAVE_LIBCRYPTO */
#ifdef WITH_ZLIB
#define ZLIB "none,zlib,zlib@openssh.com"
#define ZLIB "none,zlib@openssh.com,zlib"
#else
#define ZLIB "none"
#endif
@@ -229,8 +229,8 @@ static const char *default_methods[] = {
CHACHA20 AES,
"hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-512",
"hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha2-256,hmac-sha2-512",
"none",
"none",
ZLIB,
ZLIB,
"",
"",
NULL