1
1

1321 Коммитов

Автор SHA1 Сообщение Дата
Andreas Schneider
e19163eabb libgcrypt: Add missing config.h include
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:24:11 +01:00
Andreas Schneider
720739bc2a Happy new year!
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-02 08:05:59 +01:00
jvijtiuk
ea99215664 pki: Fix accidental ECC switch case fallthroughs into ed25119 cases when built without ECC
Summary:
When ed25519 was introduced in commit 93c7b81b4ea1046bd2f65f4a510d5966786e8d3d,
the ed25519 case was added after the ecdsa case in src/pki.c. The ecdsa case seems to
have relied on falling through to report an error, when HAVE_ECC is not defined.
If HAVE_ECC is not defined, but ecdsa keys are used, with for example,
ssh_pki_import_pubkey_file, the code fallthroughs into the ed25519 case.

Signed-off-by: Juraj Vijtiuk <juraj.vijtiuk@sartura.hr>

Test Plan: Unit tests passed. No memory leaks found with valgrind.

Reviewers: asn

Differential Revision: https://bugs.libssh.org/D13
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-28 20:46:37 +01:00
Jakub Jelen
c3c492a190 config: Avoid long -> int -> long casting for timeout configuration option
Fixes: T80

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-28 20:42:53 +01:00
Juraj Vijtiuk
778652460f add mbedtls crypto support
Summary:
This patch adds support for mbedTLS as a crypto backend for libssh.
mbedTLS is an SSL/TLS library that has been designed to mainly be used
in embedded systems.  It is loosely coupled and has a low memory
footprint.  mbedTLS also provides a cryptography library (libmbedcrypto)
that can be used without the TLS modules.
The patch is unfortunately quite big, since several new files had to
be added.
DSA is disabled at compile time, since mbedTLS doesn't support DSA
Patch review and feedback would be appreciated, and if any issues or
suggestions appear, I'm willing to work on them.

Signed-off-by: Juraj Vijtiuk <juraj.vijtiuk@sartura.hr>

Test Plan:
* The patch has been tested with a Debug and MinSizeRel build, with
libssh unit tests, client tests and the pkd tests.
* All the tests have been run with valgrind's memcheck, drd and helgrind
tools.
* The examples/samplessh client works when built with the patch.

Reviewers: asn, aris

Subscribers: simonsj

Differential Revision: https://bugs.libssh.org/D1
2017-12-28 11:17:39 +01:00
Jakub Jelen
5c3b1ee0a4 options: Rewrite set() description to get()
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-28 11:17:39 +01:00
Jakub Jelen
4dec2f989c options: Move SSH_OPTIONS_ADD_IDENTITY to *set() function description
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-21 12:38:23 +01:00
Jakub Jelen
b8e301ade3 config: Add CMake check for glob() 2017-12-21 11:43:19 +01:00
NoName115
99c5160cb5 config: glob support for include with test
Signed-off-by: NoName115 <robert.kolcun@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-21 11:43:14 +01:00
Jakub Jelen
110da49504 config: support for MACs
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-15 12:00:49 +01:00
Jakub Jelen
4da7985204 config: Set global log level from configuration file
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-15 12:00:49 +01:00
Jakub Jelen
2a66c38efa options: Typo. The expand character is %d
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-15 12:00:49 +01:00
Jakub Jelen
2e31dffdb7 config: Remove MAC option (SSHv1)
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-15 12:00:49 +01:00
Jakub Jelen
88e43d2502 config: Add configuration options from current OpenSSH 7.5 (and fix typos)
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-15 12:00:49 +01:00
Jakub Jelen
4166bb2a26 options: Document SSH_OPTIONS_GLOBAL_KNOWNHOSTS and set default value
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-15 12:00:49 +01:00
Aris Adamantiadis
f818e63f8f Add new options
Pair-Programmed-With: Jakub Jelen <jjelen@redhat.com>
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-15 12:00:49 +01:00
Andreas Schneider
9fce33a2e3 client: Add missing language tag in disconnect message
Fixes T74

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-11-16 12:10:41 +01:00
Andreas Schneider
f525fdb2e1 sftp: Check for NULL path and give correct error
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-11-09 11:41:58 +01:00
Jakub Jelen
c4ddf62f7e pki_crypto: Avoid potential memory leak
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-11-08 16:21:36 +01:00
Jakub Jelen
16818bd0e4 pki_crypto: Avoid segfault with OpenSSL 1.1.0
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-11-07 15:10:32 +01:00
Jon Simons
d29d199592 ecdh: fix build for old libgcrypt
Summary:
Fix a typo for old libgcrypt builds `k_length` -> `k_len`.

Signed-off-by: Jon Simons <jon@jonsimons.org>

Test Plan:  * Spotted this last-minute typo bug in local testing.

Reviewers: asn

Reviewed By: asn

Differential Revision: https://bugs.libssh.org/D10
2017-10-29 16:28:39 +01:00
Jon Simons
17c03005d8 ecdh: fix build for old libgcrypt
Summary:
Fix a typo for old libgcrypt builds `k_length` -> `k_len`.

