1
1

1344 Коммитов

Автор SHA1 Сообщение Дата
Andreas Schneider
2cc5b5865c kex1: Use new dh pubkey import functions
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-03-28 10:20:54 +02:00
Andreas Schneider
8d65edb41f kex1: Fix building with OpenSSL 1.1+
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-03-28 10:20:32 +02:00
Andreas Schneider
1247ba3398 channels1: Add missing config.h include
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-03-28 10:11:45 +02:00
Alberto Aguirre
be22c0d442 Add a NODELAY option
Add a new option SSH_OPTIONS_NODELAY to enable or disable the
Nagle Algorithm (TCP_NODELAY) on the session socket.

Improved performance can be achieved for some applications like
sftp servers by enabling SSH_OPTIONS_NODELAY as typically, the
next request won't arrive until the server replies, which are
typically small writes.

Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-03-21 20:44:04 +01:00
Andreas Schneider
16217454d5 crypto: Change the type of server_pubkey to ssh_key
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-03-21 20:40:02 +01:00
Alberto Aguirre
7e1e0e5098 misc: Use SecureZeroMemory if available for explicit_bzero
Useful on Windows platforms where SecureZeroMemory is available.

Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-03-11 22:58:49 +01:00
Alberto Aguirre
3fa0e3959c misc: Use memset_s if available for explicit_bzero
Useful on OSX where memset_s is available.

Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-03-11 22:58:13 +01:00
Alberto Aguirre
85ab4ee53a connector: ensure channel callbacks are removed
ssh_connector_free fails to remove the in/out channel callbacks
as ssh_connector_remove_event sets the in/out channel variables
to NULL.

Have ssh_connector_free, remove the channel callbacks first before
invoking ssh_connector_remove_event.

Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-03-07 15:48:04 +01:00
Alberto Aguirre
25f31760aa connector: Check for POLLHUP on in_fd
POLLHUP needs to be checked on in_fd, which may be a pipe.
A pipe in Linux signals EOF through POLLHUP (see:
http://www.greenend.org.uk/rjk/tech/poll.html)

Without checking POLLHUP, a client could spin up indefinetely
doing ssh_event_dopoll.

Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-03-07 15:47:03 +01:00
Juraj Vijtiuk
d11869bdb6 pki: Add mbedTLS ECDSA key comparison support
Signed-off-by: Juraj Vijtiuk <juraj.vijtiuk@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-03-07 15:44:05 +01:00
Andreas Schneider
81847bf513 priv: Implement explicit_bzero as a function if not available
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Alberto Aguirre <albaguirre@gmail.com>
2018-03-02 18:07:42 +01:00
Andreas Schneider
cc1f496741 pki: Use explicit_bzero() to wipe privkey in memory
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-02-16 16:51:37 +01:00
Andreas Schneider
ebcff9fd63 src: Use explicit_bzero() if available on the platform
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-02-12 14:41:27 +01:00
Meng Tan
f19158cadf Set channel as bound when accepting channel open request
Signed-off-by: Meng Tan <mtan@wallix.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-02-01 18:23:38 +01:00
Andreas Schneider
43bd7b6eee dh: Use calloc() instead of malloc() 2018-01-18 18:57:18 +01:00
Andreas Schneider
d7c47f529f pki_gcrypt: Use calloc() instead of malloc()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-18 18:55:52 +01:00
Andreas Schneider
2cff66c155 threads: Use calloc() instead of malloc()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-18 18:55:04 +01:00
Andreas Schneider
78ce67f579 sftpserver: Use calloc() instead of malloc()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-18 18:54:18 +01:00
Andreas Schneider
2fb8198c48 server: Use calloc() instead of malloc()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-18 18:53:35 +01:00
Andreas Schneider
2ea3683347 kex: Use calloc() instead of malloc()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-18 18:52:04 +01:00
Andreas Schneider
aaeb938ca4 channels: Use calloc() instead of malloc()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-18 18:52:04 +01:00
Andreas Schneider
ef4a81ea0c auth: Use calloc() instead of malloc()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-18 18:52:00 +01:00
Andreas Schneider
67b8f3d6df pki_crypto: Fix private key generation with password
We need to specify a cipher when we generate a key with a password.
OpenSSH uses aes_128_cbc, so we should use the same.

Thanks to Julian Lunz for the report.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:31:02 +01:00
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