Signed-off-by: Jon Simons <jon@jonsimons.org>

Test Plan:  * Spotted this last-minute typo bug in local testing.

Reviewers: asn

Differential Revision: https://bugs.libssh.org/D10
2017-10-29 16:27:02 +01:00
Andreas Schneider
509fa8a7b2 dh: Don't use deprecated function with newer OpenSSL
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-10-29 16:15:33 +01:00
Andreas Schneider
954da14c15 pki_crypto: Don't use deprecated function with newer OpenSSL
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-10-29 16:06:14 +01:00
Jon Simons
538f1bc00e server: expose 'ssh_server_init_kex' API
Expose an API 'ssh_server_init_kex' which allows one to change the set of
key exchange, hostkey, ciphers, MACs, and compression algorithms currently
configured for the ssh_session at hand, after having started the
'ssh_handle_key_exchange' process.

One can use this API from the already-existing 'connect_status_function'
callback to dynamically modify the set of algorithms used after having
received the client banner, but before sending out the initial KEXINIT
message.

For example, one might want to prevent advertising the curve25519 key
exchange algorithm for older OpenSSH clients due to interop bugs.

Fixes T25

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-10-29 15:49:12 +01:00
Andreas Schneider
f0ddde4826 Fix config.h includes
We need stdlib.h and string.h in priv.h for free() and memset().

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-10-28 14:31:37 +02:00
Jon Simons
73d76a2638 auth: fix double-free in ssh_userauth_agent_publickey
Fixes T72

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-09-11 16:28:14 +02:00
Jon Simons
1c9eb4dfb9 config: fix memory leak with repeated opcodes
Fix a memory leak in the path where parsing returns early due
to seeing a repeated opcode.  A testcase is added which
demonstrates the leak and fix with valgrind.

Resolves CID 1374267.

Signed-off-by: Jon Simons <jon@jonsimons.org>
2017-09-11 16:26:41 +02:00
Andreas Schneider
94fa1e382f match: Add missing return statement
This makey the compiler happy.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-08-25 10:06:00 +02:00
Andreas Schneider
2493e962fe packet: Fix fallthrough compiler warnings
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-08-25 10:06:00 +02:00
Jon Simons
7204d2f485 ecdh: enable ecdh_sha2_nistp{384,521} kex methods
Summary:
Based on Dirkjan's original patch series here:

 * https://www.libssh.org/archive/libssh/2015-08/0000029.html

Here the changes are adapted for the current master
branch, and expanded to include libgcrypt support.

Co-Authored-By: Dirkjan Bussink <d.bussink@gmail.com>
Signed-off-by: Jon Simons <jon@jonsimons.org>

Test Plan:
 * Ran pkd tests for libcrypto and libgcrypt builds.
 * Ran client torture_algorithms.c tests for libcrypto and libgcrypt builds.
 * Tested across multiple libgcrypts ("1.6.3" and "1.7.6-beta").

Reviewers: aris, asn

Reviewed By: asn

Tags: #libssh

Differential Revision: https://bugs.libssh.org/D7
2017-08-24 18:19:25 +02:00
Jon Simons
6252aab88a ecdh: enable ecdh_sha2_nistp{384,521} kex methods
Summary:
Based on Dirkjan's original patch series here:

 * https://www.libssh.org/archive/libssh/2015-08/0000029.html

Here the changes are adapted for the current master
branch, and expanded to include libgcrypt support.

Co-Authored-By: Dirkjan Bussink <d.bussink@gmail.com>
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>

Test Plan:
 * Ran pkd tests for libcrypto and libgcrypt builds.
 * Ran client torture_algorithms.c tests for libcrypto and libgcrypt builds.
 * Tested across multiple libgcrypts ("1.6.3" and "1.7.6-beta").

Reviewers: aris, asn

Tags: #libssh

Differential Revision: https://bugs.libssh.org/D7
2017-08-24 18:18:41 +02:00
Andreas Schneider
4c602f2255 options: Use ssh_key_type_e in ssh_options_set_algo()
Review with 'git show -b'

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-08-24 18:01:41 +02:00
Andreas Schneider
6803c2f86d kex: Use ssh_kex_types_e in ssh_verify_existing_algo()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-08-24 18:01:41 +02:00
Nikos Mavrogiannopoulos
895055ab38 ssh_options_set_algo: ensure we only set known algorithms internally
That way, we will not fail later on key exchange phase when something
unknown is negotiated.

Fixes T37

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2017-08-24 18:01:34 +02:00
Nikos Mavrogiannopoulos
8ecd65bcdb config: add support for recursive including of files
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-08-24 15:51:07 +02:00
Jon Simons
c317d95911 libcrypto: add NULL-check for EVP_CIPHER_CTX_cleanup
On OpenSSL versions prior to 1.1.0, `EVP_CIPHER_CTX_cleanup` will
dereference its argument regardless of whether it is NULL.  This
is not a problem on OpenSSL at or beyond 1.1.0, where
`EVP_CIPHER_CTX_cleanup` (macro to `EVP_CIPHER_CTX_reset`) returns
early upon NULL input.

Move the call to `EVP_CIPHER_CTX_cleanup` under the existing NULL
check in `evp_cipher_cleanup` to avoid the problem.

Introduced with this build-break fix:
 * e66f370682927ca8bd7ae0e7544754c6f4ac4969

Found in manual testing in an environment with an older OpenSSL.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-20 17:02:44 +02:00
Jon Simons
380390c4b6 misc: relax fatal errors in ssh_analyze_banner
Relax the cases where `ssh_analyze_banner` fails to extract a
major and minor version from banners which appear like OpenSSH
banners.

Update the tests to demonstrate that now a banner as might be
sent by `ssh-keyscan(1)` ("SSH-2.0-OpenSSH-keyscan") no longer
returns failure.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-18 09:32:31 +02:00
Jon Simons
e66f370682 wrapper: move EVP_CIPHER_CTX_free call to libcrypto.c
With this change, a HAVE_LIBCRYPTO #ifdef is removed from wrapper.c.
Now, the libcrypto-specific logic for EVP_CIPHER_CTX_free is moved
into the ssh_cipher_struct cleanup callback handler for those
ciphers.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-18 09:30:57 +02:00
Jon Simons
a5bc81d406 wrapper: fix gcrypt build error in ssh_cipher_clear
Fix a gcrypt build error introduced with
48e7b098f86207f8596651b5ba8242a3b834a868.

The ssh_cipher_struct only contains a `ctx` field on
the libcrypto builds, so it can't be referenced unless
within HAVE_LIBCRYPTO.

This build fix preserves the original spirit of the
change in 48e7b098f86207f8596651b5ba8242a3b834a868:
only call `EVP_CIPHER_CTX_free` when `cipher->ctx`
is non-NULL.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-18 09:30:19 +02:00
Jon Simons
2f42296edd wrapper: fix 4-space indentation in ssh_cipher_clear
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-18 09:29:56 +02:00
Jon Simons
a89a67e008 misc: fix error-checking in ssh_analyze_banner
Fix error-checking for `strtoul` in `ssh_analyze_banner`, and
enable some tests which demonstrate the fix before-and-after.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-13 19:35:34 +02:00
Jon Simons
a97db12f4f misc: reindent ssh_analyze_banner, update docs
No changes to code, only whitespace indentation and
an update to the function docs.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-13 19:34:57 +02:00
Jon Simons
a64ddff3fe libcrypto: fix resource leak in hmac_final
Fix a resource leak in `hmac_final`: say `HMAC_CTX_free` instead
of `HMAC_CTX_reset`.  This matches the error handling as done in
`hmac_init`.  Introduced with cf1e808e2ffa1f26644fb5d2cb82a919f323deba.

The problem is reproducible running the `pkd_hello` test with:

    valgrind --leak-check=full ./pkd_hello -i1 -t torture_pkd_openssh_dsa_rsa_default

Resolves https://red.libssh.org/issues/252.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-13 19:29:44 +02:00
Jon Simons
25384e9558 libcrypto-compat: fix HMAC_CTX_free for OpenSSL < 1.1.0
On older OpenSSL versions, the EVP_MD_CTX fields within an HMAC_CTX
structure are contained inlined (change here [1]): be sure to not
try to free those fields on those builds.

Found running the `pkd_hello` test with:

    valgrind ./pkd_hello -i1 -t torture_pkd_openssh_dsa_rsa_default

^ valgrind will cite "Invalid free() ..." errors which are present
before this fix and absent after, when building with OpenSSL 1.0.1.

[1] 6e59a892db

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-13 19:28:59 +02:00
Andreas Schneider
0cb2974bd8 misc: Use strtoul in ssh_analyze_banner()
Thanks to Tilo Eckert.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-06-28 12:29:53 +02:00
Aris Adamantiadis
0cffb88b80 config: fix buffer underflow with unrecognized opcodes 2017-06-08 10:45:53 +02:00
Andreas Schneider
c50f2d1356 misc: Do not fall through and return a value
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-06-06 10:25:15 +02:00
debevv
48e7b098f8 wrapper: Fix possible crash in ssh_handle_key_exchange()
If ssh_handle_key_exchange() fails, when ssh_free() is called
cipher->ctx is NULL.

Signed-off-by: debevv <valerio@sonicpengu.in>
2017-06-06 10:21:55 +02:00
Artyom V. Poptsov
5333be5988 config: Bugfix: Don't skip unseen opcodes
libssh fails to read the configuration from a config file due to a
wrong check in 'ssh_config_parse_line' procedure in 'config.c'; it's
effectively skipping every opcode (and therefore every option) from
the file.  The change fixes that behaviour.

Signed-off-by: Artyom V. Poptsov <poptsov.artyom@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-06-06 10:19:37 +02:00