Compare commits

...

3663 Commits

Author SHA1 Message Date
Andreas Schneider
e8322817a9 Bump version to 0.10.4
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2022-09-07 15:30:40 +02:00
Andreas Schneider
e0c2f2809b kdf: Avoid endianess issues
The key_type is only a letter, if we use and `int` and then cast it to
(const char *) we will end up with a 0 value on big endian.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-09-07 15:29:03 +02:00
Andreas Schneider
9bb91df20f tests: Set OPENSSL_ENABLE_SHA1_SIGNATURES=1 for all tests
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-09-07 15:29:01 +02:00
Andreas Schneider
783f2b97a8 Bump version to 0.10.3
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-09-05 14:27:29 +02:00
Andreas Schneider
8d05810255 tests: Add test with dss known_hosts file
We should not end up with an infinite loop here.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
(cherry picked from commit accbc91a86)
2022-09-05 14:25:24 +02:00
Andreas Schneider
1d29d4b627 knownhosts: Fix and infinite loop when iterating known host entries
Fixes #145

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
(cherry picked from commit 3e4c2205c5)
2022-09-05 14:25:22 +02:00
Andreas Schneider
787711a271 knownhosts: Give better warnings about unsupported key types
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
(cherry picked from commit 2d79c7a9d5)
2022-09-05 14:25:21 +02:00
Andreas Schneider
ddea657ba7 Bump version to 0.10.2
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2022-09-02 10:00:11 +02:00
Andreas Schneider
9ae46bc364 tests: Fix rekey test so it passes on build systems
The test failed on Fedora Koji and openSUSE Build Service on i686 only. Probably
the rekey on the server needs longer here to collect enough entropy. So we need
to try harder before we stop :-)

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit b3b3fbfa1d)
2022-09-02 09:56:54 +02:00
Jakub Jelen
fd1563575f config: Expand tilde when handling include directives
Related: #93

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit d69026d7a4)
2022-09-02 09:56:52 +02:00
Andreas Schneider
1f973320a8 tests: Use weak attribute for torture_run_tests() if available
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 7787dad9bd)
2022-09-02 09:56:50 +02:00
Andreas Schneider
4fc7ab4399 cmake: Check for weak attribute
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 23546e354c)
2022-09-02 09:56:48 +02:00
Jakub Jelen
87bac425a0 ci: Add apline linux target
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit e5af9524e3)
2022-09-02 09:56:43 +02:00
Andreas Schneider
0e637e3327 src: Add ABI symbols for 4.9.1 2022-08-30 16:28:00 +02:00
Andreas Schneider
9b1f4e9bf6 Bump version to 0.10.1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-08-30 15:46:13 +02:00
Jakub Jelen
630f335415 libcrypto: Avoid unused variable warning
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit f86727e06a)
2022-08-30 13:26:08 +02:00
Jakub Jelen
b7934ab370 socket: Remove needless typedef
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit a69424d4c5)
2022-08-30 13:26:06 +02:00
Jakub Jelen
0aaad9eb25 wrapper: Avoid size_t to uint8 cast
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 8aade7ce6f)
2022-08-30 13:26:05 +02:00
Jakub Jelen
8fe4cabb26 misc: Refactor ssh_strerror to check return values
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 41f2ee92c6)
2022-08-30 13:26:04 +02:00
Jakub Jelen
1689b83d0f Do not force GNU_SOURCE during build to fix #141
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 8cf9c8162f)
2022-08-30 13:26:02 +02:00
Andreas Schneider
7c6105882b options: Use exec for the proxy command
This wont create a new process but replace the shell.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit bd2db30174)
2022-08-30 10:01:48 +02:00
Andreas Schneider
bb6d1b78dc socket: Add a comment about shells
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit d642b20d9c)
2022-08-30 10:01:46 +02:00
Andreas Schneider
5a884b8c5a socket: Add error message if execv fails
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 2546b62242)
2022-08-30 10:01:36 +02:00
Andreas Schneider
90128929e7 tests: Use ncat instead of nc
The ncat tool from nmap is available on all unix platforms. The nc
binary might link to ncat or something else. Settle on one we know
also the options can be used if needed.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 6268417ac6)
2022-08-30 10:01:30 +02:00
Andreas Schneider
a7d509ca50 tests: Add test for expanding port numbers
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 8c0be750db)
2022-08-30 10:00:54 +02:00
Andreas Schneider
d26f7253a9 session: Initialize the port with the standard port (22)
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit f306aafdc6)
2022-08-30 10:00:48 +02:00
Andreas Schneider
3ad2a21d13 misc: Fix expanding port numbers
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 648baf0f3c)
2022-08-30 10:00:38 +02:00
Andreas Schneider
7f6b3fab4e misc: Fix format truncation in ssh_path_expand_escape()
error: ‘%u’ directive output may be truncated writing between 1 and 10
bytes into a region of size 6.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 20406e51c9)
2022-08-26 14:10:39 +02:00
Jakub Jelen
cd7ccf93f0 Update changelog
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2022-08-26 11:34:08 +02:00
Jakub Jelen
5944124428 examples: Fix dereference after NULL check (CID 1461477)
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 8164e1ff9c)
2022-08-25 17:45:43 +02:00
renmingshuai
8c40b2491d session->socket_callbacks.data will be set to ssh_packet_socket_callback
in ssh_packet_register_socket_callback. Here is redundant.

Signed-off-by: renmingshuai <renmingshuai@huawei.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 0799775185)
2022-08-25 17:36:45 +02:00
Timo Rothenpieler
3331b794bc misc: rename gettimeofday symbol
mingw does have this function, even though it appears to be deprecated.
So the symbol has to have a different name, or linking becomes
impossible.

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 17aec429f5)
2022-08-25 17:36:42 +02:00
Jakub Jelen
02f1873b9e CMake: Do not build PKCS#11 URI support with OpenSSL <1.1.1
The old version is missing the EVP_PKEY_up_ref(), which is needed to keep track
of the EVP_PKEY references.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
(cherry picked from commit 6e2648af6b)
2022-08-25 17:36:38 +02:00
Jakub Jelen
5da93db25a pki: Rework handling of EVP_PKEYs in OpenSSL backend
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
(cherry picked from commit a81e78aff4)
2022-08-25 17:36:36 +02:00
Jakub Jelen
b18495b56b Initialize pkcs11 engine only once
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
(cherry picked from commit 0800618f32)
2022-08-25 17:36:30 +02:00
Jakub Jelen
a96763b195 libcrypto: Skip unneccessary call to ENGINE_cleanup in OSSL>1.1
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
(cherry picked from commit f721ee847b)
2022-08-25 17:36:26 +02:00
Jakub Jelen
540257b421 pki: Factor out the backend-specifics from cleaning the key structure
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
(cherry picked from commit 382ff38caa)
2022-08-25 17:36:22 +02:00
Jakub Jelen
b657eeb65e tests: Prevent memory leaks from test
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
(cherry picked from commit bc0c027ac0)
2022-08-25 17:36:16 +02:00
renmingshuai
4a87515026 tests: Ensure the mode of the created file is ...
what we set in open funtion by the argument mode. The mode of the created file
is (mode & ~umask), So we set umask to typical default value(octal 022).

Signed-off-by: renmingshuai <renmingshuai@huawei.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 1286a70e13)
2022-08-08 10:17:05 +02:00
Jakub Jelen
886ed379d8 session: Avoid memory leak of agent_socket from configuration file
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=48268

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit aa1e136ea3)
2022-08-08 10:17:00 +02:00
Norbert Pocs
9b9197d86b gitlab-ci: Enable environment variable in centos9
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 4d96c667bc)
2022-08-03 19:43:48 +02:00
Norbert Pocs
64e89affeb torture.c Add environment variable to server fork
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 2e8e666b1d)
2022-08-03 19:43:48 +02:00
Jakub Jelen
2c1ad3262a tests: Refactor and provide plain PKCS8 PEM format
This also allows testing mbedtls with the PKCS8 PEM files

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 66be590657)
2022-08-03 10:49:24 +02:00
Jakub Jelen
14ff31490f examples: Update keygen2 example to show fingerprints
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit f193e6840d)
2022-08-03 10:49:22 +02:00
Jakub Jelen
3db3511467 curve25519: Do not check for openssl functions when other crypto backend is used
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 0982715bb5)
2022-08-03 10:49:18 +02:00
Jakub Jelen
4c5da86f91 pki: Do not check for DSA headers when DSA is not built in
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit ebeee7631d)
2022-08-03 10:49:17 +02:00
Jakub Jelen
2564246024 mbedcrypto: Refactor PEM parsing
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit aca482a5a5)
2022-08-03 10:49:15 +02:00
Jakub Jelen
146d1a620d session: Initialize pointers
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 355e29d881)
2022-08-03 10:49:14 +02:00
Anderson Toshiyuki Sasaki
19c43ff6b7 init: Free global init mutex in the destructor on Windows
Fixes: #57 (T238)

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 163951d869)
2022-08-02 16:03:06 +02:00
Norbert Pocs
58a2943d42 .gitlab-ci: Add centos9 image
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 84df28ee31)
2022-08-02 16:03:05 +02:00
Norbert Pocs
54c5472b53 .gitlab-ci: Remove remaining rawhide lines
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 224298a4d0)
2022-08-02 16:03:03 +02:00
Jakub Jelen
17e9cd70a5 Move digest functions into separate file
The external ed25519 requires also the sha512 functions to work.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit c09b02c573)
2022-08-02 16:01:42 +02:00
Jakub Jelen
cee5c9f404 Build external override library with all symbols
The curve25519 depends on ssh_get_random, which is normally built into libssh.
For the external override tests to build, we need to have them in separate
source file that can be included for this test.

For some reason, this did not happen on CI builds, but it did happen in koji
during RPM builds.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 0da54f2908)
2022-08-02 16:01:35 +02:00
Andreas Schneider
43fb1d7c8d packet: Check hmac return codes in ssh_packet_hmac_verify()
CID #1490530

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit b42e9a19a3)
2022-07-14 15:03:58 +02:00
Andreas Schneider
5c629f22f6 packet: Use consistent return codes in ssh_packet_hmac_verify()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit e27ee9d0a4)
2022-07-14 15:03:57 +02:00
Andreas Schneider
46e0703c6e packet: Reformat ssh_packet_hmac_verify()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 4a7791b784)
2022-07-14 15:03:55 +02:00
Norbert Pocs
cffa103378 Make it work with openssl3.0
The KDF was changed in the new API, fetching the algorithm first
then creating the context using it.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 9a4c5203af)
2022-07-13 15:36:07 +02:00
Norbert Pocs
ea6558b3a6 Change cmake files for new openssl API
The new API does not provide EVP_KDF_CTX_new_id function, insted
it works with EVP_KDF_CTX_new and fetching the algorithm.
Adding a check for both to make it work with the new API too.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 8343a43edc)
2022-07-13 15:36:04 +02:00
Norbert Pocs
33e12317c3 torture_options: Add test for '@' in login name
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit 964df4dc29)
2022-07-12 10:45:35 +02:00
Norbert Pocs
d17c635617 options: Parse hostname by last '@'
The login name can have '@' char in it

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit bb5f7e2707)
2022-07-12 10:45:34 +02:00
Norbert Pocs
dde5fd8d38 bind.c: Add missing size constant to err_msg
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
(cherry picked from commit e53a2711d3)
2022-07-12 10:43:25 +02:00
Andreas Schneider
46e78aaa3a gitlab-ci: Drop the rawhide runner
Fedora 36 is using OpenSSL 3.0 now.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit a0c0efaf2e)
2022-07-11 11:02:20 +02:00
Andreas Schneider
3107133d10 tests: Setup Leak Sanitizer suppressions for OpenSSL
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 21ef488121)
2022-07-11 11:02:18 +02:00
Andreas Schneider
b9ccaf6e23 cmake: Build curve25519_ref.c if we build with libgcrypt
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 0128ed0d2c)
2022-07-11 11:02:17 +02:00
Andreas Schneider
38b17e6e6e pki: Fix building pki_ed25519.c with libgcrypt
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit 6a25f07777)
2022-07-11 11:02:16 +02:00
Andreas Schneider
db0a1d6811 src: Fix building curve25519 with libgcrypt
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
(cherry picked from commit cc0939df73)
2022-07-11 11:02:14 +02:00
Andreas Schneider
ced93a09d1 Bump version to 0.10.0
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-07 15:27:23 +02:00
Andreas Schneider
3cff0eaa25 Update CHANGELOG for 0.9 changes
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-07 15:19:49 +02:00
Andreas Schneider
51c7816bea Rename ChangeLog
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-07 15:19:49 +02:00
Norbert Pocs
11a7c7b45b libgcrypt: Remove useless comparison
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-07-07 08:39:39 +02:00
Norbert Pocs
78d109596c pki_crypto: Fix segfault error when pkcs11
EVP_PKEY_dup can't be used with ENGINE generated keys and
the key can't be freed because it is passing the main key
from the struct.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-07-07 08:39:39 +02:00
Norbert Pocs
b80ad81d8e .gitlab-ci: Add fedora rawhide to gitlab CI
Rawhide has openssl 3.0 support which can test the new changes.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-07-07 08:39:39 +02:00
Norbert Pocs
20c13a2c76 Change const bignum to bignum
Openssl3.0 API retrieves bignum variables from a key.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-07-07 08:39:39 +02:00
Norbert Pocs
a9dddd89aa Use EVP_PKEY as a key type in key structs
Merge multiple key variables into one variable.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-07-07 08:39:39 +02:00
Norbert Pocs
7792d38157 Port functions to openssl3.0
Remove usage of deprecated functions.
Exceptions are:
  - pkcs11 (no openssl provider support yet)
  - ec (no support for uncompressed EC keys
    https://github.com/openssl/openssl/pull/16624)

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-07-07 08:39:39 +02:00
Norbert Pocs
fdf518435c Define EC name constants for openssl3
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-07-07 08:39:39 +02:00
Norbert Pocs
debd0ea4d3 Update HMAC function parameter type
New openssl API, libmbedtls, libgcrypt use size_t for
HMAC len pameter.

New helper functions were added in libcrypto.c to avoid
code duplication. (the header pki.h is needed for this
reason)

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-07-07 08:39:39 +02:00
Jakub Jelen
51c940adc9 misc: FreeBSD compatible strerror_r usage
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-07-07 08:38:09 +02:00
Norbert Pocs
d30cf11cb6 Rewrite strerror to ssh_strerror
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Norbert Pocs
e5bc5ffd04 Rewrite strerror to ssh_strerror
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Norbert Pocs
4b92d48085 Rewrite strerror to ssh_strerror
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Norbert Pocs
a2a037a821 Rewrite strerror to ssh_strerror
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Norbert Pocs
4719c09e6a Rewrite strerror to ssh_strerror
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Norbert Pocs
4f09bb3660 Rewrite strerror to ssh_strerror
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Norbert Pocs
594608f21b Rewrite strerror to ssh_strerror
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Norbert Pocs
c437ba5c28 Rewrite strerror to ssh_strerror
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Norbert Pocs
3efe7c3cfb Rewrite strerror to ssh_strerror
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Norbert Pocs
b44b749f28 Rewrite strerror to ssh_strerror
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Norbert Pocs
9837471c2e Rewrite strerror to ssh_strerror
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Norbert Pocs
d92e389a80 Rewrite strerror to ssh_strerror
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Norbert Pocs
0dce42c8fd Rewrite strerror to ssh_strerror
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Norbert Pocs
face3aadb4 Add constant SSH_ERRNO_MSG_MAX
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Norbert Pocs
738cedb8be Add ssh_strerror function
- strerror_r for linux
- strerror_s for windows

Keep in mind that strerror_r has two versions:
- XSI
- GNU
see manpage for more information

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Norbert Pocs
b6a4330fe4 Change include order in unittest files
The tests are compiled without -D_GNU_SOURCE, therefore
the XSI version of strerror_r is used. Defining
_GNU_SOURCE in torture.h then including *.c gives error
because it is assuming GNU version of strerror_r in
the source file.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-04 11:55:40 +02:00
Jakub Jelen
2abd4bfb6c .gitlab-ci: Fix typo in the cmake option name
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-07-04 10:11:57 +02:00
Juraj Vijtiuk
0c08159f53 Fix mbedTLS issues caused by v3 API changes
Signed-off-by: Juraj Vijtiuk <vijtiuk.juraj@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-07-04 08:52:18 +02:00
Andreas Schneider
9caedca2c6 API: Bump SO version to 4.9.0
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-07-02 07:04:48 +02:00
omsheladia
e0985fc0b4 client: Add ssh_session_set_disconnect_message()
Fix #98 by adding 'ssh_session_set_disconnect_message' Whenever the ssh
session disconnects a "Bye Bye" message was set and displayed. Now the
peer has a choice to set a customised message to be sent after the
session is disconnected. The default "Bye Bye" will be set if this
function is not called or not called correctly. The testcases in
tests/server/torture_server can also demonstrate how this function
works.

Signed-off-by: Om Sheladia <omsheladia10@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-07-02 07:04:48 +02:00
Seung Min Park
4978f30320 Add ssh_send_issue_banner() API
Signed-off-by: Seung Min Park <smpark@pnpsecure.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-07-02 07:04:48 +02:00
tatataeki
332f1c2e09 sftp: fix the length calculation of packet in sftp_write
Signed-off-by: tatataeki <shengzeyu19_98@163.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-29 18:29:26 +02:00
Andreas Schneider
63e09908f1 poll: Document errno will be set for ssh_event_dopoll()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-23 12:35:39 +02:00
Andreas Schneider
b34f8e6efa tests:client: Add a non-blocking publickey test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-23 12:22:44 +02:00
Andreas Schneider
ab07668d54 tests:client: Add a publickey test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-23 12:22:43 +02:00
Andreas Schneider
f6ad8057a7 auth: Fix error returned in ssh_userauth_try_publickey()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-23 12:22:41 +02:00
Wez Furlong
51a53cc6d4 add support for identityagent ssh_config option
This commit adds an `agent_socket` field to the session options
and connects the config parser to that option.

`SSH_OPTIONS_IDENTITY_AGENT` is added to allow applications to
set this option for themselves.

agent.c is updated to take the `agent_socket` value in preference
to the `SSH_AUTH_SOCK` environment variable.

Signed-off-by: Wez Furlong <wez@fb.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-22 13:56:14 +02:00
Wez Furlong
899ec9e519 Enable ssh agent authentication on Windows
Windows has supported unix domain sockets for a couple of years
now; see this article for more information about that:
<https://devblogs.microsoft.com/commandline/af_unix-comes-to-windows/>

This commit allows libssh to consider using agent authentication
on Windows systems.

It is mostly removing `#ifndef _WIN32` that prevented the unix
domain socket code from being compiled in, and adjusting the use
of `read(2)` and `write(2)` to `recv(2)` and `send(2)`, as the former
functions are not compatible with sockets on Windows systems.

For mingw systems, afunix.h isn't available so we use the
technique as was used to resolve building with mingw as used
by the curl project in: https://github.com/curl/curl/pull/5170

Signed-off-by: Wez Furlong <wez@fb.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-22 13:56:14 +02:00
Andreas Schneider
7bcc2d83a4 packet: Fix ssh_packet_socket_callback() return value
According to the documentation the return value is the number of
processed bytes, so the returned value is never negative. We should not
use ssize_t in public headers as it isn't available on Windows! We only
have it defined in priv.h!

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-22 12:28:30 +02:00
Andreas Schneider
2ba4b51e0f include: Add missing include for ssh_socket_callbacks_struct
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-22 12:28:30 +02:00
Andreas Schneider
1be117b351 gitlab-ci: Remove 'allow_failure' for visualstudio
This has been fixed already.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-22 12:28:28 +02:00
Jakub Jelen
bdeb7418c5 ci: Build benchmarks to catch more errors
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-06-20 12:03:11 +02:00
Jakub Jelen
f18cc433db benchmark: Add explicit extension
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-06-20 12:00:03 +02:00
Andreas Schneider
65256ad5f6 crypto: Use stdint types and make code more readable of secure_memcmp()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-20 09:18:59 +02:00
Carlo Bramini
86057e60f2 CYGWIN provides an implemention of libargp as a separate package:
https://cygwin.com/cgi-bin2/package-grep.cgi?grep=libargp&arch=x86_64

The current CMakeLists.txt already provides the detection of this library for BSD/SOLARIS/OSX, so CYGWIN can be easily added there for support.

Signed-off-by: Carlo Bramini <carlo_bramini@users.sourceforge.net>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-20 09:15:37 +02:00
Andreas Schneider
a889527c1b libsshpp: Fix openForward to not set sourcehost to NULL by default
This parameter is required.

Fixes #25

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-15 16:19:56 +02:00
Andreas Schneider
ca51565056 options: Document that the caller needs to close the socket
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-15 16:08:41 +02:00
Andreas Schneider
4b20d7ad18 client: Do not close the socket if it was set via options
Fixes #122

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-15 16:08:41 +02:00
Norbert Pocs
442599f0d1 Fix type mismatch warnings
Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-15 14:47:06 +02:00
Norbert Pocs
eb9dc8cfc4 Add errno reset with strtoul call
Contaminated errno can happen before strtoul call, thereofore
cleaning it before the call.
The errno is not used for checking later in code if fail happens,
therefore cleaning it right after error.

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-09 16:46:49 +02:00
Jakub Jelen
07f4d5e723 Document poll failures
Resolved: https://gitlab.com/libssh/libssh-mirror/-/issues/46
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-09 09:08:02 +02:00
Jakub Jelen
c9263dea2b Deprecate API functions handling old key structures
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-09 09:08:02 +02:00
Jakub Jelen
e0bceea815 Remove duplicate function in headers files
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-09 09:08:02 +02:00
Jakub Jelen
7bd850ab36 Remove bogus semicolons
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-09 09:08:02 +02:00
Sahana Prasad
4b3a6342db Deprecate duplicate/ unused functions
and fix obvious naming mistakes, mostly in documentation

Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-09 09:08:02 +02:00
Jakub Jelen
2aa137947a Reformat most of the function headers
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-09 09:08:02 +02:00
Jakub Jelen
daabd78742 Remove remaining mentions of SSH-v1 protocol
also remove anything mentioning limitation to SSHv2 as it is the only
protocol supported these days.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-09 09:08:02 +02:00
Jakub Jelen
1d238694e7 Improve documentation by mentioning the free functions
Related: https://gitlab.com/libssh/libssh-mirror/-/issues/3
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-09 09:08:02 +02:00
Jakub Jelen
6623856e08 tests: Try to test signals handling (and fail)
The cmocka captures all signals so I was not able to reproduce the code
path. But leaving the code in for future readers.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-09 09:08:02 +02:00
Jakub Jelen
9e03bf9f1e bind: Return different error if accept was interrupted
Fixes: https://gitlab.com/libssh/libssh-mirror/-/issues/13
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-09 09:08:02 +02:00
Jakub Jelen
b312d4681e Move ssh_key_dup to public API
Fixes: https://gitlab.com/libssh/libssh-mirror/-/issues/15
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-09 09:08:02 +02:00
Jakub Jelen
254bfd6d73 ssh_x11_client: Fix coverity reports
Thanks coverity

Fixes:
 * CID 1488472:  Security best practices violations  (STRING_OVERFLOW)
 * CID 1488471:  Error handling issues  (CHECKED_RETURN)
 * CID 1472029:  Error handling issues  (NEGATIVE_RETURNS)

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-09 09:08:02 +02:00
Jakub Jelen
2420e4a981 cmake: Move the ws2_32 as the last library for mingw to work
Fixes: https://gitlab.com/libssh/libssh-mirror/-/issues/84
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-06-09 09:08:02 +02:00
Carlo Bramini
b4d532b809 Don't set "-fstack-clash-protection" option on Windows
Signed-off-by: Carlo Bramini <carlo_bramini@users.sourceforge.net>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-08 09:06:42 +02:00
Carlo Bramini
79ad989cf4 keygen2 requires also ${ARGP_LIBRARY}
Signed-off-by: Carlo Bramini <carlo_bramini@users.sourceforge.net>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-08 09:06:42 +02:00
Jakub Jelen
100017982d Avoid usage of deprecated functions and whitespace cleanup
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-06-07 14:16:59 +02:00
Tomas Holmqvist
dd318aa1a1 channels: Add originator to ssh_channel_accept
Added API function ssh_channel_open_forward_port that is the same as
ssh_channel_accept_forward with the addition to determine the
originator address and port

Signed-off-by: Tomas Holmqvist <tomhol@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-06-07 14:16:59 +02:00
Andreas Schneider
fef0b3208a Fix editorconfig
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-05-23 10:14:18 +02:00
Jakub Jelen
ddd0367e9c Do not accept signatures not meeting size requirements
Thanks to Harry Sintonen from WithSecure for pointing this out.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-05-12 09:13:51 +02:00
Jakub Jelen
41b4d50e52 Allow limiting RSA Key size also for server
Thanks to Harry Sintonen from WithSecure for pointing this out.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-05-12 09:13:49 +02:00
Jakub Jelen
b408f5724a Allow limiting RSA key size used for authentication
Thanks to Harry Sintonen from WithSecure for pointing this out.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-05-12 09:13:45 +02:00
Jakub Jelen
1c0372e0aa pki: Implement ssh_key_size to get key size in bits
Thanks to Harry Sintonen from WithSecure for pointing this out.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-05-12 09:13:38 +02:00
Jakub Jelen
8b9b45066b Generate new 2k certificate key working in FIPS
The original key had 2018 bits, which falls short for current security
requirements

Steps I used:

$ ssh-keygen -f tests/keys/certauth/id_rsa -t rsa -b 2048 -C libssh_torture_auth -N ''
$ ssh-keygen -s tests/keys/user_ca -I torture_auth_carlos -n alice ./tests/keys/certauth/id_rsa.pub

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-05-12 09:13:38 +02:00
Jakub Jelen
97a03083ba unsorted formatting cleanup
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-05-10 12:39:26 +02:00
Marco Fortina
88bc364c05 examples: Add 'ssh X11 client' sample
Signed-off-by: Marco Fortina <marco.fortina@atlantica.it>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-05-02 20:06:22 +02:00
Junda Ai
41e2d17119 Fix multiple spelling and grammar mistakes
Signed-off-by: Junda Ai <aijunda29@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-05-02 19:05:51 +02:00
Dhanuka Warusadura
3084b2bc41 trivial fix: Fixes some spelling errors
Signed-off-by: Dhanuka Warusadura <csx@tuta.io>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-04-19 15:55:49 +02:00
Anh Minh Tran
af9018ce13 Solve issue #113 "Remove unneeded configuration options not supported by OpenSSH anymore"
Remove config options: protocol, mac, cipher, compressionlevel,
gssapikeyexchange,
gssapirenewalforcesrekey,
gssapitrustdns,
rhostsrsaauthentication,
rsaauthentication,
useprivilegedport,
pubkeyacceptedtypes
since they are not supported by OpenSSH

Rename some config options:
hostbasedkeytypes, challengeresponseauthentication and pubkeyacceptedkeytypes
to hosbasedacceptedalgorithms, kdbinteractiveauthentication and pubkeyacceptedalgorithms
to be consistent with the OpenSSH manual https://man.openbsd.org/sshd_config.
Keep pubkeyacceptedkeytypes for backward compatibility.
Rename SOC_PUBKEYACCEPTEDTYPES to SOC_PUBKEYACCEPTEDKEYTYPES in config.h

Update unittests/torture_config.c and unittests/torture_options.c

Signed-off-by: Anh Minh Tran <anhminh@seznam.cz>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-04-14 11:47:14 +02:00
Gene Oden
196fe36971 knownhosts, config: Avoid using MT-unsafe implementations of strtok()
Use the POSIX strtok_r() or equivalent implementations to resolve.

Thanks to @wez1 for the early review.

Fixes #104

Signed-off-by: Gene Oden <goden@fb.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-03-16 07:45:34 -07:00
Norbert Pocs
b5ce8fa96a Fix fips mode check in openssl3
FIPS_mode function is no longer supported in openssl version 3

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-03-09 16:48:43 +01:00
Jakub Jelen
70d3760daa tests: Reproducer for usage of NULL sshdir
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-02-15 12:41:35 +01:00
Jakub Jelen
2edb4b50ac config: Avoid NULL dereference if no ssh dir is set
This should never happen while parsing configuration files, but the
configuration strings do not have this safeguard.

Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44619

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-02-15 11:37:49 +01:00
Jakub Jelen
f97ff7c2e8 fuzz: Provide host and ssh dir for the fuzzer
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2022-02-15 11:34:11 +01:00
Jakub Jelen
4975487c18 config: Include files with relative paths
The libssh versions before this included files with relative path based
on the current working directory, which can result unexpected results
and is different from the OpenSSH include behavior. The manual page for
ssh_config lists:

> iles without absolute paths are assumed to be in ~/.ssh if included in
> a user configuration file or /etc/ssh if included from the system
> configuration file.

This is following the semantics as close as possible with a difference
that we do not use the hardcoded ~/.ssh for user configuration files,
but the path defined with SSH_OPTIONS_SSH_DIR, which is already used
to reference any other files in used home directory.

Fixes #93

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-10 18:22:20 +01:00
Jakub Jelen
ded3a17738 options: Updated doc text to reflect reality
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-10 18:22:20 +01:00
Jakub Jelen
0b14e40710 Fix broken link to an issue
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2022-02-10 14:06:18 +01:00
Jakub Jelen
24ac4a0129 misc: Initialize the host buffer
This fails if the gethostname() fails in a way that does not write the
buffer, but returns 0 as a success.

Fixes #106

Thanks oss-fuzz

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2022-02-10 14:06:18 +01:00
Jakub Jelen
ea83a27371 libcrypto: Initialize returning size_t value
This prevents the usage of uninitialized value on error in the known
hosts hasing code if invalid (empty) hostname is used.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2022-02-10 14:05:24 +01:00
Jakub Jelen
d171a6e444 match: Optimize pattern matching even more
The adjacent question marks and asterisks can be simplified to single
wildcard so there is no need to excersise all the recursive pattern
matching.

These inputs were generated by oss-fuzz and probably caused also the
previously reported timeouts.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-10 11:21:19 +01:00
Jakub Jelen
44665f33a4 fuzz: Add a testcase for each fuzzer with a corpus
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-10 11:21:19 +01:00
Jakub Jelen
2e68cfbf40 fuzz: Add known_hosts file fuzzer
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-10 11:21:19 +01:00
Jakub Jelen
bf7149f205 match: Limit recursion to 16
This is more than enough as it reflects to 16 asterisks in the match
string is more than enough. With larger values oss-fuzz was generating
long match strings with asterisks interleaved with normal characters,
which were timing out.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-09 17:39:12 +01:00
Jakub Jelen
354438e758 match: Reformat match_pattern
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-09 17:39:12 +01:00
Jakub Jelen
314c57d414 fuzz: Get rid of cpp mess in fuzzers
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-02-08 19:13:45 +01:00
Andreas Schneider
2756eae1c7 gitlab-ci: Use coverity build env
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-01-28 09:12:12 +01:00
Andreas Schneider
afcb85bfda gitlab-ci: Sort build env variables
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-01-28 09:11:11 +01:00
Jakub Jelen
86ee3f5a00 tests: Skip the workaround forcing SHA1 signatures
In certificate authentication with OpenSSH 8.0, the SHA2 signatures were
not accepted correctly [1]. This was not an issue up until the OpenSSH
8.8p1, which does no longer allow SHA1 signatures by default so this
broke the CI and tests against the new OpenSSH [2].

Fixes !107

[1] https://bugzilla.mindrot.org/show_bug.cgi?id=3016
[2] https://gitlab.com/libssh/libssh-mirror/-/issues/107

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2022-01-28 08:54:07 +01:00
Fabian Vogt
14991ad071 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>
2022-01-05 11:26:30 +01:00
Andreas Schneider
6f634af4fb libssh: Deprecate the SCP API
See also
https://lists.mindrot.org/pipermail/openssh-unix-dev/2021-September/039616.html

Fixes #91

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2022-01-03 14:45:16 +01:00
Andreas Schneider
a52c66008e Happy new year 2022!
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2022-01-01 06:57:24 +01:00
brian m. carlson
c573adced4 server: reply with PK_OK with correct algorithm
RFC 4252 §7 states that the public key algorithm in a
SSH_MSG_USERAUTH_PK_OK response is the public key algorithm name from
the request.  When using RSA with SHA-2, this will be either
"rsa-sha2-256" or "rsa-sha2-512" as specified by RFC 8332 §3.2.

However, currently libssh emits the public key type instead, which is
"ssh-rsa".  This is not in conformance with the RFCs, so let's fix this
by storing the signature type and emitting it in our response instead of
the public key when sending SSH_MSG_USERAUTH_PK_OK in the server.

Signed-off-by: brian m. carlson <bk2204@github.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-12-07 12:27:18 +01:00
Jakub Jelen
42d1efe4f9 bind_config: Ignore empty lines
This also avoids buffer overflow with empty lines.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-11-10 10:13:20 +01:00
Jakub Jelen
0aa3b4ee81 tests: Introduce bind configuration fuzzer
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-11-10 10:12:56 +01:00
Jakub Jelen
e5e3c6267c tests: Break bind config tests to cover also string parsing entrypoint
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-11-10 10:12:56 +01:00
Jakub Jelen
ba8ce64a1d New API to provide configuration string for bind
Similarly as we already have for the client configuraiton file

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-11-10 10:12:56 +01:00
Jakub Jelen
d76d5c633f tests: Verify the recursive includes do not crash
neither client nor server configuration parser

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-11-10 10:12:56 +01:00
Jakub Jelen
227f416183 config: Avoid infinite recursion when using Include
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-11-10 10:12:56 +01:00
Norbert Pocs
99c6eb305e examples: Missing close for 'socket_fd' when error
Defect found by covscan

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-11-09 09:36:34 +01:00
Norbert Pocs
21b6418fd9 tests: Add condition for SSHD_EXECUTABLE
Do not compile tests which need SSHD_EXECUTABLE when
it is not available

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-11-09 09:36:31 +01:00
Stanislav Zidek
ce26b56e13 client configuration fuzzing and fixes
Signed-off-by: Stanislav Zidek <szidek@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-11-02 11:33:26 +01:00
Jakub Jelen
f2f680aede channels: Avoid memory leak
Thanks oss-fuzz:

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=40116

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-11-02 11:14:26 +01:00
Andrew Wiley
1a831cfe2c emulated poll: polling for nothing should at least get socket errors
Signed-off-by: Andrew Wiley <wiley@outlook.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-10-11 14:01:09 +02:00
Sahana Prasad
95539ba0eb Adds documentation about the order of processing the IdentityFiles
specified in ~/.ssh/config.

Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-10-11 14:00:36 +02:00
Biswapriyo Nath
4a2758ecd6 cmake: Install pkgconfig file in MinGW
Signed-off-by: Biswapriyo Nath <nathbappai@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-09-29 16:35:04 +02:00
Artyom V. Poptsov
1ab2340644 channels: Fix segfaults when the channel data is freed
Calling some channel procedures on a freed channel is always resulting
in segmentation fault errors.  The reason is that when a channel is
freed with 'ssh_channel_do_free' procedure, its 'session' field is set
to NULL; then when a channel procedure tries to access any field of
'channel->session' structure it is effectively dereferencing a NULL
pointer.

The change fixes that behavior by adding a check which ensures that a
channel state is not SSH_CHANNEL_FLAG_FREED_LOCAL before accessing its
parent session.

Also the test suite is updated to check for the fixed errors, and the
Doxygen documentation updated accordingly.

There was a bug introduced in b0fb7d15: 'ssh_channel_poll',
'ssh_channel_poll_timeout' and 'ssh_channel_get_exit_status' would
compare the channel state to the 'SSH_CHANNEL_FLAG_FREED_LOCAL'
constant to check if the channel is alive.  But the procedures must
check the channel flags for the presence of
'SSH_CHANNEL_FLAG_FREED_LOCAL' bits instead.  This change fixes the
bug.

Signed-off-by: Artyom V. Poptsov <poptsov.artyom@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-09-15 11:04:45 +02:00
Andreas Schneider
76b7e0e9b5 cpack: Do not package .cache directory used by clangd
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-08-26 14:58:38 +02:00
Jakub Jelen
f8817c0c35 tests: Simple reproducer for rekeying with different kex
We do not use SHA1 as it is disabled in many systems

Verifies CVE-2021-3634

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-08-18 14:13:56 +02:00
Jakub Jelen
f5211239f9 CVE-2021-3634: Create a separate length for session_id
Normally, the length of session_id and secret_hash is the same,
but if we will get into rekeying with a peer that changes preference
of key exchange algorithm, the new secret hash can be larger or
smaller than the previous session_id causing invalid reads or writes.

Resolves https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=35485

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-08-18 14:13:56 +02:00
Jakub Jelen
a3b2229a4e More consistent logging
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-08-18 14:13:56 +02:00
Andreas Schneider
fd9fda67f9 gitlab-ci: Fix indentation and complaints by yamllint
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-08-17 14:04:12 +02:00
Andreas Schneider
a7d2fe9503 Add editorconfig config file
See https://editorconfig.org/ for details.

(neo)vim: https://github.com/editorconfig/editorconfig-vim
emacs:    https://github.com/editorconfig/editorconfig-emacs

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-08-12 20:02:35 +02:00
Kevin Jones
188d0785e1 Update is_cert_type to account for security key certificates.
Signed-off-by: Kevin Jones <kevin@vcsjones.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-08-12 20:02:31 +02:00
Norbert Pocs
63f97a3d03 Fix some compiler warnings
Covscan analyzer was used

Signed-off-by: Norbert Pocs <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-08-12 20:02:25 +02:00
Jakub Jelen
6daa95f9c1 .gitlab-ci: Allow failure of windows runners as they are broken
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-08-11 19:33:12 +02:00
Jeremy Cross
d1abe26be3 [#48/T22] Added missing server reply on auth-agent-req when a reply was requested by the client. PuTTY for Windows chokes without this reply if "Allow agent forwarding" is enabled. Reply will be successful if channel_auth_agent_req_function callback is defined. Based on an unmerged patch by Jon Simons.
Signed-off-by: Jeremy Cross <jcross@beyondtrust.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-07-07 14:17:07 +02:00
Jeremy Cross
0bee5d5e97 fixed issue with ssh_connector when data has been consumed by a channel callback
Signed-off-by: Jeremy Cross <jcross@beyondtrust.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-07-07 11:05:25 +02:00
Serdar Sanli
7dfed5c3cb Fix error in documentation
Signed-off-by: Serdar Sanli <mserdarsanli@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-07-06 11:25:32 +02:00
Xiang Xiao
925dc92d52 misc: Avoid the 4KB stack buffer in ssh_bind_options_expand_escape
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Icfd24fdb8c7f549b8cb72d793cfc767979740fdc
2021-06-16 11:58:07 +02:00
Xiang Xiao
9eba361ca2 misc: Avoid the 4KB stack buffer in ssh_path_expand_escape
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I908ef4dfa960bf89f8e42f99af2f8bcdbb006bc8
2021-06-16 11:58:06 +02:00
Xiang Xiao
f2bd44969b Make the max file line length configurable
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I0bc70f4459a6eaa6f4c87887a5ee7822faf22443
2021-06-16 11:56:53 +02:00
Xiang Xiao
dbe504ea0a Make the transfer buffer size configurable
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I5052bac703b5a0c289ca5c28569cadeb54d3d507
2021-06-16 11:56:44 +02:00
Xiang Xiao
14276f0b51 log: add ssh_vlog to save the stack space
and add LOG_SIZE macro to control the buffer size

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I3eaeea001fc531fdb55074fc3a9d140b27847c1f
2021-06-10 14:56:29 +02:00
Xiang Xiao
672c1f8a3a windows: Define PATH_MAX to MAX_PATH
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Ib3358ecb029d93c263d3cb39da25e82a772ae2c7
2021-06-10 09:22:32 +02:00
Jakub Jelen
592d256a0b Enable freebsd runner also for jjelen
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-06-07 11:34:32 +02:00
Jakub Jelen
aac975b7b2 Unbreak build on freebsd
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-06-07 11:28:29 +02:00
Andrew Wiley
c40576c6f6 add moduli file location as an ssh_bind option
Signed-off-by: Andrew Wiley <wiley@outlook.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-06-04 22:27:51 -07:00
Andrew Wiley
6aa88e22d6 build samplesshd-cb example on Windows too
Signed-off-by: Andrew Wiley <wiley@outlook.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-06-04 22:27:51 -07:00
Andrew Wiley
bd7bef8b50 fix error checks on channel writes in samplesshd-cb example
Signed-off-by: Andrew Wiley <wiley@outlook.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-06-04 22:27:51 -07:00
Andrew Wiley
fb8d120bec make GSSAPI optional in the samplesshd-cb example
Signed-off-by: Andrew Wiley <wiley@outlook.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-06-04 22:27:51 -07:00
Xiang Xiao
286a706394 scp: Avoid allocate 8KB stack buffer in ssh_scp_deny_request
since ssh_scp_deny_request is seldom called, let's
utilize malloc to reserve the precise size memory.

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I8e7a6d3153cff7691329b9487cd534a7f2887a35
2021-06-01 10:48:41 +08:00
Xiang Xiao
b6b5c59223 socket: Read the data directly into in_buffer
to avoid allocate 4KB buffer from stack

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Id144ff764ee1ae98f87aee36793a9f0e4fce21b7
2021-05-31 21:44:08 +02:00
Xiang Xiao
f7369423a4 agent: Avoid 1KB temporary buffer in agent_talk
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I9acffc6deef534659f89ca8ddb0cd60b325aaeb2
2021-05-31 21:36:26 +02:00
Xiang Xiao
a8a74a70fa examples/ssh_server_fork: Support the multi-client through pthread
so the same code base demo both multi-process and multi-thread model

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I98554a99b7a31586be37abde7c357f81a05c3d6e
2021-05-31 12:21:42 +02:00
Xiang Xiao
3b29e2ad4c sftp: Read the data directly into packet->payload
to avoid allocate 16KB buffer from stack and one memory copy

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Ib71cb5834b7810bf9791e13c58571e2b9fa5bca1
2021-05-27 13:45:47 +02:00
Xiang Xiao
3ab17e3fbd channels: Read into buffer directly in channel_read_buffer
to avoid allocate 8KB buffer from stack

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Ifc198705cb8ecec6f0a609f84965382dc151693b
2021-05-27 13:45:47 +02:00
Xiang Xiao
c027585a50 Don't allocate ssh_blf_ctx from stack in bcrypt_pbkdf
to reduce the stack size requirement

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I6a91250524786af3358b0fd0f05ba8e45f76d278
2021-05-27 13:45:47 +02:00
Xiang Xiao
ef02e524df packet: Change the last argument of ssh_packet_encrypt to uint32_t
to match the implemntation in packet_crypt.c

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Ib76c3585f67dae22ed0f1dfc10dadcd03c762032
2021-05-27 13:45:47 +02:00
Xiang Xiao
50934a542d mbedtls: Change the last argument of cipher_[de|en]crypt_cbc to size_t
to avoid their prototype different from ssh_cipher_struct

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I6cba2d4fea131f13d028226023da692494caa87d
2021-05-27 13:45:47 +02:00
Xiang Xiao
07245c1cdd Fix error: dereferencing pointer to incomplete type ‘struct timeval’
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I99d2016595966d805c9e27b5c2f2a0a5b4ad8611
2021-05-27 13:45:47 +02:00
Xiang Xiao
094aeeafbe examples/ssh_server: Free the resource in the failure path
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I60f64b9eda3ba233a825b2c4fe19d5bf7eaf2fa3
2021-05-27 13:45:47 +02:00
Sahana Prasad
cfd883196d Fixes typo in src/buffer.c
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-05-27 13:45:47 +02:00
Xiang Xiao
d2182bb7af Replace the hardcode max path length with PATH_MAX
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Icb1d36b48a759ec11dbaa4c09a39037a80ab0f85
2021-05-27 13:45:47 +02:00
Andreas Schneider
ae44d846b8 gitlab-ci: Enable new freebsd runner
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-05-27 13:25:02 +02:00
Andreas Schneider
dfcf793a9f doc: Add REAMDE how to setup a freebsd gitlab runner
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-05-27 13:25:02 +02:00
Andreas Schneider
7657994aed gitlab-ci: Use shared Windows runners from gitlab
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-05-27 11:59:38 +02:00
Andreas Schneider
7ab6194a82 gitlab-ci: Disable the freebsd runner
We need a new one. Disable till set up and registered

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-05-26 17:43:49 +02:00
Andreas Schneider
d2a41e606b tests: Fix running timeout tests on gitlab windows runners
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-05-26 17:36:51 +02:00
Xiang Xiao
9b7c4307a4 examples/ssh_client: Fix the memory leak in RTOS environment
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I20108753cf0b86e18724171dc7b25790350edb08
2021-05-12 16:01:18 +02:00
Xiang Xiao
c9e6461546 examples/ssh_client: call ssh_init explicitly
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I52011de66a9e1a6a318fcb91fb7357cd97c534a3
2021-05-12 16:01:18 +02:00
Xiang Xiao
5c919c4edb examples/ssh_server: Support the command line parser without argp package
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Ia39a402e4684d2f0ef014b4effd255692b576ce3
2021-05-12 16:01:18 +02:00
Xiang Xiao
9bff4cb9b9 examples/ssh_server: Add -u and -P option
enable pass username and password from command line

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I6404b90a99253d3240f7a28827635b159ff6a574
2021-05-12 16:01:18 +02:00
Xiang Xiao
43a31b81f2 examples/libssh_scp: Remove the duplication of free(loc->host)
and free sources at the end of program

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: Ia6a51d52439722b46547449e85350b3193e5ba28
2021-05-12 16:01:18 +02:00
Xiang Xiao
46624648f9 examples/libssh_scp: call ssh_init and ssh_finalize explicitly
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I4c80904d40b068f47334c3116576de07782162f6
2021-05-12 16:01:18 +02:00
Xiang Xiao
e909bde2c5 examples/ssh_client: Check SIGWINCH is defined before using it
since not all POSIX platform support SIGWINCH signal
and remove the global variable chan

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Change-Id: I70217020c84b056270ed680008a1871383b5fc7b
2021-05-12 16:01:18 +02:00
Jakub Jelen
605f7fb2de Revert "Fix error: dereferencing pointer to incomplete type ‘struct timeval’"
because of inconsistent author and sign-off

This reverts commit 8ea7fc6129.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-05-12 16:01:15 +02:00
Jakub Jelen
ba04f788f4 Revert "mbedtls: Change the last argument of cipher_[de|en]crypt_cbc to size_t"
because of inconsistent author and sign-off

This reverts commit aef467ab4a.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-05-12 16:01:12 +02:00
Jakub Jelen
30b548af02 Revert "packet: Change the last argument of ssh_packet_encrypt to uint32_t"
because of inconsistent author and sign-off

This reverts commit 053ed5bd91.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-05-12 16:00:49 +02:00
Jakub Jelen
9e0d76fb67 ed25519: Harmonize arguments to make new gcc happy
This started failing CI on Fedora with new GCC

/builds/jjelen/libssh-mirror/src/external/ed25519.c:80:48: error: argument 1 of type 'unsigned char *' declared as a pointer [-Werror=array-parameter=]
   80 | int crypto_sign_ed25519_keypair(unsigned char *pk,
      |                                 ~~~~~~~~~~~~~~~^~
In file included from /builds/jjelen/libssh-mirror/src/external/ed25519.c:15:
/builds/jjelen/libssh-mirror/include/libssh/ed25519.h:46:48: note: previously declared as an array 'uint8_t[32]' {aka 'unsigned char[32]'}
   46 | int crypto_sign_ed25519_keypair(ed25519_pubkey pk, ed25519_privkey sk);
      |                                 ~~~~~~~~~~~~~~~^~
/builds/jjelen/libssh-mirror/src/external/ed25519.c:81:48: error: argument 2 of type 'unsigned char *' declared as a pointer [-Werror=array-parameter=]
   81 |                                 unsigned char *sk)
      |                                 ~~~~~~~~~~~~~~~^~
In file included from /builds/jjelen/libssh-mirror/src/external/ed25519.c:15:
/builds/jjelen/libssh-mirror/include/libssh/ed25519.h:46:68: note: previously declared as an array 'uint8_t[64]' {aka 'unsigned char[64]'}
   46 | int crypto_sign_ed25519_keypair(ed25519_pubkey pk, ed25519_privkey sk);
      |                                                    ~~~~~~~~~~~~~~~~^~
/builds/jjelen/libssh-mirror/src/external/ed25519.c:117:46: error: argument 5 of type 'const unsigned char *' declared as a pointer [-Werror=array-parameter=]
  117 |                         const unsigned char *sk)
      |                         ~~~~~~~~~~~~~~~~~~~~~^~
In file included from /builds/jjelen/libssh-mirror/src/external/ed25519.c:15:
/builds/jjelen/libssh-mirror/include/libssh/ed25519.h:61:27: note: previously declared as an array 'const uint8_t[64]' {aka 'const unsigned char[64]'}
   61 |     const ed25519_privkey sk);
      |     ~~~~~~~~~~~~~~~~~~~~~~^~
/builds/jjelen/libssh-mirror/src/external/ed25519.c:180:51: error: argument 5 of type 'const unsigned char *' declared as a pointer [-Werror=array-parameter=]
  180 |                              const unsigned char *pk)
      |                              ~~~~~~~~~~~~~~~~~~~~~^~
In file included from /builds/jjelen/libssh-mirror/src/external/ed25519.c:15:
/builds/jjelen/libssh-mirror/include/libssh/ed25519.h:76:26: note: previously declared as an array 'const uint8_t[32]' {aka 'const unsigned char[32]'}
   76 |     const ed25519_pubkey pk);
      |     ~~~~~~~~~~~~~~~~~~~~~^~

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2021-05-10 13:18:11 +02:00
Xiang Xiao
8ea7fc6129 Fix error: dereferencing pointer to incomplete type ‘struct timeval’
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
Change-Id: I99d2016595966d805c9e27b5c2f2a0a5b4ad8611
2021-05-10 12:17:54 +02:00
Xiang Xiao
aef467ab4a mbedtls: Change the last argument of cipher_[de|en]crypt_cbc to size_t
to avoid their prototype different from ssh_cipher_struct

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
Change-Id: I6cba2d4fea131f13d028226023da692494caa87d
2021-05-10 12:17:36 +02:00
Xiang Xiao
053ed5bd91 packet: Change the last argument of ssh_packet_encrypt to uint32_t
to match the implemntation in packet_crypt.c

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
Change-Id: Ib76c3585f67dae22ed0f1dfc10dadcd03c762032
2021-05-10 12:17:17 +02:00
Andreas Schneider
b59184fc89 doc: Fix uninitialized variable in example code
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-04-01 11:58:32 +02:00
Jakub Jelen
d5099dec54 gitlab-ci: Run basic test with ninja
v1: Move to the test stage

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-03-30 14:43:04 +02:00
DDoSolitary
5904f19592 gitlab-ci: fix typo ADDTIONAL
Signed-off-by: DDoSolitary <DDoSolitary@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-03-26 16:18:34 +08:00
DDoSolitary
1a24b424ef cmake: Fix Ninja multiple rules error
Currently "cmake -G Ninja" complains about "multiple rules generate
src/libssh_dev.map", because the target has the same name as the output
of the custom command.

Signed-off-by: DDoSolitary <DDoSolitary@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2021-03-25 16:39:36 +01:00
Jakub Jelen
25f9ca83a4 tests: Cover sftp_new_channel function
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2021-03-18 14:44:35 +01:00
Pablo Yaggi
51b7a2421a fix sftp_new_channel constructs an invalid object
Fixes T273

Signed-off-by: Pablo Yaggi <pyaggi@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2021-03-18 14:44:35 +01:00
Jakub Jelen
78036e98ec Reformat sftp_new_channel
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2021-03-18 14:44:35 +01:00
Jakub Jelen
c10d06b322 Reformat sftp_server_new
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Sahana Prasad <sahana@redhat.com>
2021-03-18 14:44:35 +01:00
Chris Townsend
a5bb333422 [winlocks] Include stdlib.h to avoid crash in Windows
Due to the missing include, the compiler makes assumptions and leads to
a crash in ssh_mutex_lock() during runtime.

Signed-off-by: Chris Townsend <christopher.townsend@canonical.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-03-11 09:02:08 -05:00
DDoSolitary
c8b2e68fb8 cmake: Support build directories with special characters
Signed-off-by: DDoSolitary <DDoSolitary@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-02-15 10:04:31 +01:00
DDoSolitary
0679945383 cmake: Avoid setting compiler flags directly
Calling set_target_properties directly overrides previously set flags,
so replace them with target_compile_definitions and target_link_options.

Signed-off-by: DDoSolitary <DDoSolitary@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-02-04 18:04:15 +08:00
Jakub Jelen
b90cc79cbe pki: Fix memory leak on error path
Thanks coverity

CID 1445481

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-01-28 20:33:03 +01:00
Jakub Jelen
cb7ce1813b tests: Verify the configuration can set more identity files from one configuration file
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-01-28 19:11:58 +01:00
Jakub Jelen
a9061ab434 config: Support more identity files in configuration
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-01-28 19:11:58 +01:00
Jakub Jelen
ae809b3cbb dh-gex: Avoid memory leaks
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=29611
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-01-15 19:24:05 +01:00
Anderson Toshiyuki Sasaki
8e56585c72 tests/external_override: Add override test for internal implementations
This adds a test to check if the internal implementation is not used
when it is not supposed to be used.

To be able to override functions using LD_PRELOAD, a shared version of
the torture library was added, as well as a shared library for each
of the algorithms implemented internally (ChaCha20, Poly1305,
curve25519, and ed25519).

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-12 12:54:18 +01:00
Anderson Toshiyuki Sasaki
d4258d1461 libmbedcrypto: Fix chacha20-poly1305
Previously, the mbed TLS implementation wouldn't be use at all when
available, being the internal implementation always used instead.

This corrects few bugs and makes the mbed TLS implementation to be used
when ChaCha20 and Poly1305 are available.

This also makes the constant time comparison to be used when checking
the authentication tag.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-12 12:54:18 +01:00
Anderson Toshiyuki Sasaki
c50cfe7fc7 chachapoly: Use secure_memcmp() to compare auth tag
When checking the authentication tag, use secure_memcmp() instead of
memcmp().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-12 12:54:18 +01:00
Anderson Toshiyuki Sasaki
486ad81974 libcrypto: Use CRYPTO_memcmp() instead of memcmp
When comparing the authentication tag for chacha20-poly1305, use the
constant time CRYPTO_memcmp() instead of memcmp().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-12 12:54:18 +01:00
Anderson Toshiyuki Sasaki
c3ae1336fb packet_crypt: Move secure_memcmp() to a shared source
Move the secure_memcmp() function to a shared source to make it
available internally for other crypto implementations.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-12 12:54:18 +01:00
Jakub Jelen
95a4651d86 Clean memory on failure paths
Thanks oss-fuzz:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28490

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-01-12 12:46:25 +01:00
Jakub Jelen
832abe7f4a include: Introduce secure SSH_SIGNATURE_FREE()
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2021-01-12 12:46:24 +01:00
Anderson Toshiyuki Sasaki
cdac4fca5f torture_session: Test delayed close
The test for delayed close asks for the execution of a command that
generates big output (larger than the default window) to make data to
remain in buffers while the close message arrives, triggering the
delayed channel closure.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2021-01-11 20:46:02 +01:00
Tom Deseyn
a4b8045fb8 channel_rcv_close: indentation
Signed-off-by: Tom Deseyn <tom.deseyn@gmail.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2021-01-11 20:46:02 +01:00
Tom Deseyn
44dfee778f channesl: Fix delayed close
If the SSH2_MSG_CHANNEL_CLOSE was previously received, change the
channel state to SSH_STATE_CHANNEL_CLOSED in
ssh_channel_read_timeout() after reading all data available.

Fixes T31

Signed-off-by: Tom Deseyn <tom.deseyn@gmail.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2021-01-11 20:38:24 +01:00
Dirkjan Bussink
710815674a Cleanup AES compatibility code
OpenSSL 1.0.1 has support for CTR & GCM modes so the checks here are no
longer needed. This allows for a bunch of additional cleanup of the old
code.

As for old MacOS versions etc, LibreSSL is a kind of compatibility layer
there but things already don't work anyway with that, so it doesn't
break anything that isn't already broken. OpenSSL is needed on MacOS
separately anyway (like installed with Homebrew).

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-11 10:45:22 +01:00
Dirkjan Bussink
816f06e172 Remove no longer needed compatibility check
CRYPTO_THREADID_set_callback is available since 1.0.1 which is the
oldest supported version. This means the check and compatibility code
can be removed.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-11 10:45:22 +01:00
Dirkjan Bussink
38806e1dd8 Remove no longer needed compatibility function
Since OpenSSL 1.0.1 is the minimum version, this function is always
available so no compatibility check is needed anymore.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-11 10:45:22 +01:00
Dirkjan Bussink
a1e8c985d1 Remove compat reset function
This can be implemented with the init directly when the context is
reused. When a new cipher context is allocated, no initialization call
is needed either so this moves the logic to one place as well.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-11 10:45:22 +01:00
Dirkjan Bussink
da36ecd6f2 Move HMAC implementation to EVP API
Now that the minimum OpenSSL version is 1.0.1, we know that the EVP HMAC
API is always available. This switches to this API. The existing API is
deprecated for OpenSSL 3.0.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-11 10:45:22 +01:00
Dirkjan Bussink
385ac0911d Fix formatting for file with changes
This fixes the formatting for src/libcrypto.c for the last bits where it
is not correct.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-11 10:45:22 +01:00
Dirkjan Bussink
1991bdac0d Remove unneeded version conditional
The HMAC_CTX_free function in the compat layer already handles this so
there's no need to add conditional logic to the code here.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-11 10:45:22 +01:00
Dirkjan Bussink
8eb15e5cff Use correct cleanup function for cipher context
This specific cleanup function describes better what happens here and is
available for older OpenSSL releases.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-11 10:45:22 +01:00
Dirkjan Bussink
8852fd3ac9 Remove unneeded HMAC_CTX_reset function
This isn't referenced anywhere outside of the compatibility layer so it
is unneeded.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-11 10:45:22 +01:00
Dirkjan Bussink
41c08986ae Remove unneeded EVP_MD_CTX_reset custom cleanup
The EVP_MD_CTX_reset function is not used anywhere outside of the compat
layer and is not needed there. The only usage in the compat layer is for
cleanup, but EVP_MD_CTX_cleanup can be used for that which is availble
at least since OpenSSL 0.9.8.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-11 10:45:22 +01:00
Dirkjan Bussink
b6bf5bfd15 Improve cleanup logic for HMAC
Older OpenSSL version have a cleanup function that can be used here.
This removes a whole bunch of now no longer needed logic and custom
conditionals.

These functions have existed since 0.9.8 and can be used here.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-11 10:45:22 +01:00
Dirkjan Bussink
d1806a523c Remove OPENSSL_zalloc helper
This function is not needed, because in each case it is used, we follow
it up immediately with an initialization function call. This means that
the zeroing here is unneeded, since the initialization already
guarantees things end up in the right state.

It also swaps the reset call with a simpler init call, also because
reset is implemented as init with a return value that is always 1. That
means the more complex logic is not needed at all.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-11 10:45:22 +01:00
Dirkjan Bussink
ba88e0fba5 Use current OpenSSL API as the example
EVP_MD_CTX_new / EVP_MD_CTX_free is the current recommended / documented
API. The other names are defined as aliases for backwards compatibility.

The other part here is that EVP_MD_CTX_init is not needed for a context
allocated with EVP_MD_CTX_new. Only for the compatibility path for older
OpenSSL is the init needed if the structure is allocated directly.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2021-01-11 10:45:22 +01:00
Andreas Schneider
6f934cc488 Happy new year 2021!
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2021-01-01 16:08:30 +01:00
Dirkjan Bussink
d005163ace Require at least OpenSSL 1.0.1
This is now the minimum version, so check it in the CMake configuration.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-12-22 09:15:38 +01:00
Dirkjan Bussink
7e99867533 Cleanup old OpenSSL 0.9.7 compatibility code
OpenSSL 0.9.7 is already not supported, so clean up the old legacy bits
for that as well.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-12-22 09:15:38 +01:00
Dirkjan Bussink
e20fe54f3f Bump minimum version requirement for OpenSSL
This updates the minimum version requirement for OpenSSL in the
documentation to 1.0.1 and also updates the practical minimum CMake
version.

Why pick 1.0.1 as the minimum? Main reason is whatever is still out
there with long term support contracts etc. One of the oldest I could
find is Ubuntu 14.04 which still has paid extended support and is on
1.0.1.

Another reason that 1.0.1 is probably a good minimum is a bit more
involved. 1.0.1 is the first version to add TLS 1.2. Large parts of the
internet have TLS 1.2 as a minimum requirement. This means that systems
with OpenSSL older than 1.0.1 already can't access large parts of the
internet anyway, so not supporting the latest libssh there either is ok
I think.

Bumping minimum support also means things like the HMAC API can be moved
to the more recent EVP style APIs and things can be more easily made
compatible with the deprecated APIs in OpenSSL 3.0.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-12-22 09:15:38 +01:00
Kevin Kane
919387ae64 Fix CMake warning about mismatched if/endif arguments during OpenSSL detection
Signed-off-by: Kevin Kane <kkane@microsoft.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-12-14 11:14:30 +01:00
Dirkjan Bussink
0987e6065c Always check return value of ssh_list_new()
Another item identified during code review was cases where the return
value of ssh_list_new() was not properly checked and handled. This
updates all cases that were missing this to handle failure to allocate a
new list.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-12-11 13:35:20 +01:00
Dirkjan Bussink
daeee74edd Add safety checks for all ssh_string_fill calls
These calls can fail and the return code should always be checked. These
issues were identified when code review called it out on new code. The
updates here are to existing code with no behavior changes to make
review simpler.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-12-11 13:32:02 +01:00
Dirkjan Bussink
f6a2f6190c Ignore request success and failure message if they are not expected
In https://gitlab.com/libssh/libssh-mirror/-/merge_requests/145#note_463232084
behavior in libssh was identified where it diverges from how for example
OpenSSH behaves. In OpenSSH if a request success of failure message is
received, apart from it being treated as a keepalive message, it is
ignored otherwise.

Libssh does handle the unexpected message and triggers an error
condition internally. This means that with the Dropbear behavior where
it replies to a hostkeys-00@openssh.com message even with a want_reply
= 0 (arguably a bug), libssh enters an error state.

This change makes the libssh behavior match OpenSSH to ignore these
messages. The spec is a bit unclear on whether Dropbear is buggy here or
not, but let's be liberal with the input accepted here in libssh.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-12-11 13:29:46 +01:00
Kevin Kane
3c33c39455 Provide OPENSSL_CRYPTO_LIBRARIES synonym for OPENSSL_CRYPTO_LIBRARY
FindOpenSSL.cmake usually defines this synonym, but it doesn't on CMake < 3.16 when building on Windows outside of Cygwin.

Signed-off-by: Kevin Kane <kkane@microsoft.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-12-10 19:38:59 +01:00
Kevin Kane
a0e19239b8 Use OPENSSL_CRYPTO_LIBRARIES CMake variable when linking against OpenSSL
The build currently breaks when attempting to link libssh.so using a statically-linked OpenSSL. -ldl and -lpthread are required when linking a binary with the static libcrypto.a. The OPENSSL_CRYPTO_LIBRARY does not include these dependencies when linking against static OpenSSL. OPENSSL_CRYPTO_LIBRARIES contains the correct dependencies in both static and shared configurations; -ldl and -lpthread are not required when linking against shared libcrypto.so.

This change changes all uses of OPENSSL_CRYPTO_LIBRARY to OPENSSL_CRYPTO_LIBRARIES to let the FindOpenSSL CMake module always provide the correct libraries at link time.

Signed-off-by: Kevin Kane <kkane@microsoft.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-12-10 19:38:59 +01:00
Andreas Schneider
b36a5988be Revert "cmake: Use OPENSSL_CRYPTO_LIBRARIES CMake variable when linking against OpenSSL"
This reverts commit 026879e9f0.
2020-12-10 10:16:52 +01:00
Marius Vollmer
abc88c025c auth: Add ssh_userauth_publickey_auto_get_current_identity()
Signed-off-by: Marius Vollmer <mvollmer@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-12-10 09:22:13 +01:00
Kevin Kane
026879e9f0 cmake: Use OPENSSL_CRYPTO_LIBRARIES CMake variable when linking against OpenSSL
The build currently breaks when attempting to link libssh.so using a
statically-linked OpenSSL. -ldl and -lpthread are required when linking
a binary with the static libcrypto.a. The OPENSSL_CRYPTO_LIBRARY does
not include these dependencies when linking against static OpenSSL.
OPENSSL_CRYPTO_LIBRARIES contains the correct dependencies in both
static and shared configurations; -ldl and -lpthread are not required
when linking against shared libcrypto.so.

This change changes all uses of OPENSSL_CRYPTO_LIBRARY to
OPENSSL_CRYPTO_LIBRARIES to let the FindOpenSSL CMake module always
provide the correct libraries at link time.

Signed-off-by: Kevin Kane <kkane@microsoft.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-12-10 09:17:55 +01:00
Andreas Schneider
4708fc3b10 gitlab-ci: Fix packaging artifacts for Coverity runner
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-12-09 18:03:23 +01:00
Jakub Jelen
9c6404aa49 wrapper: Avoid memory leak on errors during key exchange
As reported by oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=28075

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-12-08 14:54:25 +01:00
Jakub Jelen
455a161ed7 fuzz: Extend readme for reproducing and debugging tips
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-12-08 14:54:25 +01:00
Stanislav Zidek
51f220fd41 tests for parsing configuration string; rework and many fixes
Signed-off-by: Stanislav Zidek <szidek@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-11-03 18:23:47 +01:00
Stanislav Zidek
b25feb3386 New API for parsing configuration from string
Fixes T248

Signed-off-by: Stanislav Zidek <szidek@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-11-03 18:23:47 +01:00
Jakub Jelen
635edc8adb tests: Disable *cbc ciphers in Dropbear tests
These are disabled in latest since Dropbear 2020.79, while
older do not support anything better than aes-ctr ciphers.

We should implement some dynamic algorithm detection for dropbear
too to increase test coverage.

https://bugs.libssh.org/T252

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-11-02 16:03:58 +01:00
Dirkjan Bussink
42741b1883 Fix handshake bug with AEAD ciphers and no HMAC overlap
There's currently a bug in libssh that a handshake doesn't complete if
there is no overlap between HMAC methods, but when an AEAD cipher is
used.

In case of an AEAD cipher such as chacha20-poly1305 or aes256-gcm, the
HMAC algorithm that is being picked is not relevant. But the problem
here is that the HMAC still needs to have an overlap in the handshake,
even if it is not used afterwards.

This was found with a very strict server side configuration with libssh
where only AEAD ciphers and EtM HMAC modes are accepted. The client
tested against was dropbear.

Dropbear does have support for chacha20-poly1305 and AES GCM modes, but
no support for EtM HMAC modes. This meant that the libssh server in this
case rejected the dropbear client, even though it is perfectly able to
serve it since dropbear supports AEAD algorithms.

The fix implemented here updates the HMAC phase of the handshake to
handle this case. If it detects an AEAD cipher is used, it uses the HMAC
abbreviations for the method instead. This is the same name that is used
in other places as well. It matches the client to server and server to
client values, but it does depend on the order of things in the
ssh_kex_types_e enum, which I'm assuming here is ok since it's explicit.

I've looked at how to add a test for this, but I couldn't really find a
suitable place for it. I would love some tips if this is easily
possible, or if it's easier for someone else to contribute, that's of
course welcome too.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-10-14 11:07:40 +02:00
Dirkjan Bussink
39cbe8178e Add initial server algorithm test for no HMAC overlap
This adds an initial test with all AEAD modes to verify that they work
if there is no overlap in HMAC ciphers.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-10-14 11:07:22 +02:00
Jakub Jelen
22f89e043b tests: Test MAC algorithm mismatch when AEAD cipher is selected
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-10-14 11:07:18 +02:00
Jakub Jelen
f9bd1db8c3 torture: Place additional configuration options before defaults so they can override them
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-10-14 11:07:14 +02:00
Jakub Jelen
5348267fa8 client: Reset pending_call_state on disconnect
Fixes T251

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-10-02 12:39:41 +02:00
Jakub Jelen
ccb5d6e0ac client: Reformat ssh_disconnect()
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-10-02 12:39:41 +02:00
Paul Capron
693383d1ef README: Mention CONTRIBUTING not SubmittingPatches
The “SubmittingPatches” file is no more since commit
a76badf77a, but the READMEs were still
referencing it.
They now correctly point to “CONTRIBUTING.md”.

Signed-off-by: Paul Capron <paul@fragara.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-09-29 13:05:34 +02:00
Paul Capron
a6f4f9b43a ChangeLog: Fix typo; “wierdness” → “weirdness”
“Wierdness” is… a weird word ^o^

Signed-off-by: Paul Capron <paul@fragara.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-09-29 13:05:34 +02:00
Paul Capron
03d7f7e9eb ChangeLog: Remove duplicate “version 0.3.1” entry
There were two identical entries for v0.3.1, next to each other.

Signed-off-by: Paul Capron <paul@fragara.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-09-29 13:05:34 +02:00
Paul Capron
400f4f2329 pki_gcrypt.c: Fix typo + inconsistency in warning
In function pki_signature_from_blob(), the warning message in case of
an oversized RSA key was missing an ‘o’ (reading “to” instead of “too”).

While we are here, make this oversized message the same than the ones
found in pki_crypto.c & pki_mbedcrypto.c: put the expected size in it.
The message in case of an _under_sized key include the expected size,
so that’s more consistent in that regard too (and more informative!)

Signed-off-by: Paul Capron <paul@fragara.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-09-29 13:05:34 +02:00
Paul Capron
b3a11e0185 priv.h: Fix typo in comment; “cound” → “count”
Signed-off-by: Paul Capron <paul@fragara.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-09-29 13:05:34 +02:00
Paul Capron
cbd48c497f priv.h: Fix “MAX_PACKAT_LEN” typo in #ifndef guard
The preprocessor guard was previously effectively inoperative;
it used to read “MAX_PACKAT_LEN” (note the ‘A’!), now is ‘E’.

Signed-off-by: Paul Capron <paul@fragara.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-09-29 13:05:34 +02:00
Sahana Prasad
cc953ff7e4 src/kex.c: removes DES and SHA1 from mac and kex algorithms by default.
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-09-29 11:35:51 +02:00
Anderson Toshiyuki Sasaki
d10f971bbb misc: Do not call random()
Avoid calling random() and use ssh_get_random() instead.

CID #1412376

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-09-17 10:45:25 +02:00
Dirkjan Bussink
e4c5f6d3d9 Fix another memory leak on invalid nid value
In 906cc7e7e9 a memory leak was fixed but
a similar one is present here that needs a fix as well.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-09-03 17:16:18 +02:00
Sahana Prasad
b052f665c9 ConfigureChecks.cmake: Disable HAVE_DSA by default (when mbedTLS is not enabled)
Ensure that it is not possible to enable it back with mbedTLS

Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-09-02 14:35:43 +02:00
Jakub Jelen
ff599a9c53 Add a new location of sftp-server on Tumbleweed
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-09-02 14:17:23 +02:00
Anderson Toshiyuki Sasaki
be419dee0d README.md: Add OSS-Fuzz badge
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-08-13 18:31:56 +02:00
Jakub Jelen
88d4fa5352 sftp: Fix more typos
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-08-12 13:13:13 +02:00
Harald Sitter
c0b65ccc5a sftp: fix documentation typos
Signed-off-by: Harald Sitter <sitter@kde.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-08-12 13:09:16 +02:00
Anderson Toshiyuki Sasaki
7aad964cef tests: Add test case for T191
Add a test case to verify that the server returns the correct signature
when it negotiated an RSA signature algorithm for the host key different
from the one it prefers (e.g. when the client prefers ssh-rsa over
rsa-sha2-256 and rsa-sha2-512).

Fixes T240

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-07-16 12:22:11 +02:00
Anderson Toshiyuki Sasaki
3e23fb8a24 tests: Add a test case for T75
The test checks if the client can handle the error returned by the
server when the maximum number of channel sessions is exceeded.

Fixes T239

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-07-16 12:17:10 +02:00
Jakub Jelen
90e56df74e Disable *-cbc ciphers by default
OpenSSH disabled them in 2014 and 2017 for servers and clients so its our
turn to follow the suit.

Fixes T236

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-07-16 12:01:04 +02:00
Jakub Jelen
906cc7e7e9 pki: Avoid memory leak on invalid curve NID
Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24166

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-07-16 12:01:04 +02:00
Jakub Jelen
f85464b900 packet: Fix unterminated brace and better context name in debug message
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-07-16 12:01:04 +02:00
Jakub Jelen
dcae43fa6b misc: Do not confuse client/server in debug messages
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-07-16 12:01:04 +02:00
Anderson Toshiyuki Sasaki
f10d80047c tests: Do not parse configuration file in torture_knownhosts
The test might fail if there is a local configuration file that changes
the location of the known_hosts file.  The test should not be affected
by configuration files present in the testing environment.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-06-24 11:35:23 +02:00
Anderson Toshiyuki Sasaki
750e4f3f9d channel: Do not return error if the server closed the channel
If the server properly closed the channel, the client should not return
error if it finds the channel closed.

Fixes T231

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-06-23 16:14:27 +02:00
Anderson Toshiyuki Sasaki
b0518552f1 examples: Tolerate incomplete writes in exec example
Previously, the exec example would fail if it could not write the whole
read buffer to stdout.  With this changes, the exec example will be able
to write parts of the buffer until the whole buffer is written.

This makes the exec example to run when the stdout buffer is small.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-06-22 13:58:52 +02:00
Anderson Toshiyuki Sasaki
1694606e12 tests: Add test for CVE-2019-14889
The test checks if a command appended to the file path is not executed.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-06-22 13:54:07 +02:00
Andreas Schneider
a76badf77a Merge SubmittingPatches and README.CodingStyle to CONTRIBUTING.md
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-06-19 16:48:14 +02:00
Andreas Schneider
245ad744b5 buffer: Add NULL check for 'buffer' argument
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-06-03 10:40:06 +02:00
Andreas Schneider
10b3ebbe61 buffer: Reformat ssh_buffer_add_data()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-06-03 10:40:04 +02:00
Andreas Schneider
2782cb0495 sftpserver: Add missing return check for ssh_buffer_add_data()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-06-03 10:38:40 +02:00
Andreas Schneider
533d881b0f sftpserver: Add missing NULL check for ssh_buffer_new()
Thanks to Ramin Farajpour Cami for spotting this.

Fixes T232

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-06-03 10:38:34 +02:00
Jakub Jelen
866e4442b5 Removed old, 10 years unused test files
They do not build anymore and I believe most of their functionality is already
covered by new testst.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-21 13:34:23 +02:00
Jakub Jelen
39bb93a53b options: Do not reference non-existing function
Fixes T227

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-21 13:34:23 +02:00
Sahana Prasad
4e4711d2fb unittests: updates torture_pki_ecdsa_uri test by adding negative test cases to ensure there is no crash when
ssh_pki_export_pubkey_blob() is incorrectly used to export ecdsa pubkeys from privkeys
           when pubkeys are not imported into pkcs #11 tokens.

Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-05-20 12:49:29 +02:00
Sahana Prasad
7eb6c7ee6c tests/torture.c: update the definition of torture_setup_tokens() to take load_public as an option that
determines if public keys must be loaded in pkcs #11 tokens or not.
tests:           Adds the load_public parameter in all files where torture_setup_tokens() was used.

Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-05-20 12:49:29 +02:00
Sahana Prasad
d3f7b64579 tests/pkcs11/setup-softhsm-tokens.sh: updates the script to handle LOADPUBLIC parameter.
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-05-20 12:49:29 +02:00
Sahana Prasad
7de9722d23 src/pki_crypto.c pki_publickey_to_blob() should not be used to export public key from
private keys for ecdsa keys.
                 ssh_userauth_publickey() calls ssh_pki_export_pubkey_blob() and tries to export
                 the the public key from private key if public keys are not already imported
                 into pkcs #11 tokens.

Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-05-20 12:49:29 +02:00
David Wedderwille
641a80be74 cmake: add _POSIX_SOURCE
Fixes T228

Signed-off-by: David Wedderwille <davidwe@posteo.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-05-15 18:39:21 +02:00
Heiko Thiery
bee8ed82ab cmake: Add autogenerated libssh_version.h
Set the cmake project verision to the autogenerated file to have a single
point to set the version. This will be included in the libssh.h file.

Pair-Programmed-With: Andreas Schneider <asn@cryptomilk.org>
Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-05-06 13:02:32 +02:00
Jakub Jelen
4149cebd64 fuzz: Avoid warnings from csbuild in fuzzers
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:29:16 +02:00
Jakub Jelen
425c02cb94 fuzz: Add instructions for corpus creation and first corpus files
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:29:13 +02:00
Jakub Jelen
ad8dedd4a4 fuzz: Allow to increase log level from server fuzzer
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
e26e98e59f fuzz: Do not parse configuration files
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
ae184db913 fuzz: Use none cipher and MAC
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
b88aa98550 Allow example client and server to process different configuration files
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
08a70bb474 tests: Cover ssh_options_getopt with unit tests
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
3d0ecd37fe options: Avoid memory leaks during modification of argv
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
2e7ca3e8a6 options: Properly handle unknown options with arguments
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
b90131dfe6 tests: Verify functionality of none cipher and mac
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
4f976ce5c4 packet: Skip HMAC handling if none is selected
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
239eef6322 packet: Check if set_*_key functions exists before calling it
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
201fd66176 packet: Use temporary variables to avoid long lines
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
e6aee24a1e Add basic support for none cipher and MACs
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
46499b1b90 Drop none cipher and MAC as they are not implemented
or not intended for production

Related: T85

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
62a0229f16 fuzz: Simplify definition of fuzzing targets and build them also with gcc
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
5411e0821f fuzz: Correctly sort members initialization to prevent GCC warnings
tests/fuzz/ssh_client_fuzzer.cpp:45:1: error: designator order for field ‘ssh_callbacks_struct::userdata’ does not match declaration order in ‘ssh_callbacks_struct’

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
44de453b22 tests: Enable all CASignatureAlgorithms as SHA1 certificates are now disabled in OpenSSH 8.2p1
This option is unknown to older OpenSSH versions (for example CentOS 7
with OpenSSH 7.4) so we can not add it everywhere.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
7c20875891 pki: Mark explicit fall through
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
0c7a772301 external: Do not confuse new gcc
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Jakub Jelen
c45cfce166 client: Properly indicate fall through
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-05-05 14:23:06 +02:00
Heiko Thiery
e76332bbd6 session: add missing return value documentation
Add SSH_AGAIN as return value to ssh_handle_packets documentation.

Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-04-24 16:00:29 +02:00
Heiko Thiery
99e0ad75a6 tests: add testcases for ssh_channel_poll_timeout()
This adds testcases for the regression introduced in 3bad0607.

Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-04-24 15:57:38 +02:00
Jakub Jelen
154765ae8c config: Check null deref
As reported by LGTM

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-20 14:14:33 +02:00
Jakub Jelen
6417f5a3ca channels: Avoid returning SSH_AGAIN from ssh_channel_poll_timeout()
This addresses a regression introduced in 3bad0607, partially fixed in 022409e9,
but the function was still able to return SSH_AGAIN, which was not expected by
callers.

Based on discussion in [1] and [2]

[1] https://gitlab.com/libssh/libssh-mirror/-/merge_requests/101
[2] https://www.libssh.org/archive/libssh/2020-03/0000029.html

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-20 14:14:33 +02:00
Jakub Jelen
fe0fcbbc67 channels: reformat
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-20 14:14:33 +02:00
Jakub Jelen
c2f64108a1 examples: Avoid unused parameter warnings and reformat
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-20 14:14:33 +02:00
Jakub Jelen
59ac79c4dc gitlab-ci: Avoid passing artifacts between completely unrelated stages
The introduction of stages in gitlab-ci had quite a unfortune side
effect that is described in the documentation [1]. The whole artifacts
path (in our case obj/) is passed from one stage to another by default,
which is causing very odd behavior as the previous results are only
partially overwritten by the new cmake command and can even lead to
execution of tests that are not supposed to run in particular job.

[1] https://docs.gitlab.com/ee/ci/yaml/#dependencies

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-20 14:14:33 +02:00
Jakub Jelen
7f57717f84 gitlab-ci: Fix typo
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-20 14:14:33 +02:00
Jakub Jelen
db948bdac8 tests: Enable RSA SHA1 certs for testing against older OpenSSH
The OpenSSH 7.4 or 7.6 in Ubuntu and CentOS 7 does not support SHA2
RSA certificates and libssh automatically falls back to SHA1, which
is not allowed by default.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-20 14:14:33 +02:00
Jakub Jelen
6941958b49 tests: Update coverage of config_parser
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-20 14:14:33 +02:00
Jakub Jelen
1ba6ef689f config_parser: Allow equal sign as a separator and eat up trailing whitespace
Probably fixes T210

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-20 14:14:33 +02:00
Jakub Jelen
fecdc3cc0e Disable RSA and DSA keys with sha1 by default
Fixes: T218

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-20 14:14:33 +02:00
Jakub Jelen
04ae110c61 pkd: Enable all hostkeys
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-20 14:14:33 +02:00
Jakub Jelen
9ac2d14707 tests: Enable all host key algorithms in testing client
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-20 14:14:33 +02:00
Jakub Jelen
bab2c775da Make the testing ping use all supported algorithms
Previously, it would use only the default set, which makes some tests failing
including the DSA ones and disabled RSA with SHA1.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-20 14:14:33 +02:00
Jakub Jelen
945829a5dd Reformat ssh_bind_accept()
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-15 20:05:56 +02:00
Jakub Jelen
58d53f1397 examples: Add missing includes
Fixes: T225

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-15 20:05:56 +02:00
Jakub Jelen
eebb02fff5 libcrypto-compat: Fix indentation and return value
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-15 20:05:56 +02:00
Rosen Penev
54296787a7 libcrypto: remove deprecated API usage
EVP_CIPHER_CTX_init was replaced with _reset.

Removed EVP_CIPHER_CTX_cleanup. The successive _free call handles that.

Removed old SSLeay function usage.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-15 20:05:56 +02:00
Rosen Penev
70478619ce libcrypto-compat: add extra functions
Added extra functions. The next commit will switch to them.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-15 20:05:56 +02:00
Laurent Bigonville
a881c318ac Fix FTBFS on hurd-i386
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=933015

Signed-off-by: Laurent Bigonville <bigon@bigon.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-04-15 13:23:09 +02:00
Laurent Bigonville
5f1d0c4795 Make the documentation reproducible
Signed-off-by: Laurent Bigonville <bigon@bigon.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-04-15 13:22:47 +02:00
StefanBruens
1ff6dda616 Correctly parse v4 subsecond timestamps
All subsecond timestamps are only in the packets if both the
SUBSECOND_TIMES flag and the timestamp flag, e.g. ATTR_ACCESSTIME
are set.

SUBSECOND_TIMES are not very common across server implementations
(e.g. openssh does not include it, nor does libssh's sftpserver
implementation), but this interpretation of the SFTP protocol draft
is used by WinSCP and lftp.

Fixes T219.

Signed-off-by: Stefan Brüns <stefan.bruens@rwth-aachen.de>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-04-15 13:21:28 +02:00
Anderson Toshiyuki Sasaki
e3e3a27863 client: Check if the library is initialized in ssh_connect()
If the library is not initialized, SSH_ERROR is returned and the error
message is set properly.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-04-09 11:25:49 +02:00
Anderson Toshiyuki Sasaki
0f33eecc01 client: Reformat ssh_connect()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-04-09 11:25:49 +02:00
Anderson Toshiyuki Sasaki
dba2114ed7 init: Introduce internal is_ssh_initialized()
The introduced function returns whether the library is initialized or
not.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-04-09 11:25:49 +02:00
Anderson Toshiyuki Sasaki
e3e52394c1 init: Clarify the need to call ssh_{init, finalize}()
When libssh is statically linked, it is necessary to explicitly call
ssh_init() before calling any other provided API.  It is also necessary
to call ssh_finalize() before exiting to free allocated resources.

Fixes T222

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-04-09 11:25:49 +02:00
Andreas Schneider
b36272eac1 CVE-2020-1730: Fix a possible segfault when zeroing AES-CTR key
Fixes T213

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-09 09:28:03 +02:00
Sahana Prasad
cd15043656 src/pki_crypto.c corrects the incorrect usage of enum
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-04-06 09:27:55 +02:00
Anderson Toshiyuki Sasaki
9eb1ce88ae kex: Add support for diffie-hellman-group14-sha256
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-04-06 09:27:26 +02:00
Andreas Schneider
d2f0d3270a dh-gex: Check return value of ssh_get_random()
CID #1422162

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-04-02 07:25:53 +02:00
Andreas Schneider
a9a7c2dc29 cmake: Fix building with threading support on MinGW
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-04-01 14:35:17 +02:00
Andreas Schneider
8e00d1f0a8 gitlab-ci: Add Coverity Scan
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-03-30 09:46:18 +02:00
Andreas Schneider
fc694a5c49 gitlab-ci: Add stages
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-03-30 09:46:18 +02:00
Andreas Schneider
c79e67ca1e gitlab-ci: Use variables so we can keep before_script
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-03-30 09:46:18 +02:00
Andreas Schneider
9914809ae3 gitlab-ci: Remove the tumbleweed docs build
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-03-30 09:46:18 +02:00
Andreas Schneider
45d82b3e36 gitlab-ci: Add a simple fedora build and docs build
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-03-30 09:46:18 +02:00
Andreas Schneider
7f869e4c99 gitlab-ci: Add a build template
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-03-30 09:46:18 +02:00
Andreas Schneider
b2c7fce968 cmake: Update compile flags for UndefinedSanitizer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-03-30 09:46:18 +02:00
Jakub Jelen
960d952380 doc: Add a newly published RFC about Ed25519 keys
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-03-29 10:17:27 +02:00
Anderson Toshiyuki Sasaki
3845f77d76 tests: Mark unreachable points after fail_msg()
fail_msg() is not expected to return.  Mark the points after calling it
as unreachable to clarify this to the compiler.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-03-29 10:00:57 +02:00
Anderson Toshiyuki Sasaki
b06b936819 torture_server_config: Run the server under timeout
Timeout will kill the server if it hangs.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-03-29 10:00:57 +02:00
Anderson Toshiyuki Sasaki
3feb6ebe28 torture_server: Run the server under timeout
Use the function which starts the test server under timeout.  This way
timeout will kill the server if it hangs.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-03-29 10:00:57 +02:00
Anderson Toshiyuki Sasaki
a64737cef6 torture: Added a function to setup a libssh based server
The added function runs the test server under timeout program to kill it
if it elapses the default timeout of 5 minutes.

An auxiliary function to create a libssh server configuration file was
also added.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-03-29 10:00:57 +02:00
Anderson Toshiyuki Sasaki
f529659f76 test_server: Added an option to write PID to file
Using the added option it is possible to set a path to a file in which
the server will write its PID.

This can be used later to kill the server.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-03-29 10:00:57 +02:00
Anderson Toshiyuki Sasaki
3aea2ad53f ssh_ping: Ignore system-wide configuration
Ignore the system-wide configuration when simply trying to reach the
host.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-03-29 10:00:57 +02:00
Anderson Toshiyuki Sasaki
6bd2b93f43 auth: Fix memory leak in ssh_userauth_publickey_auto()
When a key is rejected, free the allocated memory before returning.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-03-29 09:58:19 +02:00
Andreas Schneider
46c54e5ddb doc: Fix a doxygen warning
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-03-27 12:10:07 +01:00
Andreas Schneider
bbfce454de doc: Make sure we parse the server and sftp documentation
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-03-27 12:09:57 +01:00
Andreas Schneider
3e5dc99198 doc: Add SSH auth callback to libssh_auth doc group
Fixes T217

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-03-23 15:03:25 +01:00
Anderson Toshiyuki Sasaki
c8222dc1f6 tests: Verify error returned by kill
Verify the error code returned by kill() in torture_terminate_process().
The error code is raised when killing the process failed.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-25 10:54:43 +01:00
Anderson Toshiyuki Sasaki
c5fa08a2a4 tests: Close SFTP file opened during rekey tests
The SFTP files wouldn't be closed during the rekey tests leading to
memory leak.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-24 19:30:35 +01:00
Anderson Toshiyuki Sasaki
89194e0d3a tests: Do not leave temporary SFTP directory
The temporary directory created in torture_sftp_session() wouldn't be
removed.  This removes such directory in torture_sftp_close().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-24 19:30:35 +01:00
Anderson Toshiyuki Sasaki
35224092eb tests: Use a common function to start sshd
In torture_reload_sshd_server(), instead of trying to use SIGHUP to
reload the configuration file, kill the original process and create a
new one with the new configuration.  With this change, both
torture_setup_sshd_server() and torture_reload_sshd_server() need to
start sshd, with the only difference in the configuration setup.  The
shared code to start the sshd server was moved to a new introduced
internal function torture_start_sshd_server().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-24 19:29:57 +01:00
Andreas Schneider
a9e39a41ff pki: Small code cleanup in ssh_pki_signature_verify()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-12 09:46:14 +01:00
Andreas Schneider
0ece6e52aa pki: Use SSH_BUFFER_FREE() in ssh_pki_signature_verify()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-12 09:44:58 +01:00
Andreas Schneider
f208e4b332 pki: Add missing return check for ssh_buffer_pack()
CID #1419376

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-12 09:44:17 +01:00
Andreas Schneider
9fcb559301 pki: Fix memory leak of blob on error
CID #1419377

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-12 09:41:11 +01:00
Andreas Schneider
875b2a5b59 include: Remove PRIdS definitions
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-12 09:39:06 +01:00
Andreas Schneider
702e7e4c85 channels: Replace PRIdS with ANSI C99 %zu
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-12 09:39:06 +01:00
Andreas Schneider
8542f675f4 sftp: Replace PRIdS with ANSI C99 %zu
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-12 09:39:06 +01:00
Andreas Schneider
faedadf2eb packet: Replace PRIdS with ANSI C99 %zu
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-12 09:39:06 +01:00
Sahana Prasad
73f383a2e6 doc: Documents PKCS #11 URI support for libssh
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-02-11 14:25:18 +01:00
Sahana Prasad
862b2341d7 src: updates documentation incorporate PKCS#11 URIs in import functions.
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-02-11 14:25:18 +01:00
Sebastian Kinne
17b518a677 pki: add support for sk-ecdsa and sk-ed25519
This adds server-side support for the newly introduced OpenSSH
keytypes sk-ecdsa-sha2-nistp256@openssh.com and sk-ed25519@openssh.com
(including their corresponding certificates), which are backed
by U2F/FIDO2 tokens.

Change-Id: Ib73425c572601c3002be45974e6ea051f1d7efdc
Signed-off-by: Sebastian Kinne <skinne@google.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-11 10:08:26 +01:00
Jon Simons
3664ba2800 pki: fix pki_key_ecdsa_to_key_type thread-safety
Resolves https://bugs.libssh.org/T214.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-02-11 10:08:26 +01:00
Andreas Schneider
30d03498b4 gitlab-ci: Improve setting Fedora to FIPS mode
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-01-24 09:39:44 +01:00
Andreas Schneider
022409e99c channels: Fix ssh_channel_poll_timeout() not returing available bytes
Fixes T211

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2020-01-23 10:20:59 +01:00
Jakub Jelen
07f571f1c0 Implement chacha20-poly1305 in mbedTLS
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-01-23 09:48:11 +01:00
Jakub Jelen
ac1c31bda1 tests: Skip chacha20-poly1305 tests in FIPS mode
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-01-23 09:48:11 +01:00
Jakub Jelen
60a987fd17 Implement ChaCha20-poly1305 cipher using native OpenSSL
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-01-23 09:48:11 +01:00
Jakub Jelen
94fe7634e1 Do not build in internal chacha implementation if gcrypt supports that
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-01-23 09:48:11 +01:00
Jakub Jelen
8670fb101b chacha: Create common file to avoid code duplication
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-01-23 09:48:11 +01:00
Jakub Jelen
e31e7b0406 packet_crypt: Check return values from AEAD deciphering
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-01-23 09:48:11 +01:00
Jakub Jelen
6644f8ca3b curve25519: Avoid memory leaks
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-01-23 09:48:11 +01:00
Andreas Schneider
06d25497ff pki: Avoid uneeded memory duplication
CID #1412375

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-01-23 09:21:04 +01:00
Andreas Schneider
8215753402 misc: Make the src pointer const in ssh_strreplace()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-01-23 09:20:43 +01:00
Sahana Prasad
10d27a0d42 unittests: Extends testcases for ssh_strreplace().
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-01-23 09:19:07 +01:00
Sahana Prasad
240bf3236a misc: Simplifies ssh_strreplace().
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-01-23 09:19:07 +01:00
Sahana Prasad
844f92efea unittests: Removes extra empty lines.
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-01-23 09:19:07 +01:00
Sahana Prasad
dd8b6b1708 unitests: Removes unwanted comments.
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-01-23 09:19:07 +01:00
Andreas Schneider
72498bac5f pki_crypto: Fix possible memory leak on error
CID #1409680

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-01-23 09:19:07 +01:00
Andreas Schneider
4b4f568a68 messages: Add missing NULL check
CID #1409678

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-01-23 09:19:07 +01:00
Andreas Schneider
6324014866 tests: Use correct assert function for ssh return codes
CID #1398983

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-01-23 09:19:07 +01:00
Jakub Jelen
12d5c136f2 tests: Give server more time to start
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-01-22 09:10:28 +01:00
Anderson Toshiyuki Sasaki
7f5e14698f gitlab-ci: Create obj directory for Windows builds
The obj directory is not created anymore when the git repository is
cloned.  Create the directory during the build.

Also set the variable "ErrorActionPreference: STOP" to make the build to
fail if an error occurs.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2020-01-20 14:16:20 +01:00
Andreas Schneider
1fe5f03fff gitlab-ci: Re-enable client testing on Tumbleweed
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2020-01-09 14:47:54 +01:00
Jakub Jelen
df1f64d435 gitlab-ci: Unbreak Freebsd build
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 15:33:19 +01:00
Andreas Schneider
94846b1d15 Update ChangeLog
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:50:26 +01:00
Jakub Jelen
4d493c4da5 gitlab-ci: Add csbuilds for gcrypt and mbedtls
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:45:24 +01:00
Jakub Jelen
ee2fa29798 gitlab-ci: Simplify the targets definitions using inheritance
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:45:24 +01:00
Jakub Jelen
6d3941e71b gitlab-ci: Add Ubuntu target (based on Fedora one)
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:45:24 +01:00
Jakub Jelen
e5553a92d9 socket: Use the users shell for running proxy command
Fixes T200 and tests on ubuntu, which is using dash

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:45:24 +01:00
Jakub Jelen
3a6751f3d2 socket: Fix the error message
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:45:24 +01:00
Jakub Jelen
dd64980662 socket: Kill the proxy command if it still runs on disconnect
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:45:24 +01:00
Jakub Jelen
24f450fed1 pki_gcrypt: Warn about unsupported PEM export in gcrypt
Based on the following mail thread:

https://www.libssh.org/archive/libssh/2019-12/0000027.html

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:45:24 +01:00
Jakub Jelen
9d5616a18c tests: Unbreak strict builds on Ubuntu
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:45:24 +01:00
Jakub Jelen
c106cd1f83 CMakeLists: Shorten the keys lists passed to the ssh command
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:45:24 +01:00
Jakub Jelen
7e692ee1b6 libgcrypt: Do not leak memory with invalid key lengths
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:45:24 +01:00
Jakub Jelen
dd54ffb2f1 pki_gcrypt: Do not confuse static analyzers
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:45:24 +01:00
Jakub Jelen
3642224ee5 legacy,keys: Fix the macro conditions
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:45:24 +01:00
Jakub Jelen
9b858f57c5 mbedcrypto_missing: Always check return values
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Jakub Jelen
13c88a2e0a mbedcrypto_missing: Avoid potential memory leaks as reported by csbuild
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Jakub Jelen
059b6851dc pki_mbedtls: Avoid potential memory leaks
reported by csbuild

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Jakub Jelen
71ba61cc5b pki_mbedtls: Do not warn about unused arguments
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Jakub Jelen
30cc1568f4 options: Avoid needless assignment as reported by csbuild
The error was

 src/options.c:971:13: warning: Value stored to 'u' is never read
 #            u = 0;
 #            ^   ~
 src/options.c:971:13: note: Value stored to 'u' is never read
 #            u = 0;
 #            ^   ~
 #  969|           case SSH_OPTIONS_KBDINT_AUTH:
 #  970|           case SSH_OPTIONS_GSSAPI_AUTH:
 #  971|->             u = 0;
 #  972|               if (value == NULL) {
 #  973|                   ssh_set_error_invalid(session);

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Jakub Jelen
8eda4165cf tests: Do not require strict host key checking in openssh
as nothing really sets these keys up and they are probably preserverd
from some previous test, which is really not a good testing strategy.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Jakub Jelen
1563bddf88 tests: Avoid needless assignment as reported by csbuild
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Jakub Jelen
e2841908fb kex: Avoid always-false comparisons as reported by csbuild
/builds/jjelen/libssh-mirror/src/kex.c:360:17: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] <--[cc]
  360 |         if (len < 0) {
      |                 ^
/builds/jjelen/libssh-mirror/src/kex.c:372:17: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] <--[cc]
  372 |         if (len < 0) {
      |                 ^

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Jakub Jelen
2892b49a37 tests: Use the path to SSH executable consistently
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Jakub Jelen
4b85934198 examples: Enable strict build
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Aris Adamantiadis
9e7de14d59 pkd client run user executable
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Aris Adamantiadis
bba5fa18ed pkd: fix snprintf compiler warning
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Aris Adamantiadis
1089948346 tests: use detected sshd path
The static sshd directory wasn't matching the detected sshd and prevented the testcases to be run against local OpenSSH builts

Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Aris Adamantiadis
7ec67011c5 tests: use OpenSSH-provided ciphers
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Aris Adamantiadis
177e76f753 tests: search for netcat binary
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Aris Adamantiadis
3d2570ff5f pkd: use detected OpenSSH supported key types
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Aris Adamantiadis
3063a57fc8 tests: detect OpenSSH supported ciphers
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Aris Adamantiadis
23c529c888 tests: fix typos
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-23 14:31:32 +01:00
Sahana Prasad
2b76abb74c clienttest: Adds a client test that authenticates to the ssh server using ssh_connect through key obtained through PKCS11 URIs.
Signed-Off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 16:18:31 +01:00
Sahana Prasad
fa95fe3e1b unittests: Adds unitests for ecdsa and rsa with PKCS11 URIs.
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 16:18:31 +01:00
Sahana Prasad
cc1175a9af torture: Add a helper function to setup tokens using softhsm.
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 16:18:23 +01:00
Sahana Prasad
4ea09256f6 src: Implements PKCS11 URI support
Imports private and public keys from the engine via PKCS11 URIs. Uses
the imported keys to authenticate to the ssh server.

Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 16:17:33 +01:00
Sahana Prasad
6bf4ada240 src: Helper funtions to detect PKCS #11 URIs
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 14:41:02 +01:00
Sahana Prasad
86a0dfa65b src: Adds the Engine header file and invokes cleanup of the engine
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 14:40:51 +01:00
Sahana Prasad
89ec52f5b1 torture_key: Adds public keys in PEM format - as required by p11tool.
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 14:40:38 +01:00
Sahana Prasad
bbc72ed3b6 tests/CMakeLists: Adds keys to authorized hosts list. copies script used to setup tokens.
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 14:40:25 +01:00
Sahana Prasad
843052dd23 etc: Adds a new user Charlie
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 14:39:56 +01:00
Sahana Prasad
317cf070e2 tests/pkcs11: Adds a script to setup PKCS11 tokens using softhsm and p11tool.
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 14:36:57 +01:00
Sahana Prasad
2a22211e7f keys: Adds new keys to generate PKCS11 URIs used to authenticate with the ssh server.
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 14:36:45 +01:00
Sahana Prasad
105e6f05ba gitlab-ci: adds the PKCS11 URI option to build options
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 14:36:34 +01:00
Sahana Prasad
ac22e51e5a cmake: Add cmake module to find softhsm
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 14:36:20 +01:00
Sahana Prasad
fa6fb83c87 cmake: Add new option for PKCS11 URI support
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 14:36:04 +01:00
Sahana Prasad
314448786e unittest: Adds unit tests for ssh_strreplace().
Signed-off-by: Sahana Prasad <sahana@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-20 14:35:41 +01:00
Andreas Schneider
35216e7254 misc: Add ssh_strreplace()
Pair-Programmed-With: Sahana Prasad <sahana@redhat.com>
Signed-Off-by: Sahana Prasad <sahana@redhat.com>
Signed-Off-By: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-20 14:35:18 +01:00
Andreas Schneider
5317ebf0fc misc: Add ssh_tmpname()
Signed-Off-By: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-20 14:35:04 +01:00
Jussi Kivilinna
08f4469e21 libgcrypt: fix cipher handle leaks on setkey error paths
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-16 22:45:45 +02:00
Jussi Kivilinna
de4b8f88a2 libgcrypt: Implement chacha20-poly1305@openssh.com cipher using libgcrypt
Libgcrypt has supported ChaCha20 and Poly1305 since 1.7.0 version and
provides fast assembler implementations.

v3:
 - initialize pointers to NULL
 - use 'bool' for chacha20_poly1305_keysched.initialized
 - pass error codes from libgcrypt calls to variable
 - add SSH_LOG on error paths
v2:
 - use braces for one-line blocks
 - use UNUSED_PARAM/UNUSED_VAR instead of cast to void
 - use calloc instead of malloc+memset

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-16 22:31:54 +02:00
Jussi Kivilinna
af5de2d37e tests: add crypto unittest for chacha20poly1305
v3:
 - add tests for malformed encrypted inputs
v2:
 - use proper size key for chacha20poly1305
 - make copy of cleartext for chacha20poly1305 test-case
 - update chacha20_encrypted

Signed-off-by: Jussi Kivilinna <jussi.kivilinna@iki.fi>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-16 22:31:17 +02:00
Jon Simons
b94ecf18bd curve25519: fix uninitialized arg to EVP_PKEY_derive
Ensure that the `keylen` argument as provided to `EVP_PKEY_derive`
is initialized, otherwise depending on stack contents, the function
call may fail.

Fixes T205.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-13 20:00:37 -05:00
Jakub Jelen
d2a32ca6d3 torture: Accept whole pid_t range
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-11 11:38:21 +01:00
Aris Adamantiadis
e42307bbe3 tests: bigger sshd config buffer (fixes #T180)
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-11 11:38:21 +01:00
Andreas Schneider
742d81ec5d include: Rename __unused__ to __attr_unused__
This avoids a collision with valgrind.h

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-11 11:38:16 +01:00
Jakub Jelen
b03818aaed init: Fix documentation about return values of void functions
Fixes T203

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-10 21:13:07 +01:00
Jakub Jelen
8c3996ef38 Fix link for bug tracker
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-10 16:50:39 +01:00
Andreas Schneider
ecc78ec154 cpack: Ignore patch files
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 19:25:38 +01:00
Jakub Jelen
574690ae2e config: Ignore empty lines to avoid OOB array access
Fixes T187

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-09 16:08:03 +01:00
Jakub Jelen
c7cacf986f tests: Check behavior of match_pattern()
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-09 16:08:03 +01:00
Jakub Jelen
31f9c39479 match: Limit possible recursion when parsing wildcards to a sensible number
Fixes T186

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-09 16:08:03 +01:00
Jakub Jelen
cf0beff987 match: Avoid recursion with many asterisks in pattern
Partially fixes T186

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-09 16:08:03 +01:00
Andreas Schneider
178b53f924 pki: Fix possible information leak via uninitialized stack buffer
Fixes T190

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
e065d2bb3f pki_container_openssh: Initialize pointers to NULL
Fixes T190

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
9d67ca251c SSH-01-012: Fix information leak via uninitialized stack buffer
Fixes T190

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
cb0ccf372e SSH-01-010: Improve documentation for fingerprinting functions
Fixes T184

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Jakub Jelen
1fa1a467ed doc: Use https where possible
Related to T196

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-09 16:08:03 +01:00
Jakub Jelen
606a97c4d6 doc: Update the list of RFCs and clearly mention which are not implemented in libssh
Fixes T196

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-09 16:08:03 +01:00
Anderson Toshiyuki Sasaki
cc9db5b56c tests: Add a test for SCP with protocol message injection
Test if the file name is correctly escaped to avoid protocol message
injection.

Fixes T189

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Anderson Toshiyuki Sasaki
bab7ba0146 scp: Do not allow newlines in pushed files names
When pushing files or directories, encode the newlines contained in the
names as the string "\\n".  This way the user cannot inject protocol
messages through the file name.

Fixes T189

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Anderson Toshiyuki Sasaki
c9ce8fa40b misc: Add a function to encode newlines
Given a string, the added function encodes existing newline characters
('\n') as the string "\\n" and puts into a given output buffer.

The output buffer must have at least 2 times the length of the input
string plus 1 for the terminating '\0'. In the worst case, each
character can be replaced by 2 characters.

Fixes T189

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
6c79ed9801 gzip: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
7ae47df16a knownhosts: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
6734516278 pcap: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
3cf665a53d base64: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
35799bb1c6 packet: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
476bde4d69 socket: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
0938d397be examples: Use SSH_STRING_FREE_CHAR()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
4e809ef122 tests: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
80d092037f dh-gex: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
45d9802e1b message: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
5db5e7e527 message: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
d7abfe7e8f pki_container_openssh: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
f422fb02f6 pki_container_openssh: Use SSH_STRING_FREE
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
b719f705c6 gssapi: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
3b8fcbad24 gssapi: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
3ab8b76921 kex: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
7c3a6ca6bc kex: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
6eb34cec33 agent: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
45ee892327 agent: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
321b27b788 server: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
ac33b3adbc ecdh_mbedcrypto: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
5e21c24fab dh: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
abe1bf910e ecdh: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
752c906ea7 channels: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
1832ed4fef channels: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
4cae57c581 sftp: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
9384a18e91 sftp: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
88a3dd86f1 packet_cb: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
449c0d66cc sftpserver: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
4cd084f13b packet_cb: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
9020f4e63a curve25519: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
6596ee9fb2 auth: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
25f1c80950 session: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
5e6cb6891f session: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
0684f1b94a pki_mbedcrypto: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
42547772df pki_mbedcrypto: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
288bbd5bd0 ecdh_crypto: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
8525b4bb01 pki_crypto: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
d97770b025 pki_crypto: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
f89cf79c49 pki: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
189fd76589 pki: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
2786a3e96a ecdh_gcrypt: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
09dfda8489 libcrypto: Use SSH_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
9a112f1548 pki_gcrypt: Use SSH_BUFFER_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
4e2d85745f pki_gcrypt: Use SSS_STRING_FREE()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
032f25aab3 SSH-01-007: Fix possible double free of ssh strings
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
da81b99df1 gssapi: Make sure buffer is initialized
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
af2aeba838 SSH-01-006: Add missing NULL check in sftp_open()
Fixes T193

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
9ae81c5ceb SSH-01-006: Add missing NULL check in server_set_kex()
Fixes T193

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
8aa2bbd0dc SSH-01-006: Add missing NULL check in ssh_scp_push_directory()
Fixes T193

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
fff4120cbf SSH-01-006: Add missing NULL checks in ssh_scp_push_file64()
Fixes T193

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
7b9cbcebe5 SSH-01-006: Add missing NULL checks in pki_signature_from_rsa_blob()
Fixes T193

Signed-off-by: Andreas Schneider <asn@cryptomilk.org
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
56d571ab81 SSH-01-006: Add missing NULL check in ssh_pki_do_sign_agent()
Fixes T193

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
69daa602b8 SSH-01-006: Add missing NULL check in ssh_packet_hmac_verify()
Fixes T193

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
924dc5aed8 SSH-01-006: Add missing NULL check in gzip_decompress()
Fixes T193

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
6b8ab4bcd2 SSH-01-006: Add missing NULL check in ssh_gssapi_handle_userauth()
Fixes T193

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
af2ea417da SSH-01-006: Add missing NULL check in ssh_gssapi_handle_userauth()
Fixes T193

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
c7172c183f SSH-01-006: Add missing NULL check in ssh_gssapi_build_mic()
Fixes T193

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
33cca875c2 SSH-01-006: Add missing NULL check in ssh_gssapi_oid_from_string()
Fixes T193

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
b55d7f3b73 SSH-01-006: Add missing NULL check for ssh_packet_get_current_crypto()
Fixes T193

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
7588979977 SSH-01-006: Add missing ENOMEM check in ssh_gssapi_auth_mic()
Fixes T193

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
ab26db203e cmake: Add -Wsign-compare to CFLAGS
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
d60640cd0e socket: Pass port as uint16_t to ssh_socket_connect()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
64155b4f97 bignum: Print ssh_make_string_bn() using SSH_LOG()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
64cd7e7ce2 bignum: Fix integer types for ssh_make_bignum_string()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
f5bc5147b9 base64: Fix size types of bin_to_base64()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
b5160ce9e0 base64: Reformat bin_to_base64()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
fdb7cb8f17 base64: Make alphabet and const uint8_t
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
fe9991b3c6 base64: Reformat _bin_to_base64()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
159d95c26c auth: Cast echo to char in ssh_userauth_kbdint_getprompt()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
5ef416fd35 include: Mark SSH_AUTH flags as unsigned
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
1be68139bb agent: Return uint32_t for ssh_agent_get_ident_count()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
c820d2a2dc agent: Reformat ssh_agent_get_ident_count()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
b18acbdc7e sftpserver: Fix integer type in sftp_reply_data()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
d672b1d7c4 sftp: Avoid comparison of integers of different sizes
This casts ssize_t len to size_t.

Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
d40f33c400 sftp: Cast sftp version to int
This is a public struct and the version should be unsigned there.

Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
c29840060b sftp: Use uint32_t for sftp extension count
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
98824d6e11 sftp: Fix integer types in sftp_extension_supported()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
839fab6df4 sftp: Fix integer types in sftp_read()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
6b105624bf sftp: Fix integer types in sftp_write() and sftp_packet_write()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
db4345fb36 sftp: Remove internal function from sftp.h
Those are not marked as LIBSSH_API so not part of the public API and the
symbols aren't exported!

Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
6cef3e10bf server: Cast auth_methods to uint32_t
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
442d22da60 server: Make sure methods is a valid value before casting
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
3cca9994d4 pki_crypto: Cast return value of EVP_PKEY_size() to size_t
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
53635dff7e packet: Fix size types in ssh_packet_need_rekey()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
b7c628ff06 options: Define constants as unsigned in ssh_options_set()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
7823df8343 options: Define constants as unsigned in ssh_bind_options_set()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
be34ff967f kex: Use a len variable for length checks in ssh_packet_kexinit()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
815f874964 sc25519: Fix integer types of sc25519_add()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
f2d40fb94c sc25519: Fix integer types in sc25519_mul()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
31b26934b0 fe25519: Fix integer types of fe25519_iszero()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
922a2aee99 include: Fix integer type of dh_pn and dh_pmax
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
500481e101 channels: Return size_t for count_ptrs()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
dad2720355 channels: Fix integer and bool argument of channel_default_bufferize()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
6f39deefcd channels: Fix type of arguments of grow_window()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
0abd187dba channels: Fix type of arguments of channel_open()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
07a57b74ba channels: Use ssize_t for to_read
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
8d671efdbd channels: Reformat ssh_channel_read_nonblocking()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
3bad060738 channels: Use a size_t variable for length check
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
fbe115abba channesl: Reformat ssh_channel_poll_timeout()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
66c4857c4a auth: Fix integer type in ssh_kbdint_free()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
1434b4a279 auth: Fix integer type in ssh_kbdint_clean()
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
8d62257172 examples: Fix integer types in libssh_scp.c
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Andreas Schneider
0773696ee5 examples: Remove internal include from sshd_direct-tcpip.c
Fixes T188

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Anderson Toshiyuki Sasaki
3830c7ae6e CVE-2019-14889: scp: Quote location to be used on shell
Single quote file paths to be used on commands to be executed on remote
shell.

Fixes T181

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-09 16:08:03 +01:00
Andreas Schneider
0b5ee39726 CVE-2019-14889: scp: Don't allow file path longer than 32kb
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-12-09 16:08:03 +01:00
Anderson Toshiyuki Sasaki
b82d2caa90 CVE-2019-14889: tests: Add unit tests for ssh_quote_file_name()
Fixes T181

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-09 16:08:03 +01:00
Anderson Toshiyuki Sasaki
c4ad1aba98 CVE-2019-14889: misc: Add function to quote file names
The added function quote file names strings to be used in a shell.
Special cases are treated for the charactes '\'' and '!'.

Fixes T181

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-09 16:08:03 +01:00
Anderson Toshiyuki Sasaki
c75d417d06 CVE-2019-14889: scp: Log SCP warnings received from the server
Fixes T181

Previously, warnings received from the server were ignored.  With this
change the warning message sent by the server will be logged.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-09 16:08:03 +01:00
Anderson Toshiyuki Sasaki
42c727d0c1 CVE-2019-14889: scp: Reformat scp.c
Fixes T181

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-09 16:08:03 +01:00
Anderson Toshiyuki Sasaki
27bcac6845 CVE-2019-14889: tests: Add tests for SCP client
Fixes T181

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-12-09 16:08:03 +01:00
Andreas Schneider
e00ef9635a packet: Do not deref a NULL pointer in ssh_packet_set_newkeys()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-11-18 11:59:01 +01:00
Andreas Schneider
e60fc79542 SSH-01-003: Add cipher NULL checks to ssh_packet_get_current_crypto()
Fixes T183

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-11-18 11:59:01 +01:00
Jakub Jelen
c8a621c606 Use only one variable denoting the size of methods arrays
Previously, there was non-consistent usage of constans SSH_KEX_METHODS,
KEX_METHODS_SIZE and of magic number 10 to reference the arrays used
for algorithm negotiation by peers. This commit settles down to the single
constant and its usage throughout the whole codebase.

Fixes T195

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-18 11:59:01 +01:00
Anderson Toshiyuki Sasaki
ec67ad47eb session: Initialize states explicitly
In ssh_session_new(), initialize the state machines states explicitly
for better readability.

Fixes T194

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-18 11:59:01 +01:00
Anderson Toshiyuki Sasaki
553eab748a messages: Set signature state explicitly
In ssh_message_new(), initialize msg->auth_request.signature_state
explicitly for better readability.

Fixes T194

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-18 11:59:01 +01:00
Anderson Toshiyuki Sasaki
2f1f662d46 channels: Initialize states explicitly
In ssh_channel_new(), initialize channel->state and
channel->request_state explicitly for better readability.

Fixes T194

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-18 11:59:01 +01:00
Anderson Toshiyuki Sasaki
7e3995d2dd auth: Set auto_state->state explicitly
When a new ssh_auth_auto_state_struct is allocated in
ssh_userauth_publickey_auto(), initialize the state explicitly for
better readability.

Fixes T194

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-18 11:59:01 +01:00
Anderson Toshiyuki Sasaki
77bd8ed4c0 session: Use ssh_packet_state_e instead of int
Use the enum type instead of int in the ssh_session_struct

Fixes T194

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-18 11:59:01 +01:00
Anderson Toshiyuki Sasaki
39f6ba2dc9 messages: Use ssh_publickey_state_e instead of char
Use the enum type instead of char in the ssh_auth_request struct

Fixes T194

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-18 11:59:01 +01:00
Anderson Toshiyuki Sasaki
3f64fb3b3b session: Reformat ssh_new()
Fixes T194

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-18 11:59:01 +01:00
Andreas Schneider
c54fd03e50 cmake: Fix building libssh as a static lib on Windows
Fixes T198

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-11-14 21:04:03 +01:00
Andreas Schneider
db632015be gitlab-ci: Make sure we have enough git commits for csbuild
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-11-08 13:51:13 +01:00
Jakub Jelen
1ebf506913 server: Use really the negotiated signature type
Generally, when the extension negotiation is enabled and client supports
SHA2 algorithms for RSA, they are supposed to be prioritized against the
old SHA1. If it is not (ssh-rsa is listed in front of rsa-sha2-* hostkey
algorithms during negotiation), the server wrongly tries to provide the
new typo of signature, ignoring the negotiated algirithm

This commit propagates the digest algorithm from negotiation to the actual
signature functions, which were previously responsible for decision
about the hash algorithm based just on the negotiated extensions.

Fixes T191

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-07 15:55:32 +01:00
Andreas Schneider
fbc2912dde gitlab-ci: Disable client testing as pam_wrapper is broken on TW
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-11-07 14:01:01 +01:00
Andreas Schneider
ea4f71721f cmake: Fix setting up cwrap for server testing
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-11-07 14:01:01 +01:00
Andreas Schneider
4ab0fb2b48 cmake: Do not use cached LIBSSH_PUBLIC_INCLUDE_DIRS
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-11-07 14:01:01 +01:00
Andreas Schneider
8c36a865f2 cmake: Rename static library
This is only compiled for tests and fuzzers!

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-11-07 14:01:01 +01:00
Andreas Schneider
82c57c1f36 cmake: Create ssh library directly as libssh
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-11-07 14:01:00 +01:00
Andreas Schneider
c2c3545391 cmake: Add option to build shared libs
See https://cmake.org/cmake/help/latest/variable/BUILD_SHARED_LIBS.html

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-11-07 14:00:15 +01:00
Andreas Schneider
729c92606c cmake: Remove WITH_STATIC_LIB
We will honor BUILD_SHARED_LIBS from cmake next.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-11-07 14:00:15 +01:00
Andreas Schneider
498b63949e cmake: Don't cache LIBSSH_LINK_LIBRARIES
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-11-07 14:00:15 +01:00
Andreas Schneider
39f7ddaa06 cmake:pkd: Don't use LIBSSH_LINK_LIBRARIES
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-11-07 14:00:15 +01:00
Andreas Schneider
2fcc15c5dc cmake: Remove libsocket
This is already part of LIBSSH_REQUIRED_LIBRARIES

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-11-07 14:00:15 +01:00
Andreas Schneider
5e2788d4c5 cmake: Use target_include_directories()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-11-07 14:00:15 +01:00
Anderson Toshiyuki Sasaki
29d360dc70 examples: Build keygen2 only if argp is available
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-07 14:00:15 +01:00
Anderson Toshiyuki Sasaki
21655e396c cmake: Only use OpenSSL Ed25519 implementation when possible
It is possible for OpenSSL to have the type EVP_PKEY_ED25519 in
openssl/evp.h, but not the single shot functions EVP_DigestSign() and
EVP_DigestVerify() which are required to generate Ed25519 signatures.

Only switch to use OpenSSL Ed25519 implementation when OpenSSL have all
required types and functions.

Fixes: T197

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-11-07 11:59:36 +01:00
Anderson Toshiyuki Sasaki
b30875c6c7 examples: Added keygen2 example
The added example is an application which can generate keys of different
types using libssh.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-11-07 10:53:49 +01:00
Andreas Schneider
d02c06268e gitlab-ci: Mips is dead
Debian removed the cross compiling toolchain. So lets drop it.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-11-04 09:48:05 +01:00
Andreas Schneider
e5767bf0b7 channel: Document ssh_channel_request_sftp()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-11-04 09:47:02 +01:00
Andreas Schneider
4a113159b2 auth: Add missing include for explicit_bzero()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-11-04 09:46:53 +01:00
Andreas Schneider
a4b95268ee cmake: Link compile database to source dir for clangd
See
https://github.com/ycm-core/YouCompleteMe
https://github.com/abingham/emacs-ycmd

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-10-25 17:29:10 +02:00
Anderson Toshiyuki Sasaki
8a50dbc6ba tests: Do not parse global config in torture_ssh_session()
Do not parse global config file in sessions created by
torture_ssh_session().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-10-25 15:15:20 +02:00
Anderson Toshiyuki Sasaki
85239c8ea0 tests: Do not parse global configuration when testing server
This removes the tests which uses external configuration files.  This
makes the tests no not change behaviour depending on the environment
they are being executed.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-10-25 15:15:20 +02:00
Anderson Toshiyuki Sasaki
040aa0edfe tests: Do not process server config during tests
In pkd tests, avoid processing the global server configuration file.
This is to allow testing with algorithms not allowed in the global
server configuration.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-10-25 15:15:20 +02:00
Anderson Toshiyuki Sasaki
f97a8b4e3f tests: Do not process config when reinitializing session
Do not process system-wide configuration when reinitializing a session
during testing.  This could lead to different settings set from the
expected one (which was initialized during test setup).

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-10-25 15:15:20 +02:00
Anderson Toshiyuki Sasaki
d4fe8e1f62 tests: Use temporary file for known_hosts
Previously, the tests were sharing the same file path to create the
known_hosts file, which can create a race condition if the tests run in
parallel.  Such file was deleted between tests.

By using different different files for each test, the risk of race
conditions is eliminated. Moreover, it makes unnecessary to destroy the
file between tests.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-10-25 15:15:20 +02:00
Jakub Jelen
e9e8292370 packet: On failure, do not use uninitialized crypto
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-10-25 13:42:07 +02:00
Jakub Jelen
5a0177def0 packet_crypt: Avoid out of bounds access in debug functions
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-10-25 13:42:07 +02:00
Jakub Jelen
17952c4953 tests: Let shell resolve the absolute path to binaries in Exec tests
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-10-25 13:23:14 +02:00
Anderson Toshiyuki Sasaki
fe18ef2798 pki_crypto: Use temporary pointer when using i2d_*
These functions modify the provided pointer by advancing to the end of
if (point to the byte after the last written).  This makes the pointer
invalid, making necessary to use a temporary variable.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-10-07 11:41:30 +02:00
Jakub Jelen
689f1b0a6b callbacks: Improve documentation about callbacks handling
Fixes T103

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-10-01 10:24:06 +02:00
Jakub Jelen
a22367fbe1 tests: Verify multiple match conditions can be present on a line
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-10-01 10:24:01 +02:00
Jakub Jelen
46c3563da9 tests: Verify match exec keyword works on itself
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-10-01 10:24:01 +02:00
Jakub Jelen
c983c994a2 config: Implement match exec keyword
The implementation does not work on Windows, where it still reports unsupported
configuration option. On windows, separate code invoking subprocess needs to be
implemented.

Fixes T169

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-10-01 10:24:01 +02:00
Jakub Jelen
c7da113f1d tests: Verify functionality of low-level config parser functions
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-10-01 10:24:01 +02:00
Jakub Jelen
349abe5942 config_parser: Implement more useful variant of get_token()
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-10-01 10:24:01 +02:00
Anderson Toshiyuki Sasaki
a3a0529b41 pki_crypto: Support Ed25519 keys in PEM files
This adds support for Ed25519 keys from files in PEM format when using
OpenSSL with Ed25519 support.  The default encoding for the PEM file is
expected to be PKCS#8.  Encrypted files are supported.

For the lack of an API, it is not possible to export keys in PEM format,
only in OpenSSH format.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Anderson Toshiyuki Sasaki
61e6b6cc59 cmake: Do not build internal ed25519 when unnecessary
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Anderson Toshiyuki Sasaki
d463f67aba curve25519: Use OpenSSL X25519 implementation
If supported, use OpenSSL X25519 implementation for the curve25519 key
exchange.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Anderson Toshiyuki Sasaki
0b7f7d2cf7 cmake: Detect OpenSSL X25519 support
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Anderson Toshiyuki Sasaki
55cd04fbee pki: Remove unused function pki_signature_verify()
This removes unused function pki_signature_verify()
from pki_{crypto, mbedcrypto, gcrypt}.  The function was also removed
from include/libssh/pki_priv.h.  The function ssh_pki_signature_verify()
was changed to receive a const unsigned char *input.

All tests calling pki_signature_verify() were changed to call
ssh_pki_signature_verify() instead.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Anderson Toshiyuki Sasaki
2a2c1c98bf pki_crypto: Use OpenSSL for Ed25519 signatures
Use OpenSSL to generate and verify Ed25519 signatures, if supported.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Anderson Toshiyuki Sasaki
bdcaf55b90 pki: Move common Ed25519 functions to pki_ed25519_common.c
This is a preparation to use the Ed25519 implementation from OpenSSL.

The function pki_ed25519_sig_to_blob() was renamed to
pki_ed25519_signature_to_blob() and pki_ed25519_sig_from_blob() was
renamed to pki_signature_from_ed25519_blob() to follow the naming for
other algorithms.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Anderson Toshiyuki Sasaki
a0b84a8cd5 cmake: Detect OpenSSL support for Ed25519
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Anderson Toshiyuki Sasaki
97adbfe087 pki_mbedcrypto: Do not treat Ed25519 as a special case
Generate and verify Ed25519 signatures along with the other signature
types.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Anderson Toshiyuki Sasaki
38ede2e225 pki_gcrypt: Do not treat Ed25519 as a special case
Verify the Ed25519 signature in pki_verify_data_signature() along with
the other signature types.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Anderson Toshiyuki Sasaki
90944a3651 pki_crypto: Use EVP_DigestSign* and EVP_DigestVerify*
Use the newer APIs EVP_DigestSign{Init}() and EVP_DigestVerify{Init}()
to generate and verify signatures instead of the older EVP_Sign{Init,
Update, Final} and EVP_Verify{Init, Update, Final} if supported.

Also use the single shot signature/verification if supported as all the
input is provided at once.

This is a preparation to use Ed25519 implementation from OpenSSL.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Anderson Toshiyuki Sasaki
7452f0ded8 torture_pki_ed25519: Use public key to verify signatures
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Anderson Toshiyuki Sasaki
7ffa3c358d gitlab-ci: Move cmake from prep to build command in csbuild
This is required to avoid csbuild scan failures when a commit removes
source files.  The command prep is run only once before all the builds,
making csbuild to try to compile the old files using the configuration
files generated for the newest version.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-09-24 16:49:35 +02:00
Jakub Jelen
e72429f205 buffer: Simplify handling of the return codes
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-09-24 16:10:33 +02:00
Jakub Jelen
aff7c500d5 buffer: Avoid use of uninitialized values
Fixes the following oss-fuzz bug:
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=17565

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-09-24 16:06:38 +02:00
Jakub Jelen
aac682f60e dh-gex: Correctly free modulus and generator with openssl
Fixes T176

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-09-24 16:04:52 +02:00
Jakub Jelen
2f05243a4a channels: Correctly reports failed channels opening
Fixes T75

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-09-24 16:04:52 +02:00
Jakub Jelen
89a9eb8811 Reformat channel_open()
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-09-24 16:04:52 +02:00
Jakub Jelen
3cf2b41f5e channels: Do not use deprecated functions in the example code
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-09-24 16:04:52 +02:00
Jakub Jelen
223cc96239 options: Do not attempt to expand percents in PKCS#11 URIs
With the old token parser, the data was simply broken on the = sign even
if the uri was in quotes and ignored.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-09-19 15:10:08 +02:00
Jakub Jelen
61b1e0e7e9 tests: Verify the localuser match works
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-09-18 15:18:33 +02:00
Jakub Jelen
6500134259 config: Support match localuser
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-09-18 15:17:21 +02:00
Jakub Jelen
9b8b312b88 config: Make the matching case sensitive as documented in ssh_config manual pages
> note that keywords are case-insensitive and arguments are case-sensitive

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-09-18 10:45:21 +02:00
Jakub Jelen
4900ab6ca9 Skip the proxycommand test in case the netcat is not avaliable
Fixes: T142

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-09-16 09:39:58 +02:00
Jakub Jelen
618b858e49 sftp: Improve the documentation of sftp_init() and sftp_new()
Fixes: T137

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-09-16 09:35:32 +02:00
Jakub Jelen
83fa060cec known_hosts: Avoid using deprecated functions (even from deprecated functions)
Fixes: T165

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-09-16 09:35:24 +02:00
Andreas Schneider
4799915a36 gitlab-ci: Turn DEBUG_CRYPTO on for standard crypto lib builds
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-08-08 09:30:12 +02:00
Andreas Schneider
92d3efec81 dh: Add ssh_dh_debug_crypto()
We should call it where we have access to the crypto structure.

Pair-Programmed-With: Jakub Jelen <jjelen@redhat.com>
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-08-08 09:30:03 +02:00
Andreas Schneider
4e25ee6124 bignum: Pass const to ssh_print_bignum()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-08-07 09:49:00 +02:00
Andreas Schneider
89ab7b23f8 pki_mbedcrypto: Add missing misc.h header file
For ssh_log_hexdump().

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-08-07 08:25:31 +02:00
Anderson Toshiyuki Sasaki
3a61cd34a9 tests: Skip testing 1024 bits key generation in FIPS mode
In torture_threads_pki_rsa, skip the test which generates 1024 bits RSA
key pair when in FIPS mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-08-06 16:57:19 +02:00
Anderson Toshiyuki Sasaki
5b18bcb0ac knownhosts: Use ssh_mkdirs() instead of ssh_mkdir()
Previously, if the path to known_hosts file set through
SSH_OPTIONS_KNOWNHOSTS included missing directories,
ssh_session_update_known_hosts() would fail.  The added test case checks
that this is not the case anymore.

The logic of checking if the directory is accessible before creating it
was replaced by creating the directory if opening the file failed.  This
is to minimize the risk of TOCTOU race conditions.

Fixes: T166

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-08-06 16:53:22 +02:00
Anderson Toshiyuki Sasaki
742918cb1c misc: Introduce internal function ssh_mkdirs()
If the given path includes missing directories, ssh_mkdirs() tries to
create them recursively.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-08-06 16:53:22 +02:00
Anderson Toshiyuki Sasaki
7857cd1aa5 misc: Introduce internal function ssh_dir_writeable()
The introduced internal function checks if the provided path is for an
existing directory which is accessible for writing.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-08-06 16:52:24 +02:00
Richard W.M. Jones
3737e5f0e7 misc: Allow %% to escape a single % in paths.
For example "%d/config%%1" is expanded to "~/.ssh/config%1".

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-07-30 16:23:31 +02:00
Jakub Jelen
e42d44e48a libcrypto: Avoid incompatible pointers
Fixes: T164

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-07-30 16:19:32 +02:00
Jakub Jelen
683096ae7e pki_container_openssh: Avoid bogus newline in debug message
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-07-30 16:19:31 +02:00
Jakub Jelen
3811c73f8f pki_container_openssh: Reformat whitespace
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-07-30 16:19:31 +02:00
Jakub Jelen
cc92e74309 examples: Load ED25519 key when loading all keys
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-07-30 16:19:27 +02:00
Anderson Toshiyuki Sasaki
68baebbd62 Replace ssh_print_hexa() with ssh_log_hexdump()
Replace all occurrences of the deprecated function ssh_print_hexa() with
the introduced ssh_log_hexdump().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-07-30 13:26:29 +02:00
Anderson Toshiyuki Sasaki
33927f3ae8 misc: Introduce ssh_log_hexdump()
The introduced internal function is intended to be a replacement for the
deprecated function ssh_print_hexa().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-07-30 13:26:29 +02:00
Anderson Toshiyuki Sasaki
c03c9b88d1 tests: Try PEM files with leading white spaces
This adds a reproducer for T123.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-07-29 19:14:24 +02:00
Anderson Toshiyuki Sasaki
88d777e678 pki: Search OpenSSH header not only at the beginning
Try to find the OpenSSH private key header not only at the beginning of
the file.  This makes the parser to skip comments and white spaces.

Fixes: T76
Fixes: T123

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-07-29 19:14:24 +02:00
Andreas Schneider
0a85f3a58d gitlab-ci: Test installation at least on one runner
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-07-15 11:02:58 +02:00
Andreas Schneider
a5cad4e700 tests: Do not use internal macros in the fuzzer
It should be buildable without internal headers.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-09 09:31:12 +02:00
Andreas Schneider
8ce6a889aa tests: Use the correct assert function in test server
CID 1398983

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-07-08 17:26:29 +02:00
Andreas Schneider
6e4e6f8da6 tests: Fix #ifdef in torture_server_config
This should stop detecting it as dead code.

CID 1402934

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-07-08 17:26:29 +02:00
Andreas Schneider
0734bc490f examples: Fix freeing the channel in ssh_client
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-07-08 17:26:21 +02:00
Andreas Schneider
b275045ac8 examples: Update header in ssh_client
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-08 15:02:38 +02:00
Andreas Schneider
85951a156b tests: Add ssh_client_fuzzer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-08 14:58:59 +02:00
Andreas Schneider
b5a8547d91 exmples: Use SSH_CONNECTOR_STDINOUT in client example
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-08 14:58:59 +02:00
Andreas Schneider
1a26c57af2 include: Add define for SSH_CONNECTOR_STDINOUT
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-08 14:48:28 +02:00
Andreas Schneider
595c2c4336 gitlab-ci: Run the fuzzer with AddressSanitzer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-08 12:02:19 +02:00
Andreas Schneider
343c90ccf4 ctest: Run the ssh_server_fuzzer to check it works
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-08 12:02:19 +02:00
Andreas Schneider
7cd66d49f8 tests: Fix memory leak in ssh_server_fuzzer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-08 12:02:19 +02:00
Andreas Schneider
b2c7e0dd69 cmake: We don't have to define the ssh link libraries
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-08 12:02:19 +02:00
Andreas Schneider
915c006a30 cmake: Fix linking shared and static libraries
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-08 12:02:19 +02:00
Andreas Schneider
2884f97bc5 dh_crypto: Use size_t for loop variable
Also don't declare the variable in the loop.

Fixes #157

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-05 16:49:09 +02:00
Stefan Strogin
0d4658740b libcrypto: fix compilation with LibreSSL
LibreSSL does not support FIPS mode, check for FIPS_mode() in
ConfigureChecks.cmake.

Signed-off-by: Stefan Strogin <steils@gentoo.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-04 17:57:35 +02:00
Andreas Schneider
fed31c1ca3 tests: Use C99 initilizer in test_server.c
This fixes a clang build warning.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-07-04 16:32:14 +02:00
Andreas Schneider
68533147e2 cmake: Write libssh-config.cmake using EXPORTS
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-07-04 16:08:34 +02:00
Andreas Schneider
24af712931 cmake: Use GNUInstallDirs for installation
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-07-04 16:08:34 +02:00
Andreas Schneider
519074f13e tests: Improve fuzzer test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-07-04 11:56:04 +02:00
Andreas Schneider
946ac0ee28 gitlab-ci: Enable building the ssh_server_fuzzer with clang
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-07-04 11:56:04 +02:00
Andreas Schneider
5a50fc6b0d cmake: Fix building the ssh_server_fuzzer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-07-04 11:56:04 +02:00
Andreas Schneider
22f038189c config: Increase debug level for unkown and unsupported options
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-07-04 11:56:04 +02:00
Anderson Toshiyuki Sasaki
f18a7cc17e kex: Do not ignore keys in known_hosts files
Previously, if the SSH_OPTIONS_HOSTKEYS option was set by any mean,
including the client configuration file, the keys in known_hosts files
wouldn't be considered before advertising the list of wanted host keys.

This could result in the client requesting the server to provide a
signature using a key not present in the known_hosts files (e.g. when
the first wanted algorithm in SSH_OPTIONS_HOSTKEYS is not present in the
known_hosts files), causing a host key mismatch and possible key
rejection.

Now, the keys present in the known_hosts files are prioritized over the
other wanted keys.  This do not change the fact that only keys of types
present in the list set in SSH_OPTIONS_HOSTKEYS will be accepted and
prioritized following the order defined by such list.

The new wanted list of hostkeys is given by:
 - The keys present in known_hosts files, ordered by preference defined
   in SSH_OPTIONS_HOSTKEYS.  If the option is not set, a default order
   of preference is used.
 - The other keys present in the same option are appended without adding
   duplicates.  If the option is not set, the default list of keys is
   used.

Fixes: T156

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-04 10:29:20 +02:00
Anderson Toshiyuki Sasaki
65a38759ca knownhosts: Introduced ssh_known_hosts_get_algorithms_names()
The added internal function obtain a newly allocated string containing a
list of the signature types that can be generated by the keys present in
the known_hosts files, separated by commas.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-04 10:29:20 +02:00
Anderson Toshiyuki Sasaki
548753b338 token: Added function to remove duplicates
Added a function to remove duplicates from lists.  This function is used
in a new provided function to append lists removing duplicates.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-04 10:29:20 +02:00
Anderson Toshiyuki Sasaki
e5a64a3d6b knownhosts: Read knownhosts file only if found
Avoid trying to open the files if they are not accessible.  This was
already treated as a non-error, but with this we save one function call.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-04 10:29:20 +02:00
Anderson Toshiyuki Sasaki
ad68de7271 tests: Check if known_hosts works with single unaccessible file
Make sure known hosts check works when local known_hosts file is
unaccessible, but the host is present in global known_hosts file.

Remove double return value check in previous existing test.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-04 10:29:20 +02:00
Anderson Toshiyuki Sasaki
fe248414fe knownhosts: Fix possible memory leak
The memory allocated for host_port can leak if the global knownhosts
file is unaccessible.

Found by address sanitizer build in CI.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-07-04 10:29:20 +02:00
Anderson Toshiyuki Sasaki
8e42ed8220 tests: Added a check for unaccessible global known_hosts
Verify that the check process will not fail if the global known_hosts
file is not accessible and the local known_hosts file contain the host.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-28 08:03:29 +02:00
Anderson Toshiyuki Sasaki
5617eaf0e2 knownhosts: Fixed a typo
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-28 08:03:29 +02:00
Anderson Toshiyuki Sasaki
4adb13d9e3 knownhosts: Do not fail if global known_hosts file is inaccessible
Previously, if the global known_hosts file (default:
/etc/ssh/ssh_known_hosts) was inaccessible, the check for known hosts
failed.  This makes the check to fail if both files are inaccessible.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-28 08:03:13 +02:00
Anderson Toshiyuki Sasaki
da50b12051 connect: Code style formatting
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-27 10:31:46 +02:00
Anderson Toshiyuki Sasaki
a82993b320 connect: Removed unused code
The internal function ssh_connect_host() is not used.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-27 10:31:46 +02:00
Anderson Toshiyuki Sasaki
6a9185636f packet: Check return value when sending unimplemented
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-27 10:31:46 +02:00
Anderson Toshiyuki Sasaki
a1ee22eb64 packet: Reformat ssh_packet_process()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-27 10:31:46 +02:00
Anderson Toshiyuki Sasaki
1d54a3880d auth: Do not print error message for SSH_AGAIN
In non-blocking mode, it is expected SSH_AGAIN to be returned many
times.  Do not flood the log with error messages.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-27 10:31:46 +02:00
Anderson Toshiyuki Sasaki
b1ff11f416 examples: Check ssh_event_dopoll() return value
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-27 10:31:46 +02:00
Anderson Toshiyuki Sasaki
25bb6eef96 dh-gex: Check return code ssh_dh_keypair_get_keys()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-27 10:31:46 +02:00
Anderson Toshiyuki Sasaki
d00ff451db gitlab-ci: Re-enable client tests in CentOS7
The tests were disabled because of failures in torture_auth.  The server
tests are not enabled because the pkd tests are failing.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-26 17:36:46 +02:00
Anderson Toshiyuki Sasaki
4b7ce75e1f pki: Add workarounds for old OpenSSH
When we are talking to old OpenSSH versions which does not support
rsa-sha2-{256,512}-cert-v01@openssh.com or SHA2 in certificates,
fallback to old supported values.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-26 17:36:46 +02:00
Anderson Toshiyuki Sasaki
c8f49becfd tests/pkd: Fix elif without expression
This was introduced during fixes to run pkd tests in FIPS mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-26 17:36:46 +02:00
Anderson Toshiyuki Sasaki
f64814b7be tests: Add a server test case for unknown global request
The test checks if the server handles unknown global requests properly.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-26 17:36:46 +02:00
Anderson Toshiyuki Sasaki
abf5712160 tests: Introduce torture_client_global_requests
Added a test case where invalid global requests are sent to the server
which should reject them, but not stop working.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-26 17:36:46 +02:00
Anderson Toshiyuki Sasaki
1aef599ab1 messages: Reject tcpip-forward requests as client
When the session is a client session, reject tcpip-forward requests.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-26 17:36:46 +02:00
Anderson Toshiyuki Sasaki
3d7d3f303e messages: Consume unknown global requests messages
When an unknown global request is received, consume the message to avoid
sending UNIMPLEMENTED later.  Only report the failure if the request
wants a reply.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-26 17:36:46 +02:00
Andreas Schneider
220f1e1435 Update ChangeLog to add FIPS
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-24 16:01:48 +02:00
Jakub Jelen
17a531d2af tests: Skip 1k RSA key generation in FIPS
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-21 08:58:21 +02:00
Jakub Jelen
a80547bdf9 pki_crypto: Correct error checking after RSA key generation
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-21 08:55:06 +02:00
Jakub Jelen
a4fa514549 tests: Filter out bogus output from openssh in FIPS Mode
The OpenSSH in RHEL 8 in FIPS Mode outputs information about this on start
and it needs to be skipped for the version detection (and build) to pass:

$ ssh -V
FIPS mode initialized
OpenSSH_8.0p1, OpenSSL 1.1.1c FIPS  28 May 2019

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-20 17:45:52 +02:00
Jakub Jelen
d5095a55b9 tests: Add reproducer for T76
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-19 18:01:36 +02:00
Jakub Jelen
d627cba476 pki: Search for the PEM headers not only on the start of the key file
Fixes: T76 for gcrypt and mbedtls backends

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-19 18:01:33 +02:00
Jakub Jelen
23c837f4d0 pki: Reformat pki_privatekey_type_from_string()
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-19 18:01:32 +02:00
Jakub Jelen
bd69ac63ca tests: Reproducer for proxy command with stderr output (T130)
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-19 18:01:30 +02:00
Jakub Jelen
6c49c41c19 socket: Do not process stderr of proxy commands (Fixes T130)
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-19 18:01:28 +02:00
Jakub Jelen
bd65568749 socket: Reformat the rest of the file
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-19 18:01:26 +02:00
Andreas Schneider
3cb0a1bf02 Bump SO version to 4.8.1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-14 15:22:56 +02:00
Andreas Schneider
2d2a4f3784 include: Make sure ssh_session_get_known_hosts_entry is added to the API
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-14 15:22:56 +02:00
David Wedderwille
70dd8b0348 callbacks: Add ssh_threads_get_default() to the callbacks.h
Fixes: T154

Signed-off-by: David Wedderwille <davidwe@posteo.de>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-14 15:22:56 +02:00
Anderson Toshiyuki Sasaki
c4463ba5e7 tests/torture_config: Replace long long with uint64_t
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-14 15:22:45 +02:00
Anderson Toshiyuki Sasaki
fba384ac58 tests/torture_rekey: Replace long long with uint64_t
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-14 15:22:45 +02:00
Anderson Toshiyuki Sasaki
ab25ca205d channels: Do not mix integer types
Use uint32_t when expecting 32 bits unsigned int.  Use PRIu32 macro to
print correctly independently of the architecture.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-14 15:22:45 +02:00
Anderson Toshiyuki Sasaki
91960409c3 ed25519: Replace unsigned long long with uint64_t
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-14 15:22:45 +02:00
Anderson Toshiyuki Sasaki
955d6f1b17 config: Replace long long with int64_t
Do not use long long as equivalent as int64_t.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-14 15:22:45 +02:00
Anderson Toshiyuki Sasaki
0280ff12a5 sftp: Do not mix integer types
Don't use long unsigned int as equivalent as uint32_t.  Use macros to
correctly print the values independently of the architecture.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-14 15:22:45 +02:00
Anderson Toshiyuki Sasaki
b775e316fa priv.h: Add macro definitions for PRIx32 and PRIx64
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-14 15:22:45 +02:00
Anderson Toshiyuki Sasaki
dc4d4cc8d4 tests/torture_rekey: Do not mix integer types
In torture_rekey_time(), "long long" was used instead of uint32_t.  This
makes the test to fail in some architectures where the sizes don't match.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-14 07:48:01 +02:00
Jakub Jelen
4fc37bb6fe tests: Add more reproducers for valid and invalid Match exec blocks
Fixes: T152

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-14 07:48:01 +02:00
Jakub Jelen
ed8284ab09 config: Skip the rest of the line for Match exec
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-14 07:48:01 +02:00
David Wedderwille
f46eff79e2 cmake: Bump API version to 4.8.0
Fixes T153

Signed-off-by: David Wedderwille <davidwe@posteo.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:49:43 +02:00
David Wedderwille
658a150991 channels: Make ssh_message_channel_request_open_reply_accept_channel public
This also adds documentation for it.

Fixes T144

Signed-off-by: David Wedderwille <davidwe@posteo.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:49:20 +02:00
David Wedderwille
32eec7b418 SSH_LOG: Adjust log level from SSH_LOG_WARNING to SSH_LOG_PROTOCOL
Fixes T149

Signed-off-by: David Wedderwille <davidwe@posteo.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:43:44 +02:00
Andreas Schneider
1f43b52117 tests: Fix the glob test on musl libc
Fixes #150

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:43:44 +02:00
Jakub Jelen
c0c1454298 session: OpenSSH is using SHA256 fingerprints now
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Jakub Jelen
ddece69a07 .gitlab-ci.yml: Add FIPS tests
Added a build running in a Fedora image with crypto-policies set as FIPS
and forcing OpenSSL FIPS mode through environment variable.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Anderson Toshiyuki Sasaki
5568e5e520 tests/pkd: Fix OpenSSH version check
When running in FIPS mode, the OpenSSH version is not the first string
printed by "ssh -V".  This makes the parser to find the first occurrence
of the version ignoring anything printed before it.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Anderson Toshiyuki Sasaki
905b027f0f tests/pkd: Check OpenSSH version only once
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Anderson Toshiyuki Sasaki
57cf0cf230 tests/torture_server_config: Use only allowed algorithms
Use ssh_kex_get_fips_methods() instead of ssh_get_default_methods() if
in FIPS mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Anderson Toshiyuki Sasaki
4416a0dae6 tests/pkd: Add tests using certificates with SHA2 in signatures
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Anderson Toshiyuki Sasaki
73b94abea4 tests/pkd: Accept certificates with SHA2 in signatures
Previously the server in pkd tests would not accept certificates using
SHA2 in signatures.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Anderson Toshiyuki Sasaki
bd32fb020b tests/pkd: Use only allowed algorithms if in FIPS mode
Use only allowed algorithms in FIPS mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Anderson Toshiyuki Sasaki
bb36cc30ee tests/torture_pki_rsa: Avoid using SHA1 in FIPS mode
Do not use SHA1 in signatures in FIPS mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Jakub Jelen
b6aef1fdd5 tests: Update negative test cases to use EC instead of ED keys
Also systematically use assert_ssh_return_code() instead of various
checks for return codes.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Jakub Jelen
c7c3c16fc8 tests: There is no 8B block cipher in FIPS Mode
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Jakub Jelen
bfafdab035 tests: Use more widely supported RSA key as a hostkey
Intially introduced for the FIPS support

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Jakub Jelen
426c6c1321 tests: Avoid mixing stderr with stdout
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Jakub Jelen
a006c3c451 tests: Use consistent checking for ssh return code
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Jakub Jelen
20e58be7d8 tests: Adjust for FIPS and simplify initialization
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Anderson Toshiyuki Sasaki
8c59f7f236 tests/torture_pki_dsa: Skip completely if in FIPS mode
DSA is not allowed in FIPS mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Anderson Toshiyuki Sasaki
9ef0b0b029 tests/torture_pki: Skip some tests if in FIPS mode
Skip tests requiring algorithms not allowed in FIPS mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Anderson Toshiyuki Sasaki
39c69893c7 tests/torture_options: Use only allowed algorithms if in FIPS mode
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:32 +02:00
Anderson Toshiyuki Sasaki
ce888fd4c0 tests/torture_config: Use only allowed algorithms in FIPS mode
Use only allowed algorithms if running in FIPS mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:29:30 +02:00
Anderson Toshiyuki Sasaki
af031d8df6 tests/torture_bind_config: Use allowed algorithms in FIPS mode
Use only allowed algorithms if in FIPS mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:28:25 +02:00
Anderson Toshiyuki Sasaki
92a0d23eac tests/torture_hostkey: Skip some tests in FIPS mode
Skip tests using non allowed algorithms.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:28:25 +02:00
Anderson Toshiyuki Sasaki
1a6ac291a7 tests/torture_client_config: Adjust lists in FIPS mode
Use only allowed algorithms if in FIPS mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:28:25 +02:00
Anderson Toshiyuki Sasaki
bdb2ef4dcc tests/torture_algorithms: Skip some tests in FIPS mode
When running in FIPS mode, skip the tests using algorithms not allowed.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:28:25 +02:00
Anderson Toshiyuki Sasaki
41834f228b tests: Use different config if in FIPS mode
Use a different OpenSSH configuration if running in FIPS mode, which
contains only allowed algorithms.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:28:25 +02:00
Jakub Jelen
03ca994cc0 tests: Use the SHA2 extension by default to avoid issues in FIPS mode 2019-06-13 16:28:25 +02:00
Anderson Toshiyuki Sasaki
53ae2502f4 kex: Only advertise allowed signature types
Previously, if the client supported rsa-sha2-256 or rsa-sha2-512, the
server would advertise the extensions as supported without checking its
own list of allowed algorithms.  Now the server will only advertise
allowed signature algorithms.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 16:28:23 +02:00
Anderson Toshiyuki Sasaki
1b7146e28f server: Send only allowed algorithms in extension
Send only allowed algorithms in server-sig-algs extension if in FIPS
mode.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 14:37:39 +02:00
Jakub Jelen
a3ddc48cb0 pki: Derive correct algorithm identification for certificate authentication with SHA2 extension
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
132ed59d3f agent: Use SHA2 signatures also for RSA certificates
There is actually a bug in OpenSSH's ssh-agent of handling these
requests [1], but this change follows the way how OpenSSH clients
behave in regards to the communication with agent.

Without this change, the agent is asked to provide SHA1 signature
with certificates, which is not right if we negotiated SHA2 extensions.

[1] https://bugzilla.mindrot.org/show_bug.cgi?id=3016

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
f91a5fce6e tests: Use ed25519 keys explicitly
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
63f477181a tests: The DSA is not available in mbedtls
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Anderson Toshiyuki Sasaki
2c385c0e13 tests/client/torture_auth: Skip some tests if in FIPS mode
If in FIPS mode, skip tests which require algorithms not allowed.  Also
use allowed algorithms when possible to avoid skipping the test.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
66755c478c tests: Do not free pcap context while it is in use by the server session
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
9f178be1fa tests: Cover comparison of public keys, which was missing
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
1f66414805 pki_gcrypt: Do not compare private parts when comparing public keys
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
6d5ac15a51 config: Remove bogus trailing newlines in log messages
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Jakub Jelen
85241c19e9 kex: Reformat ssh_kex_get_supported_method() 2019-06-13 11:00:56 +02:00
Jakub Jelen
53cee7c9a3 kex: List also certificate types in list of allowed public key algorithms
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Anderson Toshiyuki Sasaki
f64c3dec74 tests: Add PKCS#8 PEM encrypted private keys
Copies of the DSA, RSA, and ECDSA keys were added encoded in PKCS#8
format.  For now, these keys are only used when testing with OpenSSL.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Anderson Toshiyuki Sasaki
0cfe4c7ab8 tests/torture_auth: Workaround OpenSSH agent bug
OpenSSH agent has a bug which makes it to not use SHA2 in signatures
when using certificates. It always uses SHA1.

See https://gitlab.com/libssh/libssh-mirror/merge_requests/34

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-13 11:00:56 +02:00
Anderson Toshiyuki Sasaki
01f4040218 dh: Avoid segmentation fault in GEX if fallback to known moduli
Make ssh_fallback_group() to duplicate the modulus and generator.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 12:37:43 +02:00
Anderson Toshiyuki Sasaki
7656911953 bignum: Define bignum_dup(bignum orig, bignum *dest)
The macro is defined for each crypto back end.  If (*dest) is NULL, a
new bignum is allocated.  Otherwise the value of orig is copied to
(*dest).

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-06-12 12:36:32 +02:00
Jakub Jelen
9f7f5dee18 tests: Verify duplicate items are removed from knownhosts entries list
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 11:15:20 +02:00
Jakub Jelen
5f01ed0278 tests: Verify duplicate items are removed from knownhosts algorithms
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 11:15:20 +02:00
Jakub Jelen
196361c1f0 ssh_known_hosts_get_algorithms: Avoid returning duplicate key types from known hosts algorithms
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 11:15:20 +02:00
Jakub Jelen
79cd2618ec ssh_known_hosts_read_entries: Avoid returning duplicate knownhowst items
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 11:15:20 +02:00
Anderson Toshiyuki Sasaki
54d76098ed kex, pki, server, options: Filter algorithms in FIPS mode
When in FIPS mode, filter the algorithms to enable only the allowed
ones.  If any algorithm is explicitly set through options or
configuration file, they are kept.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 11:13:52 +02:00
Jakub Jelen
56041dc784 torture_hashes: Skip the MD5 tests in FIPS mode
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 10:41:24 +02:00
Jakub Jelen
167aa8bc6c pki_crypto: Use the new OpenSSL API to read PEM files
This allows the use of the new PKCS#8 PEM files and does not
limit libssh to using only the "traditional" PEM files, that
are not default in OpenSSL since 1.0.0 and which do not work
at all in FIPS mode.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 10:41:24 +02:00
Jakub Jelen
0ce1e84d90 pki_crypto: Use the new OpenSSL API to write new PKCS#8 PEM files
Since OpenSSL 1.0.0, the "traditional" PEM format was deprecated
in favor of the PKCS#8 PEM files which is more standardized,
more secure and does not depend on the MD5 hash, which is not
available for example in FIPS mode.

This requires using the new EVP_PKEY API for reading private key
blobs.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 10:41:24 +02:00
Anderson Toshiyuki Sasaki
ee456104f1 session: Do not use MD5 in FIPS mode
Do not use MD5 when generating fingerprints in FIPS mode.  The call will
fail in such case.  The test suite was updated with a negative test for
this case.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 10:27:40 +02:00
Anderson Toshiyuki Sasaki
0fb7d9831a tests: Make sure unknown options are ignored in server config
Added a test to make sure unknown options in the configuration file are
ignored and don't make ssh_bind_options_parse_config() to fail.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
55c637f2d3 bind_config: Fail if a known option couldn't be set
Make ssh_bind_options_parse_config() to fail if setting a known option
fails.  Previously the return value of ssh_bind_options_set() were
ignored when configuring the server through a configuration file.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
d783aec96c kex: Remove unused code
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
dc35bbbeb1 server: Use default methods instead of all
Previously, when no methods were set, the server would enable all
supported methods.  This changes this behaviour by setting only the
default methods.

The server in pkd_daemon.c was changed to set explicitly all the
supported methods to keep the previous behaviour.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
2db2a4e170 kex: Make order of preferred signature algorithms consistent
The default order of preference for signature algorithms were not
consistent. This makes the following order of preference to be the
default order:

* ssh-ed25519
* ecdsa-sha2-nistp521
* ecdsa-sha2-nistp384
* ecdsa-sha2-nistp256
* rsa-sha2-512
* rsa-sha2-256
* ssh-rsa
* ssh-dss

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
a8064cb0ca tests: Added tests for server config file
The added tests run the server with different combinations of algorithms
and try to connect using a client.

Note that few combinations are tested.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
e7ef40c8f0 tests: Allow setting configuration file for test server
This allows testing the server with a configuration file.  This also
adds an option for the stand-alone test server to skip parsing the
system-wide configuration file.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
79f0c38fbd options: Allow avoiding system-wide configuration
The added option SSH_BIND_OPTIONS_PROCESS_CONFIG allows to skip
processing the system-wide configuration file.  The global configuration
file is processed automatically if this option is not set as false.

This option will only be effective if set before any call to
ssh_bind_options_parse_config().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
07faf95a10 bind_config: Add support for HostKeyAlgorithms
Add support for setting the allowed HostKey algorithms through
configuration file.

Note that this does NOT add support for adding or removing values using
'+' or '-'. Only replacing the whole list is supported.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
250a0be0f9 options: Added an option to set server HostKey algorithms
The added option SSH_BIND_OPTIONS_HOSTKEY_ALGORITHMS allows restricting
the signature algorithms to offer to the client for host authentication.
The list set is used as a filter of allowed algorithms.

First a list of possible signature algorithms to offer is created from
the keys set and then such list is filtered against the allowed
algorithms.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
8f6e6f774e bind_config: Add support for PubkeyAcceptedKeyTypes
Add support for setting the accepted public key types through
configuration file.

Note that this does NOT add support for adding or removing values using
'+' or '-'. Only replacing the whole list is supported.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
f4363f5655 options: Add option to set server accepted pubkey types
The added option SSH_BIND_OPTIONS_PUBKEY_ACCEPTED_KEY_TYPES allows
restricting the allowed public key types accepted by the server for
authentication.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
bc95a51710 kex, known_hosts: Use new tokens functions
Replace the old tokens handling functions usage with the new implementation.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
2c4850cbbd token, kex: Add functions to handle tokens lists
The added functions allow splitting chains of tokens separated by a
given character (usually ','), and extracting matching parts between two
chains of tokens.

The previously existing functions in kex.c were replaced by the
introduced ones.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
b0ff64bf1b pki: Check if the key is allowed against right list
Previously when generating the signature in server side the key was
checked against the wrong list, potentially making the server to select
the wrong algorithm to sign (e.g. rsa-sha2-512 instead of rsa-sha2-256).

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
d013a94f37 gitlab-ci: Remove cmake cache before building in csbuild
This avoids csbuild failures due to new source files added.  Previously
in some runs, csbuild would try to reuse the existing cmake cache file
which could contain added dependencies to new source files, leading to
failure in the run.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Anderson Toshiyuki Sasaki
adfd3cd3f3 gitlab-ci: Do not print crypto debug info
Do not print crypto debug information to reduce size of generated logs.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-06-12 10:17:54 +02:00
Andreas Schneider
1a3436d7d3 knownhosts: Fix use after free
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-06-12 10:17:54 +02:00
Andreas Schneider
77ada9e4dc tests: Fix null termination in torture_read_one_line()
CID 1393902

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-28 09:18:53 +02:00
Andreas Schneider
328a631a0f config: Add missing NULL check
CID 1398303

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-28 09:18:53 +02:00
Andreas Schneider
a7e17a34ad gzip: Add missing NULL check
CID 1398980

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-28 09:18:52 +02:00
Andreas Schneider
d9f9bee13f tests: Fix assert_return_code in server test
CID 1398983
CID 1398982

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-28 09:18:52 +02:00
Andreas Schneider
7e344ca052 examples: Fix a possible resource leak in sshd_direct-tcpip
CID 1398985

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-28 09:18:52 +02:00
Andreas Schneider
18a89c6ec2 pki: Avoid a null pointer derefrence
CID 1401434

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-28 09:18:51 +02:00
Andreas Schneider
cb502a4a6d pki_crypto: Make sure that we set buf to NULL after free()
CID 1401436

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-28 09:18:46 +02:00
Andreas Schneider
123db84b2c pki_crypto: Fix a possible null pointer dereference
CID 1401438
CID 1401437

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-28 09:18:23 +02:00
Anderson Toshiyuki Sasaki
30997a098c Update ChangeLog
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-22 15:36:29 +02:00
raminfp
9b1772ecbd sftp: Remove the break statements
They aren't needed and perhaps some compilers will issue "Unreachable
code" warnings.

Signed-off-by: Ramin Farajpour Cami <ramin.blackhat@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-22 15:35:29 +02:00
Anderson Toshiyuki Sasaki
9fb7fb3fac socket: Use calloc in ssh_socket_new()
This makes sure the content will be zero after successful allocation.

Resolves T134

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-22 15:32:41 +02:00
Anderson Toshiyuki Sasaki
59ba3f1896 dh-gex: Fix memory leak in DH GEX with OpenSSL
When using OpenSSL, the bignums generated during group exchange are
duplicated and don't transfer the memory management responsibility to
the back-end.  The original generated bignums can be freed.

The leak was detectable by running:

$ valgrind --leak-check=full ./tests/pkd/pkd_hello -i1 \
    -t torture_pkd_openssh_rsa_rsa_diffie_hellman_group_exchange_sha256

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-22 15:31:51 +02:00
Anderson Toshiyuki Sasaki
38f9802eec config: Add support for PubkeyAcceptedKeyTypes
The added option is an alias for the previously existing option
PubkeyAcceptedTypes.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-14 17:32:25 +02:00
Jakub Jelen
eae971c002 tests: Update knownhost tests with reproducer from T110
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-14 17:26:30 +02:00
Jakub Jelen
962bdf806c knownhosts: Handle wildcard ports matches against standard one
Fixes T110

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-14 17:26:27 +02:00
Jakub Jelen
1e22a089eb Reformat ssh_hostport()
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-14 17:26:24 +02:00
Jakub Jelen
8152c6aba4 knownhosts: Ignore OpenSSH markers related to certificates
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-14 17:26:18 +02:00
Anderson Toshiyuki Sasaki
7cc159d720 cmake,options: Allow to set global client config file
This allows the global client (ssh_session) configuration file path to
be set in configuration time by defining GLOBAL_CLIENT_CONFIG when
calling cmake.  If it is not defined, the default path is set as
"/etc/ssh/ssh_config".

usage example:

$ cmake -DGLOBAL_CLIENT_CONFIG=/etc/my/custom/path ..

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-14 17:20:39 +02:00
Anderson Toshiyuki Sasaki
248e5acd5c pki: Fail to sign when using wrong hash algorithm
Do not allow using SSH_DIGEST_AUTO for any algorithm other than
ed25519.

Do not allow using incompatible hash algorithms when signing or
verifying signatures.

Added negative tests for all combinations of signature and hash
algorithms.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
550a1a7667 pki: Remove unused code
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
db51fa1bc1 pki: Use pki_sign_data() and pki_verify_data_signature()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
d923dc39c1 tests: Use public key to verify signatures
Previously in the tests the private key structure would be used for
signature verification.  Use the corresponding public key instead.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
88a8b1f57c pki_gcrypt: Added pki_sign_data() and pki_verify_data_signature()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
7bc53f3957 pki_mbedcrypto: Added pki_sign_data() and pki_verify_data_signature()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
fd9446553b pki_crypto: Added pki_sign_data() and pki_verify_data_signature()
pki_sign_data() uses the given private key and hash algorithm to sign
the data using the OpenSSL EVP interface.  The corresponding function
pki_verify_data_signature() receives the signature, the signed data, and
the public key to verify the signature.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
33af736555 pki_crypto: Store ECDSA raw signature in ssh_signature
Store the raw signature instead of the internal backend structure.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
132c7bee64 pki_crypto: Store DSA raw signature in ssh_signature
Store the raw signature instead of the internal backend structure.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
ba67555764 pki_crypto: Store raw RSA signature in ssh_signature
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
0ea9e39e81 pki: Add a common place to store raw signatures
This is a preparation to store the raw signature for all algorithms in
the same place in ssh_signature.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
e775182c2e pki: Make DSA signature to use SHA1 instead of AUTO
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
76f9808eb2 auth, pki: Calculate hash internally when signing/verifying
This makes pki_do_sign() and pki_signature_verify() to receive the
original input instead of the pre-calculated hash.  The hash is then
calculated internally.

The hash to be used inside the signature is decided earlier, when all
the information about the signature to be generated/verified is
available.

Simplify ssh_pki_do_sign() and ssh_srv_pki_do_sign_sessionid().

The tests were modified to use pki_do_sign() instead of
pki_do_sign_hash().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
58b3b2696c pki_crypto: Change SSH_KEYTYPE_ED25519 position in switches
The goal here is to avoid errors due to fall through when
HAVE_OPENSSL_ECC is not defined.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
20c03c289e pki_crypto: Refactor pki_signature_to_blob()
Refactor pki_signature_to_blob() without behaviour changes.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
c27d41df75 pki_crypto: Fixed typos transfered -> transferred
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
99053a6c33 pki_cryto: Refactor pki_signature_from_blob()
Refactor the code without behaviour changes.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
c3b8f9c0ec pki_crypto: Make pki_signature_from_rsa_blob() to return int
The goal of this change is to make pki_signature_from_*_blob()
consistent.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
01e98a6df7 pki: Remove duplicate and unused code
Remove duplicate code previously used only in server side to generate
signatures.  Currently the code used to generate the signature is the
same for both client and server.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
dbf3f962a4 pki: Refactor ssh_srv_pki_do_sign_sessionid()
Refactor ssh_srv_pki_do_sign_sessionid() without behaviour changes.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
3917a5c916 pki: Refactor ssh_pki_do_sign()
Added ECDSA key types to ssh_key_type_to_hash(). Refactor
ssh_pki_do_sign() without behaviour changes.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
5f7a3c5c66 wrapper: Make sha{1, 256, 384, 512}() input const
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Anderson Toshiyuki Sasaki
848f59c37e wrapper.h: Add SSH_DIGEST_SHA384 to ssh_digest_e enum
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-13 16:37:51 +02:00
Jon Simons
0849e44220 dh: fix libcrypto leak via ssh_dh_keypair_set_keys
Upon SSH_OK, callers of `ssh_dh_keypair_set_keys` expect for ownership
of the `priv` and `pub` values to be transferred away and eventually
later managed by way of the `struct dh_ctx` at hand.

The mbedTLS and gcrypt builds transfer ownership of these values in
that way, but the libcrypto `ssh_dh_keypair_set_keys` is copying the
given values with `BN_dup`.  This causes a memory leak that can be
seen with pkd and valgrind:

    valgrind --leak-check=full \
      ./pkd_hello -i1 -t torture_pkd_openssh_dsa_rsa_diffie_hellman_group16_sha512

Fix the leak by replacing the `BN_dup` with direct assignment.
Now the bignums will eventually be freed via `ssh_dh_cleanup`.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-09 17:37:33 +02:00
Jon Simons
ee42e3badb dh: fix libcrypto dh_ctx leak in ssh_dh_cleanup
Ensure to free the `dh_ctx` member in `ssh_dh_cleanup` to match
the allocation in `ssh_dh_init_common`.

The before-and-after of this change can be observed with the pkd
tests and valgrind:

    valgrind --leak-check=full \
      ./pkd_hello -i1 -t torture_pkd_openssh_dsa_rsa_diffie_hellman_group16_sha512

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-05-09 17:37:33 +02:00
Andreas Schneider
ee82bab801 auth: Avoid memory on error in ssh_userauth_agent_publickey()
CID 1401095

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-05-06 11:41:02 +02:00
Andreas Schneider
db8aca69a7 knownhosts: Avoid possible null pointer dereference
CID 1401096

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-05-06 11:40:27 +02:00
Andreas Schneider
3fccb24464 tests:pkd: Fix size comparison (payload.len is size_t)
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-29 16:52:23 +02:00
Jon Simons
19cb6f1b6c server: fix sending SSH_MSG_EXT_INFO upon rekey
Fix libssh server sending SSH_MSG_EXT_INFO messages upon rekey: clients
do not expect that message during rekey, and OpenSSH in particular will
log error messages along the lines of:

    "kex protocol error: type 7 seq 15"

when the message is received during a rekey.

To fix, check against the session connected flag, which only transitions
to non-zero following the first successful authentication.

bf2c7128ab adds logic to resolve this
issue, but it turns out that checking the session_state to avoid
sending the message is insufficient, because that state is re-set
to SSH_SESSION_STATE_KEXINIT_RECEIVED during rekey.

The before-and-after effects of this change can be observed using the
pkd --rekey flag as so:

    ./pkd_hello -t torture_pkd_openssh_rsa_rsa_sha2_256 \
      -i1 --rekey=16 -v -v -v 2>&1 |
      grep -e 'KEY' -e 'EXT'

^ where before the change, multiple SSH_MSG_EXT_INFO send messages are
logged; after, there is only a single SSH_MSG_EXT_INFO logged once upon
the first initial key exchange.

Cross-reference: https://bugs.libssh.org/T121.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-29 14:00:39 +02:00
Jon Simons
c0f3a96089 server: fix queued USERAUTH_SUCCESS rekey bug
Fix a bug with server-side rekeying where the session state at hand
has been toggled to SSH_SESSION_STATE_AUTHENTICATED before performing
the packet send of the SSH2_MSG_USERAUTH_SUCCESS message.

Before this change, what can happen is that during the packet send,
the SSH2_MSG_USERAUTH_SUCCESS message can end up being queued due
to a small rekey data limit value.  libssh server will then proceed
to attempt to send KEX-related rekeying messages to the client before
the client has received USERAUTH_SUCCESS.  OpenSSH clients do not
expect to undergo rekeying before having been authenticated, and so
will exit with error when this happens.

The behavior before and after can be observed with the pkd test making
use of its new --rekey flag:

    ./pkd_hello -t torture_pkd_openssh_rsa_rsa_default -i1 --rekey=16 -v -v -v

A new CMake test entry is added for the above variation and can be run
with:

    ARGS="-R pkd_hello_rekey" make test

Before the fix, the test will fail; after, the test succeeds while
performing rekeying once every 16 bytes.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-29 14:00:39 +02:00
Jon Simons
7ef2fe7f7b packet: log when data-based rekeying needed
Log an SSH_LOG_PACKET debug message when rekeying is necessary due to
the cipher max_blocks configuration.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-29 14:00:39 +02:00
Jon Simons
175375bc09 tests/pkd: support --rekey to set rekey data limit
Support an optional --rekey input to set the SSH session rekey data
limit using SSH_OPTIONS_REKEY_DATA.  This flag can be used together
with --buffer to test out server rekeying.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-29 14:00:39 +02:00
Jon Simons
03a1f1dd0c tests/pkd: support optional --buffer for test payload
Support an optional --buffer input for the pkd tests to enable testing
with a larger payload than the default "hello\n".

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-29 14:00:34 +02:00
Jon Simons
410f100968 tests/pkd: input test payload buffer
Move the pkd test payload buffer into the arguments struct, to make
way for parameterizing the payload using command-line options.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-29 14:00:28 +02:00
Jakub Jelen
104c696bca dh-gex: Verify received primes in FIPS mode to match one of the known groups
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-29 13:18:09 +02:00
Jakub Jelen
e446507352 Provide a function to query crypto backend for FIPS status
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-29 13:18:09 +02:00
Jakub Jelen
67beaf363f dh-gex: Fall back to known primes when the moduli file is not readable
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-29 13:18:09 +02:00
Jakub Jelen
4012338862 doc: Update the description of the pki_private_key_decrypt() function to match reality
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-29 13:18:09 +02:00
Jakub Jelen
bb7920efbc tests: Avoid reading user configuration when running algorithm tests
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-29 13:18:09 +02:00
Andreas Schneider
3e8bdb122f knownhosts: Check if the hosts file exists
Fixes T135

Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:27 +02:00
David Wedderwille
cc536377f9 sftp server: Implementation of sftp_server_free() as counterpart to sftp_server_new()
Fixes T143

Signed-off-by: David Wedderwille <davidwe@posteo.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:24 +02:00
Andreas Schneider
643ca67f88 gssapi: Add missing malloc checks
Fixes T141

Reported-By: Ramin Farajpour Cami
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:21 +02:00
Andreas Schneider
8a885f0bd3 channels: Add check if we are authenticated before we create a channel
Fixes T139

Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:19 +02:00
Andreas Schneider
c4348c7b3c sftp: Check if the channel is still valid
Fixes T138

Reported-by: Jan Pazdziora <jpazdziora@redhat.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:16 +02:00
Enji Cooper
5ffc595d0d Document more @return values with doxygen for APIs
Summary:
* Note that SSH_ERROR can be returned on error in `ssh_channel_get_exit_status`
  and `ssh_channel_get_session`.
* Note the return codes for `channel_open` and `grow_window`; although these
  are internal APIs, it's best to document their behavior.
* Replace `@returns` use with `@return`. While Doxygen supports the
  former as a synonym for `@return`, it isn't documented in the manual
  (and might not be supported by other downstream documentation tools).

Signed-off-by: Enji Cooper <yaneurabeya@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>

Test Plan: n/a

Reviewers: #libssh, asn

Differential Revision: https://bugs.libssh.org/D15
2019-04-29 13:17:11 +02:00
Rosen Penev
815a53375e libcrypto: Fix compilation without deprecated OpenSSL APIs
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:09 +02:00
Till Wimmer
6cd506ea81 options: Update doc for SSH_OPTIONS_PORT
Signed-off-by: Till Wimmer <g4-lisz@tonarchiv.ch>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:06 +02:00
Till Wimmer
95ab5f0dce channel: Don't send EOF on channel more than once
Signed-off-by: Till Wimmer <g4-lisz@tonarchiv.ch>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:17:01 +02:00
Till Wimmer
9340a0af5e connector: Stop socket-to-channel EOF flooding
Signed-off-by: Till Wimmer <g4-lisz@tonarchiv.ch>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-29 13:16:54 +02:00
Ben Toews
08b3301e4f tests/pkd: connect to openssh using certificates
Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
4a01496810 tests/unittests: test that signatures can be verified with certs
Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
2f26b5d63c pki: allow certificates to be used in signature verification
A number of places checked that the signature type matched the key type. We
losen these checks to, for example, allow an RSA signature with an RSA-cert
key.

Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
7c0719e53d pki: parse keys from certificates into ssh_key
Previously, we were just storing the raw certificate in ssh_key->cert. With
this change, we parse out the nonce string at the beginning of the certificate.
This leaves us with the certificate's public key at the start of the buffer.
The existing public key parsing code can then parse this out into the key fieds
of the ssh_key.

Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
04b284dae0 tests/unittests: test ECDSA/ED25519 support
These tests are copied from the existing RSA/DSA certificate tests. They cover
importing certificates.

Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
19cd909c8d pki: support ECDSA/ED25519 certificates
As with RSA/DSS, support is still quite limited. This is mostly about adding
new ssh_keytypes_e values and updating sites that check keys' types.

Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
b1f3cfec34 libssh: deprecate SSH_KEYTYPE_ECDSA
This type is imprecise. We often need the ecdsa_nid in addition to the key type
in order to do anything. We replace this singluar ECDSA type with one type per
curve.

Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
78f764b7c9 torture_pki: store test case attributes in struct instead of multiple arrays
Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:42 +02:00
Ben Toews
e036c426f8 tests: add OpenSSL includes dir for torture tests
Tests were failing to build on macOS with OpenSS installed using homebrew.

Signed-off-by: Ben Toews <mastahyeti@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-04-17 10:21:35 +02:00
Andreas Schneider
77a6fe4a62 dh-gex: Add error check for ssh_packet_client_dhgex_group()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-15 19:58:58 +02:00
Simo Sorce
33ad6bc54e dh: Add compat function for openssl < 1.1.0
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-04 08:00:31 +02:00
Simo Sorce
33399e52f0 dh: Add OpenSSL libcrypto specific DH implementation
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-04 08:00:28 +02:00
Simo Sorce
7551857d08 dh: Move DH key handling into a separate file.
In preparation for adding crypto-libraries specific backends.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-04 08:00:23 +02:00
Simo Sorce
30d97979a2 dh: Confine DH KEX keys handling into fewer functions
In preparation for deferring computation on DH secret material to
crypto library specific backends

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-04 08:00:19 +02:00
Simo Sorce
2f38af1559 dh: Rename variables for DH key exchange
Rename and refactor how some variables are held in ssh_crypto_struct.
Refactor allocation of dh exchange public keys.

This is in preparation for switching the code to use openssl native DH
handling and allowed to better reason about the code and the overall API.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-04 08:00:15 +02:00
Simo Sorce
997fe4d418 mbedcrypto: Make bignum_bin2bn behave like others
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-04 07:59:58 +02:00
Anderson Toshiyuki Sasaki
fd30cf0676 tests: Add test cases for Match keyword in bind config
Adds test cases for the Match keyword for the bind options configuration
using a file.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:41:56 +02:00
Anderson Toshiyuki Sasaki
d9e6237a47 bind_config: Added minimal support for Match keyword
Only "Match All" is supported, if any other criterion is used, the block
is ignored and the options are not applied.

It is important to note that only a subset of the supported keywords are
allowed to be used inside a Match block, currently being "LogLevel" the
only supported keyword.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:41:53 +02:00
Anderson Toshiyuki Sasaki
25af8641b3 bind: Apply global configuration automatically
Apply the global bind configuration from the file pointed by
BIND_GLOBAL_CONFIG when a bind_new() is called.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:38:17 +02:00
Anderson Toshiyuki Sasaki
d6d9b56bb9 cmake,options: Allow to set global bind config file
This allows the global bind configuration file path to be set in
configuration time by defining the GLOBAL_BIND_CONFIG when calling
cmake.  If no value is defined, the default path is set as
"/etc/ssh/libssh_server_config".

usage example:

$ cmake -DGLOBAL_BIND_CONFIG=/etc/my/custom/path ..

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:38:17 +02:00
Anderson Toshiyuki Sasaki
68385a2e98 options: Add a bind option to set the config directory
This adds the SSH_BIND_OPTIONS_CONFIG_DIR which allows to set the
directory used to expand the escape character "%d" when passing a path
to ssh_bind_options_parse_file().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:38:17 +02:00
Anderson Toshiyuki Sasaki
fd25beff68 options: Introduce ssh_bind_options_parse_config()
The added API allows setting the options of a given bind context through
a configuration file.  The default global configuration file
"/etc/ssh/libssh_server_config" is parsed before the provided
configuration file, if it hasn't been parsed yet.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:38:17 +02:00
Anderson Toshiyuki Sasaki
bab4d2b77b tests: Add tests for server side configuration
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:38:17 +02:00
Anderson Toshiyuki Sasaki
55a713cb04 bind_config: Support server side configuration
Introduced the support to set options for a given ssh_bind through a
configuration file.

For options set more than once in a single file (or by files included in it
recursively) the first value set will be kept.

Differently from the session options configuration,
if an option previously set in one configuration file is redefined in a
later processed file, the latest will be kept.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:38:15 +02:00
Anderson Toshiyuki Sasaki
79049981a5 config: Move common parser functions to config_parser.c
This will allow the moved functions to be used in the server side
configuration parser implementation.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:25:22 +02:00
Anderson Toshiyuki Sasaki
19e886d6b1 bind: Use calloc instead of malloc
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:25:22 +02:00
Anderson Toshiyuki Sasaki
0bde6b142c tests: Add missing unit tests for bind options
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-04-01 08:25:05 +02:00
Alberto Garcia Illera
45c7d07780 misc: Avoid printing full path in debug message
Signed-off-by: Alberto Garcia Illera <agarciaillera@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-29 14:42:40 +01:00
pmorris67
f05571841b channels: Added function to create channel to UNIX socket
[asn: Reformatting and added openssh version check]
Signed-off-by: Philip Morris <philip.morris67@ntlworld.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-29 08:10:43 +01:00
Andreas Schneider
55bcefbc56 config: Use size_t instead of u_int
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-25 19:16:28 +01:00
Jan Pazdziora
b0bd05a724 sftp_get_error returns int, not char *.
Signed-off-by: Jan Pazdziora <jpazdziora@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-25 18:51:15 +01:00
Jan Pazdziora
cd8f5ddbc2 Each ssh_channel_request_exec() needs to be run on fresh channel.
Signed-off-by: Jan Pazdziora <jpazdziora@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-25 18:50:52 +01:00
Jan Pazdziora
3ce9f78fb4 The ssh_channel_callbacks_struct member name is channel_data_function.
Addressing
client.c: In function ‘show_remote_uptime’:
client.c:107:6: error: ‘struct ssh_channel_callbacks_struct’ has no member named ‘channel_data’
     .channel_data = my_channel_data_function,
      ^~~~~~~~~~~~
client.c:107:21: warning: initialization of ‘long unsigned int’ from ‘int (*)(struct ssh_session_struct *, struct ssh_channel_struct *, void *, uint32_t,  int,  void *)’ {aka ‘int (*)(struct ssh_session_struct *, struct ssh_channel_struct *, void *, unsigned int,  int,  void *)’} makes integer from pointer without a cast [-Wint-conversion]
     .channel_data = my_channel_data_function,
                     ^~~~~~~~~~~~~~~~~~~~~~~~
client.c:107:21: note: (near initialization for ‘cb.size’)

Signed-off-by: Jan Pazdziora <jpazdziora@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-25 18:50:33 +01:00
Anderson Toshiyuki Sasaki
5104c86a2b auth: Set buffer used to store password as secure
This will make such buffer to be explicity overwritten with zeroes when
freed.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-25 18:47:55 +01:00
Andreas Schneider
144e551614 doc: Add a note about OpenSSL linking
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-13 10:36:32 +01:00
Andreas Schneider
65bc24d8a4 libcrypto: Add missing includes for modes.h
This defines block128_f.

Fixes T133.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-13 10:31:39 +01:00
Jan Pazdziora
d8fc65ad71 The SSH_LOG_ENTRY is not defined all, match the descriptions to SSH_BIND_OPTIONS_LOG_VERBOSITY*.
The documentation amends change in 801bc29494.

The SSH_LOG_ENTRY macro was removed during cleanup ab60d1d678.

Signed-off-by: Jan Pazdziora <jpazdziora@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-11 16:22:07 +01:00
Jan Pazdziora
81d0f6b6b7 From the context it seems that the function being defined is authenticate_none.
Signed-off-by: Jan Pazdziora <jpazdziora@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-11 16:19:47 +01:00
Jan Pazdziora
bed7dcb3ec ssh_userauth_publickey_auto requires three arguments.
Addressing
client.c: In function ‘authenticate_pubkey’:
client.c:70:8: error: too few arguments to function ‘ssh_userauth_publickey_auto’
   rc = ssh_userauth_publickey_auto(session, NULL);
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from client.c:1:
/usr/include/libssh/libssh.h:745:16: note: declared here
 LIBSSH_API int ssh_userauth_publickey_auto(ssh_session session,
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Jan Pazdziora <jpazdziora@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-11 16:19:26 +01:00
Simo Sorce
104c9dca3f Use a common KDF function
Cleanup the KDF function to use only one function per crypto backend.
Improve the KDF function to properly handle requested lenght and to
avoid unnecessarily reallocating buffers.

In OpenSSL use the new EVP_KDF API if available.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-07 12:03:32 +01:00
Simo Sorce
c180211c6b Clean up code that generates session keys
This patch simply reworks the code to make it more understandable and
reduce if() branches.
It also avoids reallocs, and instead uses a support buffer to hold
intermediate results of the hmac function so that no buffer overrides
happen when the requested size is not an exact mutiple of the digest_len.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-07 12:03:27 +01:00
Simo Sorce
c235841436 Add unit test for fn that generates session keys
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-07 12:03:24 +01:00
Simo Sorce
449954d99a Fix crypto_free zeroing of encryption keys
The zeroing MUST use the correct cipher length as keys can be both
longer or shorter than the digest. In one case only some part of the key
may end up being zeroed, in the other memory corruption may happen as
we zero memory we do not own.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-03-07 12:02:23 +01:00
Andreas Schneider
7c444c09d7 sftp: Document how to free memory retruned by sftp_canonicalize_path()
Fixes T129

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-27 08:32:10 +01:00
Till Wimmer
8234df5dec ssh_event_dopoll can also return SSH_AGAIN
Signed-off-by: Till Wimmer <g4-lisz@tonarchiv.ch>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-27 08:17:53 +01:00
Dirkjan Bussink
4a67c19118 Add tests and implementation for Encrypt-then-MAC mode
This adds the OpenSSH HMACs that do encrypt then mac. This is a more
secure mode than the original HMAC. Newer AEAD ciphers like chacha20 and
AES-GCM are already encrypt-then-mac, but this also adds it for older
legacy clients that don't support those ciphers yet.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-22 15:31:08 +01:00
Dirkjan Bussink
e4c7912b35 Add flag for tracking EtM HMACs
This adds a flag to the type structures to track if we use a
Encrypt-then-MAC cipher instead of Encrypt-and-MAC. EtM is a more secure
hashing mechanism.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-22 15:31:02 +01:00
Dirkjan Bussink
c6608c9211 Refactor ssh_packet_hmac_verify to allow for direct buffer
This will make it easier to do Encrypt-then-MAC checks as those will be
on the direct encrypted data received before decrypting which means they
are not allocated in an ssh buffer at that point yet.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-22 15:30:59 +01:00
Dirkjan Bussink
f055319efe Select ciphers for MAC tests that need a MAC
Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-22 15:30:56 +01:00
Dirkjan Bussink
369051a5b4 Remove SHA384 HMAC
This is not supported by OpenSSH and not recommended to be implemented
either.

Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-22 15:30:52 +01:00
Dirkjan Bussink
46d15b3161 Use constant time comparison function for HMAC comparison
Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
Reviewed-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-22 15:30:29 +01:00
Jakub Jelen
1af10fcdb3 config: Avoid buffer overflow
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-22 11:41:40 +01:00
Andreas Schneider
8a73e48184 pki_gcrypt: Include missing stdbool.h
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-22 11:00:31 +01:00
Andreas Schneider
7a8ed6d02b pki: Fix size type for len in privatekey_string_to_buffer()
src/pki_gcrypt.c:485:10: error: assuming signed overflow does not occur
when simplifying conditional to constant [-Werror=strict-overflow]

Fixes T132

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-21 16:27:46 +01:00
David Wedderwille
b73ffb3f91 connector: Fallback on the socket output callback
Fixes T124

Signed-off-by: David Wedderwille <davidwe@posteo.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-21 14:03:20 +01:00
Tilo Eckert
702a6e7695 client: Add missing break, remove useless return
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-21 10:51:28 +01:00
Tilo Eckert
eb032e0dec socket: Use more portable PF_UNIX instead of PF_LOCAL
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-21 10:51:25 +01:00
Tilo Eckert
17df34da96 crypto: Use uint8_t instead of non-standard u_char
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-21 10:51:22 +01:00
Tilo Eckert
7caf6d2ab6 buffer: Fix regression introduced by 6c7eaa and c306a6
Buffer (un)packing was broken on compilers that are not
gcc-compatible since the checks for an argument count of
-1 have been removed from ssh_buffer_(un)pack(). This
fix no longer uses GCC extensions for the __VA_NARG__
macro, but only plain C99.
Note: The macro can no longer count empty argument lists
(results in compile error) which was not needed anyway.

Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-21 10:51:17 +01:00
Andreas Schneider
5a590dfb5f examples: Fix unused parameter warnings in sshd_direct-tcpip
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2019-02-21 10:51:07 +01:00
Till Wimmer
881e1b4785 examples: Add direct-tcpip server sample
Signed-off-by: Till Wimmer <g4-lisz@tonarchiv.ch>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-20 16:39:31 +01:00
Aris Adamantiadis
f890b09edb cmake: fix build problem on ubuntu 18.04
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
2019-02-07 19:16:03 +01:00
Andreas Schneider
a1559505a5 cmake: Bump API version to 4.7.4
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 14:35:35 +01:00
Jon Simons
5d279a7ad7 kex: honor client preference for rsa-sha2-{256,512} host key algorithms
Ensure to honor the client preference ordering when enabling one of
the RFC8332 RSA signature extensions (`rsa-sha2-{256,512}`).

Before this change, libssh unconditionally selects the `rsa-sha2-512`
algorithm for clients which may have offered "rsa-sha2-256,rsa-sha2-512".

The change can be observed before-and-after with the pkd tests:

    ./pkd_hello -t torture_pkd_openssh_rsa_rsa_sha2_256_512

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 13:54:22 +01:00
Jon Simons
c2077ab775 tests/pkd: repro rsa-sha2-{256,512} negotiation bug
Add four passes to the pkd tests to exercise codepaths where an
OpenSSH client requests these HostKeyAlgorithms combinations:

 * rsa-sha2-256
 * rsa-sha2-512
 * rsa-sha2-256,rsa-sha2-512
 * rsa-sha2-512,rsa-sha2-256

The tests demonstrate that the third combination currently fails:
libssh ends up choosing `rsa-sha2-512` instead of `rsa-sha2-256`,
and the initial exchange fails on the client side citing a signature
failure.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 13:54:12 +01:00
Jakub Jelen
128015bb17 pki_container_openssh: Add padding to be compatible with OpenSSH
OpenSSH has a block size of 8 so we need to always add padding.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 10:30:05 +01:00
Jakub Jelen
5700477f3e examples: Add simple way to generate key files from libssh
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 10:30:05 +01:00
Jakub Jelen
fffa66698f Allow building without Group Exchange support
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 10:30:05 +01:00
Jakub Jelen
a170580147 kex: Disable diffie-hellman-group-exchange-sha1 by default
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 10:30:05 +01:00
Jakub Jelen
0833f07c53 options: Allow to configure cryptographic algorithms for server
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 10:30:05 +01:00
Jakub Jelen
805709dd36 docs: Missing documentation for SSH_OPTIONS_HMAC_*
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 10:30:05 +01:00
Jakub Jelen
fd95b68c0f tests: Fix error message
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 10:30:05 +01:00
Jakub Jelen
82f4c6c607 buffer: Fix typo in a comment
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 10:30:05 +01:00
Jakub Jelen
c110122fb5 tests: Don't talk to ssh-agent in server authentication tests
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 10:30:05 +01:00
Andreas Schneider
686cd6e83b Update INSTALL file
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 10:30:05 +01:00
Andreas Schneider
9f9afab3e6 dh: Add function references to ssh_print_hash() doc
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 09:48:09 +01:00
Andreas Schneider
b84949b32c include: Mark ssh_print_hexa as deprecated
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-02-07 09:46:13 +01:00
Jon Simons
c0102e6a59 pki_crypto: plug pki_signature_from_blob leaks
In 3341f49a49, some direct assignments
to OpenSSL structures was replaced with usage of getter and setter
macros.  Ensure to `bignum_safe_free` a couple of intermediate values
in error paths for `pki_signature_from_blob` DSS and ECDSA cases.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-30 13:22:59 +01:00
Jon Simons
ccd73db90c pki: NULL check pki_signature_from_rsa_blob result
Check for a potential NULL result from `pki_signature_from_rsa_blob`
in `pki_signature_from_blob`.  Otherwise the following `sig->type_c`
will result in a segfault.

Introduced in 7f83a1efae.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-30 13:22:59 +01:00
Jon Simons
3760e59c13 dh: harden error handling in 'ssh_dh_init_common'
Harden the error path in 'ssh_dh_init_common' such that
all potential allocations are free'd upon exit.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-30 13:22:59 +01:00
Jon Simons
3334443089 dh: plug pubkey_blob leak in ssh_server_dh_process_init
Ensure to `SSH_STRING_FREE` the pubkey_blob local in
`ssh_server_dh_process_init`.  The leak can be seen with
valgrind and the pkd tests with:

    valgrind \
      --leak-check=full \
      --show-leak-kinds=definite \
      ./pkd_hello -i1 -t torture_pkd_openssh_rsa_rsa_diffie_hellman_group14_sha1

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-30 13:22:59 +01:00
Jon Simons
b44987a164 dh-gex: fix double-ssh_dh_init_common memory leak
Fix a memory leak whereby the x, y, and k bignum fields within
a session's next_crypto structure were being unintentionally
initialized twice.

The leak can be seen before the fix with valgrind and the pkd
tests with:

    valgrind \
      --leak-check=full \
      --show-leak-kinds=definite \
      ./pkd_hello -i1 -t torture_pkd_openssh_rsa_rsa_diffie_hellman_group_exchange_sha256

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-30 13:22:59 +01:00
Jon Simons
886681a421 dh-gex: fix moduli file stream leak
Ensure to close the moduli file stream in `ssh_retrieve_dhgroup`.
The leak is observable with the pkd tests and valgrind with:

    valgrind \
      --track-fds=yes \
      ./pkd_hello -i1 \
      -t torture_pkd_openssh_rsa_rsa_diffie_hellman_group_exchange_sha256

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-30 13:22:59 +01:00
Till Wimmer
04c97c0eaf session: Repects timeout=0 for packets on blocking sessions
Signed-off-by: Till Wimmer <g4-lisz@tonarchiv.ch>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-30 09:24:29 +01:00
Till Wimmer
d27b817acc options: Removed outdated param annotations of ssh_options_set()
Signed-off-by: Till Wimmer <g4-lisz@tonarchiv.ch>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-30 09:24:29 +01:00
Till Wimmer
16a52a8362 connector: Don't NULL connector (in|out) channels on event remove
Signed-off-by: Till Wimmer <g4-lisz@tonarchiv.ch>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-30 09:24:26 +01:00
Andreas Schneider
5bc7432b10 gitlab-ci: Enable DEBUG build options on Fedora
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-27 17:47:31 +01:00
Jakub Jelen
8c7b6bffff bignum: Reformat ssh_make_string_bn and unbreak build with DEBUG_CRYPTO
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-26 16:40:14 +01:00
Jakub Jelen
42185fbf6e dh: Reformat ssh_dh_debug, ssh_dh_build_k and unbreak build with DEBUG_CRYPTO
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-26 16:40:09 +01:00
Andreas Schneider
303bdc5a4f tests: Initialize ssh_cipher_struct in torture_crypto_aes256_cbc()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-26 15:47:49 +01:00
Andreas Schneider
9b694f396c packet: Add missing error check in packet_send2()
Found by csbuild.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-26 14:21:46 +01:00
Andreas Schneider
d41042f92d pki: Avoid a possible segfaults in error paths
Found by csbuild.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-26 14:21:26 +01:00
Andreas Schneider
9b2eefe62c dh-gex: Add error check for ssh_packet_send() in ssh_packet_server_dhgex_request
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-26 14:15:01 +01:00
Andreas Schneider
8ec80d1f5d libcrypto: Use size_t for size calculations
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-26 14:09:44 +01:00
Anderson Toshiyuki Sasaki
8ddbe7bec6 sftp: Add NULL check in sftp_ext_free()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-26 13:56:25 +01:00
Anderson Toshiyuki Sasaki
61ad276a87 sftp: Reformat sftp_ext_free()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-26 13:56:22 +01:00
Anderson Toshiyuki Sasaki
9c5a1967c3 tests: Add NULL checks in pki tests
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-26 13:56:22 +01:00
Anderson Toshiyuki Sasaki
27caaa000b tests: Prefer assert_non_null() over assert_false()
This also replaces some occurrences of assert_true() with assert_null()

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-26 13:56:22 +01:00
Anderson Toshiyuki Sasaki
bdf968c178 tests: Added NULL checks in torture_list.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-26 13:56:22 +01:00
Anderson Toshiyuki Sasaki
603b6d7222 tests: Prefer assert_non_null over assert_true
This also replaces some occurrences of assert_true with assert_null.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-26 13:56:22 +01:00
Anderson Toshiyuki Sasaki
89f58decb6 misc: Add NULL checks before accessing lists
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-26 13:56:22 +01:00
Anderson Toshiyuki Sasaki
5ed5e97114 messages: Fix NULL check, preventing SEGFAULT
The wrong conditional check for newly allocated memory would make the
function to fail when the allocation was successful and access invalid
memory when the allocation failed.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-26 13:56:15 +01:00
Andreas Schneider
6dacc8b26c gitlab-ci: Add (disabled) target with MemorySanitizer
We can't enable this till we can ignore OpenSSL.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-25 16:08:04 +01:00
Andreas Schneider
d41fd0c465 cmake: Add support for MemorySanitizer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-25 16:07:50 +01:00
Andreas Schneider
d598e4e52a packet_crypt: Make sure we always operate on initilized memory
Found by MemorySanitizer.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-25 16:07:50 +01:00
Andreas Schneider
932102bd13 session: Initialize allocated memory
Found by MemorySanitizer.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-25 14:13:10 +01:00
Andreas Schneider
e260a591f4 gitlab-ci: Fix UndefinedSanitizer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-25 11:36:07 +01:00
Baruch Siach
6c7eaa9e12 buffer: Convert argc to size_t in ssh_buffer_unpack() as well
Commit c306a693f3 ("buffer: Use size_t for argc argument in
ssh_buffer_(un)pack()") mentioned unpack in the commit log, but it only
touches the pack variants. Extend the conversion to unpack.

Pre-initialize the p pointer to avoid possible use before
initialization in case of early argc check failure.

This fixes build failure:

.../libssh-0.8.6/src/buffer.c: In function 'ssh_buffer_unpack_va':
.../libssh-0.8.6/src/buffer.c:1229:16: error: assuming signed overflow does not occur when simplifying conditional to constant [-Werror=strict-overflow]
             if (argc == -1){
		^

Signed-off-by: Baruch Siach <baruch@tkos.co.il>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 17:48:08 +01:00
Eric Bentley
83d86ef6a5 examples: add public key auth for specific key
There was no example of using a specific key for authentication so I added
one.

Signed-off-by: Eric Bentley <ebentley66@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 17:48:08 +01:00
Eric Bentley
db67fcbe88 examples: add public key authentication to ssh_server_fork
I noticed that there was no example showing server side public key encryption in the examples
so I added this one. I used authorizedkeys as a global to minimize the changes to the original
code as well as I was not sure the correct methodology of determining the .ssh directory location
for a user not using Linux. One code using the user parameter to determine the location to use
instead if desired.

Signed-off-by: Eric Bentley <ebentley66@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 17:48:04 +01:00
Jakub Jelen
be9943132e tests: Extend negative test cases for config Match keyword
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 15:15:39 +01:00
Jakub Jelen
893510db35 tests: Use assert_ssh_return_code() in config test
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 15:15:35 +01:00
Jakub Jelen
e989c4afff config: Add new Match final keyword from OpenSSH 8.0
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 15:15:18 +01:00
Jakub Jelen
3ce31532eb config: Fail if there is missing argument for some of the match keywords
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 15:13:30 +01:00
Aris Adamantiadis
3b5f9ef8d6 pkd: dh-group-exchange testcases 2019-01-24 13:06:33 +01:00
Aris Adamantiadis
53c88375fe dh-gex: Add server implementation
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 13:06:33 +01:00
Aris Adamantiadis
40faa98c5e wrapper: Move dh cleanup into dh.c
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 12:56:14 +01:00
Aris Adamantiadis
9407065879 tests: Added moduli file parsing tests
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 12:56:09 +01:00
Aris Adamantiadis
b36219369d dh-gex: Add support for moduli file parsing
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 12:51:54 +01:00
Aris Adamantiadis
31da8025b2 tests: Add dh-group-exchange algorithm tests
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 11:56:23 +01:00
Aris Adamantiadis
574bfb5459 dh-gex: Add client implementation
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 11:56:23 +01:00
Aris Adamantiadis
154eb91914 dh: move state changes inside DH code
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 11:56:23 +01:00
Aris Adamantiadis
9c88769707 dh: Do some basic refactoring
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 11:56:23 +01:00
Aris Adamantiadis
a6c47099b7 buffer: Support bignums in ssh_buffer_unpack()
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 11:53:22 +01:00
Aris Adamantiadis
2f8239ade3 mbedcrypto: fixed nasty RNG bugs 2019-01-24 11:53:22 +01:00
Aris Adamantiadis
afe2673cfa bignum: harmonize gcrypt, libcrypto and libmcrypt bignum
Ensure most of the abstraction around the 3 libs are consistent.

Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 11:04:44 +01:00
Aris Adamantiadis
43a4f86b6e dh: move unrelated functions out of dh.c
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 09:34:18 +01:00
Aris Adamantiadis
e42a423a24 kex: use runtime callbacks (server)
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 09:19:59 +01:00
Aris Adamantiadis
602a1defea kex: use runtime callbacks (client)
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-24 09:11:30 +01:00
Anderson Toshiyuki Sasaki
fd5770973f tests: Add test for server interactive authentication
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-01-22 13:12:26 +01:00
Anderson Toshiyuki Sasaki
416d03b19e tests: Add test for server auth method none
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-22 13:12:26 +01:00
Anderson Toshiyuki Sasaki
db1a999852 tests: Test server pubkey authentication
The default pubkey authentication callback is not checking
anything.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-22 13:12:25 +01:00
Anderson Toshiyuki Sasaki
29445e4ff1 tests: Added functions to get the default callbacks
This makes easier to create test cases using callbacks based on the
default callbacks (e.g. using the default callbacks but replacing one
specific callback)

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-22 13:12:25 +01:00
Anderson Toshiyuki Sasaki
13aa791e7b tests: Provide the server state to callbacks
This aims to make it easier to implement custom callbacks.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-22 13:12:25 +01:00
Jakub Jelen
7f18a27504 tests: Reproducer for cockpit issue, where server provides an invalid signature
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-22 13:12:25 +01:00
Jakub Jelen
2113dc9d23 tests: Check return values
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2019-01-22 13:12:25 +01:00
Jakub Jelen
1f7a15ffb1 tests: Initialize allocated memory
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2019-01-22 13:12:25 +01:00
Anderson Toshiyuki Sasaki
37262b98ef tests: Added test server
The server can be configured through command line options or by
providing a state structure with the desired values set.

Currently supports only password based authentication.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2019-01-22 13:12:25 +01:00
Andreas Schneider
e91e221d02 pcap: Correctly initialize sockaddr_in in ssh_pcap_context_set_file()
Error: CLANG_WARNING:
src/pcap.c:329:22: warning: The left operand of '!=' is a garbage value

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-22 13:12:25 +01:00
Andreas Schneider
79fe88bfb8 pcap: Reformat ssh_pcap_context_connect()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-22 13:12:25 +01:00
Andreas Schneider
98a8bf771d tests: Fix uninitialized warning in torture_threads_pki_rsa
Error: CLANG_WARNING: tests/unittests/torture_threads_pki_rsa.c:520:5:
warning: 1st function call argument is an uninitialized value

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-22 13:12:25 +01:00
Andreas Schneider
0ceda043ce cmake: Add -Wmissing-field-initializers compile flag
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-22 13:12:25 +01:00
Andreas Schneider
86849c0883 bind: Check for POLLRDHUP on the server if available
This is a feature on modern Linux.

Thanks to Ludovic Courtès <ludo@gnu.org> for the pointer.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-15 15:44:50 +01:00
Andreas Schneider
0e9add9a89 bind: Reformat ssh_bind_get_poll()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-15 15:44:48 +01:00
Andreas Schneider
2eb0dc6446 Update ChangeLog 2019-01-11 15:56:02 +01:00
Marcin Szalowicz
4b4fb638f8 Fix cleaning up HMAC context for openssl < 1.1 remove old compatibility code for openssl < 0.9.7
Signed-off-by: Marcin Szalowicz <marcin.szalowicz@oracle.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-11 15:56:02 +01:00
Tilo Eckert
f118ea010b tests: Refactor test so that all RSA + hash combinations are tested
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-11 15:56:02 +01:00
Tilo Eckert
481d749559 tests: Fix incorrect hash type parameter on signature import
RSA with SHA-256/512 signatures have been interpreted as RSA with SHA-1

Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-11 15:56:02 +01:00
Jakub Jelen
c7aba3a716 tests: Refactor the sftp initilization to avoid invalid memory access on sftp failures
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-11 15:06:56 +01:00
Andreas Schneider
0170ed8883 socket: Set socket error to get better error messages
We do not want an error for ssh_socket_close() here.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 15:50:24 +01:00
Andreas Schneider
de54a88ee1 poll: Return early for timeout and count every revent
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 15:50:24 +01:00
Andreas Schneider
51f035aa3f poll: Do not generate SIGPIPE with recv() in bsd_poll()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 15:50:24 +01:00
Andreas Schneider
edc7b96b2f poll: Improve checks for POLLHUP and POLLERR
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 15:50:21 +01:00
Andreas Schneider
ab269f036e poll: Zero (read|write|expect)fds in bsd_poll()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 15:43:39 +01:00
Andreas Schneider
4512a3fead poll: Reformat bsd_poll()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 15:43:37 +01:00
Andreas Schneider
fc840d8d69 poll: Fix size type
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 15:42:43 +01:00
Andreas Schneider
0e7a962417 poll: Reformat ssh_poll_ctx_dopoll()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 15:42:33 +01:00
Jakub Jelen
531b80a60b kex: List also the SHA2 extension when ordering hostkey algorithms
By default, the list of already stored known host types is preferred,
but this selection so far ignored the SHA2 extension and excluded these
keys in the KEXINIT list leading to not using this extension if not
explicitly enabled from configuration.

This commit extends the default list with the SHA2 signatures algoritms
and compares only base types so they can be listed in the KEXINIT list.

This adjust the tests to expect the full list of algorithms to pass.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 13:18:05 +01:00
Jakub Jelen
27fe60954c server: Correctly handle extensions
If the server had an RSA host key, it provided unconditionally SHA2
signatures without consulting the client proposed list of supported host
keys.

This commit implements more fine-grained detection of the extension
to provide the client with valid signatures according to RFC 8332
Section 3.1.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 13:17:31 +01:00
Jakub Jelen
ca62632170 dh: Make sure we do not access uninitialized memory
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 13:16:50 +01:00
Andreas Schneider
fae1ed7ded gitlab-ci: Disable debian cross mips runner
This runner always times out.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 13:15:44 +01:00
Jakub Jelen
851c580cf5 gitlab-ci: Run the Windows machines for me too
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 13:15:44 +01:00
Jakub Jelen
40b63f7c39 tests: Verify rekeying initialized by the server works
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 13:15:44 +01:00
Jakub Jelen
8012afd5e4 tests: Allow to modify sshd config from the test
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 13:15:44 +01:00
Jakub Jelen
7e41d08f26 packet: Dump also the packet type
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:31:49 +01:00
Jakub Jelen
347af845ab tests: Verify that rekey limits are effective from the client side
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
2019-01-09 10:31:49 +01:00
Jakub Jelen
bfff7db5ff options: Update documentation for rekey limits
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:31:49 +01:00
Jakub Jelen
58cae2366a packet: Implement rekeying based on the recommendation from RFC's
The default rekeying recommendations are specified in
RFC4344 Section 3 (First and Second Rekeying Recommendations).
Additionally, the rekeying can be specified in configuration
file/options allowing us to turn the rekeying off, base it
on time or make it more strict.

The code is highly inspired by the OpenSSH rekeying code.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:31:49 +01:00
Jakub Jelen
c86a00d06b packet: Provide a function to switch crypto in separate directions
This also fixes the test using the crypto directly

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:31:45 +01:00
Jakub Jelen
8e0c047031 packet: Introduce a new function to access crypto
And remove most of the direct access to the structure throughout the code

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:14:56 +01:00
Jakub Jelen
8d90266661 server: Reformat ssh_auth_reply_success
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:14:56 +01:00
Jakub Jelen
836982358a packet: Adjust the packet filter to allow client-initialized rekey
If the rekey is initialized by client, it sends the first KEXINIT
message, changes to the INIT_SENT state and waits for the KEXINIT
message from the server. This was not covered in the current filter.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:14:56 +01:00
Jakub Jelen
a61368a06a packet: Prepare counters to handle rekeying limits
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:14:56 +01:00
Jakub Jelen
92e978f2f3 tests: Verify we can parse RekeyLimit configuration option
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:14:56 +01:00
Jakub Jelen
1a92c4bc64 config: Parse rekey limits and apply them
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:14:56 +01:00
Jakub Jelen
e973f95b37 options: Introduce new options for handling rekey limits
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:14:56 +01:00
Jakub Jelen
78427a9264 priv: Provide PRIu32 for Visual Studio
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:14:56 +01:00
Jakub Jelen
b3ae5e06ee tests: Allow to generate unencrypted PCAP files from testsuite
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:14:56 +01:00
Jakub Jelen
d4e5644e21 tests: Reproducer for T122
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:14:56 +01:00
Jakub Jelen
42c92074b9 tests: Do not run SSHD with PAM when not needed
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:14:56 +01:00
Jakub Jelen
81fdb574e7 packet: Write also incoming packets to .pcap files
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:14:56 +01:00
Jakub Jelen
fff2e85ab2 pcap: Reformat ssh_pcap_context_write()
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Daiki Ueno <dueno@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:14:56 +01:00
Jakub Jelen
1be9618f4e kex: Correctly check for the rekey (amends 83f2ac4a)
This is more reliable fix than 83f2ac4a, which was failing for the
server initialized rekeying, because the session_state is altered
by receiving the KEXINIT from server.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-09 10:14:56 +01:00
Andreas Schneider
b26ca652f5 client: Happy new year!
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-05 13:18:12 +01:00
Andreas Schneider
9f1718e159 Revert "sftp: Set error if invalid session pointer is passed to sftp_new()"
This reverts commit d011b780c3.
2019-01-05 13:17:32 +01:00
Andreas Schneider
d011b780c3 sftp: Set error if invalid session pointer is passed to sftp_new()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2019-01-04 13:31:34 +01:00
Andreas Schneider
c6460cc955 Bump SO version to 4.7.3
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-24 07:58:20 +01:00
Andreas Schneider
b5f1949480 gitlab-ci: Build with blowfish cipher support on fedora
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-12-19 14:57:36 +01:00
Andreas Schneider
dea6fe3d89 crypto: Disable blowfish support by default
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-12-19 14:57:29 +01:00
Andreas Schneider
6cd8d4a24a channels: Don't call ssh_channel_close() twice
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-12 18:31:31 +01:00
Andreas Schneider
0bd404bcbd gitlab-ci: Add minimal build
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-12 18:29:14 +01:00
Jakub Jelen
c9bdb9a01e tests: Do not segfault when built without ZLIB
Signed-off-by: Jakub Jelen <jakuje@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-10 20:28:01 +01:00
Jakub Jelen
973da84a47 tests: Verify we can parse the ProxyJump configuration option
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-10 17:56:07 +01:00
Jakub Jelen
990794c580 config: Parse ProxyJump configuration option and implement it using ProxyCommand with OpenSSH
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-10 17:56:05 +01:00
Jakub Jelen
9b1852f728 tests: Verify ProxyCommand works with ssh
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-10 17:52:56 +01:00
Jakub Jelen
055bf830db tests: Use torture_server_address() in proxycommand test
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-10 17:52:56 +01:00
Jakub Jelen
8c812dbfa3 tests: Verify all the options are copied over
The ssh_options_copy() function was missing several options that were added
in recent years.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-10 17:52:56 +01:00
Jakub Jelen
9128ecf397 options: Copy also the new options
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-10 17:52:56 +01:00
Jakub Jelen
48aede2a31 options: Check for null
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-10 17:52:56 +01:00
Anderson Toshiyuki Sasaki
fe309ba43f packet: Allow SSH2_MSG_EXT_INFO when authenticated
When the server requests rekey, it can send the SSH2_MSG_EXT_INFO.  This
message was being filtered out by the packet filtering.  This includes a
test to enforce the filtering rules for this packet type.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-10 16:42:26 +01:00
Andreas Schneider
c3067f8e73 channels: Send close if we received a remote close
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-10 16:42:22 +01:00
Andreas Schneider
1d5b222cc4 channels: Reformat ssh_channel_free()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-10 14:59:21 +01:00
Andreas Schneider
13b9d268d4 channel: Add SSH_CHANNEL_FLAG_CLOSED_LOCAL
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-10 14:59:21 +01:00
Andreas Schneider
0ba10870d1 channel: Reformat ssh_channel_close()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-10 14:57:50 +01:00
Andreas Schneider
e4e51ccc13 session: Check the session timeout and use it if set
This checks if a timeout has been set using ssh_options_set(). If it has
been set it will use that parametr by default for blocking sessions.

This is at least what users are expecting.

Fixes T33

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 17:49:19 +01:00
Andreas Schneider
8ece2abfab session: Use long for the timeout
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 17:49:17 +01:00
Anderson Toshiyuki Sasaki
f05717d23e sftp: Add NULL check in sftp_fstat()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2018-12-07 17:47:22 +01:00
Anderson Toshiyuki Sasaki
eaa97d2062 sftp: Add NULL check in sftp_xstat()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 17:47:18 +01:00
Anderson Toshiyuki Sasaki
bda2cc69af sftp: Add NULL check in sftp_opendir()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 17:47:11 +01:00
Anderson Toshiyuki Sasaki
83d827d7dd sftp: Set sftp error when received unexpected message
Set sftp error to SSH_FX_BAD_MESSAGE if an unexpected message is
received.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 17:47:00 +01:00
Anderson Toshiyuki Sasaki
0f95295966 sftp: Set sftp error code when fail occurs
When an operation fails in sftp subsystem, set the sftp error, so that
it can be obtained by sftp_get_error().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 17:44:52 +01:00
Anderson Toshiyuki Sasaki
8e69d435ef channels: Set error state when closed channel is read
When an attempt to read a closed channel happens, set the session error
state properly.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 17:44:46 +01:00
Anderson Toshiyuki Sasaki
d78a29eb79 sftp: Set error when EOF is received in sftp_packet_read()
When reading a sftp packet and an EOF is received before all requested
bytes are read, set the session and sftp error codes.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 17:43:08 +01:00
Andreas Schneider
58113d489e connect: Fix size type for i an j in ssh_select()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 14:08:31 +01:00
Andreas Schneider
c306a693f3 buffer: Use size_t for argc argument in ssh_buffer_(un)pack()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 14:08:31 +01:00
Jakub Jelen
21e2522360 config: Get rid of the dynamic seen array
* This makes the array constant in the session structure, avoiding
   allocations and frees while parsing the file
 * It also drops passing the seen array to all the functions,
   because it is already part of the passed session
 * The test cases are adjusted to match these changes

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 14:08:27 +01:00
Jakub Jelen
8f887e82c7 config: Reformat local_parse_file
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 14:07:31 +01:00
Jakub Jelen
993e24a361 config: Reformat ssh_config_parse_file
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 14:07:31 +01:00
Jakub Jelen
cf6f1e7a64 tests: Cover also compression with unit tests
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 14:07:31 +01:00
Jakub Jelen
31bc83f366 tests: Do not recreate unnecessary files for every test case
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 13:57:03 +01:00
Jakub Jelen
42ce989488 tests: Cover missing parts of the config parsing
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-12-07 13:28:11 +01:00
Andreas Schneider
4282f3c664 gitlab-ci: Fix csbuild to run latest 20 commits
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 18:52:40 +01:00
Andreas Schneider
3784226fd8 sftp: Do not overwrite errors set by channel functions
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 18:52:40 +01:00
Andreas Schneider
cf24048f02 libcrypto: Fix integer comparison in evp_cipher_aead_encrypt()
src/libcrypto.c:773:27: warning: comparison of integer expressions of
different signedness: ‘int’ and ‘size_t’ {aka ‘long unsigned int’}
[-Wsign-compare] <--[cc]
     if (rc != 1 || outlen != len - aadlen) {
                           ^~
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 18:47:25 +01:00
Anderson Toshiyuki Sasaki
f427a975b8 tests: Fix a clang possible memory leak warning
clang was reporting a possible memory leak after mkdtemp() call, which
was a false positive, since mkdtemp() returns the same pointer provided
as the parameter, in case of success.  This changes the code so that the
static analyser don't get confused.

Found by csbuild runner.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 18:28:40 +01:00
Anderson Toshiyuki Sasaki
c413834764 tests: Test calling ssh_init() after ssh_finalize()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 18:26:55 +01:00
Anderson Toshiyuki Sasaki
41b0d263d6 libcrypto: Fix access violation in ssh_init()
This fixes an access violation when ssh_init() was called after
ssh_finalize() in Windows when using OpenSSL 1.0.2 and libssh statically
linked.

Fixes T120

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 18:26:55 +01:00
Andreas Schneider
a08a97f9c7 tests: Use UNUSED macros in torture_threads_init
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 18:25:12 +01:00
Andreas Schneider
c0ae59e102 bignum: Use UNUSED macros 2018-11-30 18:25:12 +01:00
Andreas Schneider
109a203453 include: Add macro for unused arguments and variables
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 18:25:12 +01:00
Andreas Schneider
ac8b954019 bignum: Use size_t in ssh_make_string_bn*
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 18:25:12 +01:00
Andreas Schneider
c6ca62d7e1 crypto: Use size_t for len argument in encrypt and decrpyt fn
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 18:25:12 +01:00
Anderson Toshiyuki Sasaki
6d3672911b gitlab-ci: Added builds for native Windows
This uses a runner configured with the tag "vs2017 or windows".

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 18:25:12 +01:00
Tilo Eckert
95f83c2391 src: Fix multiple typos
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 16:29:17 +01:00
Jakub Jelen
130256c348 tests: Verify that signatures are sane and can not be verified by non-matching key
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 16:26:48 +01:00
Jakub Jelen
b72c9eead6 pki: Sanitize input to verification
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 16:26:07 +01:00
Jakub Jelen
c7628fbfea pki: Return default RSA key type for DIGEST_AUTO
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 16:24:21 +01:00
Jakub Jelen
783e5fd206 pki: Verify the provided public key has expected type
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 16:24:14 +01:00
Jakub Jelen
c79c33e224 pki: Sanity-check signature matches base key type
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 16:22:51 +01:00
Jakub Jelen
968fdf4e18 tests: Do not require base RSA type for SHA2 extension whitelist
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 16:22:13 +01:00
Jakub Jelen
bc91fa98ea packet_cb: Properly verify the signature type
Issue reported by Tilo Eckert <tilo.eckert@flam.de>

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 16:21:52 +01:00
Jakub Jelen
d2434c69c0 pki: Separate signature extraction and verification
Initial solution proposed by Tilo Eckert <tilo.eckert@flam.de>

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 16:21:18 +01:00
Jakub Jelen
7f83a1efae pki: Set correct type for imported signatures
Issue reported by Tilo Eckert <tilo.eckert@flam.de>

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 16:20:19 +01:00
Jakub Jelen
7b725e6bc7 pki: Use self-explanatory variable names
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 16:20:10 +01:00
Jakub Jelen
46d8840f7e The largest ECDSA key has 521 bits
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 16:20:04 +01:00
Jakub Jelen
c1fdb56d23 pki_gcrypt: Do not abort on bad signature
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-30 16:19:59 +01:00
Jakub Jelen
57bdc9cb20 Whitespace cleanup
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-29 14:22:08 +01:00
Anderson Toshiyuki Sasaki
312084731e tests: Use temporary directories in torture_pki_ed25519.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-28 15:51:06 +01:00
Anderson Toshiyuki Sasaki
500bf54a34 tests: Use temporary directories in torture_pki_ecdsa.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-28 15:51:06 +01:00
Anderson Toshiyuki Sasaki
a56fa14fda tests: Use temporary directories in torture_pki_dsa.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-28 15:51:06 +01:00
Anderson Toshiyuki Sasaki
ac1377148f tests: Use temporary directories in torture_threads_pki_rsa.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-28 15:51:06 +01:00
Anderson Toshiyuki Sasaki
f38c6fcc6e tests: Use temporary directories in torture_pki_rsa.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-28 15:51:06 +01:00
Anderson Toshiyuki Sasaki
0dd2b375c7 tests: Introduce functions to change directories
This introduces torture_get_current_working_dir() and
torture_change_dir() to allow changing directories in tests.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-28 15:51:06 +01:00
Anderson Toshiyuki Sasaki
77be4ce905 tests: use torture_create_temp_file() in torture_knownhosts_parsing
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-28 15:51:06 +01:00
Anderson Toshiyuki Sasaki
78b1f0ead3 tests: Introduce torture_create_temp_file()
Introduced torture_create_temp_file() and torture_close_fp() to allow
creating temprary files transparently in Unix and Windows environment.
This also adds a unit test for the added functions.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-28 15:51:06 +01:00
Anderson Toshiyuki Sasaki
31527d4105 tests: Use torture_make_temp_dir() in torture_setup_socket_dir()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-28 15:51:06 +01:00
Anderson Toshiyuki Sasaki
65e16b8d9e tests: Introduce torture_make_temp_dir()
Introduces a function to create temporary dir for testing purposes.
Also adds a minimal test for the temporary directory creation.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-28 15:51:06 +01:00
Anderson Toshiyuki Sasaki
1f6b929735 tests: Replace tests filtering with cmocka builtin filter
This completely removes the tests filter code from torture.c and calls
cmocka_set_test_filter() instead, if available.  The checks for required
libraries, headers, and the availability of cmocka_set_test_filter()
were added to the cmake configuration.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-28 15:51:06 +01:00
Anderson Toshiyuki Sasaki
74285d3aca tests: Define flags not present in Windows
Define flags S_IRWXO and S_IRWXG in torture_knownhosts_parsing.c when
building for Windows.  These flags don't exist in Windows and are not
used.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-28 11:10:29 +01:00
Anderson Toshiyuki Sasaki
7960fbaabb tests: Add Windows alternatives for low level I/O
In Windows environment, there are available low level I/O operations in
io.h, such as _read(), _write(), _open(), and _close().

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-28 11:10:10 +01:00
Anderson Toshiyuki Sasaki
a2baf6e97b tests: Include config.h in torture_pki.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-27 11:52:12 +01:00
Anderson Toshiyuki Sasaki
f9ff53b494 tests: Include unistd.h only if available
Include the header in tests/torture_pki.c only if it is available.  It
is not available in Windows environment.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-27 11:52:12 +01:00
Andreas Schneider
98487f464b gitlab-ci: If there is not old sha check last 20 commits
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Jakub Jelen
b214f84538 tests: Avoid warnings about unused arguments
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Jakub Jelen
05417665b9 tests: Drop duplicate log level setup
Already done in the setup phase.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Jakub Jelen
e639c9d0d8 kex,packet,packet_cb: Reformat
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Jakub Jelen
bf2c7128ab server: Do not send SSH_MSG_EXT_INFO after rekey
This should not be a problem for well-behaving clients that do not
append the ext-info-c to the rekey, but if they do, we should not
send it either.

Resolves: T121

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Jakub Jelen
83f2ac4abb kex: Do not negotiate extensions during rekey
The RFC 8308 clearly says, that the additional  ext-info-c  should
be added only to the first SSH_MSG_KEXINIT.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Jakub Jelen
0b4c2a8e62 session: Reformat ssh_{set,is}_blocking
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Jakub Jelen
8418a1131e tests: Fix indentation
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Jakub Jelen
c18ed4eafa Drop unused header file
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Jakub Jelen
daabb084fe tests: Check the new AES-GCM ciphers
Signed-off-by: Jakub Jelen <jakuje@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Jakub Jelen
6709f2edf9 tests: Do not require all the crypto libs to build testsuite
This was failing when I tried to run the testsuite without
gcrypt devel libraries installed.

Signed-off-by: Jakub Jelen <jakuje@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Jakub Jelen
5bdb7a5079 crypto: Avoid unused parameter warnings
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Jakub Jelen
824c56067b config: Drop bogus newline in log
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Jakub Jelen
db5721d041 tests: Verify setting NULL knownhosts does not crash
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Jakub Jelen
3da5fcbb56 options: Do not crash when setting knownhosts to NULL (T108)
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Andreas Schneider
9d8c943c68 Update INSTALL
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-23 17:30:16 +01:00
Andreas Schneider
21881cde34 libcrypto: Fix checking for config.h defines
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-21 18:17:56 +01:00
Aris Adamantiadis
55252e4d70 libcrypto: disable AES-NI engine when running inside valgrind
Valgrind detects many uninitialized memory false positives from
libcrypto's AES-NI internals. Roll back to software AES when running
tests.

Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-21 16:54:36 +01:00
Aris Adamantiadis
8e002b9415 tests: Add tests for dh-group14, group16 and group18
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-21 16:54:24 +01:00
Aris Adamantiadis
f4339df577 packets: allow removal of callbacks
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-21 16:54:20 +01:00
Aris Adamantiadis
0197e5e1e5 libcrypto: detect non matching headers/shared lib
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-21 16:54:15 +01:00
Aris Adamantiadis
9546b20dec gcrypt: Bugfix for very slow ecdh
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-21 16:53:40 +01:00
Tilo Eckert
b227c12ad2 socket: Add missing braces
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-21 12:25:50 +01:00
Tilo Eckert
f369d02932 socket: Remove redundant code
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-20 07:59:32 +01:00
Tilo Eckert
0b9e07fbdc socket: Fix potential buffer overrun
If nread is < 0 and no exception callback is set,
the following code block would cause a buffer overrun.

Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-20 07:58:08 +01:00
Tilo Eckert
c47cdc0f97 pki: Fix typos in documentation
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-20 07:57:33 +01:00
Tilo Eckert
4b6eb05023 packet: Fix timeout on hostkey type mismatch instead of proper error
If the hostkey type was not in the list of acceptable hostkey
types, the function failed to set the error state. Due to the
fact that the calling function ssh_packet_process() does not
handle the SSH_ERROR return code, the newkeys packet from the
server was silently ignored, stalling the connection until a
timeout occurred.

Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-20 07:56:04 +01:00
Nicolas Viennot
59ada799d7 packets: Fix ssh_send_keepalive()
ssh_send_keepalive() should use global_request() to properly configure
the state machine for packet filtering.

Signed-off-by: Nicolas Viennot <nicolas@viennot.biz>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-20 07:55:08 +01:00
Andreas Schneider
bb5d46c190 COPYING: Reformat the last paragraph
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-17 20:11:51 +01:00
Andreas Schneider
aa56b8ca53 tests: Fix chroot_wrapper location
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-15 13:38:02 +01:00
Sanne Raymaekers
67f418218b knownhosts: Take StrictHostKeyChecking option into account
Signed-off-by: Sanne Raymaekers <sraymaek@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-08 16:19:18 +01:00
Sanne Raymaekers
03c30e9c8a tests: Ensure the ssh session fd is read-/writeable in torture_proxycommand
Signed-off-by: Sanne Raymaekers <sraymaek@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-08 16:18:16 +01:00
Rosen Penev
61cac32288 crypto: Fix compilation for OpenSSL without deprecated APIs
Added missing bn.h include.

Made engine.h include conditional, otherwise it would fail.

DSA_generate_parameters was deprecated long before 1.1.0.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2018-11-08 09:32:28 +01:00
Christophe Giboudeaux
aa899f8ec0 cmake: Refresh the CMake Config files
This commit fixes a couple issues in the CMake configuration files and uses
native features from CMake:

* libssh-build-tree-settings.cmake is deleted. There was a typo that made
this file unusable, anyway.
* use the macros available in CMakePackageConfigHelpers.cmake to generate
the version file and check that the files exist
* Remove the LIBSSH_THREADS_LIBRARY variable, it used the non-existent
  LIBSSH_THREADS_LIBRARY_NAME variable.
* Fix the in tree build. libssh can be used uninstalled again.

Test plan:
The values were tested after installing the new files and also without running
'make install'.

Signed-off-by: Christophe Giboudeaux <christophe@krop.fr>
2018-11-06 13:53:43 +01:00
Andreas Schneider
c88fb4c55b tests: Use correct assert function in torture_client_config
CID 1396565
CID 1396564
CID 1396563

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-05 07:57:13 +01:00
Andreas Schneider
a8ed5e31dc tests: Check for NULL in torture_client_config
CID 1396566

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-05 07:54:30 +01:00
Andreas Schneider
86dabfe7e4 cmake: Only check for bounded attribute on OpenBSD
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-02 16:42:06 +01:00
Jakub Jelen
1650d8178e config: Avoid potential file descriptor leak
Found by csbuild runner.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-02 13:26:09 +01:00
Jakub Jelen
6eb43fcbf3 tests: Verify the configuration reparsing with real client
This tests verifies that the only the first seen option is applied
throughout all the configuration files processed. It also verifies
that the configuration files are parsed automatically and that this
behavior can be overridden by configuration option.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-02 11:16:38 +01:00
Jakub Jelen
9aa47fef99 tests: Adjust test that require complete config re-parsing
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-02 11:16:38 +01:00
Jakub Jelen
de7405f1c7 config: Preserve the seen array among invocations
This follows the OpenSSH behavior of parsing subseqent configuration
files, while applying only the first option.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-02 11:16:38 +01:00
Jakub Jelen
4a95a35bc6 tests: Properly set the bob's UID also in other tests than pubkey
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-02 11:16:38 +01:00
Jakub Jelen
f6b390084e tests: Make sure that no other configuration options will get pulled to the auth test from system
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-02 11:16:38 +01:00
Jakub Jelen
b7fefb0500 options: Provide a way of disabling automatic config parsing
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-02 11:16:35 +01:00
Jakub Jelen
89a8a6fcf0 Process OpenSSH configuration files by default.
This will allow to use the same configuration in client applications
including the users aliases or system wide cryptographic configuration.

As the configuration parsing is the last thing before doing the
actual connection, it might overwrite previously set options.
If this is not intended, the client application can
ask the configuration files to be parsed before setting some other
options that should not ve overwritten. The code ensures that
the configuration is not parsed again.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-02 11:15:30 +01:00
Jakub Jelen
7e44ce1556 tests: Improve error reporting in auth test
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-02 10:08:20 +01:00
Jakub Jelen
5fc4d5b22a tests: Typo -- the flags should be checked according to the comment
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-02 10:08:20 +01:00
Jakub Jelen
5159cd96e8 knownhosts: Make sure we have both knownhosts files ready
If either one is missing at this point, fill it with default vaules in
ssh_options_apply().

Previously, when setting up only knownhosts, global_knownhosts file
was left pointing to NULL and the ssh_known_hosts_read_entries()
was trying to open NULL file which is invalid.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-11-02 10:08:20 +01:00
Jakub Jelen
35c417312c client: Reformat comment
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-30 16:22:17 +01:00
Jakub Jelen
e1a8b359c1 tests/pkd: Properly clean up memory
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-30 16:22:17 +01:00
Jakub Jelen
c8519c435e session: Drop unused structure member (SSHv1)
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-30 16:22:17 +01:00
Jakub Jelen
d85bc347d3 misc: Properly check for errors returned from getpwuid_r()
Resolves: T118

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-30 16:22:17 +01:00
Jakub Jelen
9c4baa7fd5 misc: Reformat ssh_get_user_home_dir and ssh_file_readaccess_ok
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-30 16:22:17 +01:00
Andreas Schneider
a4342b97d6 Bump SO version to 4.7.2
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-29 09:33:46 +01:00
Mike Frysinger
963c3077a4 doc: fix up various typos and trailing whitespace
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-28 12:15:02 +01:00
Andreas Schneider
a280747462 libcrypto: Fix memory leak in evp_final()
Fixes T116

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-27 22:15:56 +02:00
Meng Tan
bce8d56705 gssapi: Set correct state after sending GSSAPI_RESPONSE (select mechanism OID)
Signed-off-by: Meng Tan <mtan@wallix.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-26 07:28:20 +02:00
Sanne Raymaekers
ced05eb6db socket: Undouble socket fds
Signed-off-by: Sanne Raymaekers <sraymaek@redhat.com>
2018-10-25 18:49:29 +02:00
Meng Tan
b796924fea client: Send KEX as soon as banners are exchanged
Signed-off-by: Meng Tan <mtan@wallix.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 19:56:15 +02:00
Andreas Schneider
2af4e3970e gitlab-ci: Add static analysis with csbuild
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 14:30:38 +02:00
Andreas Schneider
cf3c2ee5b3 tests: Improve asserts in torture_pki_ecdsa
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
57eb6a400a tests: Init pubkey string with NULL in torture_keyfiles
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
8c77a49729 tests: Fix pointer arithmetic in torture_pki_*_publickey_base64
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
8c8026b892 tests: Init cipher structure in thread_crypto_aes256_cbc()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
80be1d0ee9 legacy: Fix possible null pointer dereference
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
9c3ba94960 buffer: Fix size comparison with count
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
194c34ebe3 messages: Use SSH_MESSAGE_FREE
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
00cd5b1c83 messages: Add SSH_MESSAGE_FREE
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
9fbbdcc154 messages: Rework ssh_message_queue()
Return early and make it easier to understand.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
b9ac61d5a3 messages: Use calloc in ssh_message_new()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
ca425ebe67 messages: Make ssh_message_queue() static
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
7e6b540277 exmpales: Init rc in ssh_server_fork
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
12ec1fed2f examples: Zero fds in sshnetcat
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
fb70d0fb41 pki: Add NULL check in ssh_pki_key_ecdsa_name()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
f8b70d6a73 pki_crypto: Mark iqmp as unused
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
74888a6fa4 pki: Remove superfluous statement
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
729384f346 pki: Add log message on error in ssh_pki_openssh_import()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
7e5291668c gssapi: Check return code of gss_indicate_mechs()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
bb081f6681 gssapi: Ignore return codes of gss_release_buffer()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
8a3ea3bdd5 packet: Do not segfault if we don't have packet_second_block
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
a190ff9302 packet: Add missing null pointer check in ssh_packet_socket_callback()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
2e7e0ad6c9 wrapper: Fix size type and loops in crypt_set_algorithms_server()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
39b08af2e8 wrapper: Reformat crypt_set_algorithms2()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
60a3796041 messages: Log message if callback for window change fails
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
cc4f220fd3 messages: Log message if sending reply fails
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
bc72ec5821 messages: Some cleanup for ssh_packet_service_request
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
54ec81db2d messages: Reformat ssh_packet_service_request()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
1ec2ca4202 connect: Zero the origfds struct
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
2fad391456 client: Remove superfluous strlen()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
cde13b0f00 channels: Check return code of ssh_packet_send()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
8f31623947 channels: Reformat ssh_channel_send_eof()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
253bda4bac channels: Check return of ssh_buffer_unpack()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
480915c07d libsshpp: Pass username and submethods to ssh_userauth_kbdint()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
e27c6b21b5 include: Fix HAVE_<FEATURE> checks in pki.h
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
f65c00f39d cmake: Fix -Wattributes check in ConfigureChecks.cmake
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Andreas Schneider
1d33a4424d gitlab-ci: Fix -DWITH_PCAP=ON
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-24 09:48:35 +02:00
Jakub Jelen
0386e088eb tests: Verify we can authenticate using ed25519 key
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 17:43:20 +02:00
Jakub Jelen
e91bb29e9d tests: Global known_hosts are used for host key verification
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 17:43:20 +02:00
Jakub Jelen
f622c4309b knownhosts: Consult also the global known hosts file
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 17:43:20 +02:00
Jakub Jelen
ae6b0e0f49 options: Set the global known_hosts file
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 17:43:20 +02:00
Jakub Jelen
bdb3bb9ccd tests: Verify the hostkey ordering for negotiation is correct
Previously, not all of the host keys algorithms were used for algorithm
negotiation. This verifies the algorithms list is sane and ordered
with the key types from known hosts in the first place.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 17:43:20 +02:00
Jakub Jelen
32e502a79d tests: Generate valid known_hosts file, fixing the current test
Previously, the file contained the known_hosts strings separated
by NULL bytes which somehow magically worked.

The test was also expecting all the keys from the file will have
the same key type, which was not indeed true.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 17:43:20 +02:00
Jakub Jelen
6ec5a08639 tests: Verify the ecdsa key types are handled correctly
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 17:43:20 +02:00
Jakub Jelen
35a6455489 kex: Use all supported hostkey algorithms for negotiation
Previously, only the algorithms we had a keys for in known_hosts
were used, which could lead to no-matching algorithms errors if the
one key we used to depend on was removed from the server.

This commit adds also the other algorithms, but lists them only after
all the key types we have in known_hosts file.

Resolves: T105

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 17:43:17 +02:00
Jakub Jelen
c1a8c41c5d kex: Honor more host key algorithms than the first one (ssh-ed25519)
The code as it was written used only the first algorithm from
preferred_hostkeys  array and compared it with the list returned
from the known hosts.

This commit is fixing the code so we actually compare each of the
algorithms from both of the lists and returns the intersection.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 17:42:55 +02:00
Jakub Jelen
893b69d82b knownhosts: Use the correct name for ECDSA keys for host key negotiation
The conversion from  ssh_keytype_e  to string does not work for ECDSA keys,
because different key lengths have different string representation.

The usage of  type_c  should work also for every other key type in future,
but it does not reflrect different signature types (SHA2 extension for RSA
keys), but this early in the key exchange phase, we can not make any
assumptions about supported extensions by the server.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 17:42:55 +02:00
Jakub Jelen
9285e8516b tests: Do not trace sshd
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 17:42:55 +02:00
Andreas Schneider
91f35eca4d libsshpp: Use ssh_session_update_known_hosts()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 17:42:02 +02:00
Andreas Schneider
49e287006f tests: Add option tests for global and user specific known_hosts
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 12:31:04 +02:00
Andreas Schneider
85fc0d5b83 options: Add support for getting the known_hosts locations
Fixes T111

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 12:31:04 +02:00
Andreas Schneider
0ff566b6dd examples: Explicitly track auth state in samplesshd-kbdint
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 12:31:04 +02:00
Andreas Schneider
9c200d3ef4 messages: Check that the requested service is 'ssh-connection'
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 12:31:04 +02:00
Meng Tan
4ea46eecce server: Set correct state after sending INFO_REQUEST (Kbd Interactive)
Signed-off-by: Meng Tan <mtan@wallix.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-19 10:20:53 +02:00
Andreas Schneider
009ca5c9dd priv: Add ssize_t if not available with MSVC
Fixes T113

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Tested-by: Wolf Wolfswinkel <wolf.wolfswinkel@objectplus.nl>
2018-10-17 15:37:28 +02:00
Andreas Schneider
fe618a35dc packet: Add missing break in ssh_packet_incoming_filter()
CID 1396239

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-17 08:19:23 +02:00
Andreas Schneider
795389ae1b src: Fix typos
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 16:36:20 +02:00
Andreas Schneider
60037f3275 Bump ABI to 4.7.1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 09:24:39 +02:00
Anderson Toshiyuki Sasaki
e1548a71bd CVE-2018-10933: Add tests for packet filtering
Created the test torture_packet_filter.c which tests if packets are
being correctly filtered.

Fixes T101

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 09:19:03 +02:00
Anderson Toshiyuki Sasaki
75be012b4a CVE-2018-10933: Introduced packet filtering
The packet filter checks required states for the incoming packets and
reject them if they arrived in the wrong state.

Fixes T101

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 09:19:03 +02:00
Anderson Toshiyuki Sasaki
68b0c7a934 CVE-2018-10933: Check channel state when OPEN_FAILURE arrives
When a SSH2_MSG_OPEN_FAILURE arrives, the channel state is checked
to be in SSH_CHANNEL_STATE_OPENING.

Fixes T101

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 09:19:03 +02:00
Anderson Toshiyuki Sasaki
459868c4a5 CVE-2018-10933: Check channel state when OPEN_CONFIRMATION arrives
When a SSH2_MSG_OPEN_CONFIRMATION arrives, the channel state is checked
to be in SSH_CHANNEL_STATE_OPENING.

Fixes T101

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 09:19:03 +02:00
Anderson Toshiyuki Sasaki
5d7414467d CVE-2018-10933: Set correct state after sending MIC
After sending the client token, the auth state is set as
SSH_AUTH_STATE_GSSAPI_MIC_SENT.  Then this can be expected to be the
state when a USERAUTH_FAILURE or USERAUTH_SUCCESS arrives.

Fixes T101

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 09:19:03 +02:00
Anderson Toshiyuki Sasaki
20981bf229 CVE-2018-10933: Introduce SSH_AUTH_STATE_AUTH_NONE_SENT
The introduced auth state allows to identify when a request without
authentication information was sent.

Fixes T101

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 09:19:03 +02:00
Anderson Toshiyuki Sasaki
825f4ba964 CVE-2018-10933: Introduce SSH_AUTH_STATE_PASSWORD_AUTH_SENT
The introduced auth state allows to identify when authentication using
password was tried.

Fixes T101

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 09:19:03 +02:00
Anderson Toshiyuki Sasaki
2bddafeb70 CVE-2018-10933: Introduced new auth states
Introduced the states SSH_AUTH_STATE_PUBKEY_OFFER_SENT and
SSH_AUTH_STATE_PUBKEY_AUTH_SENT to know when SSH2_MSG_USERAUTH_PK_OK and
SSH2_MSG_USERAUTH_SUCCESS should be expected.

Fixes T101

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 09:19:03 +02:00
Andreas Schneider
16b876d07f examples: Use ssh_session_update_known_hosts() for updating known_hosts
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 08:58:31 +02:00
Andreas Schneider
a80caec19b cmake: Disable deprecation warnings for old known_hosts API
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 08:56:46 +02:00
Andreas Schneider
d6b6fff7f7 cmake: Only check for -Wno-gnu-zero-variadic-macro-arguments with clang
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-16 08:46:25 +02:00
Andreas Schneider
259d7de153 include: Mark old known_hosts API as deprecated
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-13 22:08:41 +02:00
Tilo Eckert
d13517e922 chacha: remove re-declared type
re-declaring typedefs are not supported by some compilers

Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
2018-10-13 22:08:39 +02:00
Tilo Eckert
45058285fc knownhosts: Fix invalid read of known_hosts token
Fixes invalid read introduced by commit 21962d.
Accessing tokens[4] for a known_hosts line of
three tokens led to randomly rejected host keys.

This commit completely removes the check because
the optional comments field may contain whitespace.

Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
2018-10-13 22:08:36 +02:00
Jakub Jelen
42bd7cdf6c tests: Add aes-gcm ciphers tests
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 13:05:38 +02:00
Jakub Jelen
72bd2fe197 libmbedtls: Support OpenSSH-compatible AES-GCM ciphers using mbedTLS
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 13:05:38 +02:00
Jakub Jelen
a2120e168b libmbedtls: Simplify the cipher setup
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 13:05:38 +02:00
Jakub Jelen
5790036a23 libgcrypt: Implement OpenSSH-compatible AES-GCM ciphers using libgcrypt
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 13:05:38 +02:00
Jakub Jelen
032f486f27 cmake: Link against gpg-error
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 13:05:38 +02:00
Jakub Jelen
46090facba libcrypto: Implement OpenSSH-compatible AES-GCM ciphers using OpenSSL
The commit also propares the internals throughout the code base
for the inclusion of a new AEAD cipher, because previously, the
source code counted only with chacha20-poly1305 cipher, which
is very specific in many cases.

The SSH_HMAC_AEAD_GCM mac algorithm is not actually used, but the name
needed to be defined so we can match in the algorithms selection per
OpenSSH specification (MACs are ignored in case GCM is select as a cipher [1]).

If the provided OpenSSL does not provide  EVP_aes_128_gcm()  function,
the AES-GCM ciphers will not be compiled in.

[1] https://cvsweb.openbsd.org/src/usr.bin/ssh/PROTOCOL.chacha20poly1305?annotate=HEAD

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 12:05:40 +02:00
Jakub Jelen
777786d76c libcrypto: Do not use magic numbers for AES block size
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 12:05:40 +02:00
Jakub Jelen
101df98e54 libcrypto: Avoid double free
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 12:05:40 +02:00
Andreas Schneider
f747e46f33 init: Only add DllMain if we create a shared library
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-09 11:40:31 +02:00
Andreas Schneider
275f73125d packet: Use a stack buffer for the header
This removes the allocation for the header buffer for each packet we
send.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-08 09:27:12 +02:00
Andreas Schneider
422376efd4 packet: Reformat packet_send2()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-08 09:27:09 +02:00
Andreas Schneider
3245b50795 sftp: Only prepend header data once
This reduces memory moving.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-08 09:27:06 +02:00
Andreas Schneider
508dfc5251 sftp: Reformat sftp_packet_write()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-08 09:26:59 +02:00
Andreas Schneider
43a40999da agent: Use (PUSH|PULL)_BE_U32 in agent_talk()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-05 14:38:43 +02:00
Andreas Schneider
e701913fc8 agent: Just use uint32_t for the count
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-05 14:38:43 +02:00
Andreas Schneider
aec9fa4442 sftp: Use bytearray macros
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-05 14:38:43 +02:00
Andreas Schneider
85a274ff3c include: Add macros for bytearray handling
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-10-05 14:38:43 +02:00
Andreas Schneider
e210b61148 examples: Reformat knownhosts
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-05 14:38:43 +02:00
Andreas Schneider
f09ca85ebf cmake: Always build position independent code
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-10-02 14:48:02 +02:00
Andreas Schneider
096d966e43 gitlab-ci: Report errors on debian 2018-09-27 18:06:23 +02:00
Anderson Toshiyuki Sasaki
cc513c4c9a messages: Fixed possible memory leak in ssh_message_queue
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
31202822a7 examples: Add null checks in libssh_scp.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
6118628424 examples: Fix libssh_scp.c code style
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
00e5ef1b3c examples: Fix possible memory leak in libssh_scp.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
6eef4b4a3c tests: Add frees to avoid memory leak errors
The added frees are unnecessary, but the static analyser does not know.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
79e907402e tests: Replace ssh_buffer_free() with SSH_BUFFER_FREE()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
ca7da823c3 tests: Replace ssh_string_free() with SSH_STRING_FREE()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
2eaa23a20e tests: Replace ssh_key_free() with SSH_KEY_FREE()
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
143b5e2e50 tests: Use SSH_STRING_FREE_CHAR
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Anderson Toshiyuki Sasaki
11d480134c include: Add SSH_KEY_FREE
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 15:21:30 +02:00
Andreas Schneider
3786db4cdf gitlab-ci: Get build and test errors from mingw
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-27 08:45:41 +02:00
Andreas Schneider
9cf341bad3 gitlab-ci: Use -DCMAKE_BUILD_TYPE=UndefinedSanitizer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-26 16:55:28 +02:00
Andreas Schneider
e57f0273a6 cmake: Add UndefinedSanitizer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-26 16:54:31 +02:00
Andreas Schneider
3d74c3802e cmake: Also add DEFAULT_LINK_FLAGS for Solaris
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-26 16:53:29 +02:00
Anderson Toshiyuki Sasaki
667fb5f9a9 cmake: Rewritten AddCMockaTest.cmake
This changes add_cmocka_test() to receive compiler options, the
libraries to be linked to the test, and the linker options.  The way the
tests are declared in tests/unittests and tests/client were updated.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-26 16:27:22 +02:00
Alberto Aguirre
14f5624ff5 sftpserver: allocate packet on sftp_server_new
Ensure sftp_server_new allocates the packet and payload as
sftp_packet_read now expects the packet and payload to be
pre-allocated.

Similarly, ensure sftp_get_client_message does not free the packet.

Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25 16:41:54 +02:00
David Wedderwille
9adc2d36eb connector: Add checks if file descriptor is a socket
Fixes T104

Signed-off-by: David Wedderwille <davidwe@posteo.de>
2018-09-25 14:37:25 +02:00
Andreas Schneider
1e5e09563a socket: Pass MSG_NOSIGNAL to send()
This avoid that we get a SIGPIPE.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25 14:37:25 +02:00
Andreas Schneider
35bf5334b8 socket: Return ssize_t for ssh_socket_unbuffered_write()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25 14:37:25 +02:00
Andreas Schneider
a7604c7d6e socket: Reformat ssh_socket_write()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25 14:37:25 +02:00
Andreas Schneider
c5cadaa982 socket: Reformat ssh_socket_unbuffered_write()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25 14:37:25 +02:00
Andreas Schneider
caf50270c6 socket: Return ssize_t for ssh_socket_unbuffered_read()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25 14:37:25 +02:00
Andreas Schneider
b7a29c7ffd socket: Reformat ssh_socket_pollcallback()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25 14:37:25 +02:00
Andreas Schneider
491a42d046 socket: Reformat ssh_socket_unbuffered_read()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25 14:37:25 +02:00
Andreas Schneider
642a1b1aa4 connect: Fix build warning on Windows
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25 14:37:25 +02:00
Andreas Schneider
f709c3ac58 config: Fix building without globbing support
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25 14:37:25 +02:00
Andreas Schneider
ae2b9a3bde include: Do not declare ssh_channel_new() twice
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25 14:37:25 +02:00
Andreas Schneider
1d7520b68a cmake: Add -Wattributs for configure checks
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-25 14:37:25 +02:00
Andreas Schneider
9c37c8c5a5 cmake: Bump library version 2018-09-20 16:35:13 +02:00
Chris Townsend
6c56c1e0d7 sftpserver: Support some openssh extensions
Add support for "hardlink@openssh.com" and
"posix-rename@openssh.com" extensions.

Signed-off-by: Chris Townsend <christopher.townsend@canonical.com>
Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-20 16:35:13 +02:00
Andreas Schneider
e4711c469f pki: Use strndup in ssh_pki_export_privkey_base64()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-20 16:35:13 +02:00
Andreas Schneider
8410f43d8b tests: Add a test for ssh_pki_export_privkey_base64()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-20 16:35:13 +02:00
DavidWed
d0ce2d1ecd pki: Add ssh_pki_export_privkey_base64()
Fixes T53

Signed-off-by: DavidWedderwille <davidwe@posteo.de>
Reviewed-by: Andreas Schneider <asn@samba.org>
2018-09-20 16:35:13 +02:00
Andreas Schneider
5a198732a5 tests: Add test for ssh_get_fingerprint_hash()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-20 16:35:13 +02:00
Andreas Schneider
92aa2cf496 dh: Use ssh_get_fingerprint_hash() in ssh_print_hash()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-20 16:35:13 +02:00
Andreas Schneider
bbed139eca dh: Add ssh_get_fingerprint_hash()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-20 16:35:13 +02:00
Anderson Toshiyuki Sasaki
0eab270754 dh: Removed duplicated code
The code for calculating SHA 512 in ssh_make_sessionid() had been
duplicated; the cases were unified.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2018-09-20 15:37:23 +02:00
Anderson Toshiyuki Sasaki
71594f9d6c dh: Add diffie-hellman-group18-sha512 support
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2018-09-20 15:37:23 +02:00
Andreas Schneider
2ae2baf9ca buffer: Don't call va_end() twice
This is handled in the cleanup.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-20 15:37:23 +02:00
Andreas Schneider
4c47719d98 examples: Reformat authenticaton.c
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-20 15:37:23 +02:00
Andreas Schneider
a30d542207 sftp: Include stdint.h
Thanks to Apex Liu

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-19 12:25:03 +02:00
Anderson Toshiyuki Sasaki
d9d3b65df2 dh: Add diffie-hellman-group16-sha512 support
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-19 12:17:02 +02:00
Harald Sitter
97cb302c0e sftp: fix buffer_unpack argument to be char** rather than char*
Summary:
buffer variable 's' gets unpacked as char**, the previous code was passing
a char* causing segfaults on all readlink calls inside the unpacking code

Test Plan:
- without patchy examples/samplesftp segfaults in readlink
- with patchy it doesn't

Reviewers: asn

Differential Revision: https://bugs.libssh.org/D14

Signed-off-by: Harald Sitter <sitter@kde.org>
2018-09-19 11:18:12 +02:00
Andreas Schneider
90373d8394 buffer: Do cleanup if ssh_buffer_unpack() fails in the first loop
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-19 11:18:12 +02:00
Andreas Schneider
07f7fa7806 buffer: Fix invalid memory access in ssh_buffer_unpack()
Found by oss-fuzz.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-19 11:18:02 +02:00
Andreas Schneider
5123f7955b tests: Add OK: and a new line to ssh_ping
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 18:46:28 +02:00
Jakub Jelen
c15ad753a7 tests: Wait for the server to start
The previous timeout of 500 ms was not enough on slower machines or
while running the tests under valgrind. On much faster machines the
sleep() was bringing unnecessary overhead.

This method opens simple connection to the server verifying it is ready
to accept the connection from the test for 5 seconds. It the server
does not start until then, it fails the tests during initialization,
rather than leaving the cases to run against missing server.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 18:07:27 +02:00
Anderson Toshiyuki Sasaki
63aa274f4b tests: Add null checks in torture_threads_pki_rsa.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 10:19:59 +02:00
Anderson Toshiyuki Sasaki
8170e30073 tests: Add null checks in torture_pki_rsa.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 10:19:59 +02:00
Anderson Toshiyuki Sasaki
77f58a225f tests: Add null checks in torture_pki_ed25519.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 10:19:59 +02:00
Anderson Toshiyuki Sasaki
48459c37f6 tests: Add null checks in torture_pki_ecdsa.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 10:19:59 +02:00
Anderson Toshiyuki Sasaki
31f24ed23e tests: Add null checks and frees in torture_pki_dsa.c
These frees are unnecessary because the negative tests should not
allocate the keys, but the static analyser reports memory leak errors.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 10:19:59 +02:00
Anderson Toshiyuki Sasaki
82c3faa44d tests: Add return and null checks in torture_options.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 10:19:59 +02:00
Anderson Toshiyuki Sasaki
7c75e76d10 tests: Add null checks in torture_config.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 10:19:59 +02:00
Anderson Toshiyuki Sasaki
f246e31ca0 examples: Fix code style in samplesftp.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 10:19:59 +02:00
Anderson Toshiyuki Sasaki
7390db6bbb examples: Fixed possible memory leak in samplesftp.c
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 10:19:59 +02:00
Andreas Schneider
cc83b463ce sftp: Fix a possible null pointer dereference
CID 1395721

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 10:19:59 +02:00
Jakub Jelen
39975fdd6d tests: Verify we can read public key from OpenSSH container
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 09:53:49 +02:00
Jakub Jelen
1226de875b pki: Implement reading public key from OpenSSH private key container
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 09:53:49 +02:00
Jakub Jelen
2307be32cf Revert "pkd: Generate host keys in old format"
This is no longer needed since libssh can read the private keys
in new OpenSSH format.

This reverts commit 100c9c98ce.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 09:53:49 +02:00
Jakub Jelen
eaaa4131de tests: Verify the keys loaded from new OpenSSH format
This runs the same test that are ran on the legacy PEM files
also with the new OpenSSH key files.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 09:53:49 +02:00
Jakub Jelen
39102224b2 pki: Allow reading keys in new OpenSSH format
This implements reading the OpenSSH key format accross the
cryptographic backends. Most of the code is shared and moved
to pki.c, just the building of the keys is implemented in
pki_privkey_build_*() functions.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 09:53:49 +02:00
Jakub Jelen
e365aed6d2 tests: Provide testing keys also in OpenSSH format
This extends the torture API to provide a way to request
keys in different formats. This extends the keys with
private keys in the new OpenSSH format (default since
OpenSSH 7.8).

This also needs modifications to the ed25519 tests, which
do not support PEM format and expected the new format out of the
box.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 09:53:49 +02:00
Jakub Jelen
d23bda8181 pki: Use unpack to simplify public key reading
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 09:53:49 +02:00
Jakub Jelen
86d521cbe7 buffer: Make sure unpack of secure buffers securely cleans up
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 09:53:49 +02:00
Andreas Schneider
856dc698a9 libmbedcrypto: Fix creating evp hash
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-18 09:51:41 +02:00
Jakub Jelen
4d09c6dc31 buffer: Reformat ssh_buffer_get_ssh_string
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 16:39:38 +02:00
Jakub Jelen
03a66b8599 tests: Use stdbool for with_passphrase argument
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 16:39:38 +02:00
Jakub Jelen
c04eac40f3 pki_crypto: Clarify that memory passed with set0 is managed by openssl objects
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 16:39:38 +02:00
Jakub Jelen
8cc0672c0c pki_mbedcrypto: pki_pubkey_build_rsa: properly clean up on error
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 16:39:38 +02:00
Jakub Jelen
8f7214a584 pki: Initialize pointers to NULL
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 16:39:38 +02:00
Jakub Jelen
9d2de880ec tests: Drop duplicate ed25519 key creation
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 16:39:38 +02:00
Jakub Jelen
039c066da5 buffer: Fix typo
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 16:39:38 +02:00
Jakub Jelen
6efbf7a30e tests: Verify the pubkey authentication works with ECDSA keys
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2018-09-17 16:39:38 +02:00
Andreas Schneider
e5170107c9 auth: Fix ecdsa pubkey auth
Pair-Programmed-With: Jakub Jelen <jjelen@redhat.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2018-09-17 16:39:12 +02:00
Andreas Schneider
30df04a8a5 tests: Do not call sftp_canonicalize_path()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 14:35:39 +02:00
Andreas Schneider
aaca395bd3 tests: Add a sftp benchmark test for write/read
The tests writes and reads a file of 128M.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
0762057eb9 sftp: Move the packet payload to the message
This reduces memory allocations and copying.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
57153f6481 sftp: Use SSH_BUFFER_FREE in sftp_message_free()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
4c32befd93 sftp: Reformat sftp_message_free()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
be8302e2f3 sftp: Allocate a new buffer in sftp_packet_read() if needed
We will move the buffer to the message instead of duplicating the
memory.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
97d2e1f4cb sftp: Reformat sftp_read_and_dispatch()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
12fc0ea1bf sftp: Validate the packet handle before we allocate memory
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
573eab0d51 sftp: Reformat sftp_get_message()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
0e317e612f sftp: Use bool for is_eof in sftp_packet_read()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
01135703a3 sftp: Use 's' only in the scope it is needed
This revaled a bug when reading the packet type.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
c070414309 sftp: Use 16K for the transfer buffer size
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
d2cc4eccc7 sftp: Get the packet type directly from the buffer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
38781f69b0 sftp: Limit packet size to 256 MB
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
dc4faf9952 sftp: Directly read and validate the packet size from the bufffer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
cbbc6ddcb6 sftp: Use read_packet from sftp handle
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
a7456bf4d5 sftp: Simplify the code for reading data
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
afc14fe003 sftp: Reformat sftp_packet_read()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
79a3fcac72 sftp: Keep a ssh_packet for reading in the sftp handle
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
945afaa6b4 sftp: Remove ZERO_STRUCTP from sftp_free()
The structure doesn't hold any sensitive data and this would be
optimized away anyway.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
d840a05be3 sftp: Reformat sftp_free()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
662c30eb72 sftp: Reformat sftp_new()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
29b5477849 include: Add SSH_BUFFER_FREE
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
2e8f2f03e7 cmake: Correctly detect if glob has gl_flags member
Thanks to Baruch Siach.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-17 10:48:49 +02:00
Andreas Schneider
983d1189d0 gitlab-ci: Add builds with gcc7
It looks like gcc7 has more warning enabled or something is broken in
gcc8.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-10 13:02:40 +02:00
Andreas Schneider
7b2e1c7fb7 gitlab-ci: Big cleanup
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-10 12:02:08 +02:00
Andreas Schneider
ceecd3fd6f config: Fix size type
src/config.c:562:12: error: assuming signed overflow does not occur when
    simplifying conditional to constant [-Werror=strict-overflow]

         if (args < 1) {
            ^

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-06 08:28:24 +02:00
Andreas Schneider
bfd33ecf29 cmake: Use -Wpedantic and remove -pedantic-errors
We get -Werror if -DPICKY_DEVELOPER=ON is set.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-06 08:28:24 +02:00
Jakub Jelen
56317caafc tests: UsePrivilegeSeparation has no effect since OpenSSH 7.5
Additionally, we can already work around the privilege separation.

http://www.openssh.com/txt/release-7.5

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 15:43:11 +02:00
Jakub Jelen
ca4fb9c6f8 tests: Do not trace sshd
OpenSSH's sshd does not work well under valgrind so lets avoid tracing it.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 15:43:00 +02:00
Andreas Schneider
91800eb243 cmake: Move CompilerFlags to own file
They need to be included before the project() call.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 15:28:29 +02:00
Andreas Schneider
2923ad59f9 cmake: Update defaults
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 15:21:34 +02:00
Jakub Jelen
556ad59a5a tests: Verify the Match keyword from configuration file
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 11:43:05 +02:00
Jakub Jelen
fcb203cb2d tests: No need to restore log level now
Since the verbosity is now set from the setup phase, we do not
need to reset the verbosity, especially not to any arbirary value
such as WARNING.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 11:43:05 +02:00
Jakub Jelen
6dbcc21921 tests: Use global verbosity in tests
This allows adjusting the log level of config and options tests using
environment variable LIBSSH_VERBOSITY as it works in most of the other
tests.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 11:43:05 +02:00
Jakub Jelen
2eccd04ff6 tests: Missing unlink
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 11:43:05 +02:00
Jakub Jelen
e9b44d26b1 config: Parse Match keyword
Amends f818e63f8, which introduced the constants and matching of this
configuration option, but did not implement the handling of the values
which was causing the configuration parser failing for certain
configurations.

This commit exposes match_pattern_list() from match.c

Red Hat Bugzilla:
https://bugzilla.redhat.com/show_bug.cgi?id=1624425

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 11:43:05 +02:00
Jakub Jelen
9f5f10552b config: Do not overwrite previously matched result in Host blocks
The match_hostname() expects comma separated list, while the Host
config keyword in openssh uses spaces separated list by default.
Therefore any subseqent match or negated match in space separated
list will overwrite the previous matches.

This also adjusts the tests to make sure both of the versions work.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 11:43:05 +02:00
Andreas Schneider
458bda8877 tests: Define LIBSSH_STATIC for torture_cmocka
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 11:43:05 +02:00
Andreas Schneider
3d35250c07 tests: Fix linking unit tests
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 11:43:05 +02:00
Andreas Schneider
ef06ef2c1b channels: Allow infinite timeout for ssh_channel_read_timout()
This is also documented.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-05 11:43:05 +02:00
Andreas Schneider
ba1ff992ce libsshpp: Initialize the string returned by getIssueBanner()
Fixes T13

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-04 20:52:31 +02:00
Andreas Schneider
e558827c4e channels: Don't read from a closed channel
Fixes T76

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-04 20:34:52 +02:00
Andreas Schneider
1e195a232a auth: Use calloc to allocate memory
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:59:07 +02:00
Andreas Schneider
d1cd914012 misc: Use C99 initializer to initialize string
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:59:01 +02:00
Andreas Schneider
c3980d433a pki_container: Use string functions for cleanup
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:58:47 +02:00
Andreas Schneider
78498ee289 packet: Use C99 initializer to reset session->in_packet
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:58:38 +02:00
Andreas Schneider
76f5a60a82 packet: Reformat ssh_packet_parse_type()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:58:30 +02:00
Andreas Schneider
07986731c6 gzip: Use calloc in initcompress() and initdecompress()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:58:23 +02:00
Andreas Schneider
f1608778be kex: Use C99 initializer instead of memset
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:58:17 +02:00
Andreas Schneider
72e91d5131 channels: Remove memset in ssh_channel_do_free()
We have nice tools to detect that in the meantime.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:58:11 +02:00
Andreas Schneider
4af4b59e21 channels: Reformat ssh_channel_free()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:58:03 +02:00
Andreas Schneider
ca464ca2ba channels: Use calloc() in ssh_channel_new()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:57:58 +02:00
Andreas Schneider
9ac6ac6c26 channel: Reformat ssh_channel_new()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:57:53 +02:00
Andreas Schneider
b6b5a61c97 pki_mbedcrypto: Use explicit_bzero()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:57:48 +02:00
Andreas Schneider
1acb82e38a pki_crypto: Use explicit_bzero()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:57:43 +02:00
Andreas Schneider
a6d59811bb getpass: Use explicit_bzero()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:57:31 +02:00
Andreas Schneider
d4a443d56c getpass: Use calloc to allocate memory
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:57:22 +02:00
Andreas Schneider
62bff4aff1 wrapper: Use explicit_bzero() in crypto_free()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:57:16 +02:00
Andreas Schneider
f8e68b92b8 wrapper: Fix size type
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:57:12 +02:00
Andreas Schneider
9c5d2d4543 wrapper: Reformat crypto_free()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 19:57:06 +02:00
Andreas Schneider
7867126aa6 tests: Add a test for sftp_canonicalize_path()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-04 18:13:37 +02:00
Andreas Schneider
4774d2b9f7 sftp: Fix segfault in sftp_canonicalize_path()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-04 17:30:18 +02:00
Andreas Schneider
f48dcb26e3 string: Don't allow to allocate strings bigger than 256M
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 12:29:20 +02:00
Andreas Schneider
d1f23cd6d8 string: Reformat ssh_string_new()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-09-04 12:29:09 +02:00
Andreas Schneider
e601dbd8e3 sftp: Use ssh_buffer_pack() in sftp_fstat()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:39:23 +02:00
Andreas Schneider
f3ffd8aa41 sftp: Reformat sftp_lstat()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:39:23 +02:00
Andreas Schneider
4d98b1cd7e sftp: Use ssh_buffer_pack() in sftp_xstat()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:39:23 +02:00
Andreas Schneider
b00a0578f9 sftp: Reformat sftp_xstat()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:39:23 +02:00
Andreas Schneider
336c097ae7 sftp: Use ssh_buffer_unpack() in sftp_canonicalize_path()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:39:23 +02:00
Andreas Schneider
1dd8466f66 sftp: Use ssh_buffer_pack() in sftp_canonicalize_path()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:39:23 +02:00
Andreas Schneider
8b19ef05f3 sftp: Reformat sftp_canonicalize_path()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:39:23 +02:00
Andreas Schneider
7e11e41a9f sftp: Use sftp_buffer_pack() in sftp_fstatvfs()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:39:23 +02:00
Andreas Schneider
5914ea7c75 sftp: Reformat sftp_fstatvfs()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:39:23 +02:00
Andreas Schneider
f1e84d5e67 sftp: Use ssh_buffer_pack() in sftp_fsync()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:39:23 +02:00
Andreas Schneider
8e3dd09e11 sftp: Use ssh_buffer_pack() in sftp_statvfs()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:39:23 +02:00
Andreas Schneider
ae0afec98d sftp: Reformat sftp_statvfs()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:39:23 +02:00
Andreas Schneider
0be43c333e sftp: Use ssh_buffer_unpack() in sftp_readlink()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:39:23 +02:00
Andreas Schneider
83a5d3b258 sftp: Use ssh_buffer_pack() in sftp_readlink()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:39:23 +02:00
Andreas Schneider
bb4bdec184 sftp: Reformat sftp_readlink()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:39:16 +02:00
Andreas Schneider
e0449ba21f sftp: Use ssh_buffer_pack() in sftp_setstat()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:37:24 +02:00
Andreas Schneider
8a56b90c3e sftp: Reformat sftp_setstat()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:36:29 +02:00
Andreas Schneider
218c67a51d sftp: Use ssh_buffer_pack() in sftp_mkdir()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:36:29 +02:00
Andreas Schneider
89c525bbf1 sftp: Reformat sftp_mkdir()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:36:29 +02:00
Andreas Schneider
2c0baef7d4 sftp: Use ssh_buffer_pack in sftp_open()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:34:00 +02:00
Andreas Schneider
bfb6718b50 sftp: Reformat sftp_open()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:34:00 +02:00
Andreas Schneider
d99c066a0b sftp: Use ssh_buffer_pack() in sftp_handle_close()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:34:00 +02:00
Andreas Schneider
2844942c1b sftp: Reformat sftp_handle_close()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:34:00 +02:00
Andreas Schneider
3a729829fd sftp: Use ssh_buffer_pack() in sftp_readdir()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:34:00 +02:00
Andreas Schneider
576fdbe1e8 sftp: Reformat sftp_readdir()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:32:45 +02:00
Andreas Schneider
87df9cfc5d sftp: Use ssh_buffer_pack() in sftp_opendir()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:32:23 +02:00
Andreas Schneider
ea375d1605 sftp: Reformat sftp_opendir()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:32:23 +02:00
Andreas Schneider
c15bd2831f buffer: Precalculate the size required for ssh_buffer_pack()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:32:12 +02:00
Andreas Schneider
efef877356 buffer: Only reduce the buffer size if it gets bigger than 64K
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:29:15 +02:00
Andreas Schneider
254a0f7132 buffer: Only allow to allocate a maximum of 256MB
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:27:32 +02:00
Andreas Schneider
d2131b286f buffer: Always preallocate a buffer with 64 bytes
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:26:36 +02:00
Andreas Schneider
c1c32bda14 buffer: Rewrite ssh_buffer_free()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 18:19:58 +02:00
Andreas Schneider
a1b57d3b94 buffer: Use bool for secure buffer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 15:00:53 +02:00
Andreas Schneider
be703974e9 buffer: Reformat buffer_shift()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 15:00:53 +02:00
Andreas Schneider
29f36791c9 buffer: Cleanup buffer_verify
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 15:00:53 +02:00
Andreas Schneider
492e3d5c77 cmake: Store Profiling and AddressSanitizer flags in the cache
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 15:00:53 +02:00
Andreas Schneider
9a3f43f4ee cmake: Add -fstack-clash-protection
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-03 14:18:25 +02:00
Andreas Schneider
baa434ebed cmake: Small improvements to AddCMockaTest
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-02 11:25:43 +02:00
Andreas Schneider
f99e6766d6 auth: Fix freeing memory in ssh_userauth_agent_publickey()
CID 1395453

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-02 10:01:47 +02:00
Andreas Schneider
3efc64112a include: Add SSH_STRING_FREE() and SSH_STRING_FREE_CHAR()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-02 09:54:20 +02:00
Andreas Schneider
bc19f892eb gitlab-ci: Correctly run AddressSanitizer with cmake
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-01 21:26:48 +02:00
Andreas Schneider
f8fc0b9dfb messages: Fix memory leak in ssh_packet_userauth_request
Found by AddressSanitizer.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-01 21:26:37 +02:00
Andreas Schneider
1b12a2415d gitlab-ci: Enable address sanitzer build
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-01 10:21:06 +02:00
Andreas Schneider
1c0ac0b12e tests: Fix memory leaks in torture_hashes
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-01 10:16:56 +02:00
Andreas Schneider
ea2b403ab2 auth: Fix a memory leak in ssh_userauth_agent_publickey()
CID 1230358

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-01 09:41:11 +02:00
Andreas Schneider
8323cd791f pki: Fix a memory leak in ssh_pki_do_sign()
CID 1395335

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-01 09:41:11 +02:00
Andreas Schneider
461ebd1e2f packet: Add a bound check for nr_extensions
CID 1395335

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-09-01 09:40:44 +02:00
Andreas Schneider
be147e897d doc: Update Public Key Algorithms
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 15:04:37 +02:00
Andreas Schneider
1d329236b3 gitlab-ci: Move tumbleweed to the end of the file
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Andreas Schneider
0c6544adcb gitlab-ci: Only run static-analysis on tumbleweed
Tumbleweed offers a newer clang version and we don't really have to
waste resources.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Andreas Schneider
09a1d95b69 gitlab-ci: Add a clang build on tumbleweed
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
6b10bbea2f tests: Properly initilize library in threads tests
This was already done in the torture_threads_pki.

Without the explicit initialization, we can observe random
failures tests (at least of the torture_threads_crypto) from
various threads.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
b4c8bd9fe4 pki: Support RSA SHA2 signatures of sessionid for server
This involves mostly creation of host keys proofs but needs
to follow the same procedure as the client authentication
signatures.

At the same time, the SHA2 extension is enabled in the pkd
so we are able to atomicaly provide correct signatures and
pass tests.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
5d13006650 server: We should list SHA2 variants in offered hostkeys
The SHA2 variants should be preferred. Also the buffer needs to be
extended to fit all possible public key algorithms.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
6fa5e8adb0 server: Support for extension negotiation
This includes intercepting the  ext-info-c  string from
the client kex proposal, configuring the server to allow using
this extension and sending the SSH_MSG_EXT_INFO packet back
to the client after the new keys are in use.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
60ad7ee15d messages: Create correct digest for pki signatures
This does not affect old signatures, where the public key algorithm
matches the public key type.

This is a problem when using SHA2 extension for the RSA keys, where
the new signature algorithsm are introduced in addition to the
exitsing ssh-rsa which was ignored throughout the code.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
5fe81e89fb tests: Verify the public key algorithms can be limited by configuration option
SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES configuration option can limit
what keys can or can not be used for public key authentication.

This is useful for disabling obsolete algorithms while not completely
removing the support for them or allows to configure what public key
algorithms will be used with the SHA2 RSA extension.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
09cf301eee auth: Prevent authentication with non-allowed key algorithms
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
594c62d718 tests: PUBLICKEY_ACCEPTED_TYPES are effective
Verify the PUBLICKEY_ACCEPTED_TYPES option is handled correctly
and affects the signature algorithm selection based on the
extensions and can be used to limit list of offered mechanisms
to the server.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
4169be45eb pki: Allow filtering accepted public key types based on the configuration
This effectively allows to disable using the SHA2 extension, disable
other old public key mechanisms out of the box (hello DSA) or force
the new SHA2-based key algorithm types if needed.

This exposes the  default_methods  array from  kex.c.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
5d53f519bc tests: Cover PubkeyAcceptedTypes configuration option
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
37864b6575 config: Accept the PubkeyAcceptedTypes configuration option
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
4521ab73b6 options: The new option SSH_OPTIONS_PUBLICKEY_ACCEPTED_TYPES
This option allows to specify acceptable public key algorithms
and reflects the PubkeyAcceptedTypes configuration option from
OpenSSH.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
9ca6127b91 kex: The public key algorithms are no longer only host keys
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
ebb01549d0 SHA2 extension in the ssh-agent interface
The new constants for flags are defined in draft-miller-ssh-agent-02
are active if the SHA2 extension is negotiated with the server.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
945469c9e0 tests: SHA2 extension signatures
This introduces a new test case for RSA unit tests, verifying that
libraries are able to provide and verify the RSA signatures with
SHA2 hash algorithms.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
82da0c3361 auth: Support SHA2 extension for pubkey authentication (RFC 8332)
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
1f08aabe43 pki: RSA signatures with SHA2 hash algorithms (RFC 8332)
* This change introduces a new API to request signature using
   one key and different hash algorithms. This is used only with
   RSA keys, that used to have SHA1 hardcoded, but the new
   algorithsms allow to use the SHA2 hashes, if the extension
   is negotiated.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
3ca7e1eea9 kex: Offer SHA2 extension signature algorithms by default
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
fa60827840 pki: Support RSA verification using different hash algorithms
This changes the private API by adding one more argument to function

  pki_signature_from_blob()

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
761225712a client: Handle the MSG_EXT_INFO packet signalling supported extensions
RFC 8308: The extension negotiation in Secure Shell (SSH) Protocol

RFC 8332: Use of RSA Keys with SHA-256 and SHA-512
          in the Secure Shell (SSH) Protocol

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
df13d8c61f kex: Signalize support for the extension negotiation in client (RFC 8308)
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
cbccae795d pkd: Produce more useful logs
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Jakub Jelen
100c9c98ce pkd: Generate host keys in old format
This is required to work against OpenSSH 7.8, which is now
writing keys in new openssh format by default

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Andreas Schneider
d7a64b9519 tests: Ignore SIGPIPE in pkd
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Andreas Schneider
fc212d73ed cmake: Use -fstack-protector-strong if possible
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 14:18:34 +02:00
Andreas Schneider
2b05e46b62 examples: Reformat ssh_client
The example should be clean code if possible.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 10:21:06 +02:00
Andreas Schneider
8d8b64cc3f doc: Update that_style
We don't need the source css files.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-31 08:04:24 +02:00
Andreas Schneider
11d87238b8 poll: Fix size types in ssh_event_free()
src/poll.c:1024:9: error: assuming signed overflow does not occur when
    simplifying conditional to constant [-Werror=strict-overflow]

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-30 08:52:42 +02:00
Andreas Schneider
8243030c55 poll: Reformat ssh_event_free()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-30 08:51:33 +02:00
Andreas Schneider
111d06eac5 cmake: Set version to 0.8.90
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-30 08:21:25 +02:00
Andreas Schneider
20ca6e09dd cmake: VERSION_GREATER_EQUAL is not suppored by cmake 3.3
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-30 07:34:16 +02:00
Andreas Schneider
66a0f14a0c cmake: Only support building docs the on cmake >= 3.9
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 21:51:42 +02:00
Andreas Schneider
aba6e34b63 cmake: Fix SSP compiler flag check
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 21:21:17 +02:00
Andreas Schneider
4fcc0bd407 Bump library version to 4.6.0
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 19:04:44 +02:00
Andreas Schneider
7960b8ed1b cmake: Fix final map generation
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 19:04:44 +02:00
Anderson Toshiyuki Sasaki
2aeee5194c cmake: Fix target to make sure copy runs in the end
The target created to copy the file must be the one make dist is
depending on.  Otherwise it will not copy the generated files to the
desired path.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 19:04:44 +02:00
Anderson Toshiyuki Sasaki
ca925588b0 cmake: Fix extract_symbols COPY_TO
Moved the symbols list formatting to the ExtractSymbols.cmake.  The
resulting list of symbols is sorted and printed in a more readable way
(one symbol per line).  Fixed the script to copy the generated symbols.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 19:04:44 +02:00
Andreas Schneider
5b07c1aa2c examples: Use ssh_print_hash()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 19:04:44 +02:00
Jan-Niklas Burfeind
9510a538c2 tests: Add torture_hashes for pubkey hashes
Signed-off-by: Jan-Niklas Burfeind <libssh@aiyionpri.me>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 19:04:44 +02:00
Jan-Niklas Burfeind
f32cb70675 dh: Add ssh_print_hash() function which can deal with sha256
Signed-off-by: Jan-Niklas Burfeind <libssh@aiyionpri.me>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 19:04:44 +02:00
Jan-Niklas Burfeind
1499b38aef dh: Add SSH_PUBLICKEY_HASH_SHA256 to ssh_get_publickey_hash()
Signed-off-by: Jan-Niklas Burfeind <libssh@aiyionpri.me>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 19:04:44 +02:00
Andreas Schneider
509331ec81 sftp: Use strndup()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 19:04:44 +02:00
Andreas Schneider
247983e982 misc: Add strndup implementation if not provides by the OS
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 19:04:44 +02:00
Andreas Schneider
f0e99961b6 cmake: Require at least abimap-0.3.1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 18:08:59 +02:00
Andreas Schneider
2291c75ab0 cmake: Detect abimap version
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 18:08:59 +02:00
Andreas Schneider
77b4801e11 cmake: Fix typo in doc file
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 18:08:59 +02:00
Andreas Schneider
a3c8dac6b6 tests: Fix size types in pkd
tests/pkd/pkd_hello.c:743:12: error: assuming signed overflow does not
    occur when simplifying conditional to constant [-Werror=strict-overflow]

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 11:07:08 +02:00
Andreas Schneider
5334cb9d55 doc: Update doxygen documentation
This fixes some issues with the new docs and uses a new modern style.

https://github.com/jl-wynen/that_style

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 11:05:47 +02:00
Andreas Schneider
9a73fa885a doc: Remove obsolete Doxyfile.in
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-29 11:05:47 +02:00
Alex Hermann
23f60a56f3 misc: Set default port to 22 in ssh_path_expand_escape()
Fixes, among others, ProxyCommand with %p when no port is used on
commandline or config file, thus using the default port.

Fixes T94

Signed-off-by: Alex Hermann <alex@hexla.nl>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-28 15:44:37 +02:00
Andreas Schneider
648f5cf400 cmake: Fix doxygen generation
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-27 16:46:01 +02:00
Anderson Toshiyuki Sasaki
f49bb1b6a3 cmake: Fix FindABIMap targets
Fix the targets and output files handling to make the symbols to be
updated correctly when a symbol is added or removed.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-27 14:42:56 +02:00
Jakub Jelen
f0a4c1e888 doc: There is no hostbased authentication implemented
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-27 11:29:20 +02:00
Andreas Schneider
a0fec81221 auth: Reset errors on successful authentication
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-27 11:29:20 +02:00
Andreas Schneider
0aad4de5f4 error: Add ssh_reset_error() function
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-27 11:29:18 +02:00
Andreas Schneider
280519af29 auth: Also log the current auth method
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-27 11:25:29 +02:00
Andreas Schneider
0ae376f133 auth: Fix the pending_call_state of ssh_userauth_password()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-27 11:25:08 +02:00
Andreas Schneider
73c9d60e5a session: Group auth variables in a struct
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-27 09:30:24 +02:00
Jakub Jelen
ae3825dfb2 sftp: Avoid race condition reading incomplete data messages
This changes amends f561e6bcb3 which
introduces same check in one place, but miss it in other two places.

We encountered this issue with qemu using SFTP to transfer large
data chunks and in some cases, the file transfer was interrupted
without any reason. From the debug messages, it showed up that
last part of data message/packet was not handled in the time
of the sftp_read() call, therefore the ssh_channel_read() returned
zero (there was no more data to read yet), which made the whole
transfer fail hard instead of retrying later.

The proposed change is reusing the code from previously referenced
commit also in the other places.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-27 09:29:24 +02:00
Andreas Schneider
8f1e995cec auth: Fix possible NULL pointer dereference
explicit_bzero() doesn't handle NULL.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-27 09:29:24 +02:00
Andreas Schneider
4de8ed684b cmake: Check if the linker supports version scripts
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-27 09:29:24 +02:00
Anderson Toshiyuki Sasaki
d0f3cdfa10 docs: Update threading documentation
Updated threading documentation mentioning changes in the requirements
to use libssh in multithread scenarios.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-24 14:58:52 +02:00
Andreas Schneider
a97e227a9d cmake: Improve compiler flag detection
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-24 07:51:00 +02:00
Andreas Schneider
119a457357 options: Fix size types
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-24 07:31:39 +02:00
Andreas Schneider
4ae7e35d9c cmake: Allow zero for variadic macro argument
This is also needed for clang.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-23 22:33:29 +02:00
Andreas Schneider
47bf099c36 cmake: Add header to AddCCompilerFlag.cmake 2018-08-23 22:33:29 +02:00
Andreas Schneider
9a43298b3a options: Fix integer types
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-23 22:33:29 +02:00
Andreas Schneider
3f17154367 options: Reformat ssh_options_getopt()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-23 22:33:29 +02:00
Andreas Schneider
f8435e261c cmake: Disable include_guard as oss-fuzz's cmake version is too old
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 12:12:06 +02:00
Andreas Schneider
6162b63d5e gitlab-ci: Add target to build the docs
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 09:08:39 +02:00
Andreas Schneider
19e081aedb cmake: Remove obsolete UseDoxygen.cmake
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 09:08:39 +02:00
Andreas Schneider
a154bd9f22 cmake: Use FindDoxygen package provided by cmake
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 09:08:39 +02:00
Andreas Schneider
e618298bda doc: Update Doxyfile.in
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 09:08:39 +02:00
Andreas Schneider
7e1b67754c knownhosts: Add knownhosts to libssh_session group
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 09:08:39 +02:00
Andreas Schneider
868623f9a8 libssh: Document ssh_known_hosts_e
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 09:08:39 +02:00
Andreas Schneider
49f92cf5cd libsshpp: Match documentation with the code
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 09:08:39 +02:00
Andreas Schneider
c2fc9ac956 channels: Fix timeout variable to match documentation
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 09:08:39 +02:00
Andreas Schneider
15473426c8 tests: Temporarily increase log verbosity for torture_forward
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 08:55:21 +02:00
Andreas Schneider
9820a35a9e cmake: Remove obsolete DefineCompilerFlags.cmake
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 08:54:59 +02:00
Andreas Schneider
5e9435924c cmake: Set -D_FORTIFY_SOURCE=2 if possible
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 08:54:59 +02:00
Andreas Schneider
64a354159f gssapi: Fix size types
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 08:54:59 +02:00
Andreas Schneider
0a46690eca options: Fix size types
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 08:51:00 +02:00
Andreas Schneider
26263aabd4 kex: Fix size types
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 08:51:00 +02:00
Andreas Schneider
6867a35004 tests: Check return code of setuid()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-22 08:35:19 +02:00
Andreas Schneider
7946104566 known_hosts: Update documentation of deprecated knwon_hosts functions
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-21 11:39:50 +02:00
Andreas Schneider
140ddf5109 gitlab-ci: Add two builds with optimizations turned on
This enables the optimizer and will give use additional compiler
warnings and errors.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
887908107a gitlab-ci: Enable PICKY_DEVELOPER
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
8855a140cf cmake: Add support for picky developer flags
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
a9a99fb31f cmake: Improve compiler flag detection
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
26a4097742 cmake: Check for -Werror in ConfigureChecks.cmake
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
99a9cf0fcb cmake: Respect CMAKE_REQUIRED_* variables in CHECK_C_COMPILER_FLAG_SSP
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
fd157befae tests: Make sure pointer are initialized in torture_pki_ed25519
Fixes compiler warnings.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
6f6840a88a tests: Make sure pointer are initialized in torture_pki_ecdsa
Fixes compiler warnings.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
562e579675 tests: Make sure pointer are initialized in torture_pki_dsa
Fixes compiler warnings.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
1e89896d05 tests: Make sure pointer are initialized in torture_pki_rsa
Fixes compiler warnings.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
3b896750b8 tests: Use ZERO_STRUCT for readfds
This fixes a compiler warning on FreeBSD.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
f433949dcd tests: Fix function declaration in pkd_hello
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
8e418ea020 tests: Fix function declaration in torture_packet
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
6766b0a860 log: Make sure the buffer for date is big enough
src/log.c:71:32: error: '%06ld' directive output may be truncated
writing between 6 and 20 bytes into a region of size between 0 and 63
[-Werror=format-truncation=]
         snprintf(buf, len, "%s.%06ld", tbuf, (long)tv.tv_usec);

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
ce45de9ea2 agent: Fix type of the buffer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
85d2c0371a mbedtls: Use getter for ssh_mbedtls_ctr_drbg
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
1d9f548204 examples: Fix function declaration in sshnetcat
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Andreas Schneider
dad456a1ee include: Fix shadow variables in libsshpp
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-20 18:42:03 +02:00
Jakub Jelen
a0214dfc9a sftp: Fix the debug message in sftp_enqueue()
This fixes the assignment of variables to comments and makes
the output symmetric with sftp_dequeue().

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-18 10:00:37 +02:00
Jakub Jelen
c004b43fde tests: Unsupported and unknown configuration options do not crash
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2018-08-16 17:51:05 +02:00
Jakub Jelen
6848c23d84 config: Do not access negative indexes of seen array
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2018-08-16 17:51:05 +02:00
Andreas Schneider
4104d2fb91 cmake: Correctly detect support for __bounded__ attribute
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-16 17:45:56 +02:00
Andreas Schneider
86d00f438c init: Fix DllMain
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-16 09:19:58 +02:00
Andreas Schneider
f65882cca6 cmake: Fix optional ABIMap detection
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
2018-08-14 15:54:55 +02:00
Andreas Schneider
a3475c2e4b cmake: Bump library version for release 2018-08-13 22:18:41 +02:00
Andreas Schneider
4d87256ca7 init: Add a library constructor and destructor for VC
If we compile with Visual Studio, we need a DllMain() for running init
and finialize which is the same as a constructor and destructor.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 21:48:48 +02:00
Andreas Schneider
6aa9392699 cmake: Only set -Werror on UNIX
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 21:48:48 +02:00
Andreas Schneider
0656f8a43d cmake: Improve NSIS detection on Windows
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 21:48:48 +02:00
Anderson Toshiyuki Sasaki
66a3bc0332 init: ignore init counter if destructor calls finalize
If the destructor calls finalize, ignore the init counter and finalize
the library anyway.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 15:27:36 +02:00
Andreas Schneider
dbce0e5228 cmake: Fix PACKAGE and VERSION in config.h
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 13:44:58 +02:00
Andreas Schneider
8ef35a005c cmake: Fix pkg-config file
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 13:44:58 +02:00
Andreas Schneider
8425dce7b2 cmake: Remove obsolete libssh_threads.pc.cmake
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 13:44:58 +02:00
Anderson Toshiyuki Sasaki
0be1ae0e3b threads: use static error check mutex initializer if available
This changes the condition to use the static error check mutex
initializer.  If it is not available, use the default static mutex
initializer.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 12:00:13 +02:00
Andreas Schneider
83898f3f6c cmake: Only install static lib if built WITH_STATIC_LIB
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 10:27:17 +02:00
Andreas Schneider
a33e71ae88 include: Bump libssh version
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 09:22:39 +02:00
Andreas Schneider
f2b6899298 init: Only use constructor attribute if available
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 09:21:39 +02:00
Andreas Schneider
4c058aefd9 cmake: Detect constructor and destructor attributes
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 09:21:17 +02:00
Andreas Schneider
8c2ad7bdd3 cmake: Fix fallthrough attribute detection
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 09:15:35 +02:00
Andreas Schneider
e04a8b3abd cmake: Fix check for bounded attribute
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 09:14:15 +02:00
Andreas Schneider
15ab612592 cmake: Set the PACKAGE_VERSION correctly
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-13 08:47:39 +02:00
Andreas Schneider
4f0f1a9160 cpack: Fix ignore files
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-10 14:18:18 +02:00
Andreas Schneider
d66ea0b3b1 Update ChangeLog entries for 0.8.0
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-10 12:20:57 +02:00
Andreas Schneider
1d93b94086 cmake: Remove DESCRIPTION from project
This is only available with cmake >= 3.9.0. It should fix oss-fuzz.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-10 12:20:57 +02:00
Anderson Toshiyuki Sasaki
efc427fdce cmake: Introduce symbol versioning
This adds a cmake module, FindABIMap, which looks for abimap and
provides functions to generate a symbol version linker script.

The module can be included using find_package(ABIMap).

This also adds the option to compile with symbol versioning.  The symbol
list is obtained from the header files by filtering those marked with
the LIBSSH_API modifier.

Such symbols are used as input to generate the version script used by
the linker.  The version script is automatically updated as new symbols
marked with LIBSSH_API are added to the header files.

If any symbol is removed, the build will fail due to break in the ABI.

Symbol versioning is enabled by default if abimap has been found. It is
disabled in non-UNIX platforms. It can be disabled by passing
"-DWITH_SYMBOL_VERSIONING=OFF" option to cmake.

Pair-Programmed-With: Andreas Schneider <asn@cryptomilk.org>

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-08 20:58:23 +02:00
Andreas Schneider
0f64bc78a8 ABI: Add map file for library version 4.5.0
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-08 20:58:23 +02:00
Andreas Schneider
2dbb7ff091 cmake: Update cmake and cpack config
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-08 20:58:23 +02:00
Andreas Schneider
b77fa93551 gitlab-ci: Point openSUSE to its krb5-config
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-08 20:58:23 +02:00
Andreas Schneider
8ce4004260 tests: Free memory of tmp_file in torture_knownhosts_parsing
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-08 15:04:59 +02:00
Andreas Schneider
8c11367410 tests: Fix memory leak in torture_knownhosts_read_file()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-08 15:04:59 +02:00
Andreas Schneider
460026459b tests: Do not leak memory when freeing ed25519 keys
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-08 15:04:59 +02:00
Andreas Schneider
6c87316a9c session: Fix memory leak of global_knownhosts
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-08 15:04:59 +02:00
Andreas Schneider
96476f74af kownhosts: Fix a memory leak in ssh_session_has_known_hosts_entry()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-08 15:04:59 +02:00
Andreas Schneider
52b57077de knownhosts: Fix a memory leak in ssh_session_get_known_hosts_entry()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-08 15:04:59 +02:00
Andreas Schneider
2839d48cb8 tests: Fix a typo in torture.c
Thanks Nikos for spotting it.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-07 15:41:45 +02:00
Marcin Szalowicz
5ea81166bf include: Fix segfault in getIssueBanner, add missing wrappers in libsshpp
Also make some private properties protected

Signed-off-by: Marcin Szalowicz <marcin.szalowicz@oracle.com>
2018-08-07 14:31:55 +02:00
Andreas Schneider
a86d1d335b torture: Increase wait time for sshd startup
It is much slower when started with valgrind.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 15:23:43 +02:00
Anderson Toshiyuki Sasaki
18dd902307 gssapi: set error state when GSSAPI auth fails
When errors occurred, the session auth state was not being updated,
leading to failures due to the wrong state in following authentication
methods.

Fixes T56

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 10:48:16 +02:00
Anderson Toshiyuki Sasaki
d85827f646 auth: Some code style fixes
Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 10:26:19 +02:00
Anderson Toshiyuki Sasaki
6e74c6c1dc auth: Improve pending call error messages
This can help when debugging in the future

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 10:26:00 +02:00
Andreas Schneider
ec6df9896a tests: Add missing check for valid fd
CID 1032753

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 09:52:14 +02:00
Andreas Schneider
ab7c5c448c tests: Add additional NULL checks
CID 1393894

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 09:43:51 +02:00
Andreas Schneider
5871d604cd tests: Use fstat instead of lstat
CID 1393878

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 09:38:59 +02:00
Andreas Schneider
f6fe7488e3 tests: Add some null checks
CID 1393898

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 09:36:50 +02:00
Andreas Schneider
24aef4fbf1 sftp: Add missing size checks
CID 1238630

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 09:36:50 +02:00
Andreas Schneider
fbfe002460 tests: Check for memory allocation error in torture_pki_ed25519_sign()
CID 1393899

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 09:36:47 +02:00
Andreas Schneider
c7525c056c tests: Improve torture_connect_socket()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 08:58:27 +02:00
Andreas Schneider
1509693cce tests: null terminate buffer in torture_read_one_line()
CID 1393902

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 08:52:42 +02:00
Andreas Schneider
67ef808a95 tests: Add additional NULL check in torture_pki_rsa_write_privkey()
CID 1393904
CID 1393903

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 08:50:11 +02:00
Andreas Schneider
aeefcd8199 tests: Initialize readfds in torture_channel_select()
CID 1393905

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 08:46:37 +02:00
Andreas Schneider
9bc050d07d tests: Check return code of ssh_pki_import_privkey_base64
CID 1393906

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 08:44:28 +02:00
Andreas Schneider
c2776f70c1 tests: Improve test checks
CID 1394620

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-06 08:32:07 +02:00
Andreas Schneider
e6020f94bf server: Fix echo access in ssh_message_auth_interactive_request()
Fixes T94

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-03 19:08:57 +02:00
Anderson Toshiyuki Sasaki
9305762fcd Remove internal calls to ssh_init
Since the call is made automatically when the library is loaded, these
calls are no longer required (if the library is not linked statically).

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-03 16:43:03 +02:00
Anderson Toshiyuki Sasaki
e0e0d62a71 tests: Run thread tests on Windows
When pthreads is available, run the threads tests on Windows

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-03 16:43:03 +02:00
Anderson Toshiyuki Sasaki
708f127788 tests: Add test for RSA PKI running on threads
Run the tests from torture_pki_rsa.c on threads.  Tests requiring files
to be removed are not tested, since they would require the access to
the files to be synchronized.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-03 16:43:03 +02:00
Anderson Toshiyuki Sasaki
dd3d867452 tests: Add test for crypto running on threads
The test run crypto test on multiple threads.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-03 16:43:03 +02:00
Anderson Toshiyuki Sasaki
5443863723 tests: Add test for buffer running on threads
The test run buffer tests on multiple threads.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-03 16:43:03 +02:00
Anderson Toshiyuki Sasaki
edcdef94ee tests: Add test for init running on threads
The test runs ssh_init()/ssh_finalize() on multiple threads.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-03 16:43:03 +02:00
Anderson Toshiyuki Sasaki
04cc7b769a threads: Add Windows threads implementation
Added Windows threads implementation based on CriticalSection.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-03 16:43:03 +02:00
Anderson Toshiyuki Sasaki
83b43443e5 threads: Automatically call ssh_init on load
This makes unnecessary to call ssh_init() when the library is
dynamically loaded.  Also removes the threads shared library.  The used
threads implementation is chosen in configuration time, changing the
ssh_threads_get_default() depending on the available threads library.

Internally, it is expected a threads implementation providing:

- void ssh_mutex_lock(void **mutex);
- void ssh_mutex_unlock(void **mutex);
- struct ssh_threads_callbacks_struct *ssh_threads_get_default(void);

and a crypto implementation providing:

- int crypto_thread_init(struct ssh_threads_callbacks_struct *user_callbacks);
- void crypto_thread_finalize(void);

This adds internal threads implementation for pthreads and noop.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-03 16:43:03 +02:00
Andreas Schneider
6a077fe750 gitlab-ci: Build with cmake3 on CentOS7
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-03 16:43:03 +02:00
Andreas Schneider
b2a681bd29 cmake: Require at least cmake 3.1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-03 16:43:03 +02:00
Jakub Jelen
18077673ac pki: Log really the signature algorithm type
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-01 16:05:37 +02:00
Jakub Jelen
25407209b0 pkd: Add missing ECDH mechanisms + whitespace cleanup
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-01 16:05:12 +02:00
Jakub Jelen
0e886ba803 pkd: Support ed25519 host keys in server
This adds support for the ed25519 keys in the pkd framework and adds
openssh-only tests utilizing these host keys (dropbear does not support
them yet).

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-01 16:04:40 +02:00
Jakub Jelen
c8429113fa bind: Complete loading ed25519 in server
Previously, the support was only partial and if the ed25519 key was
the only one, the internal checks were failing the tests.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-01 16:03:48 +02:00
Jakub Jelen
e1d2454dd7 session: Do not search for RSA1 keys in ~/.ssh/identity
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-01 16:03:41 +02:00
Jakub Jelen
ed738bee34 test: Fix text labels (copy & paste error)
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-01 16:03:17 +02:00
Pino Toscano
12284b75fa buffer: Add and use ssh_buffer_allocate_size()
Add a small helper for ssh_buffer to ensure that the buffer has a
certain amount of space already preallocated. This can be useful in case
it is known how much data is going to be added to a buffer, to avoid
multiple reallocations.

Make use of it in few places in the library.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-08-01 11:04:33 +02:00
Andreas Schneider
afa4021ded tests: Add umask() around mkstemp()
CID 1391450

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-07 11:38:59 +02:00
Andreas Schneider
c425082394 tests: Fix errno check in pkd
CID 1393877

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-07 11:35:00 +02:00
Aris Adamantiadis
db9da99a36 bignum: Make bignum_free safer
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-05 14:35:13 +02:00
Andreas Schneider
c3dac948c9 pki: Improve pubkey buffer handling form file
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-05 13:21:23 +02:00
Andreas Schneider
c866768da4 torture_pki_dsa: Improve torture_pki_dsa_publickey_base64
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-05 13:15:14 +02:00
Aris Adamantiadis
2b40ad29c0 crypto: Split init and finalize functions
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-05 12:55:23 +02:00
Andreas Schneider
38c53db953 libcrypto: Use new RAND_priv_bytes() for strong randomness
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-05 12:12:17 +02:00
Andreas Schneider
c503bb572e crytpo: Make sure we check return of ssh_get_random() correctly
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-05 12:12:14 +02:00
Aris Adamantiadis
36a727e656 bignum: Harmonize ssh_get_random()
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-05 12:09:52 +02:00
Andreas Schneider
7b9a07c363 cmake: Print if server testing is enabled
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-04 20:33:31 +02:00
Jakub Jelen
4b298ca770 kex: Check allocation result
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-04 08:24:54 +02:00
Jakub Jelen
8e211c0689 tests: Verify various host keys can be successfully negotiated and verified
This verifies that all the supported host keys can be used and
verified by the client, including the SHA2 extension in RFC 8332.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-04 07:52:50 +02:00
Jakub Jelen
d25b8fb550 packet: Avoid warnings by using correct template
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-04 07:48:32 +02:00
Jakub Jelen
f1b36c18f6 client: Properly reset session structures on disconnect
torture_connect_double  test case used to test the connect only up
to key exchange phase, but not after the new keys are stated to be
used for communication. The keys from previous connectoin were not
cleaned up from the previous invocation as well as the seqence
number was not reset and therefore any further packet was failing
with length-check errors or MAC errors.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-04 07:47:54 +02:00
Andreas Schneider
b3a7e86a4a knownhosts: Fix memory leak
CID 1393774

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-04 07:09:24 +02:00
Andreas Schneider
d316390825 gitlab-ci: Only enable freebsd runner where it is enabled
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-03 15:08:40 +02:00
Andreas Schneider
3141dec632 known_hosts: Remove deprecated ssh_knownhosts_algorithms()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-03 15:08:40 +02:00
Andreas Schneider
539d7ba249 kex: Use ssh_known_hosts_get_algorithms()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-03 15:08:40 +02:00
Andreas Schneider
83a46c7756 tests: Add knownhosts test for detecting conflics
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-03 15:08:40 +02:00
Andreas Schneider
2d90bc9d6b knownhosts: Fix checking if server is known
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-03 15:08:40 +02:00
Andreas Schneider
de44fdfd35 tests: Add knownhosts test for SSH_KNOWN_HOSTS_UNKNOWN
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-03 15:08:40 +02:00
Andreas Schneider
65a5154eff tests: Add knownhosts test for SSH_KNOWN_HOSTS_OTHER
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-03 15:08:40 +02:00
Andreas Schneider
613dcc95e6 knownhosts: Fix return codes
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-03 15:08:40 +02:00
Andreas Schneider
77e1761734 tests: Add client test for ssh_known_hosts_get_algorithms()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-03 15:08:40 +02:00
Andreas Schneider
e49e4e13f3 knownhosts: Implement ssh_known_hosts_get_algorithms()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-03 15:08:38 +02:00
Andreas Schneider
e73ae60e1a tests: Use assert_ssh_return_code() in client tests
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-03 07:45:51 +02:00
Andreas Schneider
584c345451 gitlab-ci: Fix mips compilation on debian
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-02 09:53:02 +02:00
Andreas Schneider
bfbd574098 gitlab-ci: Add missing debian variable
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-02 09:06:42 +02:00
Andreas Schneider
b4462bdea0 tests: Use assert_ssh_return_code() in torture_algorithms
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-07-02 08:03:20 +02:00
Andreas Schneider
6b8d1aa836 gitlab-ci: Fix path to toolchain file
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 15:41:50 +02:00
Andreas Schneider
d90b88588f gitlab-ci: Add 32bit build on openSUSE
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 15:39:27 +02:00
Andreas Schneider
6a715b80d6 cmake: Unset CMAKE_REQUIRED_* variables
This should fix the 'gcc -m32' build!

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 15:27:09 +02:00
Andreas Schneider
084769b88c libcrypto: Fix size printing
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 15:27:09 +02:00
Andreas Schneider
f4408f38a3 torture: Give sshd at least 100ms to start.
This should avoid some 'No route to host' errors.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 15:27:09 +02:00
Andreas Schneider
6dd9303729 chachapoly: Use a function instead of an extern variable
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 14:37:04 +02:00
Andreas Schneider
a19513b87a example: Add missing error checks in ssh_server_fork
CID 1393676

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 14:37:04 +02:00
Andreas Schneider
21962dd154 known_hosts: Simplify invalid tokens check
CID 1393677

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 14:37:04 +02:00
Andreas Schneider
8917b84840 examples: Make gobal variables static in scp_download
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 14:37:04 +02:00
Andreas Schneider
4b0fd10a99 examples: Define LIMIT as unsinged long
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 14:37:04 +02:00
Andreas Schneider
3350fd7479 chachapoly: Make global variables static
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 14:37:04 +02:00
Andreas Schneider
c98b00a5f4 log: Make global variables static
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 14:37:04 +02:00
Andreas Schneider
88673b2d1f channels: Fix NULL check in channel_rcv_data callback
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 14:37:04 +02:00
Andreas Schneider
f425ebb098 tests: Use new assert ssh return code macros in torture_connect
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 14:37:04 +02:00
Andreas Schneider
f6284eafd6 torture: Add assert macros for ssh return codes
This allows us to print errors from ssh sessions.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 14:37:04 +02:00
Andreas Schneider
cf250171de include: Add arpa/inet.h for htonl
This should fix a build warning on FreeBSD.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 14:37:04 +02:00
Andreas Schneider
a82e24f024 config: Initialize glob_t with C99 initializer
Should fix a build warning on FreeBSD.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-30 14:37:04 +02:00
Andreas Schneider
60450ef936 gitlab-ci: Fix stage 2018-06-29 17:26:34 +02:00
Andreas Schneider
d11d764c9d gitlab-ci: Fix path for artifacts
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 16:55:40 +02:00
Nikos Mavrogiannopoulos
ac5c90d771 gitlab-ci: Add build for mips platform
This tests multiple items, (1) cross compilation, (2) compilation
on debian and (3) CI run on MIPS systems, tested under qemu. This target
was originally written for GnuTLS by Michael Weiser.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2018-06-29 16:53:33 +02:00
Andreas Schneider
14045f516e doc: Document server testing
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 16:22:59 +02:00
Tilo Eckert
3e70f06fc8 doc: add documentation about building with client tests
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 15:59:08 +02:00
Tilo Eckert
a2a6dddacf tests: adjust test for kex string "curve25519"
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 15:57:57 +02:00
Tilo Eckert
a366bb3b45 tests: add pkd tests for kex curve25519
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 15:57:51 +02:00
Tilo Eckert
a4a6017e6e tests: add algorithm tests for kex curve25519
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 15:57:45 +02:00
Tilo Eckert
e60cb2ee10 kex: add curve25519-sha256 as alias for curve25519-sha256@libssh.org
see: https://tools.ietf.org/id/draft-ietf-curdle-ssh-curves-07.html

Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 15:57:11 +02:00
Aris Adamantiadis
da0f360478 kex: log negotiated methods
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 15:55:37 +02:00
Andreas Schneider
206f3ff895 Rest in Peace SSHv1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
2018-06-29 14:41:14 +02:00
Andreas Schneider
81b4320318 gitlab: Fix build on FreeBSD
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 11:45:14 +02:00
Andreas Schneider
bed60f9b84 kex: Enable chacha20-poly1304 KEX with mbedtls
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 11:41:22 +02:00
Andreas Schneider
10728f8577 cmake: Disable torture_packet on Windows
The test uses socketpair().

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 10:57:36 +02:00
Andreas Schneider
72141cae0b gitlab: Disable client testing on freebsd
The host doesn't have cwrap installed.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 10:54:35 +02:00
Andreas Schneider
ec842c3ca3 gitlab: Remove the debian aarch64 build
This doesn't work anymore

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 10:52:46 +02:00
Andreas Schneider
054d2dffc1 gitlab: Add SERVER_TESTING and updates for cmake
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 10:49:52 +02:00
Andreas Schneider
d971983d5e cmake: Add SERVER_TESTING option
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 10:49:14 +02:00
Andreas Schneider
946f8f64ef cmake: Rename WITH_CLIENT_TESTING option to CLIENT_TESTING
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 10:32:07 +02:00
Andreas Schneider
84ac7d1de0 cmake: Rename WITH_TESTING option to UNIT_TESTING
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 10:31:53 +02:00
Andreas Schneider
f4ddf9df53 tests: Fix key parsing in torture_pki_dsa_publickey_base64
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 10:05:06 +02:00
Andreas Schneider
d7477dc745 tests: Remove system includes from torture_packet
This fixes the build on Windows. Those come in via the include of
socket.c anyway.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 09:35:54 +02:00
Andreas Schneider
1444ae5add pki: Fix random memory corruption
Fixes T78

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 09:30:59 +02:00
Andreas Schneider
aa95eb1965 tests: Move CHACHA20 define out of HAVE_DSA ifdef
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-29 09:08:07 +02:00
Andreas Schneider
649a7490a6 gitlab: Do not build with SSHv1 support
This will be removed soon.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 18:00:47 +02:00
Jon Simons
c089b700c6 chacha: fix build for mbedTLS
Fix the build for mbedTLS:
 * set HAVE_CHACHA for non-mbedTLS builds
 * only compile chachapoly.c when HAVE_CHACHA
 * use empty CHACHA20 in src/kex.c unless HAVE_CHACHA

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Jon Simons
c8d6445d44 packet_crypt: remove set_decrypt_key upon ssh_packet_decrypt_len
In 06b9901e64, invocations of `set_decrypt_key`
and `set_encrypt_key` were moved into the `ssh_packet_newkeys` callback, away
from the packet decrypt and encrypt functions.

Remove the extra `set_decrypt_key` for the case that an `aead_decrypt_length`
is not NULL.  At this time, only the chacha20-poly1305@openssh.com cipher
is affected by this change.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Jon Simons
d4a4ce4d44 chacha: use a cipher cleanup callback
With this change there is less code specific to the
chacha20-poly1305 cipher found in src/wrapper.c.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Jon Simons
7a2624dee4 packet_crypt: fix unused variable compiler warning
The local `rc` variable here is never set.  Fix a warning that is
emitted due to `-Wunused-variable`.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Jon Simons
f827833d82 tests: fix torture_packet.c test_data
Make the `test_data` larger so that tests do not read beyond
its length.  Observed in testing with an `-fsanitize=address`
build locally.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Jon Simons
6f38e0b771 pkd: move chacha20-poly1305@openssh.com tests to OPENSSHONLY section
Dropbear does not currently implement the 'chacha20-poly1305@openssh.com'
cipher, so move it into the OPENSSHONLY suite.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Jon Simons
622ff855f5 pkd: add passes for chacha20-poly1305@openssh.com cipher
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Alberto Aguirre
26734a547a torture_packet: Set encryption/decryption keys
Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Alberto Aguirre
1ece5a849c packet_crypt: Avoid setting keys every time
Avoid setting keys on every packet decrypt or encrypt operation.

Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Aris Adamantiadis
23accdde1a tests: send more packets of various sizes
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Aris Adamantiadis
321ec2cb1c tests: packet encryption unit testing
That code is really ugly, but it wasn't meant to be modular at all in the
first place.

Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Aris Adamantiadis
27711f6a4c tests: test for chacha20-poly1305@openssh.com
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Aris Adamantiadis
238202d380 libgcrypt: make it compatible with chacha20
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Aris Adamantiadis
8a735d5eb7 chacha: packet decryption
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Aris Adamantiadis
d038c4dee7 chacha: packet encryption
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Aris Adamantiadis
ebd76bf347 cmake: detect "bounded" compiler attribute
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Aris Adamantiadis
acc1ade74a external: Add ChaCha and Poly1305 implementations from OpenSSH
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Andreas Schneider
72e4500da9 gitlab: Disable SSHv1 support
This will be removed soon.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:06:30 +02:00
Andreas Schneider
c4f3bf4ffa torture: Remove unused variable
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 09:05:58 +02:00
Andreas Schneider
c563ed636a Remove vim modelines from all files
If you want modelines use my vim plugin:
https://github.com/cryptomilk/git-modeline.vim

git config --add vim.modeline "ts=4 sw=4 et"

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 08:41:08 +02:00
Andreas Schneider
f3de2974a9 tests: Disable ssh_is_ipaddr("255.255.255") on Win32
Till we get the issue fixed in Wine.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 08:36:54 +02:00
Andreas Schneider
1b8ce5a6ed tests: Workaround for a Wine bug
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-28 08:27:08 +02:00
Jon Simons
deb7630c67 pkd: log but ignore ungraceful client disconnects
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 21:38:35 -07:00
Jon Simons
cbd9569b99 pkd: move hmac-sha2-256 to OpenSSH-only lists
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 19:52:32 -07:00
Jon Simons
a45a04ff4d pkd: omit -v for dbclient by default
The `-v` is only recognized by `dbclient` when dropbear is built
in its DEBUG_TRACE mode.  Omit that flag by default to avoid a
warning log emitted to stderr.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 19:42:57 -07:00
Jon Simons
7aa496d844 pkd: remove blowfish-cbc cipher passes
Support for the `blowfish-cbc` cipher has been removed from OpenSSH
as of version 7.6.  Remove this cipher from the pkd tests so that
the tests will pass together with a modern OpenSSH client.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 19:42:51 -07:00
Jon Simons
bf10a66b5d pkd: emit error message for OpenSSH clients < 7.0
Emit a friendly error message for OpenSSH clients older than
7.0.  Some of the recent pkd changes now require a modern
client to support some newer config options.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 19:42:43 -07:00
Jon Simons
adc817cf13 pkd: specify PubkeyAcceptedTypes for OpenSSH client
As of OpenSSH 6.9, support for `ssh-dss` user keys is disabled by default
at runtime.  Specify an explicit `-o PubkeyAcceptedKeyTYpes` in the pkd
tests to explicitly enable each user key type being tested, including
`ssh-dss`.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 19:42:37 -07:00
Jon Simons
787a649390 pkd: specify HostKeyAlgorithms for OpenSSH client
As of OpenSSH 6.9, support for `ssh-dss` host keys is disabled by default
at runtime.  Specify an explicit `-o HostKeyAlgorithms` in the pkd tests
to explicitly enable each host key type being tested, including `ssh-dss`.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 19:42:33 -07:00
Jon Simons
54690e6cdd pkd: run with SOCKET_WRAPPER_LIBRARY
Use the socket_wrapper preload shim when running the `pkd_hello`
test with `make test`.  The end goal here is to get this test
running alongside normal tests in regular CI.  Changes to do
this:

 * Configure PKD_ENVIRONMENT for the `pkd_hello_i1` test in the
   CMakeLists.txt file.

 * Add a `--socket-wrapper-dir|-w` flag that is used to opt-in to
   initializing a SOCKET_WRAPPER_DIR as expected by the socket_wrapper
   library.

   A runtime flag is used here to make it easy to run `pkd_hello`
   with the socket_wrapper library while avoiding a hard dependency.

Testing done: observed socker_wrapper in effect with `strace`;
running `make test` uses the wrapper correctly on my local
machine.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 19:41:10 -07:00
Jon Simons
4e3fb81172 pkd: add_test pkd_hello_i1 for make test
Add an entry for a `pkd_hello_i1` test which runs one iteration
through each of the pkd algorithm combinations.

Testing done: now `make test` will run `pkd_hello -i1` which
completes in ~25 seconds on my local machine.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 19:41:02 -07:00
Jon Simons
6273c409e3 pkd: fix missing config.h #include
Ensure to include config.h so that the `HAVE_DSA` value is properly set
when building the pkd tests.

Introduced with 778652460f,

Testing done: with this change, the `pkd_hello` test is passing on an
OpenSSL 1.1.0 build for me.  Previously it would fail pubkey exchange
early on for DSA- and ECDSA-type host keys.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 21:25:36 +02:00
Jon Simons
7798d39187 dh: fix two leaks in ssh_get_pubkey_hash
Fix two memory leaks in `ssh_get_pubkey_hash` for some error paths.
The local `h` buffer and `ctx` MD5 context each must be free'd for
the SSH_ERROR cases.

Introduced with 16217454d5.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 21:25:34 +02:00
Jon Simons
58ef1e96b8 dh: fix ssh_get_pubkey_hash indentation
Fix `ssh_get_pubkey_hash` indentation to use softabs
with 4 spaces.  No change in behavior.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 21:25:32 +02:00
Jon Simons
732818ebb2 tests: fix -Wunused-function warning in torture_pki_ecdsa.c
Wrap some function definitions with `HAVE_LIBCRYPTO` ifdefs to
match their usages in `torture_run_tests`.

Fixes this warning I observe when building locally:

    torture_pki_ecdsa.c:341:13: warning:
         ‘torture_pki_ecdsa_write_privkey’ defined but not used
         [-Wunused-function]

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 21:25:30 +02:00
Jon Simons
448de134ac ecdh: fix SSH_MSG_KEXDH_REPLY for mbedTLS
Ensure to provide the `ssh_string` pubkey blob to the buffer packing
routine when computing the SSH_MSG_KEXDH_REPLY message, rather than
the new `ssh_key` type.

Introduced with 16217454d5.

Testing done: with this change, the `pkd_hello` test is passing on a
mbedTLS build for me.  Previously it would segfault during pubkey
exchange with "ecdh-sha2-nistp256".

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 21:25:28 +02:00
Jon Simons
fd3d8d6496 ecdh: fix SSH_MSG_KEXDH_REPLY for libgcrypt
Ensure to provide the `ssh_string` pubkey blob to the buffer packing
routine when computing the SSH_MSG_KEXDH_REPLY message, rather than
the new `ssh_key` type.

Introduced with 16217454d5.

Testing done: with this change, the `pkd_hello` test is passing on a
libgcrypt build for me.  Previously it would segfault during pubkey
exchange with "ecdh-sha2-nistp256".

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 21:25:26 +02:00
Jon Simons
0b90ab102e ecdh: fix SSH_MSG_KEXDH_REPLY for libcrypto
Ensure to provide the `ssh_string` pubkey blob to the buffer packing
routine when computing the SSH_MSG_KEXDH_REPLY message, rather than
the new `ssh_key` type.

Introduced with 16217454d5.

Testing done: with this change, `pkd_hello` test is passing on an
OpenSSL 1.1.0 build for me.  Previously it would segfault during
pubkey exchange with "ecdh-sha2-nistp256".

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 21:25:24 +02:00
Anderson Toshiyuki Sasaki
cd3170fcb1 gitlab: Use wine to run tests built for Windows
When building in a cross-compiling environment, use wine to run the
tests.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 21:23:12 +02:00
Anderson Toshiyuki Sasaki
9eaf55898e cmake: Added executable exension on test binaries
This is necessary when building the tests for Windows.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 21:20:26 +02:00
Andreas Schneider
10e1e396fc gitlab: Add build with mbedtls
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 12:01:54 +02:00
Andreas Schneider
c1db283c39 gitlab: Enable build with libgcrypt
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 12:01:51 +02:00
Andreas Schneider
6c97122120 torture: Don't exclude filter mechanism on Windows
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 10:51:45 +02:00
Andreas Schneider
0dd33d8ed1 torture: Don't include sys/socket.h on Windows
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 10:44:31 +02:00
Andreas Schneider
0db12d7f75 gitlab: Don't error out if obj exists
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 10:16:45 +02:00
Anderson Toshiyuki Sasaki
c1d8ba47dd gitlab: Added builds for Windows using MinGW
Only the unit tests are run.

Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 09:45:35 +02:00
Andreas Schneider
dc4cc08c3a gitlab: Use obj dir for building
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 09:45:35 +02:00
Andreas Schneider
e880cafed0 tests: Call ssh_session_is_known_server()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 09:45:35 +02:00
Andreas Schneider
1ae014f52a dh: Fix reference to ssh_session_update_known_hosts()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 09:45:35 +02:00
Andreas Schneider
1369559385 include: Fix reference to ssh_session_update_known_hosts
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 09:45:35 +02:00
Andreas Schneider
7ef72ec91f doc: Updated guided tour for knownhosts changes
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 09:45:35 +02:00
Andreas Schneider
b74a184172 torture: Fix building on Windows
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-27 09:45:35 +02:00
Alberto Aguirre
b50fb638f7 knownhosts: Fix windows build failure
Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-25 08:20:40 +02:00
Andreas Schneider
e06ae8e096 include: Declare ge25519_base as extern
Thanks to Tilo Eckart.

The global variable "ge25519_base" is referenced in the module
"src/external/ed25519.c" and initialized in "src/external/ge25519.c".
The lack of the extern keyword in the header results in different
instances being compiled into both translation units with some
compilers.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-21 17:41:32 +02:00
Andreas Schneider
0940b0f29b knownhosts: Do not double free memory
CID 1393236

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-06 08:38:14 +02:00
Andreas Schneider
03b05c8a5e tests: Add missing newline to KNOWN_HOST_ENTRY_ED25519
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-05 14:42:21 +02:00
Andreas Schneider
9e4f9a26d4 tests: Allow knownhosts verify test to validate ed25519 and ecdsa
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-05 10:50:59 +02:00
Andreas Schneider
f5f8c0fc76 knownhosts: Fix resource leak in ssh_known_hosts_parse_line()
CID 1391444

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-05 10:44:54 +02:00
Andreas Schneider
c4dbe3b863 knownhosts: Fix a memory leak on error
CID 1391446

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-05 10:43:08 +02:00
Andreas Schneider
669678119c knownhosts: Fix possible null pointer dereference
CID 1391447

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-05 10:35:42 +02:00
Andreas Schneider
34e7a3cf8c knownhosts: Fix resource leak in ssh_session_update_known_hosts()
CID 1391448

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-05 10:34:56 +02:00
Andreas Schneider
1001cbbb99 knownhosts: Fix resource leak in ssh_known_hosts_read_entries()
CID 1391449

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-05 10:34:49 +02:00
Aris Adamantiadis
36d52ee205 buffer: Add ssh_buffer_allocate() function
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 16:55:23 +02:00
Aris Adamantiadis
0ad462102a packet: Add more debugging
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 16:55:21 +02:00
Aris Adamantiadis
c6ee41bff3 cmake: add WITH_PACKET_DEBUG option
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 16:55:18 +02:00
Andreas Schneider
5012a9c146 examples: Use new known hosts functions
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
93781f9d5a libsshpp: Use new known hosts functions
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
4550c99222 known_hosts: Mark ssh_is_server_known as deprecated
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
a209f928d2 kwonhosts: Add functions to check if servers public key is known
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
f23dbe6f42 knownhosts: Add ssh_session_update_known_hosts()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
974e1831a0 knownhosts: Add ssh_session_export_known_hosts_entry()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
963c46e4fb knownhosts: Add ssh_session_has_known_hosts_entry()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
32c49ea134 misc: Add ssh_list_count()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
a465ea2d49 knownhosts: Add ssh_known_hosts_read_entries()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
702e9e8ad5 knownhosts: Introduce new known hosts managing functions
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
250bf37a28 tortrue: Add ed25519 hostkey to sshd
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:20:28 +02:00
Andreas Schneider
952c64b4c0 threads: Fix compiler warning
Use a protype for libcrypto_lock_callback().

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:18:12 +02:00
Andreas Schneider
bcaeaf17af tests: Fix size for bob_ssh_cert
Fixes a gcc8 warning.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-06-04 11:12:36 +02:00
Jim McDonough
f4e57a6e22 Add builds for opensuse tumbleweed
Signed-off-by: Jim McDonough <jmcdonough@suse.com>
2018-05-30 14:33:47 +02:00
Andreas Schneider
8457580f61 wrapper: Fix memory leak when freeing server_pubkey
Thanks to John McVann.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-05-14 08:17:08 +02:00
Andreas Schneider
f1ff9ae00c torture: Increase wait time for process termination to 10ms
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-05-07 21:01:05 +02:00
Andreas Schneider
ed4ea51bb8 connector: Add missing check for POLLHUP to detect EOF
Thanks to Chris Townsend.

Fixes T81

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-05-07 20:36:56 +02:00
Andreas Schneider
22a92da30d auth: Handle SSH_AUTH_PARTIAL in agent auth correctly
Thanks to Orion Poplawski.

Fixes T82

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-05-07 20:32:13 +02:00
Andreas Schneider
362b20a0bc server: Fix segfault in dh_handshake_server()
Thanks to Felix Jones

Fixes T91

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-05-07 20:09:56 +02:00
Andreas Schneider
72f6b34dbc tests: We should only init and finalize libssh once
This should fix a segfault with gcrypt.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-05-07 08:33:32 +02:00
Andreas Schneider
816234350d pki: Fix duplicating ed25519 public keys
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-25 16:25:32 +02:00
Andreas Schneider
4aeb0cfd9c server: Fix session pubkey import
This is a regression introduced by 16217454d5

We import the pubkey into current_crypto which is NULL instead of
next_crypto.

Fixes T90

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-20 13:47:46 +02:00
Nikos Mavrogiannopoulos
be414423d7 Introduce a gitlab CI for centos7, debian and Fedora
This introduces builds for:
  centos7 with openssl 1.0.x (x86-64)
  fedora28 with openssl 1.1.x (x86-64)
  fedora28 with libgcrypt (x86-64) - disabled
  debian with openssl 1.0.x (aarch64)
  address-sanitizer (gcc) - disabled
  undefined-sanitizer (gcc)
  static-analyzer (clang)

See https://gitlab.com/libssh/libssh-mirror/

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-18 10:57:32 +02:00
Nikos Mavrogiannopoulos
abd1a1f372 README: Added markdown readmine with gitlab CI badge
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-18 10:51:43 +02:00
Andreas Schneider
c705fb6e3b kex1: Add missing NULL check in make_rsa1_string()
CID 1388445

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-18 10:33:55 +02:00
Andreas Schneider
1a36aa21ba packet_cb: Fix the if check in ssh_packet_newkeys()
CID 1388446

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-18 10:32:35 +02:00
Andreas Schneider
c2f8010b60 known_hosts: Do not leak pubkey_buffer in check_public_key()
CID: 1388447

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-18 10:29:21 +02:00
Andreas Schneider
64985f7bea server: Do not leak pubkey_blob in ssh_get_key_params()
CID 1388448

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-18 10:27:01 +02:00
Nikos Mavrogiannopoulos
3f562ee586 buffer: Do not call explicit_bzero with null arguments
This allows compiling and testing with undefined sanitizer.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-18 10:24:47 +02:00
Nikos Mavrogiannopoulos
eb796b4bbb buffer: Do not call memcpy with null arguments
This allows compiling and testing with undefined sanitizer.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-18 10:24:42 +02:00
Andreas Schneider
87b8d232bd buffer: Apply coding style to ssh_buffer_reinit()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-18 10:22:03 +02:00
Andreas Schneider
6f1f8d2bdb buffer: Apply coding style to realloc_buffer()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-18 10:22:03 +02:00
Nikos Mavrogiannopoulos
a95bc8a016 kex1: Use libcrypto-compat.h for RSA_get0_key with OpenSSL
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-17 18:00:52 +02:00
Nikos Mavrogiannopoulos
f3a19d8c96 torture_path_expand_tilde_unix: use getpwuid() if no env variables
This allows operating under environments where the username variables
are not present.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-17 17:59:14 +02:00
Meng Tan
e005fd310f Fix ssh_event_add_session() when session socket has two pollhandlers
Signed-off-by: Meng Tan <mtan@wallix.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-10 11:20:52 +02:00
Axel Eppe
fb2fefb3c6 channels: add ssh_channel_request_send_break to support RFC 4335
Signed-off-by: Axel Eppe <aeppe@google.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-10 11:16:23 +02:00
Andreas Schneider
6026fc8036 cmake: Fix libfuzzer linking with clang6
This is always available using -fsanitize=fuzzer now.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-04-10 11:13:57 +02:00
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
467d78a442 tests: Fix mixed code compiler warning in torture_rand
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-03-21 20:41:16 +01:00
Andreas Schneider
a4aeee972c torture: Increase wait time for the sshd process to exit
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-03-21 20:40: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
dd20253fec tests: fix OSX build errors when enabling tests
Fix OSX build error about embedding a directive within macro arguments.
Apparently, snprintf is implemented as a macro on that platform.

Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-03-11 22:54:47 +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
bba40abc76 priv: Fix explicit_bzero macro if we pass a function
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-02-22 16:28:24 +01:00
Alberto Aguirre
0c12643466 sftp: Remove stray semi-colon in sftp.h header
The stray semi-colon in sftp.h is flagged when using -pedantic
which affects clients that include the header and use -pedantic
and -Werror on their codebase.

Signed-off-by: Alberto Aguirre <albaguirre@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-02-22 16:28:24 +01:00
Andreas Schneider
1319d2ceb2 cmake: Mark LIBSSH_LIBRARIES and LIBSSH_INCLUDE_DIR as advanced
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-02-16 16:52:02 +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
jvijtiuk
963111b836 tests: Fix segfault with mbedTLS built without threading support
torture_rand and torture_server_x11 call ssh_init without checking
the return value. If mbedTLS is built without threading support
ssh_init fails but the tests continue and then segfault since threading
wasn't correctly initialised.

Add a section that documents requirements for mbedTLS usage in a
multi threaded environment to README.mbedtls.

Signed-off-by: Juraj Vijtiuk <juraj.vijtiuk@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2018-02-12 20:05:49 +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
Andreas Schneider
25ff1214a4 cmake: Build ssh_server_fuzzer if enabled
Fixes T67

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-02-04 11:52:45 +01:00
Alex Gaynor
d84b0926f0 tests: Added a fuzzer for the server
Fixes T67

Signed-off-by: Alex Gaynor <alex.gaynor@gmail.com>
2018-02-04 11:51:58 +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
459677e20e libssh: Bump the version to 0.7.90
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-29 20:43:35 +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
e9073a6bdb torture_pki_ed25519: Add tests for private key with passphrase
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:31:02 +01:00
Andreas Schneider
9086d5ca33 torture_pki_ecdsa: Add tests for private key with passphrase
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:31:02 +01:00
Andreas Schneider
3c65057fad torture_key: Add ecdsa keys with passphrase
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:31:02 +01:00
Andreas Schneider
f9b1dece41 torture_pki_dsa: Add tests for private key with passphrase
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:31:02 +01:00
Andreas Schneider
f7a2330de7 torture_pki_rsa: Add tests for private key with passphrase
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:31:02 +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
b0af812710 tests: Move torture keys to own file
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:31:02 +01:00
Andreas Schneider
d13a17a27c cmake: Move ed25519 tests into unix part
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:31:02 +01:00
Andreas Schneider
ddfc36aa56 tests: Move rsa tests to own test file
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:31:02 +01:00
Andreas Schneider
a5997d180d tests: Remove obsolete setup_both_keys()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:31:02 +01:00
Andreas Schneider
51875db70c tests: Move ed25519 functions to the right file
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:31:02 +01:00
Andreas Schneider
5ad7da7fd2 tests: Move ecdsa tests to own test file
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:27:52 +01:00
Andreas Schneider
59308bc269 tests: Move dsa tests to own test file
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:27:52 +01:00
Andreas Schneider
fd2ef07f37 tests: Move helper functions to a common file
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:24:11 +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
37acd3eca8 torture: Give sshd more time to start up
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10 22:24:11 +01:00
Andreas Schneider
cc13e85202 tests: Fix torture_pki with libcrypto
This stops asking for a passphrase on commandline.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-04 15:35:37 +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 93c7b81b4e,
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
Eric Bentley
5fdfa8fe44 docs: correction for importing key file
Signed-off-by: ebentley66@gmail.com
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-21 12:31:11 +01:00
Jakub Jelen
176b92a4f4 tests/client/algorithms: Respect global verbosity settings
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-21 11:43:19 +01:00
Jakub Jelen
afc6a4e973 tests/config: Verify LogLevel from config is applied
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-21 11:43:19 +01:00
Jakub Jelen
53d84abb17 tests/config: Newly parsed options
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-21 11:43:19 +01:00
Jakub Jelen
dab8985c05 tests/config: Enable and disable authentication methods
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-21 11:43:19 +01:00
Jakub Jelen
0bd6ccc066 tests/config: Verify known_hosts files are applied
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-21 11:43:19 +01:00
Jakub Jelen
5c7b8802f2 tests: HostkeyAlgorithms passed from config to options
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-21 11:43:19 +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
f3754dc072 tests/config: Text KexAlgorithms parsing in ssh_config
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
78a3ab2eaa tests/options: Verify key exchange algorithms are set properly
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
Jakub Jelen
094aa5eb02 tests: Temporarily build chroot_wrapper 2017-12-15 12:00:49 +01:00
Jakub Jelen
5d3ab421e1 tests: Do not generate pcap file by default
pcap file is generated by the processes writing to the sockets,
which is not allowed for privilege-separated process in new
OpenSSH servers (confined by seccomp filter).

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
f8f7989c3d tests: Give server more time to start
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
b92c499626 tests: Do not test blowfish ciphers with OpenSSH 7.6 and newer 2017-12-15 11:59:19 +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
7a65f7f028 test: ssh_userauth_kbdint_setanswer() does not network interaction
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-11-09 15:35:22 +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
Andreas Schneider
01994ea302 examples: Build server examples on Linux too
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-11-08 16:28:35 +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
Andreas Schneider
2ec633f33d examples: Rename samplessh to ssh-client
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-11-07 15:28:52 +01:00
Jakub Jelen
748d749675 doc: Missing new Host Key algorithms
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-11-07 15:12:27 +01:00
Jakub Jelen
77f632a559 doc: Missing new MAC algorithms in documentation
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-11-07 15:12:27 +01:00
Jakub Jelen
54165a394a doc: Missing new ECDH algorithms in documentation
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-11-07 15:12:27 +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
7527876fad torture_algorithms: deduplicate kex method passes
Summary: Signed-off-by: Jon Simons <jon@jonsimons.org>

Test Plan:  * Re-ran the `torture_algorithms` test.

Reviewers: asn

Reviewed By: asn

Tags: #libssh

Differential Revision: https://bugs.libssh.org/D8
2017-10-29 15:56:08 +01:00
Jon Simons
9d79b7629c torture_algorithms: deduplicate kex method passes
Summary: Signed-off-by: Jon Simons <jon@jonsimons.org>

Test Plan:  * Re-ran the `torture_algorithms` test.

Reviewers: asn

Tags: #libssh

Differential Revision: https://bugs.libssh.org/D8
2017-10-29 15:50:09 +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
Andreas Schneider
d3834f69bc cmake: Fix parsing the gcrypt version
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-10-12 10:16:23 +02:00
Andreas Schneider
f7b8394127 cmake: Bump version numbers
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-09-12 07:40:45 +02:00
Andreas Schneider
72cf2e3ae2 README.Coding: Add section about pointers
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-09-11 17:14:21 +02:00
DavidWed
164cee66ee sftp-server: Fix LIBSSH_API
Fixes T44

Signed-off-by: DavidWedderwille <davidwe@posteo.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-09-11 16:34:11 +02:00
Jon Simons
9003f92e8f pkd_daemon.c: force close pkd_state.server_fd upon stop
There's a race window between the accept loop's call to
accept(2) and it checking `ctx.keep_going`.  Forcefully
close the server socket such that any raced `accept` ends
up failing.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-09-11 16:31:01 +02:00
Jon Simons
8d7563a9c3 pkd_daemon.c: split final close loop; wait for client to close
Sometimes, but not always, the pkd tests will fail because they
close the socket at hand a bit too early for the client.  The
client in turn may exit non-zero when that happens.

Split up the final close loop so that pkd waits to receive a
channel close from the client, and then socket close, before
finally returning.

With this change I observe that tests are now passing in
environments that would previously tickle the above race
and fail.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-09-11 16:30:54 +02:00
Jon Simons
4c4a03f056 pkd_hello.c: fix return code upon test failure
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-09-11 16:30:45 +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
2e70077bbc examples: Fix fallthrough compiler warnings
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
Andreas Schneider
a9846ccc0d cmake: Add check for fallthrough attribute
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
316ee071cf torture_options: test the setting of ciphers and MACs
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
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
Andreas Schneider
de35212789 priv: Add macro for MAX
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-08-24 17:27:34 +02:00
Nikos Mavrogiannopoulos
337306600b INSTALL: mention the way to test
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-08-24 15:58:33 +02:00
Nikos Mavrogiannopoulos
efb7635162 tests: added unit test on including config files
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-08-24 15:57:19 +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
Andreas Schneider
74d17a6531 arcconfig: Add missing comma 2017-08-21 09:12:36 +02:00
Andreas Schneider
b9b89ef7c6 arc: Make the history immutable
Under an immutable history the history will not be rewritten.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-08-18 08:00:42 +02:00
Jon Simons
a4dc74064c tests: plug leak in torture_bind_options_import_key
Summary:
Hello, this is a resend for a quick memory leak fix for one of the unit
tests, originally sent to the mailing list here:

 * https://www.libssh.org/archive/libssh/2017-07/0000017.html

Test Plan:
 * Before the fix and running the test with valgrind:

```
[simonsj@simonsj-lx5 : unittests] valgrind --leak-check=full ./torture_options >/dev/null
==93134== Memcheck, a memory error detector
==93134== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==93134== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==93134== Command: ./torture_options
==93134==
[  PASSED  ] 10 test(s).
[  PASSED  ] 1 test(s).
==93134==
==93134== HEAP SUMMARY:
==93134==     in use at exit: 80 bytes in 1 blocks
==93134==   total heap usage: 977 allocs, 976 frees, 75,029 bytes allocated
==93134==
==93134== 80 bytes in 1 blocks are definitely lost in loss record 1 of 1
==93134==    at 0x4C28C20: malloc (vg_replace_malloc.c:296)
==93134==    by 0x41BAB0: ssh_key_new (pki.c:107)
==93134==    by 0x40DF90: torture_bind_options_import_key (torture_options.c:222)
==93134==    by 0x4E3AA3A: cmocka_run_one_test_or_fixture (cmocka.c:2304)
==93134==    by 0x4E3ACEA: cmocka_run_one_tests (cmocka.c:2412)
==93134==    by 0x4E3B036: _cmocka_run_group_tests (cmocka.c:2517)
==93134==    by 0x40E9E3: torture_run_tests (torture_options.c:276)
==93134==    by 0x40DE68: main (torture.c:1100)
==93134==
==93134== LEAK SUMMARY:
==93134==    definitely lost: 80 bytes in 1 blocks
==93134==    indirectly lost: 0 bytes in 0 blocks
==93134==      possibly lost: 0 bytes in 0 blocks
==93134==    still reachable: 0 bytes in 0 blocks
==93134==         suppressed: 0 bytes in 0 blocks
==93134==
==93134== For counts of detected and suppressed errors, rerun with: -v
==93134== ERROR SUMMARY: 1 errors from 1 contexts (suppressed: 0 from 0)
```

 * And after:

```
[simonsj@simonsj-lx5 : unittests] valgrind --leak-check=full ./torture_options >/dev/null
==93294== Memcheck, a memory error detector
==93294== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==93294== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==93294== Command: ./torture_options
==93294==
[  PASSED  ] 10 test(s).
[  PASSED  ] 1 test(s).
==93294==
==93294== HEAP SUMMARY:
==93294==     in use at exit: 0 bytes in 0 blocks
==93294==   total heap usage: 977 allocs, 977 frees, 75,029 bytes allocated
==93294==
==93294== All heap blocks were freed -- no leaks are possible
==93294==
==93294== For counts of detected and suppressed errors, rerun with: -v
==93294== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
```

Reviewers: asn

Reviewed By: asn

Differential Revision: https://bugs.libssh.org/D3
2017-08-17 09:33:13 +02:00
Jon Simons
fa86229673 pkd: a few improvements and fixups
Summary:
Hello, resending this patch series for the `pkd` tests, originally
sent to the mailing list here:

 *  https://www.libssh.org/archive/libssh/2017-07/0000011.html

Here are a few improvements and fixups for the `pkd` tests, including
a new flag `-m` that can be used to run only certain subsets of the
test passes.

Jon Simons (5):
  pkd: rename AES192 cipher suite -> OPENSSHONLY
  pkd_daemon.c: mark `pkd_ready` field as volatile
  pkd: fixups for updated CMocka CMUnitTest struct
  pkd: refactor -t testname lookup-by-name
  pkd: support -m to match multiple tests

 tests/pkd/pkd_daemon.c |  2 +-
 tests/pkd/pkd_daemon.h |  1 +
 tests/pkd/pkd_hello.c  | 84 +++++++++++++++++++++++++++++++++-----------------
 3 files changed, 58 insertions(+), 29 deletions(-)

--

Test Plan:
 * I've been using the new `-m` mode locally for a long time to run
   only certain groups of tests.

 * The CMocka struct fixes can be seen in the pkd output before and
   after: after, there are no more extraneous test output strings.

 * The fix for the `pkd_ready` field can be observed when building
   the libssh tests with `-Os` on a Debian system (before the fix,
   pkd would hang, after the fix, it runs as intended).

Reviewers: asn

Reviewed By: asn

Tags: #libssh

Differential Revision: https://bugs.libssh.org/D2
2017-08-17 09:24:19 +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:
 * e66f370682

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
48e7b098f8.

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 48e7b098f8:
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
Andreas Schneider
d9ff44b46e tests: Fix endif
Ups.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-14 08:53:15 +02:00
Andreas Schneider
c480ac8522 tests: Only run ssh_bind test if we build with server support
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-14 08:52:08 +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
14d8e940e6 tests: torture-misc: add torture_ssh_analyze_banner
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-13 19:32:58 +02:00
Jon Simons
effd7ba13c tests: torture-misc: fix 4-space indentation
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-13 19:32:35 +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 cf1e808e2f.

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
Andreas Schneider
87527adada Add config file for arcanist
This is for the commanline-client to access https://bugs.libssh.org

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-06-19 09:36:19 +02:00
Aris Adamantiadis
0cffb88b80 config: fix buffer underflow with unrecognized opcodes 2017-06-08 10:45:53 +02:00
Aris Adamantiadis
b0c2ca1b66 tests: fix buffer overflow in testcase 2017-06-07 18:49:56 +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
Andreas Schneider
e4f80bd142 doc: Fix documentation for ssh_userauth_none() usage
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-06-06 10:18:25 +02:00
Andreas Schneider
abbd6e304a messages: Make sure we always free the answers pointer
Found by ozz-fuzz

BUG: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1272

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-26 10:55:25 +02:00
Andreas Schneider
7c79b5c154 messages: Do not leak memory of previously allocated answers
Found by ozz-fuzz

BUG: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1222

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-25 16:20:06 +02:00
Andreas Schneider
5eb41492c4 messages: Do not leak memory if answeres had been allocated previously
Found by ozz-fuzz

BUG: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1222

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-24 13:27:20 +02:00
Andreas Schneider
c78c6c6542 messages: Do not leak memory if answered had been allocated previously
BUG: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1184

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-21 11:12:10 +02:00
Andreas Schneider
d5d8349224 misc: Validate integers converted from the SSH banner
BUG: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1181

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-21 11:02:29 +02:00
Andreas Schneider
67a2ba6f99 messages: Fix memory leaks in the ssh_packet_global_request callback
BUG: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=1208

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-21 10:56:13 +02:00
Andreas Schneider
79437fa0c9 auth: Use calloc in ssh_userauth_agent_pubkey()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-21 10:50:37 +02:00
Peter Volpe
76ba2b0055 session: Free session->kbdint in ssh_free()
Makes sure we free pending keyboard auth prompts
so prompts that have not be replied to do not leak.

Signed-off-by: Peter Volpe <pvolpe@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-20 17:04:21 +02:00
Andreas Schneider
68b7ca6e92 buffer: Validate the length before before memory allocation
Check if the size the other party sent is a valid size in the
transmitted buffer.

Thanks to Alex Gaynor for finding and reporting the issue.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-13 16:25:40 +02:00
Andreas Schneider
c165c396de buffer: Create ssh_buffer_validate_length()
This functions allows if a given length can be obtained from the buffer.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-13 16:25:29 +02:00
Andreas Schneider
f21ddefedb Revert "buffer: Create ssh_buffer_validate_length()"
This reverts commit 34bdc1ca78.
2017-04-13 16:19:28 +02:00
Andreas Schneider
0cf1c85542 Revert "buffer: Validate the length before before memory allocation"
This reverts commit 57550e6211.
2017-04-13 16:19:23 +02:00
Andreas Schneider
57550e6211 buffer: Validate the length before before memory allocation
Check if the size the other party sent is a valid size in the
transmitted buffer.

Thanks to Alex Gaynor for finding and reporting the issue.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-13 16:12:27 +02:00
Andreas Schneider
34bdc1ca78 buffer: Create ssh_buffer_validate_length()
This functions allows if a given length can be obtained from the buffer.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-13 16:12:27 +02:00
Alex Hermann
5f202d7ffa config: Only use first occurence of each parameter
ssh_config's manpage says:
"For each parameter, the first obtained value will be used."

Make libssh adhere to this rule.

BUG: https://red.libssh.org/issues/256

Signed-off-by: Alex Hermann <alex@hexla.nl>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-13 16:08:20 +02:00
Alex Hermann
c3a8b5009f config: Don't expand Host variable
Tokens are not allowed (according to the manpage).
Expansion was introduced by a wrong fix for #127.

This commit reverts part of 6eea08a9ef

Signed-off-by: Alex Hermann <alex@hexla.nl>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-13 15:58:52 +02:00
Alex Hermann
9ef7e90821 config: Support expansion in the HostName variable
BUG: https://red.libssh.org/issues/127

The original "fix" for 127 was expanding the wrong variable: Host instead
of HostName.

Signed-off-by: Alex Hermann <alex@hexla.nl>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-13 15:55:12 +02:00
Yanis Kurganov
38cb19268a session: Add SSH1 support in ssh_send_debug()
Signed-off-by: Yanis Kurganov <ykurganov@ptsecurity.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2017-04-11 17:40:38 +02:00
Yanis Kurganov
72fdb4867e session: Add SSH1 support in ssh_send_ignore()
Signed-off-by: Yanis Kurganov <ykurganov@ptsecurity.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2017-04-11 17:40:30 +02:00
Alfredo Mazzinghi
9dc650b7fb server: Add option SSH_BIND_OPTIONS_IMPORT_KEY to server
This sets the bind private key directly from an ssh_key struct instead
of reading a file.

Signed-off-by: Alfredo Mazzinghi <am2419@cl.cam.ac.uk>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-11 10:00:13 +02:00
Max Bachmann
3ec8babfaf messages: Utilize the message queue for SSH_REQUEST_GLOBAL.
Signed-off-by: Max Bachmann <mabahltm@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-11 09:55:22 +02:00
Andreas Schneider
462c7726c3 cmake: Fix GCRYPT_ROOT_DIR and check correct paths
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-11 09:42:53 +02:00
Andreas Schneider
e0fa48d2ed Update SubmittingPatches 2017-02-27 11:49:10 +01:00
Andreas Schneider
73e8277072 libcrypto-compat: Check if EVP_CIPHER_CTX_new is needed
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-02-23 16:59:28 +01:00
Andreas Schneider
c7e9dc2ee3 cmake: Check for EVP_CIPHER_CTX_new
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-02-23 16:54:26 +01:00
Andreas Schneider
166b9f7709 buffer: Use calloc to allocate a zero'ed buffer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-02-06 09:42:49 +01:00
Andreas Schneider
de369b46b1 pki: Use byte mode for fopen()
BUG: https://red.libssh.org/issues/251

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-02-03 13:18:16 +01:00
Justus Winter
043560d7dd pki_gcrypt: Fix freeing of ECDSA signatures.
* src/pki.c (ssh_signature_free): Fix test for ECC using gcrypt.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-09 18:20:40 +01:00
Justus Winter
4b33c6bb97 pki_gcrypt: Fix memory leak.
* src/pki_gcrypt.c (pki_key_ecdsa_to_nid): Release 'sexp'.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-09 18:20:19 +01:00
Andreas Schneider
2f6a866373 cmake: Only build libcrypto and libcrypto-compat when needed
This also fixes the gcrypt build.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-08 10:31:20 +01:00
Andreas Schneider
f8ef200e76 tests: Fix session management of torture_knownhosts
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-08 08:16:20 +01:00
Andreas Schneider
3daf1760a1 cmake: Use configure check for CRYPTO_ctr128_encrypt
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-07 11:46:47 +01:00
Andreas Schneider
2dff359a33 threads: Use new API call for OpenSSL CRYPTO THREADID
BUG: https://red.libssh.org/issues/222

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-07 11:46:47 +01:00
Jakub Jelen
3341f49a49 pki_crypto: Use getters and setters for opaque keys and signatures
This is for OpenSSL 1.1.0 support.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-07 11:46:47 +01:00
Jakub Jelen
5d2e9ee66e libcrypto: Use a pointer for EVP_CIPHER_CTX
This has been made opaque and it needs to be a pointer.

This is for OpenSSL 1.1.0 support.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-07 11:46:47 +01:00
Jakub Jelen
607c671f67 libcrypto: Use a pointer for EVP_MD_CTX
This is for OpenSSL 1.1.0 support.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-07 11:46:41 +01:00
Jakub Jelen
cf1e808e2f libcrypto: Use newer API for HMAC
This is for OpenSSL 1.1.0 support.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-07 11:45:07 +01:00
Jakub Jelen
b6cfde8987 libcrypto: Introduce a libcrypto compat file
This is for OpenSSL 1.1.0 support.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-07 11:42:06 +01:00
Jakub Jelen
d73f665edd libcrypto: Remove AES_ctr128_encrypt()
This is for OpenSSL 1.1.0.

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-07 11:42:06 +01:00
Andreas Schneider
52efbc3a23 misc: Use simpler macros for htonll and ntohll
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-07 09:39:19 +01:00
Andreas Schneider
639dc3b5fd tests: Fix typo in torture_crypto
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-07 07:50:24 +01:00
Andreas Schneider
cff7882391 log: Add missing config.h include
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-06 12:39:45 +01:00
Andreas Schneider
5d1a8cd88b cmake: Check for io.h on Windows
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-06 11:57:52 +01:00
Andreas Schneider
528b9c5323 cmake: Correctly check for sys/[u]time.h
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-06 11:52:12 +01:00
Andreas Schneider
fab85b495e cmake: Always check for strtoull
This fixes building with different compilers on Windows

BUG: https://red.libssh.org/issues/225

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-06 11:41:48 +01:00
Andreas Schneider
293ab4bd40 doc: Improve documentation for ssh_set_auth_methods()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-06 11:29:02 +01:00
Andreas Schneider
a45db022e9 bcrypt: Fix type of shalen
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-06 11:18:55 +01:00
Andreas Schneider
02be4802d5 pki_ed25519: Do paranoia checks before we allocate memory
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-06 11:15:23 +01:00
Andreas Schneider
5437deed1b callbacks: Add support for MSVC
__typeof__ is GCC specific

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-05 20:00:02 +01:00
Andreas Schneider
422271bd40 connector: Fix build with Visual Studio
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-05 18:03:34 +01:00
Andreas Schneider
801bc29494 options: Fix log level documentation
BUG: https://red.libssh.org/issues/210

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-05 17:15:31 +01:00
Stef Walter
857ce2376e known_hosts: Add ssh_dump_knownhost() function
This works similarly to ssh_write_knownhost(), but allows the caller
to get a line with the known_hosts line.

BUG: https://red.libssh.org/issues/207

Signed-off-by: Stef Walter <stefw@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-05 17:12:07 +01:00
Andreas Schneider
1bf6c965e4 cmake: Correctly check for *snprintf functions on Windows
BUG: https://red.libssh.org/issues/205

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-05 16:39:37 +01:00
Andreas Schneider
fa2332354b examples: Reformat usage() function
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-05 15:53:20 +01:00
Andreas Schneider
e9aebb1198 tests: Fix memory leak in torture_auth_cert
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-05 11:13:43 +01:00
Andreas Schneider
fbe8ccdf3b tests: Fix memory leak in torture_callbacks
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-04 08:33:33 +01:00
Andreas Schneider
34241cbb2b tests: Reset output buffer in torture_crypto
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-04 08:31:43 +01:00
Andreas Schneider
e9ba2da9e9 tests: Some cleanup for torture_pki
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-04 08:21:39 +01:00
Andreas Schneider
5b84772343 tests: Fix memory leak in torture_auth_cert
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-04 08:15:38 +01:00
Andreas Schneider
d8474207b6 tests: Fix memory leaks in torture_knownhosts
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-04 08:11:50 +01:00
Andreas Schneider
b78f2ed75d tests: Fix build warning with pkd_hello and cmocka 1.1.0
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-04 07:58:52 +01:00
Andreas Schneider
2af88a679d bignum: Use const in ssh_print_bignum()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-03 15:22:47 +01:00
Andreas Schneider
ad0ac12c40 tests: Disable x11 test which fails too often
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-03 15:22:00 +01:00
Justus Winter
e3a866b8c1 ecdh: Implement ECDH using libgcrypt
* include/libssh/crypto.h (struct ssh_crypto_struct): Provide a
suitable 'ecdh_privkey'.
* include/libssh/ecdh.h: Also define 'HAVE_ECDH' if we do ECC using
libgcrypt.
(ecdh_build_k): New prototype.
* src/CMakeLists.txt (libssh_SRCS): Add backend-specific files.
* src/ecdh.c: Move backend-specific parts to...
* src/ecdh_crypto.c: ... this file.
* src/ecdh_gcrypt.c: New file.
* src/wrapper.c (crypto_free): Free 'ecdh_privkey'.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-03 15:20:36 +01:00
Justus Winter
f62cded9f0 pki_gcrypt: Handle ECDSA keys and signatures
* ConfigureChecks.cmake: Set 'HAVE_ECC' and 'HAVE_GCRYPT_ECC' if
applicable.
* include/libssh/pki.h (struct ssh_key_struct): Fix type of field
'ecdsa'.
(struct ssh_signature_struct): Likewise for 'ecdsa_sig'.
* src/pki.c (ssh_pki_key_ecdsa_name): Relax guard now that the used
function is also provided by the gcrypt backend.
(ssh_signature_free): Free ecdsa signature.
* src/pki_gcrypt.c (ECDSA_HEADER_{BEGIN,END}): New macros.
(privatekey_string_to_buffer): Handle ECDSA keys.
(pki_key_ecdsa_to_nid): New function.
(pki_key_ecdsa_nid_to_gcrypt_name): Likewise.
(pki_key_ecdsa_nid_to_name): Likewise.
(pki_key_ecdsa_nid_to_char): Likewise.
(pki_key_ecdsa_nid_from_name): Implement.
(asn1_oi_to_nid): New function.
(b64decode_ecdsa_privatekey): Likewise.
(pki_private_key_from_base64): Handle ECDSA keys.
(pki_pubkey_build_ecdsa): Implement.
(pki_key_dup): Handle ECDSA keys.
(pki_key_generate): Likewise.
(pki_key_generate_ecdsa): Implement.
(pki_key_compare): Handle ECDSA keys.
(pki_publickey_to_blob): Likewise.
(pki_signature_from_blob): Likewise.
(pki_signature_verify): Likewise.
(pki_do_sign): Likewise.
(pki_do_sign_sessionid): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-03 15:20:30 +01:00
Justus Winter
7e315629b9 libgcrypt: Implement the 'evp' interface
* include/libssh/libgcrypt.h (EVPCTX): Fix type.
(NID_gcrypt_nistp{256,384,521}): New constants.
* src/libgcrypt.c (nid_to_md_algo): New function mapping curves to
digest algorithms.
(evp{,_init,_update,_final}): New functions.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-03 15:20:26 +01:00
Justus Winter
3c2ea78a09 pki_gcrypt: Add a little more ASN1 infrastructure
* src/pki_gcrypt.c (ASN1_OCTET_STRING): New macro.
(ASN1_OBJECT_IDENTIFIER): Likewise.
(asn1_check_tag): New function.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-03 15:19:34 +01:00
Justus Winter
85bcfab719 curve25519: Small libgcrypt bignum fix
* src/curve25519.c (ssh_client_curve25519_init): Make use of the
gcrypt-variant of 'bignum_bin2bn'.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-02 18:53:59 +01:00
Pino Toscano
67ffe26dea Remove extra newlines from log/error messages
Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-10-22 16:05:32 +02:00
Pino Toscano
bc78383fac sftp: Fix memory leak in sftp_fstat
When parsing the result of a successful fstat call, make sure to free
the resulting reply message.

Signed-off-by: Pino Toscano <ptoscano@redhat.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-10-22 16:03:33 +02:00
Andreas Schneider
1ec528b048 tests: Add test for sftp_fsync()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-10-08 13:38:56 +02:00
Andreas Schneider
2a9c396603 torture: Add support to specify verbosity level via env variable
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-10-08 13:38:18 +02:00
Tilo Eckert
4f392ebc7e session: Add missing ifdef that prevented Windows builds
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-10-08 10:54:36 +02:00
Tilo Eckert
1cc1a352fc sftp: Add support for append in sftp_open()
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
2016-10-08 10:50:38 +02:00
Tilo Eckert
cfe7065ce1 sftp: Do not always set SSH_FXF_READ
Comparison ((flags & O_RDONLY) == O_RDONLY) is always true.
Also, O_RDWR, O_WRONLY and O_RDONLY are mutually exclusive => no need to check all of them

Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
2016-10-08 10:45:30 +02:00
Andreas Schneider
f561e6bcb3 sftp: Correctly check for EOF else keep spinning if there is no data
This fixes an issue introduced with
dbf72ffba2

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-10-07 13:36:58 +02:00
Andreas Schneider
83421c0e8c gssapi: Use correct return code in ssh_gssapi_auth_mic()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-10-06 18:36:54 +02:00
Andreas Schneider
095733ed9c gssapi: Print minor stat in error logging function
This also releases the memory allocated for the messages.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-10-06 18:22:26 +02:00
Andreas Schneider
155a155d1d sftp: Add sftp_fsync() function
BUG: https://red.libssh.org/issues/141

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-10-06 16:26:52 +02:00
Jeremy Cross
dbf72ffba2 sftp: ensure sftp_packet_read recognizes channel EOF to avoid infinite loop
Signed-off-by: Jeremy Cross <jcross@bomgar.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-09-09 11:39:32 +02:00
Andreas Schneider
47d21b6420 sftpserver: Fix SSH_FXP_FSTAT arguments
Thanks to Игорь Коваленко <igor.a.kovalenko@gmail.com>

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-10 10:15:05 +02:00
Andreas Schneider
72eb4adbf0 tests: Try to fix the x11 test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-09 15:47:38 +02:00
Andreas Schneider
3f9ce10525 tests: Fix buffer test without NARG macro support
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-09 15:45:45 +02:00
Andreas Schneider
412c501442 sftp: Use calloc() instead of malloc()/memset()
This is calloc() is faster then calling memset().

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-04 14:56:22 +02:00
Andreas Schneider
5c70dd8b85 config: Fix build warnings
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-04 14:38:48 +02:00
Andreas Schneider
d5068ed07d examples: Fix endif()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-04 14:25:46 +02:00
Travers Carter
bc2db86d1c Make "Host" pattern list handling consistent with OpenSSH
https://red.libssh.org/issues/187

Signed-off-by: Travers Carter <tcarter@noggin.com.au>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 17:57:12 +02:00
Andreas Schneider
2fe9c2e352 tests: Improve the torture_request_env test
This still doesn't work on FreeBSD

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 12:52:07 +02:00
Andreas Schneider
d4e3401c23 examples: Fix building on FreeBSD
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 12:12:23 +02:00
Andreas Schneider
2bd6501552 torture: Fix a warning
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 10:35:11 +02:00
Andreas Schneider
4f7be0dbb2 priv: Fix client banner specification for libssh
BUG: https://red.libssh.org/issues/231

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 09:41:26 +02:00
Andreas Schneider
1da5c94b44 client: If SSHv1 is disabled send the banner immediately
This saves a round-trip with SSHv2 connecting to the server. See RFC
4253 section 5.2 (New Client, Old Server).

Thanks to Yang Yubo <yang@yangyubo.com> for the suggestion.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 09:41:26 +02:00
Andreas Schneider
3d1edffe77 client: Fix ssh_send_banner() to confirm with RFC 4253
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 09:41:26 +02:00
Andreas Schneider
cb52ed7b12 client: Fix maximum banner length
According to RFC 4253 the max banner length is 255.

Thanks to Saju Panikulam <spanikulam@ipswitch.com> for the report.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 09:41:26 +02:00
Andreas Schneider
22799b107d client: Reformat callback_receive_banner()
The function is hard to read as the indentation is not correctly
applied.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 09:41:26 +02:00
Ken Reister
c3ce3d5cc3 client: Receive the banner correctly
Comply with RFC 4253 compliance section 4.2.

Allow data other than "SSH-" to be sent across prior to the actual
version striong.

Signed-off-by: Ken Reister <reister.kenneth@CIMCOR.COM>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-03 09:41:26 +02:00
Aris Adamantiadis
32eea120af sockets: Fix callback registration bug
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 17:34:09 +02:00
Aris Adamantiadis
8e42d3959c packet: Improve logging output
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 17:27:16 +02:00
Aris Adamantiadis
f8be4d1b3b sample: Migrate client to connector API
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:59:18 +02:00
Aris Adamantiadis
9b3648ded0 connector: Implement ssh_connector_except()
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:58:47 +02:00
Aris Adamantiadis
0701745cbc channels: Move ssh_channel_write_stderr out of server-only
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:57:13 +02:00
Aris Adamantiadis
bbe437dbb1 callbacks: Implement list of callbacks for channels
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:56:54 +02:00
Aris Adamantiadis
5c67530f1e tests: Add test for ssh_callbacks_iterate()
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:56:50 +02:00
Aris Adamantiadis
e40e6e8686 callback: Add macro to iterate callbacks
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:56:31 +02:00
Aris Adamantiadis
6f3a7d36bb tests: Add unit test for ssh_callbacks_execute_list
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:56:25 +02:00
Aris Adamantiadis
5dddebd338 callbacks: Add macro for callbacks execute list
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:56:05 +02:00
Aris Adamantiadis
80d88dd3d9 packets: Handle flow control callbacks
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:55:46 +02:00
Andreas Schneider
0faffac020 examples: Do not usre deprecated functions
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:55:29 +02:00
Aris Adamantiadis
5aaae4cb6b events: Add functions for poll objects
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 16:40:43 +02:00
Kohei Suzuki
c092101e01 Add id_ed25519 to the default identity list
Signed-off-by: Kohei Suzuki <eagletmt@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 15:34:01 +02:00
David Kedves
d7df4429eb channels: Bugfix for a possible invalid pointer usage (channel->session) in various places
BUG: https://red.libssh.org/issues/230

Signed-off-by: David Kedves <kedazo@severalnines.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 15:31:46 +02:00
Stef Walter
ffe8b98cc2 auth: Cleanup memory leak when using SSH agent
In Cockpit we've seen this memory leak:

at 0x4C2A9C7: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x5B76B03: ssh_userauth_agent (auth.c:778)
by 0x40DD5A: cockpit_ssh_authenticate (cockpitsshtransport.c:327)

BUG: https://red.libssh.org/issues/208

Signed-off-by: Stef Walter <stefw@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 15:28:24 +02:00
Aris Adamantiadis
aa5c7c3b0c Doc: we don't support publickey v2 subsystem 2016-05-02 14:45:47 +02:00
Aris Adamantiadis
886fdc8bc2 osx: fix compilation 2016-05-02 13:33:34 +02:00
Andreas Schneider
33ecaaac01 auth1: Fix non-blocking SSHv1 auth
BUG: https://red.libssh.org/issues/232

Thanks to Fengyu Gao.

TODO: Add SSHv1 tests to our testsuite.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 12:19:00 +02:00
Justus Winter
3c69092cde pki_gcrypt: Add primitive to read ASN.1 bit strings
* src/pki_gcrypt.c (ASN1_BIT_STRING): New macro.
(asn1_get_bit_string): New function.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 12:07:07 +02:00
Andreas Schneider
e8b28f978e Update the README 2016-05-02 11:55:39 +02:00
Justus Winter
92fdf31d29 pki: Fix debug message
* src/pki.c (ssh_pki_signature_verify_blob): Fix debug message.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 11:55:39 +02:00
Justus Winter
878a650c7a dh: Print hexadecimal data to stderr
* src/dh.c (ssh_print_hexa): Print to stderr.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 11:55:38 +02:00
Justus Winter
e518ec1cb7 pki_gcrypt: Rework 'pki_export_pubkey_rsa1'
* src/pki_gcrypt.c (pki_export_pubkey_rsa1): Rework to be more
idiomatic.  Fix leaking MPIs.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 11:55:38 +02:00
Justus Winter
ed34425306 pki_gcrypt: Rework 'pki_publickey_to_blob'
* src/pki_gcrypt.c (pki_publickey_to_blob): Rework using the new
helper 'ssh_sexp_extract_mpi'.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 11:55:38 +02:00
Justus Winter
1d7f87fc0e pki_gcrypt: Rework 'pki_key_dup'
* src/pki_gcrypt.c (pki_key_dup): Rework to be more idiomatic.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 11:55:38 +02:00
Justus Winter
735e34f932 libgcrypt: Add helper to extract MPIs into ssh_strings
* include/libssh/libgcrypt.h (ssh_sexp_extract_mpi): New prototype.
* src/libgcrypt.c (ssh_sexp_extract_mpi): New function.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 11:55:38 +02:00
Justus Winter
fea9e3050c options: Check if a port has been given
* src/options.c (ssh_options_getopt): Only call 'ssh_options_set' if
a port has been given.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 11:55:38 +02:00
Andreas Schneider
bbd0522026 dh: Rename ssh_get_publickey() to ssh_get_server_publickey()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02 11:55:38 +02:00
Justus Winter
e37fd83254 tests: Make test suite work out of the box on Debian
* tests/torture.c (torture_setup_create_sshd_config): Rework how the
location of the sftp server is discovered, and add the Debian-specific
location.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-21 20:06:04 +01:00
Justus Winter
926b9e937b pki: Mention relevant RFC for EC key encoding
* src/pki.c (ssh_pki_export_pubkey_blob): Mention relevant RFC for EC
key encoding.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-21 18:39:46 +01:00
Justus Winter
fc9434465c pki_gcrypt: Fix memory leak
* src/pki_gcrypt.c (_bignum_cmp): Fix memory leak.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-21 18:39:39 +01:00
Justus Winter
ba3ee9f007 pki_gcrypt: Burn key material
* src/pki_gcrypt.c (b64decode_rsa_privatekey): Burn key material.
(b64decode_dsa_privatekey): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-21 18:39:31 +01:00
Justus Winter
38d8befcd0 pki_gcrypt: Generalize asn1_get_int
* src/pki_gcrypt.c (asn1_get): Generalize from 'asn1_get_int'.
(asn1_get_int): New function simply calling 'asn1_get'.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-21 18:39:23 +01:00
Justus Winter
e1d36314a2 pki_gcrypt: Fix memory leak
* src/pki_gcrypt.c (b64decode_rsa_privatekey): Free 'v' on version
mismatch.
(b64decode_dsa_privatekey): Likewise.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-21 18:39:13 +01:00
Justus Winter
9a54f91bb7 torture: Fix guard
* tests/unittests/torture_pki.c (setup_ecdsa_key*): Check for
'HAVE_ECC' instead of 'HAVE_OPENSSL_ECC'.

Signed-off-by: Justus Winter <justus@g10code.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-21 18:38:57 +01:00
Andreas Schneider
16d58e93af cmake: Fix torture build
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-17 10:45:40 +01:00
Andreas Schneider
2384236849 cmake: Try to fix FindArgp module
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-17 10:42:52 +01:00
Axel Eppe
252cd6eae9 torture_auth: Add tests for client side certificate authentication
- enabled TrustedUserCAKeys option in torture.c
 - adds a new set of (signed) keys for bob in a separate dir

 The private key used to generate the certs is included, but not required.

Signed-off-by: Axel Eppe <aeppe@google.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-15 08:38:13 +01:00
Axel Eppe
8fe8dbb378 agent: Add cert auth support to ssh_agent_get_next_ident()
Signed-off-by: Axel Eppe <aeppe@google.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-15 08:37:57 +01:00
Axel Eppe
8923a01264 auth: Add cert auth support to ssh_userauth_publickey()
Signed-off-by: Axel Eppe <aeppe@google.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-15 08:36:27 +01:00
Axel Eppe
6cbab4936d pki_gcrypt: Add cert auth support to pki_publickey_to_blob()
Signed-off-by: Axel Eppe <aeppe@google.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-15 08:36:09 +01:00
Axel Eppe
0310cba2b6 pki_crypto: Add cert auth support to pki_publickey_to_blob()
Signed-off-by: Axel Eppe <aeppe@google.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-15 08:35:47 +01:00
Aris Adamantiadis
0b9804a95b server: handle keepalive@openssh.com global requests 2016-03-14 22:28:03 +01:00
Aris Adamantiadis
7c2db045a8 cmake: detect MIT gssapi shim on osx 2016-03-14 22:27:38 +01:00
Aris Adamantiadis
5027627344 cmake: detect argp.h on osx 2016-03-14 22:27:06 +01:00
Andreas Schneider
4d43fbfb50 options: Document SSH_OPTIONS_ADD_IDENTITY
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-03 20:07:16 +01:00
Aris Adamantiadis
4e6ff36a9a dh: Fix CVE-2016-0739
Due to a byte/bit confusion, the DH secret was too short. This file was
completely reworked and will be commited in a future version.

Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-02-23 08:16:10 +01:00
Hani Benhabiles
f8bde7156f options: Fix documentation typo
Signed-off-by: Hani Benhabiles <hani@linux.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-02-23 08:14:29 +01:00
Younes Serraj
66c6ae1a55 pki: Fixed documentation about return value.
Documentation now is congruent with the code:
- SSH_OK is returned on success,
- SSH_ERROR is returned on error.

Signed-off-by: Younes Serraj <younes.serraj@gmail.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2016-02-23 08:12:34 +01:00
Andreas Schneider
1bc4176d65 torture: Use ECDSA key for x11 test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-02-08 18:46:22 +01:00
Andreas Schneider
de309c51a7 torture: Fix ssh version detection
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-02-08 18:38:24 +01:00
Andreas Schneider
f128ffd88b tests: Fix running ssh-agent
ssh-agent needs to be executed as the local user and not a fake user or
we will not be able to add identies.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-02-03 09:01:29 +01:00
Andreas Schneider
063430744d torture: Set sshd debug level to DEBUG3
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-02-03 09:01:27 +01:00
Andreas Schneider
cbd75c3e35 tests: Switch to user bob in setup
This makes sure we can apply options correctly.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-02-03 09:01:24 +01:00
Andreas Schneider
1729d4a168 tests: Always start tests as root so we can switch to a user
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-02-03 09:01:22 +01:00
Andreas Schneider
773771659e tests: Use different uids and gids for testing
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-02-03 09:01:17 +01:00
Andreas Schneider
c365ff3d05 torture: Also write stderr to a file
This allows to capture debug information of the wrappers.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-21 14:11:26 +01:00
Andreas Schneider
1bbfe058f9 torture: Add additional sftp-server path for BSD
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-21 12:21:58 +01:00
Andreas Schneider
02d9b05f54 torture: Give sshd more time to start
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-21 09:07:02 +01:00
Fabiano Fidêncio
5c5b1aaaa7 buffer: expose ssh_buffer_get()
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:08 +01:00
Fabiano Fidêncio
6953c8ec91 buffer: expose ssh_buffer_{add,get}_data()
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:08 +01:00
Fabiano Fidêncio
58aff4495e buffer: expose ssh_buffer_reinit()
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:08 +01:00
Fabiano Fidêncio
3e2a61cc47 libssh.h: move LIBSSH_API buffer' functions to libssh.h
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:08 +01:00
Fabiano Fidêncio
120d2b5333 buffer: remove ssh_buffer_get_begin()
Note that removing ssh_buffer_get_begin() doesn't break API
compatibility, as this functions has never been exposed (it only
has the LIBSSH_API prefix).

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:08 +01:00
Fabiano Fidêncio
d1d003c232 buffer: use ssh_buffer_get() instead of ssh_buffer_get_begin()
This commit is a preparatory stage for removing ssh_buffer_get_begin().
Note that removing ssh_buffer_get_begin() doesn't break API
compatibility, as this functions has never been exposed (it only has the
LIBSSH_API prefix).

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:08 +01:00
Fabiano Fidêncio
3cf72e5258 buffer: remove ssh_buffer_get_rest_len()
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:08 +01:00
Fabiano Fidêncio
05fd0acf45 buffer: do not use ssh_buffer_get_rest_len()
As ssh_buffer_get_len() actually calls ssh_buffer_get_rest_len(), let's
just use the first one. This is a preparatory step for removing
ssh_buffer_get_rest_len().

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:08 +01:00
Fabiano Fidêncio
25707e9752 pki_gcrypt: adapt to the new behavior of ssh_buffer_get_len()
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:08 +01:00
Fabiano Fidêncio
9774b1062d buffer: make ssh_buffer_get_len() call ssh_buffer_get_rest_len()
This is a preparatory step for having the behavior of
ssh_buffer_get_rest_len() in the ssh_buffer_get_len() and then remove
the ssh_buffer_rest_len()

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
954341dd1f buffer: rename ssh_buffer_get_rest() to ssh_buffer_get()
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
56d0e91e10 buffer: cosmetic change in ssh_buffer_get_u8() documentation
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
d7349d04d0 buffer: fix documentation for ssh_buffer_get_u32()
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
1226add976 tests: Fix warning about expected format for printf
/home/ffidenci/src/upstream/libssh/tests/benchmarks/bench_scp.c: In
function ‘benchmarks_scp_down’:
/home/ffidenci/src/upstream/libssh/tests/benchmarks/bench_scp.c:112:14:
warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has
type ‘size_t {aka long unsigned int}’ [-Wformat=]
       printf("Only %d bytes available (on %lu requested).\n",size,bytes);
              ^
/home/ffidenci/src/upstream/libssh/tests/benchmarks/bench_scp.c:116:14:
warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has
type ‘size_t {aka long unsigned int}’ [-Wformat=]
        printf("File is %d bytes (on %lu requested). Will cut the end\n"
        ,size,bytes);

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
234b05708c pki_gcrypt: Fix warning about not handled values in switch
/home/ffidenci/src/upstream/libssh/src/pki_gcrypt.c: In function
‘pki_key_compare’:
/home/ffidenci/src/upstream/libssh/src/pki_gcrypt.c:1082:5: warning:
enumeration value ‘SSH_KEYTYPE_DSS_CERT01’ not handled in switch
[-Wswitch]
     switch (k1->type) {
          ^
/home/ffidenci/src/upstream/libssh/src/pki_gcrypt.c:1082:5: warning:
enumeration value ‘SSH_KEYTYPE_RSA_CERT01’ not handled in switch
[-Wswitch]

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
e368d01385 cleanup: use ssh_ prefix in the packet (non-static) functions
Having "ssh_" prefix in the functions' name will avoid possible clashes
when compiling libssh statically.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
310c41a89a cleanup: use ssh_ prefix in the gcrypt missing functions
Having "ssh_" prefix in the functions' name will avoid possible clashes
when compiling libssh statically.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
1102ea4c55 cleanup: use ssh_ prefix in the kex (non-static) functions
Having "ssh_" prefix in the functions' name will avoid possible clashes
when compiling libssh statically.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
c487f5db5b cleanup: use ssh_ prefix in the dh (non-static) functions
Having "ssh_" prefix in the functions' name will avoid possible clashes
when compiling libssh statically.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
501faacf8e cleanup: use ssh_ prefix in the channels (non-static) functions
Having "ssh_" prefix in the functions' name will avoid possible clashes
when compiling libssh statically.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
adc8c20ac1 cleanup: use ssh_ prefix in the buffer (non-static) functions
Having "ssh_" prefix in the functions' name will avoid possible clashes
when compiling libssh statically.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
63e52afd5b cleanup: use ssh_ prefix in the blf (non-static) functions
Having "ssh_" prefix in the functions' name will avoid possible clashes
when compiling libssh statically.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
6f60449e18 cleanup: use ssh_ prefix in the bignum (non-static) functions
Having "ssh_" prefix in the functions' name will avoid possible clashes
when compiling libssh statically.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Fabiano Fidêncio
77052d3a1e cleanup: use ssh_ prefix in the agent (non-static) functions
Having "ssh_" prefix in the functions' name will avoid possible clashes
when compiling libssh statically.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:31:07 +01:00
Younes Serraj
898be61fc6 auth: Remove references to ssh_userauth_pubkey in documentation
- replaced references to ssh_userauth_pubkey (legacy function) by ssh_userauth_publickey.
- added missing \n in a couple of Returns sections.

This patch is an answer to this discussion:
http://www.libssh.org/archive/libssh/2016-01/0000009.html

Signed-off-by: Younes Serraj <younes.serraj@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:20:46 +01:00
Andreas Schneider
9ccb6864be tests: Initialize output and iv in torture_crypto
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:15:42 +01:00
Andreas Schneider
2379ddff17 pki: Make sure checkint1 and checkint2 are not used uninitialized
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:11:29 +01:00
Andreas Schneider
41a10699e6 buffer: Make sure we do not use u32len uninitialized
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:09:06 +01:00
Andreas Schneider
b1c0121507 valgrind: Add suppression for glibc dlopen issue
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:03:52 +01:00
Andreas Schneider
f6bea8d061 torture: Fix a memory leak
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-19 11:02:13 +01:00
Andreas Schneider
9bb7e68b86 torture: Add missing include for AF_INET
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-18 15:19:20 +01:00
Andreas Schneider
20718ec52b tests: Require pam_wrapper 1.0.1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-18 12:02:45 +01:00
Andreas Schneider
a3557b81de tests: Wait for sshd to start before connecting
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-18 12:01:56 +01:00
Andreas Schneider
485d78d768 tests: Turn on kbdint tests in torture_auth
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
7aa84318ae tests: Turn on PAM support in sshd with pam_wrapper
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
0e98f1214d torture: Improve process termination function
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
6e7eae968a tests: Support other openssh versions ...
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
5bb9b570f4 tests: Rename torture_sftp_static to torture_sftp_ext
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
571f547556 tests: Migrate torture_sftp_read to a cwrap test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
af3de262b6 tests: Migrate torture_sftp_dir to cwrap test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
bd4a0aa705 torture: Add sftp session pointer to torture_state
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
4bc6af6c17 tests: Migrate torture_request_env to cwrap test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
27834cce2c tests: Migrate torture_session to cwrap test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
a30d16c48a torture: Start sshd as root
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
e4653b82bd tests: Migrate torture_proxycommand to new cwrap test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
b65dcb3a35 tests: Migrate torture_knownhosts to new cwrap test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
c1fb948397 torture: Enable old host key algos for testing
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
be25b58380 tests: Migrate torture_forward to a cwrap test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
66f51df9df torture: Fix torture_ssh_session() for cwrap testing
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
3014e3c458 tests: Migrate torture_algorithms to a cwrap test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
dd0d04ae8d torture: Enable old cipher and kex algos in sshd
We need to test them, so enable them in the sshd.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
112d4cc7e6 tests: Migrate torture_auth as a cwrap test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
ee8664418a tests: Add public keys for bob
This also allows bob to auth as alice.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
ae89b6c078 torture: Create a torture_terminate_process() function
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
d403c01a30 tests: Convert torture_connect to a cwrap test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
14f1ce2e5b torture: Add torture_teardown_sshd_server().
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
62b0f58d24 torture: Restrict files to we write to our user.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
c3f963e71e torture: Add function to setup sshd server
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
fd09c4cb29 torture: Add torture_teardown_socket_dir().
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
13f68fc2d5 torture: Add torture_setup_socket_dir().
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
7a523597ad torture: Add server to get address and port.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
c2d636270c tests: Add ssh host keys for test environment.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
21b0d29e38 cmake: Configure nss_wrapper and uid_wrapper
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
6596d27e19 cmake: Search for cwrap and sshd.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
ed6294b4bb examples: Do not include internal headers in ssh_server_fork
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:49 +01:00
Andreas Schneider
12da51ac5a doc: Update documentation of ssh_userauth_try_publickey()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-01-14 08:04:27 +01:00
pouete
b3ad6a015b cmake: use check_symbol for (v)snprintf
Updated how snprintf and vsnprintf are discovered by cmake. Visual studio
2015 now include it in the file stdio.h.
More information here :
https://msdn.microsoft.com/en-us/library/bb531344.aspx

Reviewed-By: Aris Adamantiadis <aris@0xbadc0de.be>
2015-12-30 19:51:11 +01:00
Sebastián Peyrott
be36586d74 CMake: include CheckIncludeFiles for calls to check_include_files. 2015-12-24 13:01:37 +01:00
Fabiano Fidêncio
0d7da3207f Fix a bunch of -Wmaybe-uninitialized
Reviewed-By: Aris Adamantiadis <aris@0xbadc0de.be>
2015-12-17 15:01:05 +01:00
Dirk Neukirchen
71ce6592e4 headers: fix missing mode_t (2nd)
Reviewed-By: Aris Adamantiadis <aris@0xbadc0de.be>
2015-11-10 18:38:16 +01:00
Aris Adamantiadis
a5d6ccdc2c Revert "headers: fix missing mode_t"
I commited a patch file *headdesk*
This reverts commit 378fcccc0a.
2015-11-10 18:34:39 +01:00
Dirk Neukirchen
378fcccc0a headers: fix missing mode_t
Signed-off-by: Dirk Neukirchen <dirkneukirchen@web.de>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2015-11-10 18:27:31 +01:00
Andreas Schneider
3ed3833a38 Ignore all build and obj* directories
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-10-28 09:28:33 +01:00
Aris Adamantiadis
5450b478f5 Doc: remove mentions of des-cbc-ssh1 2015-10-27 10:19:46 +01:00
Andreas Schneider
94d00009cc libcrypto: Fix build with DEBUG_CRYPTO turned on
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-10-22 08:17:01 +02:00
Andreas Schneider
21bf499bb4 agent: Fix agent auth on big endian machines
BUG: https://red.libssh.org/issues/204

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-10-20 17:16:38 +02:00
Aris Adamantiadis
8ec46cbd42 crypto: fix broken ifdef 2015-09-25 12:01:36 +02:00
Aris Adamantiadis
0409a302bb cmake: fix EVP detection with gcc 2015-09-25 12:00:25 +02:00
Aris Adamantiadis
84a85803b4 crypto: old-fashioned aes_ctr when evp_aes_ctr is missing 2015-09-25 11:51:45 +02:00
Aris Adamantiadis
d46fe6a51c SSH1: fix duplicate identifier 2015-09-25 08:52:38 +02:00
Aris Adamantiadis
e83b4e8129 libcrypto: clean up EVP functions 2015-09-25 00:05:10 +02:00
Aris Adamantiadis
392e09e3de moved libcrypto structs to c99 notation 2015-09-24 21:57:44 +02:00
Aris Adamantiadis
06b9901e64 crypto: move key setup in newkeys handler 2015-09-24 16:46:12 +02:00
Aris Adamantiadis
677fa8ced2 tests: add test for cipher.(de|en)crypt 2015-09-23 15:09:23 +02:00
Aris Adamantiadis
3c333aa9b4 libcrypto: refactor EVP_(de|en)crypt 2015-09-23 15:09:23 +02:00
Aris Adamantiadis
73d8c919b7 crypto: fix potential memory leak in ECDH 2015-09-21 15:01:37 +02:00
Andreas Schneider
747e7d05db kex: Fix zlib compression
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-16 08:34:28 +02:00
Andreas Schneider
1f3a9105ff cmake: Use tar.xz source package generator
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-15 15:16:06 +02:00
Andreas Schneider
b0f22fde62 kex: Prefer sha2 over sha1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-15 15:09:03 +02:00
Andreas Schneider
11f43df873 pki: Fix a memory leak on error in ssh_pki_copy_cert_to_privkey()
CID 1323516

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-09 09:34:22 +02:00
Andreas Schneider
1254ed1833 pki: Fix a memory leak in pki_import_cert_buffer()
CID #1323517
2015-09-09 09:32:40 +02:00
Andreas Schneider
f55b10e4ed tests: Fix return code of torture_init
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-09 09:17:46 +02:00
Axel Eppe
d8be35de7f tests: Add tests for the new ssh_pki cert functions
Signed-off-by: Axel Eppe <aeppe@google.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-07 13:30:34 +02:00
Axel Eppe
bdfe6870f6 pki: Add certificate loading functions
- ssh_pki_import_cert_base64()
- ssh_pki_import_cert_file()
- ssh_pki_import_cert_blob()
Those functions are currently simple wrappers around their pubkey counterpart.

- ssh_pki_copy_cert_to_privkey()
This function copies the cert-specific data to a private key.

Signed-off-by: Axel Eppe <aeppe@google.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-07 13:30:14 +02:00
Axel Eppe
9775f78ab2 pki: Add Add new pki_import_cert_buffer function
Signed-off-by: Axel Eppe <aeppe@google.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-07 13:29:52 +02:00
Axel Eppe
6da4e21065 pki: Add rsa, dss certificate key type definitions
- Add rsa/dsa (ssh-{rsa,dss}-cert-v01@openssh.com) as key types.
- Add a cert_type member in the ssh_key struct.

Signed-off-by: Axel Eppe <aeppe@google.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-07 13:29:23 +02:00
Andreas Schneider
7bfe8d2f03 tests: Migrate pkd_hello to new cmocka API
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-07 12:44:23 +02:00
Andreas Schneider
3b0b1c3ee3 pki: Use the standard logging function
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-07 10:57:34 +02:00
Andreas Schneider
82a80b205b tests: Migrate to new cmocka API
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-07 10:40:12 +02:00
Andreas Schneider
5b586fdfec cmake: Handle libssh threas library correctly
This should fix the build on Windows and would not install pkg files.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-09-07 07:46:11 +02:00
Michael Wilder
2f193b5cbb bignum: Fix OpenSSL crash in SAFE_FREE
Signed-off-by: Michael Wilder <wilder.michael@cimcor.com>
Reviewed-by: Andreas Schneider <asn@samba.org>
2015-09-07 07:45:02 +02:00
Michael Wilder
e6f93c887b crypto: Add OpenSSL EVP functions for FIPS compatibility
Signed-off-by: Michael Wilder <wilder.michael@cimcor.com>
2015-09-07 07:45:01 +02:00
Andreas Schneider
36d9b62f1f server: Fix return code check of ssh_buffer_pack()
Thanks to Andreas Gutschick <andreas.gutschick@mitel.com>

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-08-18 09:09:31 +02:00
Andreas Schneider
da4bebbe1e doc: Fix typos in sftp tutorial
Thanks to Anthony Baker <AnthonyBaker@fico.com>

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-08-18 09:04:16 +02:00
Andreas Schneider
d54a1ab798 tests: Add checks for ssh_key_is_private()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-08-10 13:57:47 +02:00
Andreas Schneider
e1081796af pki: Fix return values of ssh_key_is_(public|private)
Thanks to Kevin Haake <khaake@red-cocoa.com>

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-08-10 13:57:28 +02:00
Tilo Eckert
672c3be9ed sftp: Fix incorrect handling of received length fields
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
2015-08-01 10:52:57 +03:00
Peter Volpe
dc9c4d22ab auth: Fix return status for ssh_userauth_agent()
BUG: https://red.libssh.org/issues/201

Return SSH_AUTH_DENIED instead of SSH_AUTH_ERROR when the provided agent
offers no public keys.

Signed-off-by: Peter Volpe <pvolpe@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-07-30 10:51:42 +02:00
Tilo Eckert
71d86be42e define our own platform-independent S_IF macros
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-07-30 10:47:34 +02:00
Tilo Eckert
267fe02088 fix file mode checks in sftp_open()
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-07-30 10:46:34 +02:00
Aris Adamantiadis
52b5258ed4 fix permissions 2015-07-08 16:33:34 +02:00
Fabiano Fidêncio
2bf6e66ffe client: handle agent forward open requests with callbacks
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Aris Adamantiadis <aris@badcode.be>
2015-07-07 13:24:55 +02:00
Andreas Schneider
728c2fbd01 cmake: Fix zlib include directory
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-07-03 12:36:26 +02:00
Andreas Schneider
613b71b385 cmake: Fix OpenSSL detection in non-standard path
This should fix the detection on Windows.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-07-03 11:38:58 +02:00
Andreas Schneider
70cc11618a cmake: Fail if can't find OpenSSL aes and des headers
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-07-03 10:51:36 +02:00
Andreas Schneider
387fd2cf53 include: Add stdarg.h so we can check for va_copy macro
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-06-30 09:58:47 +02:00
Tilo Eckert
0423057424 SSH_AUTH_PARTIAL is now correctly passed to the caller of ssh_userauth_publickey_auto().
Implicitly fixed unsafe return code handling that could result in use-after-free.

Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-06-29 11:10:45 +02:00
Tilo Eckert
cc25d747d4 available auth_methods must be reset on partial authentication
Signed-off-by: Tilo Eckert <tilo.eckert@flam.de>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-06-29 11:06:20 +02:00
Peter Volpe
7637351065 channels: Fix exit-signal data unpacking
Signed-off-by: Peter Volpe <pvolpe@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-06-29 09:50:09 +02:00
Peter Volpe
7aeba71a92 agent: Add ssh_set_agent_socket
Allow callers to specify their own socket
for an ssh agent.

Signed-off-by: Peter Volpe <pvolpe@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-06-29 09:47:02 +02:00
Seb Boving
e020dd8d59 Don't allocate a new identity list in the new session's options.
The previous list is not freed. Since the new session just got
created, an identity list is already allocated and empty.

Signed-off-by: Sebastien Boving <seb@google.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-06-24 18:28:36 +02:00
Douglas Heriot
a65af1b3b8 cmake: Do not use CMAKE_(SOURCE|BINARY)_DIR 2015-06-24 18:17:05 +02:00
Tiamo Laitakari
5478de1a64 pki: Fix allocation of ed25519 public keys
Signed-off-by: Tiamo Laitakari <tiamo.laitakari@cs.helsinki.fi>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-06-24 17:53:22 +02:00
Jordy Moos
fa9fbb1d67 Documentation fix where unsigned is used where signed is expected
Signed-off-by: Jordy Moos <jordymoos@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-06-24 17:13:26 +02:00
Andreas Schneider
ef751a26d0 misc: Correctly guard the sys/time.h include
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-06-24 17:13:19 +02:00
Andreas Schneider
30a7229fc5 include: Add support for older MSVC versions
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-06-24 16:23:13 +02:00
Andreas Schneider
1d69e073af kex: Add comments to #if clauses
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-06-24 16:23:13 +02:00
Aris Adamantiadis
c480a29052 channels: fix exit-status not correctly set 2015-06-03 16:41:05 +02:00
Mike DePaulo
4aef82237d Comment that ssh_forward_cancel() is deprecated.
Signed-off-by: Aris Adamantiadis <aris@badcode.be>
2015-05-29 11:29:49 +02:00
Mike DePaulo
8a4a22d7b7 Reintroduce ssh_forward_listen() (Fixes: #194)
Signed-off-by: Aris Adamantiadis <aris@badcode.be>
2015-05-29 11:23:31 +02:00
Andreas Schneider
5eb7a6ca38 cpack: Use application version.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-08 13:54:56 +02:00
Andreas Schneider
3f4b5436e5 Bump version to 0.7.0
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-06 11:01:33 +02:00
Andreas Schneider
82cf5ea24c Update ChangeLog
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-06 11:00:43 +02:00
Andreas Schneider
90e4786523 valgrind: Add suppression for openssl FIPS dlopen leak
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-06 10:27:09 +02:00
Andreas Schneider
f65f41acc2 valgrind: Ignore valgrind free bug on exit
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-06 10:23:27 +02:00
Andreas Schneider
8979150745 tests: Migrate torture_keyfiles to testkey functions
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-06 09:47:37 +02:00
Andreas Schneider
f81d296e54 torture: Move TORTURE_TESTKEY_PASSWORD to header
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-06 09:47:17 +02:00
Andreas Schneider
57afe78167 tests: Fix memory leak in torture_server_x11 test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-06 09:33:51 +02:00
Jon Simons
ee460dc04b kex: also compare host keys for 'first_kex_packet_follows'
Also consider the host key type at hand when computing whether a
'first_kex_packet_follows' packet matches the current server settings.
Without this change libssh may incorrectly believe that guessed
settings which match by kex algorithm alone fully match: the host
key types must also match.  Observed when testing with dropbear
clients.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-05 22:03:47 +02:00
Jon Simons
f134cb3d57 server: return SSH_OK for ignored SSH_MSG_KEXDH_INIT case
Return SSH_OK for the case that an incoming SSH_MSG_KEXDH_INIT should be
ignored.  That is, for the case that the initial 'first_kex_packet_follows'
guess is incorrect.  Before this change sessions served with libssh can be
observed to error out unexpectedly early when testing with dropbear clients
that send an incompatible guess.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-05 22:03:32 +02:00
Andreas Schneider
3eaad77de2 tests: Only link against threading library if available
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-05 19:09:51 +02:00
Andreas Schneider
9244750a63 cmake: Add missing OpenSSL include directory
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-05 19:04:49 +02:00
Andreas Schneider
e8720a30e2 cmake: Add --enable-stdcall-fixup for MinGW builds
This fixes warnings for getaddrinfo() and freeaddrinfo().

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-05 18:59:30 +02:00
Andreas Schneider
ad09009201 include: Fix variadic macro issues with MSVC
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-05 18:45:47 +02:00
Andreas Schneider
e4e3b3052f tests: Apply umask before calling mkstemp()
CID: #978660

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-05 11:27:09 +02:00
Andreas Schneider
96882cc58c example: Fix a use after free in the scp example
CID: #1032343

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-05 11:27:09 +02:00
Andreas Schneider
7c79959e94 example: Check return value of ssh_get_fd()
CID: #1199454

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-05 11:27:09 +02:00
Andreas Schneider
ca501df8c8 sftp: Fix size check
CID: #1296588

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-05 11:26:40 +02:00
Andreas Schneider
a4cecf59d5 external: Fix resetting the state
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-04 18:10:30 +02:00
Andreas Schneider
244881b87d external: Make sure we burn buffers in bcrypt
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-04 17:54:01 +02:00
Andreas Schneider
cf05e653de external: Fix a possible buffer overrun in bcrypt_pbkdf
CID: #1250106

This fixes a 1 byte output overflow for large key length (not reachable
in libssh). Pulled from OpenBSD BCrypt PBKDF implementation.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-04 17:54:01 +02:00
Andreas Schneider
4b9916136d sftp: Add bound check for size
CID: #1238630

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-04 17:54:01 +02:00
Andreas Schneider
33ecff11dd buffer: Cleanup vaargs in ssh_buffer_unpack_va()
CID: #1267977

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-04 17:54:01 +02:00
Andreas Schneider
83d3ee7fdb string: Improve ssh_string_len() to avoid tainted variables
CID: #1278978

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-04 17:54:01 +02:00
Andreas Schneider
b1a3f4ee33 pki_container: Fix a memory leak
CID: #1267980

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-04 17:54:01 +02:00
Andreas Schneider
05498e0e33 pki_container: Add check for return value
CID: #1267982

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-04 17:54:01 +02:00
Andreas Schneider
4948fe21cd tests: Fix ctest default script
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-04 15:52:17 +02:00
Andreas Schneider
fe8fcb805c cmake: Add support for Address Sanitizer
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-04 15:25:17 +02:00
Andreas Schneider
c4af6fbce3 config: Add missing HAVE_ARPA_INET_H define
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-05-04 10:04:26 +02:00
Aris Adamantiadis
3091025472 buffers: Fix a possible null pointer dereference
This is an addition to CVE-2015-3146 to fix the null pointer
dereference. The patch is not required to fix the CVE but prevents
issues in future.

Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-23 10:33:52 +02:00
Aris Adamantiadis
bf0c7ae0ae CVE-2015-3146: Fix state validation in packet handlers
The state validation in the packet handlers for SSH_MSG_NEWKEYS and
SSH_MSG_KEXDH_REPLY had a bug which did not raise an error.

The issue has been found and reported by Mariusz Ziule.

Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-23 10:15:47 +02:00
Kevin Fan
b5dc8197f7 Fix leak of sftp->ext when sftp_new() fails
Signed-off-by: Kevin Fan <kevinfan@google.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-14 20:56:56 +02:00
Andreas Schneider
19e23e6128 cmake: Require cmake 2.8.5
I've improved FindOpenSSL and FindZLIB in that version to work well with
Windows and Linux. This was 2011 it should be old enough that most
distributions have at least this version available.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-10 14:35:29 +02:00
Andreas Schneider
195f25cfbd cmake: Detect network function correctly on Windows
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-10 13:32:09 +02:00
Andreas Schneider
1cb940c44a socket: Cleanup ssh_socket_close() code.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-10 13:32:09 +02:00
Andreas Schneider
3f04367fb8 bind: Correctly close sockets and invalidate them.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-10 13:32:09 +02:00
Andreas Schneider
6c7e552509 cmake: Require cmake version 2.8.0 2015-04-10 13:32:09 +02:00
Andreas Schneider
b1cb8de385 cmake: Check for sys/param.h header file
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-10 13:07:12 +02:00
Andreas Schneider
69c9cd029f cmake: Check for arpa/inet.h header file
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-10 13:02:56 +02:00
Andreas Schneider
c699b9ca94 external: Use standard int types
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-10 13:02:56 +02:00
Andreas Schneider
53586ed4ba include: Do not make x11 variables const
We allocate them and also free them after the callback has been
executed.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-02 16:19:45 +02:00
Andreas Schneider
5236358a48 messages: Don't leak memory after callback execution
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-02 16:13:20 +02:00
Andreas Schneider
d6fe9dc220 unittests: Fix memory leak in torture_pki_ed25519
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-02 15:05:19 +02:00
Andreas Schneider
e0a73d3dbe poll: Fix compilation with struct ssh_timestamp
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-02 15:02:29 +02:00
Andreas Schneider
dbe7df7571 cmake: Detect __func__ and __FUNCTION__ during configure step
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-02 13:41:02 +02:00
Andreas Schneider
a3357b8920 include: We should use __func__ which is C99
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-04-02 10:58:36 +02:00
Seb Boving
7ec798d3e7 Locally restart ssh_poll() upon EINTR.
BUG: https://red.libssh.org/issues/186

Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
Signed-off-by: Sebastien Boving <seb@google.com>
2015-02-23 22:05:54 +01:00
xjoaalm
f32e5f2191 Sending EOF on Socket that received a Broken Pipe makes call to poll to hang
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
Signed-off-by: Joao Pedro Almeida Pereira <joao.almeida@blue-tc.com>
2015-02-23 22:01:15 +01:00
Andreas Schneider
cd078c7085 cmake: Drop reports via https only.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-20 15:47:22 +01:00
Aris Adamantiadis
2e445d5871 torture: fix includes for freebsd10 2015-02-14 22:09:02 +01:00
Aris Adamantiadis
5c46fbc680 tests: torture-misc: check for NULL return codes
Use the LOGNAME environment variable if USER is not set, as it sometimes
happens in cron jobs.
2015-02-12 11:38:21 +01:00
Aris Adamantiadis
2a780afc57 tests: workaround for compiling with older cmocka 2015-02-12 11:19:04 +01:00
Aris Adamantiadis
940cb233ce buffer: buffer_pack & unpack on non-gnu compilers 2015-02-08 18:49:32 +01:00
Aris Adamantiadis
a653e27a2e buffer: detect compilers not supporting __VA_ARGS__ 2015-02-08 18:49:02 +01:00
Aris Adamantiadis
d3f30da158 buffer: fix use-before-nullcheck (coverity #1267979)
Additionally, the function call was already existing after
the NULL check
2015-02-03 22:21:22 +01:00
Aris Adamantiadis
760d93e87b Revert "pki_gcrypt: fix warnings for SSH_KEYTYPE_ED25519"
This reverts commit 10f71c6769.
Commit was redundant with ed25519 branch
2015-02-03 09:58:28 +01:00
Aris Adamantiadis
d42a1a35b0 tests: allow conditionnal execution on pattern
Option can be used to filter out irrelevant tests
usage: ./torture_pki '*ed25519'

Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 17:34:15 +01:00
Aris Adamantiadis
8af829a42a base64: Use secure buffers
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 17:33:58 +01:00
Andreas Schneider
ad8fa427dd buffer: Abort if the canary is not intact in ssh_buffer_unpack()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2015-02-02 17:32:34 +01:00
Andreas Schneider
de10a7754b buffer: buffer: Improve argument checking of in ssh_buffer_pack()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2015-02-02 17:32:31 +01:00
Andreas Schneider
6789170799 buffer: Abort if the canary is not intact in ssh_buffer_unpack()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2015-02-02 17:32:28 +01:00
Andreas Schneider
afc9988c93 buffer: Improve argument checking in ssh_buffer_pack()
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2015-02-02 17:32:18 +01:00
Aris Adamantiadis
2490404d45 Move all 3rd-party C files to src/external/
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:53 +01:00
Aris Adamantiadis
fbdb940c46 ed25519: Add test for signatures and verification
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
c8d0b724b3 tests: Add ed25519 encrypted keys export
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
9e4700cdc0 ed25519: Add support for OpenSSH encrypted container export
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
b76d37b341 tests: Add ed25519 encrypted keys import
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
423fa6818b ed25519: ADd OpenSSH encrypted container import
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
61e2c8f0f7 external: Add OpenSSH bcrypt and blowfish implementation
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
c02b260e7e server: Add support for ed25519 keys in the server.
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
01a6004171 kex: Add support for ed25519 on client connections.
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
4f5660e081 tests: Add ed25519 OpenSSH key saving
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
46bc11f977 ed25519: Add support to export OpenSSH container keys
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
119840b0a9 tests: Add ed25519 OpenSSH key loading and operations
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
4343ac5b08 libgcrypt: Make the PEM parser ed25519 aware
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
6b9183a20b libcrypto: Make the PEM parser ed25519 aware
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
3ec3a926e5 ed25519: Add support o import OpenSSH container keys
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
2f7886837f pki.h: Replace tabs with spaces
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-02-02 14:45:52 +01:00
Aris Adamantiadis
7febad5821 kex: disable des-cbc-ssh1 by default
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-01-26 08:57:06 +01:00
Andreas Schneider
b235c380f2 packet_cb: Add misssing include for ntohl().
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-01-21 09:23:43 +01:00
Andreas Schneider
f6a50aff4c tests: Fix torture_server_x11(). 2015-01-21 09:19:30 +01:00
Alan Dunn
6b7f275c32 tests: Add torture_server_x11 test.
torture_server_x11 tests whether a libssh server can correctly parse an
X11 request.

Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-01-20 20:23:19 +01:00
Alan Dunn
4bde48bb2e tests: Add ssh server setup functionality
Add the ability to generate a keypair (RSA, but tests that focus on
what occurs over a connection may well not care) and an ssh_bind
easily.

Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-01-20 19:50:52 +01:00
Alan Dunn
f4154c503b tests: Add port option to torture_ssh_session
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-01-20 19:41:53 +01:00
Léo Peltier
8db4520d89 cmake: Add libsshpp.hpp to the distributed headers list.
BUG: https://red.libssh.org/issues/163

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-01-20 19:32:48 +01:00
Andreas Schneider
9a7d450098 pki: Make sure sig is not used unintialized.
BUG: https://red.libssh.org/issues/167

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-01-20 19:31:12 +01:00
William Orr
7070117dc3 examples: Use safer names for stdin, stdout, stderr
BUG: https://red.libssh.org/issues/168

On some platforms, like OpenBSD, stdin and friends are macros which break
compilation of this struct. I've fixed these names such that it compiles and
runs cleanly on OpenBSD

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-01-20 19:27:14 +01:00
Andreas Schneider
433f8fd550 threads: Fix building with POSIX threads in MinGW.
BUG: https://red.libssh.org/issues/181

Originally written by Patrick von Reth <vonreth () kde ! org>.

This patch is part of the larger patch:
https://projects.kde.org/projects/kdesupport/emerge/repository/revisions/master/changes/portage/win32libs/libssh/0002-add-a-way-to-test-ssh-connections-on-windows.patch

MinGW (in particular, the MinGW-w64 fork) can use either posix threads
or win32 threads. This patch fixes the MinGW build when using posix
threads.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-01-20 19:01:15 +01:00
Yanis Kurganov
c6590bd189 channels1: Fix pty request state
Signed-off-by: Yanis Kurganov <YKurganov@ptsecurity.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-01-20 18:58:13 +01:00
Andreas Schneider
929868c691 Update README.CodingStyle 2015-01-20 12:08:51 +01:00
Andreas Schneider
06a0d8ff1c connect: Fix a memory leak.
CID: #1238618

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2015-01-14 15:20:52 +01:00
Andreas Schneider
af0dd3fb02 sftp: Fix a possible integer overflow.
CID: #1238630

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2015-01-14 15:20:49 +01:00
Andreas Schneider
ce02f6576a sftp: Use a declared variable for data len.
CID: #1238632

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2015-01-14 15:20:46 +01:00
Andreas Schneider
68e720a3da pkd: Make sure we do not pass -1 to close.
CID: #1245696

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2015-01-14 15:20:43 +01:00
Andreas Schneider
c224508bf8 pkd: Check return value of pkd_run_tests().
CID: #1245697

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2015-01-14 15:20:34 +01:00
Tobias Klauser
15d71a8c51 sftp: Fix memory leak on realloc failure
If realloc of sftp->ext->name or sftp->ext->data fails, the memory
previously allocated for the respective member is leaked. Fix this by
storing the return value of realloc() in a temporary variable which only
gets assigned to the respective sftp->ext member on success.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-01-14 10:22:55 +01:00
Andreas Schneider
8536cd9808 cmake: Fix ntohll and htonll macro detection.
BUG: https://red.libssh.org/issues/164

Thanks to Ryan Schmidt!

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-01-13 08:53:42 +01:00
Tobias Klauser
353751e3e3 doc: Fix a typo in curve25519-sha256@libssh.org.txt
Fix the typo 'stengths' -> 'strengths' and remove the trailing white
space on the same line.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2015-01-13 08:45:51 +01:00
Andreas Schneider
159ef828dd doc: Fix link to curve25519-sha256@libssh.org spec. 2015-01-06 15:24:30 +01:00
Andreas Schneider
3dd069c0c8 doc: Fix a typo, blank lines and trailing spaces. 2015-01-06 15:22:16 +01:00
Andreas Schneider
a198193723 connect: Fix mingw build.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2015-01-06 15:12:17 +01:00
Andreas Schneider
e051135a05 connect: Check that errno is 0 to fix Windows build.
Thanks to Viktor Butskih.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-25 12:34:59 +01:00
Andreas Schneider
bb18442fe8 options: Fix setting the port.
Make sure we correctly read the port from the config file.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-25 12:32:16 +01:00
Jon Simons
c2aed4ca78 CVE-2014-8132: Fixup error path in ssh_packet_kexinit()
Before this change, dangling pointers can be unintentionally left in the
respective next_crypto kex methods slots.  Ensure to set all slots to
NULL in the error-out path.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-17 19:45:09 +01:00
Andreas Schneider
b7b535816d libcrypto: Fix Windows build with ssh_reseed().
gettimeofday() is not available on Windows and we need it only in case
of forking.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-17 19:39:18 +01:00
Andreas Schneider
d8e691b58a cmake: Fix config variable names.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-17 10:38:56 +01:00
William Orr
52968b1a11 config: Also tokenize on equal sign.
The ssh config specifies it as a valid separator.

BUG: https://red.libssh.org/issues/166

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-17 10:34:27 +01:00
Jon Simons
b35f1f488c pki_gcrypt: fix DSA signature extraction
Fix DSA signature extraction for the LIBGCRYPT build.  Here, the same fix
that was applied to the LIBCRYPTO build for https://red.libssh.org/issues/144
is now adapted for pki_gcrypt.  Additionally, ensure to set the resulting
output sig_blob buffer before returning.

Before this fix, one can observe the failure with the pkd test on a LIBGCRYPT
build as so:

  # ./pkd_hello -i 1 -t torture_pkd_openssh_dsa_dsa_default

After, runs of 10000 back-to-back iterations of the same test are passing.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-09 19:21:47 +01:00
Jon Simons
10f71c6769 pki_gcrypt: fix warnings for SSH_KEYTYPE_ED25519
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-09 19:21:34 +01:00
Jon Simons
014fde0542 torture: fix warning for SSH_KEYTYPE_ED25519
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-09 19:21:18 +01:00
Jon Simons
ca2acec34a bignum: no-op make_string_bn_inplace for LIBGCRYPT
Disable the 'make_string_bn_inplace' helper function for the LIBGCRYPT
build, rather than using '#error' to fail the build completely.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-09 19:20:46 +01:00
Davide \"FunkyAss\" Del Zompo
bb197de75d doc: clarify tutorial error section
Signed-off-by: Davide "FunkyAss" Del Zompo <davide.delzompo@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-05 11:09:00 +01:00
Hani Benhabiles
03095f1516 Set the correct error in ssh_options_set().
Signed-off-by: Hani Benhabiles <hani@linux.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-05 11:03:55 +01:00
Jon Simons
6895d0b727 session: add getter for kexalgo
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-05 10:48:07 +01:00
Jon Simons
4745d652b5 pki_crypto.c: plug ecdsa_sig->[r,s] bignum leaks
Per ecdsa(3ssl), ECDSA_SIG_new does allocate its 'r' and 's' bignum fields.
Fix a bug where the initial 'r' and 's' bignums were being overwritten with
newly-allocated bignums, resulting in a memory leak.

BUG: https://red.libssh.org/issues/175

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-12-05 10:42:32 +01:00
Andreas Schneider
a48711ae7e connect: Do not fail if the connect is in progress.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-15 10:27:55 +02:00
Jon Simons
a25790d343 tests: fix pkd build breakages
Fix a build breakage when '-DWITH_SERVER=OFF' is set: skip building the
pkd test for that case.  Add some missing includes for the OpenIndiana
and FreeBSD builds.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-15 10:26:24 +02:00
Stef Walter
cd2dc3770a gssapi: ssh_gssapi_set_creds() is a client side function
It should not be guarded by the WITH_SERVER #ifdef

Signed-off-by: Stef Walter <stefw@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-12 15:41:15 +02:00
William Orr
250f506487 Check return code of connect(2).
Signed-off-by: William Orr <will@worrbase.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-12 15:39:58 +02:00
Jon Simons
9dc932c02b tests: introduce pkd_hello
Introduce a sample public-key testing daemon to the 'pkd' test directory,
and add support code for cycling through various combinations of different
key exchange, cipher, and MAC algorithms.

The goal of the 'pkd_hello' test is to make it easy to test interactions
between non-libssh clients and a libssh-server, and to provide a starting
point for testing new implementations for key types, ciphers, MACs, and
so on.  The thinking is that testing a new algorithm should be as simple
as adding a new line for it in the PKDTESTS_* lists.

Macros are used to generate the tests and helper functions for a couple of
clients -- here, OpenSSH and dropbear are included for the first cut.  If
binaries are found for these clients, their test lists will be enabled;
when binaries are not found for a given client, those tests are skipped.

Tests are run in one large batch by default, but can also be run individually
to help with tracking down things like signature bugs that may take many
iterations to reproduce.

Each test logs its stdout and stderr to its own file, which is cleaned up
when a test succeeds.  For failures, those logs can be combined with verbose
libssh output from pkd itself to start debugging things.

Some example usages:

  pkd_hello
    Run all tests with default number of iterations.

  pkd_hello --list
    List available individual test names.

  pkd_hello -i 1000 -t torture_pkd_openssh_ecdsa_256_ecdh_sha2_nistp256
    Run only the torture_pkd_openssh_ecdsa_256_ecdh_sha2_nistp256
    testcase 1000 times.

  pkd_hello -v -v -v -v -e -o
    Run all tests with maximum libssh and pkd logging.

Included in the tests are passes for all existing kex, cipher, and MAC
algorithms.

BUG: https://red.libssh.org/issues/144

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-12 15:01:02 +02:00
Artyom V. Poptsov
aaae6cd97d pki_gcrypt: Initialize 'type_c' in 'pki_do_sign_sessionid'
Add missing initialization of 'type_c' field of a SSH signature in
'pki_do_sign_sessionid' procedure.

If libssh is compiled with GCrypt, 'dh_handshake_server' fails with
"Could not sign the session id" error.  The change fixes that.

Signed-off-by: Artyom V. Poptsov <poptsov.artyom@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-02 08:30:17 +02:00
Jon Simons
509676e3a4 server: fix auth_interactive_request reply
Fix a missing 'buffer_pack' formatter in 'ssh_message_auth_interactive_request'.
With this fix the 'examples/samplesshd-kbdint' program is working again for me.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-02 08:29:22 +02:00
Jon Simons
a6d412f0d7 ed25519: fix leak in pki_ed25519_sign
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-02 08:28:51 +02:00
Jon Simons
59da8dab50 pki: check ssh_buffer_pack return in ssh_pki_do_sign
Check the 'ssh_buffer_pack' return in ssh_pki_do_sign for the ED25519 case.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-02 08:28:05 +02:00
Jon Simons
7edbedf0dd pki: fail when pubkey buffer length is not ED25519_PK_LEN
Fail fast in 'pki_import_pubkey_buffer' for the ED25519 case if a buffer
sized ED25519_PK_LEN can not be retrieved.  Before, the 'memcpy' could
have read beyond the bounds of 'ssh_string_data(pubkey)'.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-02 08:27:05 +02:00
Jon Simons
af25c5e668 crypto: check malloc return in ssh_mac_ctx_init
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-02 08:25:53 +02:00
Jon Simons
092fe0b727 wrapper: fix z_stream leak
Ensure to free the z_stream structures as allocated from
the gzip.c initcompress, initdecompress functions.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-10-02 08:25:10 +02:00
Andreas Schneider
1ddb99c46f string: Correctly burn the string buffer.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-09-15 20:45:47 +02:00
Aris
93c7b81b4e ed25519: Generate, sign and verify keys.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-09-07 22:07:34 +02:00
Aris Adamantiadis
93e82fa0c0 crypto: Add ed25519 implementation from OpenSSH.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-09-07 21:35:20 +02:00
Aris Adamantiadis
e9b2d164e0 base64: Use a secure buffer.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-09-07 10:38:23 +02:00
Aris Adamantiadis
86ae6b2251 buffer: Add a secure buffer mechanism to avoid memory spills
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-09-07 10:36:32 +02:00
Aris Adamantiadis
2cb2587b55 buffer: Implement "t" for text in ssh_buffer_pack().
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-09-07 10:27:35 +02:00
Andreas Schneider
86294ad3ea dh: Fix packing a pointer into the buffer.
Thanks to Giovanni Panozzo <giovanni@panozzo.it>.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-08-25 12:23:17 +02:00
Andreas Schneider
173994786b tests: Fix writing the '\0'.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-08-18 21:41:36 +02:00
Andreas Schneider
81123d6a91 ec: Fix build on CentOS.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2014-08-18 10:08:00 +02:00
Andreas Schneider
25eb9c4914 tests: Use public testkey passphrase function in pki test.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:32:57 +02:00
Andreas Schneider
c6210f5aef torture: Add public testkey passphrase function.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:32:54 +02:00
Andreas Schneider
c673543e54 tests: Use public testkeys in pki test.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:32:51 +02:00
Andreas Schneider
edca9d6e96 torture: Add public testkey functions.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:32:47 +02:00
Andreas Schneider
83aed7610c tests: Make write file a public torture function.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:32:37 +02:00
Andreas Schneider
5fa4721c6e auth: Fix a memory leak in agent publickey auth.
CID: 1230358

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:26 +02:00
Andreas Schneider
8b7627efd5 tests: Make sure we null terminate the buffer.
CID: 1230359

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:23 +02:00
Andreas Schneider
662217f409 packet: Check return value of ssh_buffer_unpack().
CID: 1230357

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:20 +02:00
Andreas Schneider
19433dca00 messages: Check return value of ssh_buffer_unpack().
CID: 1230356

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:16 +02:00
Andreas Schneider
6961dd79ad tests: Fix memory leak in buffer test.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:13 +02:00
Andreas Schneider
1b6375ce89 buffer: Make sure rc is initialized.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:11 +02:00
Andreas Schneider
64f6abead7 libgcrypt: Fix initializer name.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:07 +02:00
Andreas Schneider
f20a6d0a82 bignum: Add missing include.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-15 12:29:00 +02:00
Andreas Schneider
97c6b76863 messages: Fix two ssh_buffer_unpack().
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
Reviewed-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-08-07 17:28:42 +02:00
Aris Adamantiadis
6019cf1bed Fix sftp endianess bugs
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 10:08:25 +02:00
Aris Adamantiadis
228dc08038 bignums: detach bignum-related functions from dh.c.
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 10:07:36 +02:00
Aris Adamantiadis
33cd594f1f crypto: fix secure burning, structure members naming
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 10:05:19 +02:00
Aris Adamantiadis
0cd0f685c9 torture_pki: avoid generating keys with ssh-keygen
ssh-keygen makes the tests very slow because new keys are generated
at the start of every test.
ssh-keygen on OSX doesn't support ecdsa keys, even if libcrypto does.

Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 10:04:57 +02:00
Aris Adamantiadis
664b94d1c5 tests: test the canary feature in buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 10:00:07 +02:00
Aris Adamantiadis
3b4b0f01ec buffer: add a hidden canary to detect format errors
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 09:58:52 +02:00
Aris Adamantiadis
7bd62dd652 buffers: adapt sftpserver.c to ssh_buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 09:52:29 +02:00
Aris Adamantiadis
c341da03d3 buffers: adapt sftp.c to ssh_buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 09:51:00 +02:00
Aris Adamantiadis
c238136010 buffers: adapt session.c to ssh_buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 09:47:35 +02:00
Aris Adamantiadis
5a08ddcff2 buffers: adapt server.c to ssh_buffer_(un)pack()
Signed-off-by: Andreas Schneider <asn@samba.org>
2014-08-06 09:46:14 +02:00
Aris Adamantiadis
a182926024 buffers: adapt pcap.c to ssh_buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 09:46:14 +02:00
Aris Adamantiadis
9457685320 buffers: adapt ecdh.c to ssh_buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 09:46:14 +02:00
Aris Adamantiadis
e9fd14c7f0 buffers: adapt packet.c to ssh_buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 09:46:14 +02:00
Aris Adamantiadis
cfd2e4894e buffers: adapt messages.c to ssh_buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 09:46:14 +02:00
Aris Adamantiadis
3703389feb buffers: adapt gssapi.c to ssh_buffer_(un)pack() 2014-08-06 09:46:14 +02:00
Aris Adamantiadis
673990f568 buffers: adapt curve25519.c to ssh_buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 09:33:32 +02:00
Aris Adamantiadis
97638a1465 buffers: adapt client.c to ssh_buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 09:33:07 +02:00
Aris Adamantiadis
506e11fa8b buffers: adapt channels.c to ssh_buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 09:33:03 +02:00
Aris Adamantiadis
1dd95675df buffer: adapt dh.c to new ssh_buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 09:20:49 +02:00
Aris Adamantiadis
cb10ad0c84 buffer: adapt kex.c to new ssh_buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 09:20:49 +02:00
Aris Adamantiadis
1f2c61d6ad buffer: adapt auth.c to ssh_buffer_(un)pack()
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-08-06 09:20:49 +02:00
Aris Adamantiadis
1d97f75b0a tests: test for ssh_buffer_(un)pack
Reviewed-by: Andreas Schneider <asn@samba.org>
2014-08-06 09:20:45 +02:00
Aris Adamantiadis
835e34d1eb Buffer: add ssh_buffer_(un)pack()
That function permits chaining of buffer values to minimize buffer handling
in packet sending code.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-08-06 09:04:34 +02:00
Aris Adamantiadis
13c42bff3f examples: cast arguments of connect(2)
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-07-06 20:36:49 +02:00
Andreas Schneider
59a1799501 log: Add check for return value.
For some reason I got a segfault in gdb here. Make sure it works
correctly.
2014-06-10 13:52:38 +02:00
Andreas Schneider
d9c47a8cfa tests: Add test for the logging function. 2014-06-10 13:52:20 +02:00
Jon Simons
987991a3f2 session: fix ssh_session->srv.ecdsa_key leak
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-05-28 10:23:46 +02:00
Andreas Schneider
a738507ad2 cmake: Fix the build on Windows. 2014-05-27 15:42:53 +02:00
Andreas Schneider
142b2e4ede cmake: Fix libssh cmake-config files. 2014-05-22 14:52:52 +02:00
Hani Benhabiles
517a01b7ad Set the correct version in CMakeLists.txt
Signed-off-by: Hani Benhabiles <hani@linux.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-05-20 09:41:20 +02:00
Andreas Schneider
83633d539e pki: Fix build without ECC support.
Signed-off-by: Andreas Schneider <asn@samba.org>
2014-05-09 08:55:49 +02:00
Andreas Schneider
c2ee63431b pki: Add missing semi-colon. 2014-05-07 09:30:29 +02:00
Jon Simons
9e4bc10525 kex: NULL checks for 'first_kex_packet_follows'
Add NULL checks to 'is_first_kex_packet_follows_guess_wrong'
to ensure that a 'strdup(NULL)' path can not be taken.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-05-06 09:04:07 +02:00
Alan Dunn
f37c844bf7 messages: Add missing ntohl on X11 request screen number
BUG: https://red.libssh.org/issues/160

Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-05-06 08:56:44 +02:00
Hani Benhabiles
2c7dfb02a8 Small documentation fix.
Signed-off-by: Hani Benhabiles <hani@linux.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-05-06 08:52:55 +02:00
Andreas Schneider
2884bbf5b1 pki: Correctly update the ECDSA keytype. 2014-04-23 11:16:28 +02:00
Andreas Schneider
f48a99b97c pki: Move ssh_pki_key_ecdsa_name() to the correct file. 2014-04-23 11:15:05 +02:00
Andreas Schneider
11cfb2903e pki: Make pki_key_ecdsa_nid_to_name() a shared function. 2014-04-23 11:12:08 +02:00
Dirkjan Bussink
c520d97dd9 Add tests for SHA2 HMAC algorithms
BUG: https://red.libssh.org/issues/91

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-04-22 10:57:35 +02:00
Dirkjan Bussink
6c74d6f891 Add options support for setting and getting HMAC algorithms
BUG: https://red.libssh.org/issues/91

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-04-22 10:57:18 +02:00
Dirkjan Bussink
262c82ac06 Add negotiation for SHA2 HMAC algorithms
BUG: https://red.libssh.org/issues/91

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-04-22 10:57:00 +02:00
Dirkjan Bussink
164b8e99cc Add logic to support SHA2 HMAC algorithms
BUG: https://red.libssh.org/issues/91

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-04-22 10:56:46 +02:00
Dirkjan Bussink
4a08902664 Add SHA2 algorithms for HMAC
BUG: https://red.libssh.org/issues/91

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-04-22 10:55:59 +02:00
Gangadhar Sandrani
d6e6a453fc log: Fix log levels.
Signed-off-by: Gangadhar Sandrani <gangadhar.sandrani@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-04-22 09:35:33 +02:00
Jon Simons
eb86fd8cdf kex: server fix for first_kex_packet_follows
Ensure to honor the 'first_kex_packet_follow' field when processing
KEXINIT messages in the 'ssh_packet_kexinit' callback.  Until now
libssh would assume that this field is always unset (zero).  But
some clients may set this (dropbear at or beyond version 2013.57),
and it needs to be included when computing the session ID.

Also include logic for handling wrongly-guessed key exchange algorithms.
Save whether a client's guess is wrong in a new field in the session
struct: when set, the next KEX_DHINIT message to be processed will be
ignored per RFC 4253, 7.1.

While here, update both 'ssh_packet_kexinit' and 'make_sessionid' to
use softabs with a 4 space indent level throughout, and also convert
various error-checking to store intermediate values into an explicit
'rc'.

Patch adjusted from original to ensure that client tests remain passing
(ie 'torture_connect'): restrict the changes in 'ssh_packet_kexinit'
only for the 'server_kex' case.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-04-22 09:26:59 +02:00
Alan Dunn
099e2e8438 build: Do not link against libssl, only libcrypto
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-04-22 09:24:54 +02:00
Andreas Schneider
291312c5e4 cmake: Install cmake config files to the correct directory. 2014-04-16 15:45:33 +02:00
Andreas Schneider
e2805abbf7 Revert "kex: server fix for first_kex_packet_follows"
The patch breaks the client with ECDSA.

This reverts commit 5865b9436f.
2014-04-15 09:49:25 +02:00
Andreas Schneider
79d51099ac examples: Fix a bad shift if ssh_get_fd() returns -1.
Found by Coverity.

CID: #1199454
2014-04-14 21:24:28 +02:00
Andreas Schneider
adf23533e0 doc: Improve docs for ssh_channel_get_exit_status().
BUG: https://red.libssh.org/issues/154
2014-04-10 08:54:11 +02:00
Andreas Schneider
927cd90dc1 channels: Fix exit-signal request.
BUG: https://red.libssh.org/issues/153
2014-04-10 08:54:11 +02:00
Andreas Schneider
b5efbe75cd session: Fix a memory leak with custom banner.
BUG: https://red.libssh.org/issues/152
2014-04-10 08:54:10 +02:00
Andreas Schneider
01311dd419 cmake: Fix doxygen. 2014-04-10 08:54:10 +02:00
Jon Simons
5865b9436f kex: server fix for first_kex_packet_follows
Ensure to honor the 'first_kex_packet_follow' field when processing
KEXINIT messages in the 'ssh_packet_kexinit' callback.  Until now
libssh would assume that this field is always unset (zero).  But
some clients may set this (dropbear at or beyond version 2013.57),
and it needs to be included when computing the session ID.

Also include logic for handling wrongly-guessed key exchange algorithms.
Save whether a client's guess is wrong in a new field in the session
struct: when set, the next KEX_DHINIT message to be processed will be
ignored per RFC 4253, 7.1.

While here, update both 'ssh_packet_kexinit' and 'make_sessionid' to
use softabs with a 4 space indent level throughout, and also convert
various error-checking to store intermediate values into an explicit
'rc'.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-04-10 08:54:10 +02:00
Andreas Schneider
ad1313c2e5 Revert "direct-tcpip and forwarded-tcpip callbacks"
This reverts commit efe785e711.

We need a Signed-off version. I didn't have the Certificate of Origin
yet.
2014-04-09 12:49:06 +02:00
Andreas Schneider
0cb9f792b8 cmake: Update doxygen module. 2014-04-09 11:21:29 +02:00
Loïc Michaux
efe785e711 direct-tcpip and forwarded-tcpip callbacks 2014-04-09 11:13:57 +02:00
Jon Simons
48aca98cd5 pki crypto: expose new ssh_pki_key_ecdsa_name API
Enable retrieving the "ecdsa-sha2-nistpNNN" name of ECDSA keys with a
new 'ssh_pki_key_ecdsa_name' API.  This gives more information than the
'ssh_key_type_to_char' API, which yields "ssh-ecdsa" for ECDSA keys.
The motivation is that this info is useful to have in a server context.

The torture_pki unit test is updated to include the new API, and a few
more passes are added to additionally test 384 and 521-bit keys.

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-04-09 11:01:11 +02:00
Petar Koretic
89e154f78c libsshpp: include required <string> header for std::string
Signed-off-by: Petar Koretic <petar.koretic@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-04-09 10:59:59 +02:00
Alan Dunn
491b407d17 examples: Update ssh_server_fork for new SSH_BIND_OPTIONS_HOSTKEY
Tested by

ssh_server_fork -k <an ecdsa key> -k <an rsa key> ...

and connection succeeded with OpenSSH clients both for ECDSA and RSA
(the latter forced via -o HostKeyAlgorithms=ssh-rsa and some known
hosts clearing was necessary).  Also

ssh_server_fork -k <an ecdsa key> -k <another ecdsa key> ...

caused the second key to be used, as expected.

Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-04-09 10:59:21 +02:00
Alan Dunn
2f4589b765 doc: Document new meaning of SSH_BIND_OPTIONS_HOSTKEY
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-04-09 10:59:10 +02:00
Alan Dunn
acb7161c81 options: Repurpose SSH_BIND_OPTIONS_HOSTKEY to load host keys
SSH_BIND_OPTIONS_HOSTKEY will now load host keys of any supported type
rather than set the algorithms that the server permits (which seems
like an unhelpful option anyway; it seems you can always control this
by just loading the right keys).

This option has slightly different semantics than the
SSH_BIND_OPTIONS_<x>KEY options because it requires the key file to
exist immediately rather than on ssh_bind_listen or
ssh_bind_accept_fd.  The semantics of this option makes more sense to
me.

We also eliminate ssh_bind_options_set_algo, since it is no longer
used.

Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-04-09 10:57:16 +02:00
Andreas Schneider
437a39c798 cmake: Enable creation of the compile command database by default. 2014-04-04 10:03:43 +02:00
Andreas Schneider
b3e6d5df53 packet: Fix function name. 2014-03-27 11:26:27 +01:00
Luka Perkov
53644a14ac style: be consistent when iterating over wanted_methods
Signed-off-by: Luka Perkov <luka.perkov@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 11:23:34 +01:00
Jon Simons
aa05248ca8 packet: elide two buffer_prepend calls into one
In packet_send2, rather than issue two separate buffer_prepend_data calls
(each of which may entail realloc + memmove + memcpy), elide the prepend
work into a single buffer_prepend_data: the header information is computed
locally, and a single 5 byte prepend operation is now done instead of
prepending 1, then 4 bytes.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 11:19:50 +01:00
Andreas Schneider
04543c9dbc doc: Fix ssh_userauth_none() function signature.
Thanks to David Tibbe!

BUG: https://red.libssh.org/issues/151
2014-03-27 11:06:01 +01:00
Alan Dunn
d5aeebe323 socket: Fix style of ssh_socket_pollcallback
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:54:55 +01:00
Alan Dunn
47bd0b6d1f doc: Improve and consolidate ssh_bind_options_set docs
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:49:08 +01:00
Petar Koretic
8e2590b535 libssh: libhpp: overload read function to support timeout parameter
Signed-off-by: Petar Koretic <petar.koretic@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:48:13 +01:00
Petar Koretic
c51f42a566 libssh: libhpp: avoid unnecessary call to ssh_channel_read
ssh_channel_read is a wrapper for ssh_channel_read_timeout with timeout
-1 (infinite) so we call that directly.

Signed-off-by: Petar Koretic <petar.koretic@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:46:21 +01:00
Petar Koretic
00d4fbe753 libssh: libhpp: fix multiple definitions for acceptForward function
Defining a non inlined class function in a header will cause multiple
definitions when header is included in more that one file since for each
file function will get defined.

Signed-off-by: Petar Koretic <petar.koretic@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:45:54 +01:00
Jon Simons
dee8e5688b channel: check for closed state in waitwindow loops
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:34:22 +01:00
Jon Simons
40d81bb7ca kex: enable more ECDSA hostkey algos
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:28:06 +01:00
Jon Simons
10bc5ac203 pki_crypto: guard against NULL pubkey->rsa in signature extraction
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:27:23 +01:00
Luka Perkov
8ba9402282 session: fix comment typo
Signed-off-by: Luka Perkov <luka.perkov@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:16:24 +01:00
Luka Perkov
a2fe341da5 messages: use predefined macro for clearing sensitive data
Signed-off-by: Luka Perkov <luka.perkov@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:16:14 +01:00
Luka Perkov
dbb2de272b client: fix corner case when sockets are manually created
If the sockets are created manually and passed to libssh the internal session
state is set to SSH_SESSION_STATE_SOCKET_CONNECTED. Result of this fix can be
verified by running torture_connect test (torture_connect_socket) with -vvvv
flags.

Signed-off-by: Luka Perkov <luka.perkov@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:15:54 +01:00
Luka Perkov
9423a3a065 tests: torture_connect: add test for user provided socket
Signed-off-by: Luka Perkov <luka.perkov@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:14:35 +01:00
Luka Perkov
0c5d4954a7 tests: torture_connect: fix coding style
Signed-off-by: Luka Perkov <luka.perkov@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:13:57 +01:00
Petar Koretic
0b8d24f800 pki_crypto: Replace deprecated RSA_generate_key() with RSA_generate_key_ex()
On Mar 16, 09:41, Aris Adamantiadis wrote:
> Hi Petar,
> I agree with the principle, but I don't think this code can work...
> RSA_generate_key takes an RSA* as parameter and in our code we probably
> have key->rsa==NULL. (if we don't then the old code had a memory leak).
>
> Does the test case work ?
>
> Aris
>

Yes, you are right. This works, tested with tests/unittests/torture_pki

Signed-off-by: Petar Koretic <petar.koretic@sartura.hr>
2014-03-27 10:11:24 +01:00
Luka Perkov
48354f56ec update gitignore file
The libssh library by default does not allow in-source build (with cmake
MacroEnsureOutOfSourceBuild macro). The INSTALL file (implicitly) suggests
creating a build directory. So lets add build to list of git ignore files to
avoid complaints from git.

Signed-off-by: Luka Perkov <luka.perkov@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:10:48 +01:00
Alan Dunn
5c0c95bd34 examples: Add ECDSA key option to ssh_server_fork
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:06:36 +01:00
Alan Dunn
c82dd2eb81 examples: Add no default keys options to ssh_server_fork
It seems useful to be able to run ssh_server_fork without being
required to load some key of RSA and DSA keytypes.  However, with the
current ssh_server_fork, you need to have some keys as some default
value is set by default and you can't unset the value for a keytype
(e.g. by using NULL as an argument).  So the "no default keys"
argument turns off the default key assignments.

Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:06:11 +01:00
Alan Dunn
f6276fe739 doc: Add ECDSA keys to docs, make key docs consistent
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:05:58 +01:00
Alan Dunn
2a1089d607 options: Allow use of host ECDSA key
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:05:23 +01:00
Andreas Schneider
fbf73ede1e tests: Check the the ecdsa_nid is the same. 2014-03-27 10:01:12 +01:00
Alan Dunn
577840d7f7 tests: Add test case for bug #147
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-27 10:01:01 +01:00
Alan Dunn
3d9b1693eb pki_crypto: Always copy ecdsa_nid into duplicated ECDSA keys
BUG: https://red.libssh.org/issues/147

Signed-off-by: Alan Dunn <amdunn@gmail.com>
2014-03-12 14:14:03 +01:00
Alan Dunn
15f3988bc8 pki: Use SHA-2 for session ID signing with ECDSA keys
Previously, SHA-1 was used always.

BUG: https://red.libssh.org/issues/148

Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-12 14:13:29 +01:00
Luka Perkov
9c2127b798 server: silence build warning
The commit fixes this build warning:

====
src/server.c:223:8: warning: ‘privkey’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     rc = ssh_pki_export_privkey_to_pubkey(*privkey, &pubkey);
        ^
src/server.c:243:11: note: ‘privkey’ was declared here
   ssh_key privkey;
====

Signed-off-by: Luka Perkov <luka.perkov@sartura.hr>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-12 14:12:18 +01:00
Jon Simons
0bb779904d packet: log disconnect code in host byte order
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-12 14:11:09 +01:00
Jon Simons
5eeac3566e bind: only set bindfd after successful listen
In 'ssh_bind_listen', move setting of 'sshbind->bindfd' to only happen after
the listen call: otherwise 'bindfd' can be set to a bogus descriptor for the
case that listen fails.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-03-12 14:09:35 +01:00
Aris Adamantiadis
e99246246b security: fix for vulnerability CVE-2014-0017
When accepting a new connection, a forking server based on libssh forks
and the child process handles the request. The RAND_bytes() function of
openssl doesn't reset its state after the fork, but simply adds the
current process id (getpid) to the PRNG state, which is not guaranteed
to be unique.
This can cause several children to end up with same PRNG state which is
a security issue.
2014-03-04 09:55:28 +01:00
Andreas Schneider
c96e862c08 examples: Add missing include for stderr.
This should fix the build on FreeBSD.
2014-02-17 09:20:46 +01:00
Andreas Schneider
7021a46617 cmake: Merge server examples. 2014-02-16 17:59:46 +01:00
Andreas Schneider
c7cb2d0657 examples: Remove old samplesshd-tty. 2014-02-16 17:58:55 +01:00
Andreas Schneider
fd50a4dd9f examples: Remove old samplesshd. 2014-02-16 17:57:09 +01:00
Audrius Butkevicius
afe97d6cab examples: Add ssh_server_fork example
Signed-off-by: Audrius Butkevicius <audrius.butkevicius@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-16 17:52:50 +01:00
Audrius Butkevicius
00949383f4 config: Add missing HAVE_LIBUTIL_H define in config.h
Signed-off-by: Audrius Butkevicius <audrius.butkevicius@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-16 17:45:47 +01:00
Andreas Schneider
2a1cb323f7 examples: Add missing include on FreeBSD. 2014-02-14 10:33:07 +01:00
Andreas Schneider
4463d89a4a cmake: Check for libutil.h on FreeBSD. 2014-02-14 10:33:07 +01:00
Andreas Schneider
9e0fb9f29b pki: Fix build warning about unused variables. 2014-02-14 10:33:07 +01:00
Audrius Butkevicius
a277dd9277 Add session/channel byte/packet counters
Signed-off-by: Audrius Butkevicius <audrius.butkevicius@elastichosts.com>
2014-02-12 18:21:16 +01:00
Andreas Schneider
370d4b014d pki: Fix the build on OpenSolaris. 2014-02-12 09:39:49 +01:00
Andreas Schneider
7bd5e4101c pki: Fix memory leak with ecdsa signatures. 2014-02-11 10:32:50 +01:00
Andreas Schneider
352c7381a8 cpack: Ignore obj directory. 2014-02-10 10:16:38 +01:00
Andreas Schneider
3e57b54688 packet: Improve readablity of packet decrypt.
After discussion with Aris and it was not obvious enough to understand
the issue we decided to refactor it.

Reviewd-by: Aris Adamantiadis <aris@0xbadc0de.be>
2014-02-06 20:30:29 +01:00
Alan Dunn
2a183440c7 packet_crypt: Make packet_{en,de}crypt fail consistently on len == 0
Right now the behavior of packet_{en,de}crypt on len == 0 depends on
the behavior of malloc.  Instead, make these consistently fail based
on what I assume the desired behavior is due to the first error
message in each.

Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-06 19:41:01 +01:00
Alan Dunn
bb0023b7c7 packet: Do not decrypt zero length rest of buffer
If we receive a packet of length exactly blocksize, then
packet_decrypt gets called on a buffer of size 0.  The check at the
beginning of packet_decrypt indicates that the function should be
called on buffers of at least one blocksize, though the check allows
through zero length.  As is packet_decrypt can return -1 when len is 0
because malloc can return NULL in this case: according to the ISO C
standard, malloc is free to return NULL or a pointer that can be freed
when size == 0, and uclibc by default will return NULL here (in
"non-glibc-compatible" mode).  The net result is that when using
uclibc connections with libssh can anomalously fail.

Alternatively, packet_decrypt (and probably packet_encrypt for
consistency) could be made to always succeed on len == 0 without
depending on the behavior of malloc.

Thanks to Josh Berlin for bringing conneciton failures with uclibc to
my attention.

Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-06 19:41:00 +01:00
Raphael Kubo da Costa
398e8d50b5 build: Use Threads_FOUND to decide whether to build ssh_threads.
Follow-up to 4e04ec8, which caused a regression on OS X.

Checking the value of CMAKE_THREAD_LIBS_INIT to decide whether any threading
library is present on a system turns out to be wrong -- in OS X, for
example, usage of pthreads does not depend on any additional linker or
compiler flags, so CMAKE_THREAD_LIBS_INIT is empty and our check in
src/CMakeLists.txt failed (it used to work before 4e04ec8 because
CMAKE_HAVE_THREADS_LIBRARY is set).

Instead, just look for Threads_FOUND, which FindThreads sets just like any
other Find module when it has found what it was looking for.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-06 11:12:50 +01:00
Jon Simons
fa34d11749 session: skip timestamp init for non-blocking case
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-06 10:21:57 +01:00
Jon Simons
93370d61ba session: add getters for session cipher names
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-06 10:21:07 +01:00
Aris Adamantiadis
22d6c36800 Revert f2c2687ca6
Fix bug #142
The mode does need to be an octal numeric string. Mode 0600 now gets sent on the wire as 0384, triggering a "scp: protocol error: bad mode" response, and an "scp status code 1d not valid" message from libssh.
2014-02-05 22:29:22 +01:00
Aris Adamantiadis
c28ad814d0 knownhosts: resolve leaks found by coverity 2014-02-05 08:07:45 +01:00
Aris Adamantiadis
fdc660f313 knownhosts: detect variations of ecdsa 2014-02-04 22:28:30 +01:00
Audrius Butkevicius
57418dd2cc server: use custom server banners
Value of session->serverbanner never gets used

Signed-off-by: Audrius Butkevicius <audrius.butkevicius@gmail.com>
2014-02-04 15:54:20 +01:00
Raphael Kubo da Costa
4e04ec8bf5 threads: Be less strict when deciding whether to build libssh_threads.
As mentioned in the previous commit, there are cases where
CMAKE_HAVE_THREADS_LIBRARY is not set and pthreads _is_ being used: one can
pass -DTHREADS_HAVE_PTHREAD_ARG=1 to CMake directly so that it just passes
-pthread to the compiler/linker and does not set CMAKE_HAVE_THREADS_LIBRARY.

Since we are only interested in knowing whether any threading library has
been found, we should use CMAKE_THREAD_LIBS_INIT instead (Threads_FOUND
would also work).

Note that, at the moment, there is only a pthreads backend available in
threads/, so if it is not found configuration will fail because CMake will
try to create a library from an empty set of source files.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-03 14:38:39 +01:00
Raphael Kubo da Costa
79a80cdc77 ConfigureChecks: Stop checking for CMAKE_HAVE_THREADS_LIBRARY.
libssh is primarily interested in whether pthreads is present and can be
used. Checking for CMAKE_HAVE_THREADS_LIBRARY is not the same thing, as
there are cases where pthread exists but CMAKE_HAVE_THREADS_LIBRARY is not
set (for example, FreeBSD passes -DTHREADS_HAVE_PTHREAD_ARG=1 to CMake by
default as a way to skip the checks for -lpthread, -lpthreads and others and
tell the build system that -pthread is the one expected to be used).

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-03 14:36:56 +01:00
Jon Simons
95782ada1f socket: fix read of non-connected socket
Ensure to check whether the socket at hand is indeed still connected
throughout POLLIN processing in ssh_socket_pollcallback.

Before this change, the POLLIN block in ssh_socket_pollcallback is
predicated against the condition (s->state == SSH_SOCKET_CONNECTED).
Once entered, data from the socket is consumed through the data
callback in this loop:

  do {
    r = s->callbacks->data(buffer_get_rest(s->in_buffer),
                           buffer_get_rest_len(s->in_buffer),
                           s->callbacks->userdata);
    buffer_pass_bytes(s->in_buffer,r);
  } while (r > 0);

However, it is possible for the socket data callback to change the
state of the socket (closing it, for example).  Fix the loop to only
continue so long as the socket remains connected: this also entails
setting the ssh_socket state to SSH_SOCKET_CLOSED upon close.

The bug can be observed before the change by sending a bogus banner
to the server: 'echo -e "A\r\nB\r\n" | nc localhost 22'.  Each of
'A' and 'B' will be processed by 'callback_receive_banner', even
though the client socket is closed after rejection of 'A'.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-02 22:19:46 +01:00
Jon Simons
f7b61bf557 doc: correct ssh_channel_read_timeout units
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-02 22:19:46 +01:00
Audrius Butkevicius
adf4d4f147 doc: Document expected return value of channel data callback
Signed-off-by: Audrius Butkevicius <audrius.butkevicius@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-02 22:19:46 +01:00
Audrius Butkevicius
dc93edc932 src: Fix argument order in ssh_channel_pty_window_change_callback
So that it would match ssh_channel_pty_request_callback as well as the documentation

Signed-off-by: Audrius Butkevicius <audrius.butkevicius@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-02 22:19:46 +01:00
Joseph Southwell
6bbdaceaca src: Define MAX_BUF_SIZE globally and use it.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-02 22:19:46 +01:00
Joseph Southwell
eedecd0269 client: Fix EOF session error reporting.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-02 22:19:46 +01:00
Oleksandr Shneyder
d904784489 Make function ssh_channel_accept() nonblocking if timeout is 0.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-02-02 22:19:45 +01:00
Aris Adamantiadis
31fb4e1e69 build: remove OSX deprecated warnings for openssl 2014-02-02 21:41:32 +01:00
Aris Adamantiadis
3bdc2b1d4f build: fix cmake bug introduced yesterday
Compilation failed on OSX because of the missing OR OSX
2014-02-02 20:56:21 +01:00
Aris Adamantiadis
1e37430dbe Kex: fix coverity warning + edge case 2014-02-02 20:50:36 +01:00
Aris Adamantiadis
671f1979a6 server: allow custom server banners (bug #83) 2014-02-01 18:00:01 +01:00
Aris Adamantiadis
fdaa42da1a Knownhosts: implement hostkey with knownhosts heuristic 2014-02-01 17:34:16 +01:00
Aris Adamantiadis
8d450ef81a knownhosts: add test case for bug #138 2014-02-01 16:48:36 +01:00
Aris Adamantiadis
c433ac02bd known_hosts: add ssh_knownhosts_algorithms()
Goal of that function is to test the preferred key exchange methods
based on what's available in the known_hosts file
2014-02-01 16:42:29 +01:00
Aris Adamantiadis
1c24a0508f Added known host test cases 2014-02-01 15:33:15 +01:00
Aris Adamantiadis
f0d6ce8958 tests: fix compilation on OSX (libargp detection) 2014-02-01 14:49:57 +01:00
Andreas Schneider
75be42df75 pki_crypto: Fix memory leak with EC_KEY_set_public_key().
BUG: https://red.libssh.org/issues/146
2014-01-28 11:56:59 +01:00
Andreas Schneider
3224506fe0 doc: Document the unit for ssh_select() timeout.
BUG: https://red.libssh.org/issues/143
2014-01-23 11:29:39 +01:00
Rod Vagg
d4d30d0375 dh: Fix NULL check for p_group14.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-01-23 11:21:51 +01:00
Jon Simons
7ff6b3537f pki_crypto: fix DSA signature extraction
Fix the DSA portion of 'pki_signature_to_blob': before this change, it
is possible to sometimes observe DSA signature validation failure when
testing with OpenSSH clients.  The problem ended up being the following
snippet which did not account for the case when 'ssh_string_len(x)' may
be less than 20:

  r = make_bignum_string(sig->dsa_sig->r);
  ...
  memcpy(buffer,
         ((char *) ssh_string_data(r)) + ssh_string_len(r) - 20,
         20);

Above consider the case that ssh_string_len(r) is 19; in that case the
memcpy unintentionally starts in the wrong place.  The same situation
can happen for value 's' in this code.

To fix, adjust the offsets used for the input and output pointers, taking
into account that the lengths of 'r' and 's' can be less than 20.  With
the fix I am no longer able to reproduce the original failure mode.

BUG: https://red.libssh.org/issues/144

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-01-23 11:17:13 +01:00
Andreas Schneider
368509f5d1 pki: Use ssh_buffer_add_data() in pki_gcrypt.. 2014-01-22 16:12:31 +01:00
Alan Dunn
7eff889384 doc: Fix description of error parameter for ssh_get_error*
ssh_get_error can actually work on anything with an ssh_common_struct
as its first member.  It is already used in examples in the
distribution with ssh_sessions and ssh_binds.

Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-01-22 09:45:45 +01:00
Jon Simons
465816f4a0 pki_crypto: pad RSA signature blobs
Pad RSA signature blobs to the expected RSA signature length
when processing via 'pki_signature_to_blob'.

Some clients, notably PuTTY, may send unpadded RSA signatures
during the public key exchange: before this change, one can
sometimes observe failure in signature validation when using
PuTTY's 'plink' client, along these lines:

   ssh_packet_process: ssh_packet_process: Dispatching handler for packet type 50
   ssh_packet_userauth_request: ssh_packet_userauth_request: Auth request for service ssh-connection, method publickey for user 'foo'
   ssh_pki_signature_verify_blob: ssh_pki_signature_verify_blob: Going to verify a ssh-rsa type signature
   pki_signature_verify: pki_signature_verify: RSA error: error:04091077:rsa routines:INT_RSA_VERIFY:wrong signature length
   ssh_packet_userauth_request: ssh_packet_userauth_request: Received an invalid  signature from peer

For cross-reference this issue once also existed between
PuTTY and OpenSSH:

  http://www.chiark.greenend.org.uk/~sgtatham/putty/wishlist/rsa-verify-failed.html

  http://www.openbsd.org/cgi-bin/cvsweb/src/usr.bin/ssh/ssh-rsa.c?rev=1.19;content-type=text%2Fx-cvsweb-markup

With the fix I am unable to reproduce the above failure mode when
testing with 'plink'.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-01-21 16:11:12 +01:00
Alan Dunn
9fff70fa41 Test change to ssh_bind_accept_fd
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-01-21 16:07:09 +01:00
Alan Dunn
d3e081ba44 Import keys during ssh_bind_accept_fd
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-01-21 16:07:04 +01:00
Alan Dunn
086847f997 Separate out key import functionality from ssh_bind_listen
Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-01-21 16:06:53 +01:00
Andreas Schneider
cb9786b3ae src: Rename buffer_add_data() to ssh_buffer_add_data(). 2014-01-19 20:55:55 +01:00
Andreas Schneider
9c4144689d src: Rename buffer_init to ssh_buffer_init(). 2014-01-19 20:43:29 +01:00
Andreas Schneider
e745236ae5 doc: Fix channel documentation. 2014-01-17 11:08:49 +01:00
Andreas Schneider
13eef19000 pki: Do not use deprecated string functions. 2014-01-17 09:29:24 +01:00
Andreas Schneider
2fe59071b2 src: Do not use deprecated functions. 2014-01-16 15:27:46 +01:00
Andreas Schneider
a7157b7907 include: Mark functions as deprecated! 2014-01-16 15:27:23 +01:00
Jon Simons
6007c3c43f bind: fix possible double-frees in ssh_bind_free
Make sure to explicitly set key pointers to NULL following the use
of 'ssh_key_free' throughout bind.c.

Before this change, a double free can happen via 'ssh_bind_free'
as in this example callpath:

  // create an ssh_bind
  ssh_bind b = ssh_bind_new();

  // provide a path to a wrong key-type
  ssh_bind_options_set(b, SSH_BIND_OPTIONS_DSAKEY, path_to_rsa_key);

  // initialize set key-type
  ssh_bind_listen(b);

    -> error path "The DSA host key has the wrong type: %d",

       ssh_key_free(sshbind->dsa)

         -> ssh_key_clean(key) // OK

         -> SAFE_FREE(key)     // OK, but, sshbind->dsa is *not* set to NULL

  // ssh_bind_listen failed, so clean up ssh_bind
  ssh_bind_free(b);

    -> ssh_key_free(sshbind->dsa)  // double-free here

To fix, set pointers to NULL that have been free'd with 'ssh_key_free'.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-01-16 09:27:41 +01:00
Andreas Schneider
9d1ddd0547 doc: Add changes to the forwarding tutorial. 2014-01-16 09:13:06 +01:00
Andreas Schneider
5229253f86 channel: Fix the name scheme of the forward functions. 2014-01-16 09:13:06 +01:00
Oleksandr Shneyder
a1c4fc07d4 channel: Add ssh_channel_accept_forward().
This works same way as ssh_forward_accept() but can return a destination
port of the channel (useful if SSH connection forwarding several TCP/IP
ports).

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2014-01-16 09:12:03 +01:00
Andreas Schneider
6d09104ad3 Rename build directory to obj.
Some buildsystem use build in the pathname and so we will filter out
e.g. docs generation.
2014-01-16 08:53:32 +01:00
Aris Adamantiadis
57ef959aa3 threads: support libgcrypt 1.6 hack
Not 100% satisfied of this patch, but the way libgcrypt handles
threading in 1.6 is not compatible with custom handlers. The
new code basicaly uses pthreads in every case. This will probably
not work on windows.
2014-01-08 18:57:31 +01:00
Andreas Schneider
b617d7fa29 include: Remove warning cause VSC doesn't know about it. 2014-01-08 10:55:20 +01:00
Andreas Schneider
4b3363ecf2 include: Fix building if we do not have asm volatile. 2014-01-08 10:52:29 +01:00
Andreas Schneider
6fe51b13fb src: Update my mail address. 2014-01-07 16:08:23 +01:00
Andreas Schneider
8bcbfb1642 cmake: Remove unused macro modules. 2014-01-07 16:07:00 +01:00
Aris Adamantiadis
aecd952d18 update copyright information 2014-01-07 15:18:15 +01:00
Aris Adamantiadis
fedb1b3def tests: avoid reading uninitialized bytes 2014-01-07 14:43:46 +01:00
Aris Adamantiadis
8fdfa13227 pki: fix gcrypt signature process 2014-01-07 14:20:49 +01:00
Andreas Schneider
9d90d15e91 examples: Make sure buffer is initialized. 2014-01-07 09:19:02 +01:00
Andreas Schneider
09a715b147 example: Add missing include for forkpty(). 2014-01-07 09:03:53 +01:00
Aris Adamantiadis
42ad55377f test: fixed torture_auth_none condition 2014-01-06 22:09:43 +01:00
Aris Adamantiadis
d771dafe04 test: test case for async auth_none
This test currently fails
2014-01-06 16:52:44 +01:00
Aris Adamantiadis
09af855b6f tests: auth_agent_nonblocking should run in nonblocking 2014-01-06 16:52:44 +01:00
Aris Adamantiadis
0571360f37 tests: use LC_LIBSSH instead of LANG for env tests.
LANG is stripped and replaced on many distros and LC_* is accepted
by default on debian
2014-01-06 16:17:16 +01:00
Andreas Schneider
f3e3700063 session: Fix a possible memory leak. 2014-01-05 23:05:13 +01:00
Aris Adamantiadis
41fe03e0d6 poll: fix poll_handles ownerships 2014-01-05 22:33:45 +01:00
Aris Adamantiadis
b514957af7 socket: don't attempt reading a non-connected socket 2014-01-05 21:54:08 +01:00
Andreas Schneider
d9c5d0767c examples: Fix building samplesshd-tty on FreeBSD. 2013-12-26 09:42:32 +01:00
Andreas Schneider
8f162e3b13 poll: Correctly free ssh_event_fd_wrapper.
This is allocated by ssh_event_add_fd.
2013-12-22 22:08:45 +01:00
Andreas Schneider
32ba84dac7 config: Support expansion in the Host variable too.
BUG: https://red.libssh.org/issues/127
2013-12-21 12:30:32 +01:00
Andreas Schneider
7f806b7c68 tests: Fix non-blocking auth tests.
The ssh_userauth_none() call should already be non-blocking. However
this this function is broken in non-blocking mode. It should reveal the
existing bug.
2013-12-15 21:03:00 +01:00
Andreas Schneider
a6107f7432 tests: Fix blocking mode in password auth test. 2013-12-15 20:42:18 +01:00
Andreas Schneider
9829aa2236 tests: Use new auth API in the torture_session test. 2013-12-15 20:29:30 +01:00
Andreas Schneider
f8debe9a19 tests: Use new auth API in the torture_auth test. 2013-12-15 20:26:17 +01:00
Andreas Schneider
8b407f1ca2 tests: Fix pki test with gcrypt. 2013-12-11 21:11:49 +01:00
Jon Simons
20b5734649 channel: fix setting of channel->flags
Fix the setting of 'channel->flags' to use '|='.  Before this
change, one bug symptom can be that channels are never fully
free'd via ssh_channel_free, resulting in memory leaks.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-12-11 21:02:47 +01:00
Jon Simons
0557f57c63 client: use ssh_channel_do_free in ssh_disconnect
Ensure to use 'ssh_channel_do_free' in 'ssh_disconnect', when removing and
free'ing up a session's channels.  This matches the behavior in 'ssh_free',
and is necessary to fully free any channel which may not have been closed
completely (see usage of flags SSH_CHANNEL_FLAG_CLOSED_REMOTE,
SSH_CHANNEL_FLAG_FREED_LOCAL).

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-12-11 21:02:05 +01:00
Andreas Schneider
4f4e917187 bind: Correctly free all memory in ssh_bind_free().
Thanks to Jacob Baines.
2013-12-09 19:49:54 +01:00
Jon Simons
a1f0b2acfc session: Add ssh_get_clientbanner(). 2013-12-07 16:24:33 +01:00
Andreas Schneider
d65777b570 channels: Add a ssh_channel_read_timeout function. 2013-12-04 20:34:13 +01:00
Andreas Schneider
2df00fd84c tests: Try to fix torture_forward. 2013-12-04 14:21:52 +01:00
Andreas Schneider
d1d3beac33 tests: Fix memory leaks. 2013-11-28 14:40:11 +01:00
Andreas Schneider
ad0abff8b3 tests: Add missing line breaks. 2013-11-28 11:49:11 +01:00
Andreas Schneider
cdd7a6cb8d pki: Fix a memory leak.
CID #1132819
2013-11-28 09:09:45 +01:00
Andreas Schneider
004240af48 tests: Add torture_pki_write_privkey_ecdsa test. 2013-11-27 22:54:13 +01:00
Andreas Schneider
4e3d16e291 tests: Add torture_pki_write_privkey_dsa test. 2013-11-27 22:54:13 +01:00
Andreas Schneider
7933aef747 tests: Add torture_pki_write_privkey_rsa test. 2013-11-27 22:54:13 +01:00
Andreas Schneider
136efd6ed5 pki: Add ssh_pki_import_privkey_file(). 2013-11-27 22:54:13 +01:00
Andreas Schneider
94969cf263 pki_crypto: Add pki_private_key_to_pem(). 2013-11-27 22:54:13 +01:00
Andreas Schneider
68c3c26029 pki_gcrypt: Add pki_private_key_to_pem() stub. 2013-11-27 22:54:13 +01:00
Andreas Schneider
fd185acbea curve25519: Fix memory leaks in ssh_server_curve25519_init().
CID #1125255
2013-11-27 20:26:14 +01:00
Andreas Schneider
7a4e8e58f0 curve25519: Do not leak q_s_string.
CID #1125256
2013-11-27 20:20:07 +01:00
Andreas Schneider
cbeb2a9de7 curve25519: Fix a memory leak.
CID #1125257
2013-11-27 20:18:25 +01:00
Andreas Schneider
d61fcbf7b2 examples: Fix else branch.
CID #1127816
2013-11-27 20:16:09 +01:00
Andreas Schneider
75e61f498b packet: Remove logically dead code.
CID #1128796
2013-11-27 20:14:02 +01:00
Andreas Schneider
09edee123a tests: Try to fix valgrind warnings. 2013-11-27 18:04:44 +01:00
Andreas Schneider
060171028c tests: Fix a valgrind warning. 2013-11-27 17:55:48 +01:00
Andreas Schneider
7ecdc3e0d5 ecdh: Check if we have ECC support. 2013-11-27 17:38:21 +01:00
Andreas Schneider
67a080874b ecdh: Use bignum_bin2bn. 2013-11-27 17:35:36 +01:00
Nicolas Viennot
7b63fe2f22 server: Add a ssh_send_keepalive() function.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-24 23:21:04 +01:00
Jon Simons
3d934f3ddc channel: fix infinite loop in channel_write_common
BUG: https://red.libssh.org/issues/130

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-22 10:34:23 +01:00
Rod Vagg
06cc94eecf flush channel after EOF and CLOSE 2013-11-18 17:22:30 +01:00
Aris Adamantiadis
f6443b725a logging: fix server-side logging 2013-11-18 15:29:27 +01:00
Aris Adamantiadis
d8ead516de gssapi: fix logging 2013-11-18 15:11:26 +01:00
Aris Adamantiadis
ccdc0f1805 sockets: null pointer check 2013-11-18 14:42:40 +01:00
Simo Sorce
66e7e7023b gssapi: Fix support of delegated credentials
In a previous refactoring patch, the code underpinning the
ssh_gssapi_set_creds() API was inadvertently removed. This patch
fixes the problem.

Also clarify what variable holds which credentials and insure that
credentials created within the library are propelry freed.

Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-15 23:32:20 -05:00
Simo Sorce
b4fc5d9524 gssapi: Add support for GSSAPIDelegateCredentials config option.
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-15 16:53:59 -05:00
Simo Sorce
811c645f2a options: Add SSH_OPTIONS_GSSAPI_DELEGATE_CREDENTIALS option.
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-15 16:10:29 -05:00
Andreas Schneider
c2312f9dda gssapi: Add error checks and cleanup the code in ssh_gssapi_auth_mic(). 2013-11-15 16:28:49 +01:00
Simo Sorce
440d2ec0ea gssapi: Use GSSAPIClientIdentity to acquire creds
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-15 16:19:28 +01:00
Andreas Schneider
47e53deebd gssapi: Add support for GSSAPIClientIdentity config option. 2013-11-15 15:50:09 +01:00
Andreas Schneider
095a01b70c options: Add SSH_OPTIONS_GSSAPI_CLIENT_IDENTITY option. 2013-11-15 15:50:09 +01:00
Andreas Schneider
503c729bb0 gssapi: Add support for GSSAPIServerIdentity config option. 2013-11-15 15:50:09 +01:00
Andreas Schneider
41d99d32e8 gssapi: Add suppport to set GSSAPI server identity. 2013-11-15 15:50:09 +01:00
Simo Sorce
c481f9dafd Fix gssapi credential handling.
- Properly acquire and inquitre credentials to get the list of available
credentials.
- Avoid enforcing a specific username it breaks some use cases (k5login).
- Remove confusing references to delegated credentials as there is no code
that actually uses delegated credentials in the initialization case.

Signed-off-by: Siom Sorce <simo@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-15 14:49:29 +01:00
Andreas Schneider
f240ecf328 socket: Fix connect if we pass in a fd.
BUG: https://red.libssh.org/issues/106

Thanks to Saju Panikulam.
2013-11-15 08:47:58 +01:00
Andreas Schneider
1972a27fe0 packet: Remove dead code. 2013-11-14 11:43:49 +01:00
Andreas Schneider
097760db17 packet: Set the packet to the processed data position.
Else we could end up with packet - current_macsize if to_be_read is 0.
2013-11-14 11:42:21 +01:00
Andreas Schneider
b3a08ba8d3 dh: Fix wrong assignment.
Ups, sorry.
2013-11-14 08:08:49 +01:00
Andreas Schneider
fef7e1dffe poll: Fix realloc in ssh_poll_ctx_resize(). 2013-11-09 13:27:59 +01:00
Andreas Schneider
6d7bbe63fe dh: Avoid possible memory leaks with realloc. 2013-11-09 13:20:13 +01:00
Andreas Schneider
387e26c837 packet: Refactor ssh_packet_socket_callback().
Make error checking more readable and add additional NULL checks.
2013-11-09 13:10:41 +01:00
Andreas Schneider
e8e99ec6de server: Fix malloc call. 2013-11-09 12:47:02 +01:00
Colin Walters
13c4499449 session: Always request POLLIN
The assumption is that if libssh functions are being invoked, we want
to read data.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-09 12:29:07 +01:00
Colin Walters
4cc7f4ad03 Add ssh_get_poll_flags()
For integration with an external mainloop, we need to know how to
replicate libssh's internal poll() calls.  We originally through
ssh_get_status() was that API, but it's not really - those flags only
get updated from the *result* of a poll(), where what we really need
is to know how libssh would *start* a poll().

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-09 12:26:19 +01:00
Colin Walters
a8dc67ded8 client: If we have a pre-connected FD, set state to SOCKET_CONNECTED
Otherwise applications providing their own fd end up tripping an
assertion, since the session is just in _CONNECTING.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-09 12:25:41 +01:00
Andreas Schneider
aa33d18930 example: Use ssh_get_publickey_hash(). 2013-11-06 17:10:41 +01:00
Andreas Schneider
8c5777554a dh: Move ssh_get_hexa() and ssh_print_hexa() down.
This way they are in the documentation block for the session and we get
documentation for them.
2013-11-06 17:10:41 +01:00
Andreas Schneider
06cd9bc4dc dh: Add new ssh_get_publickey_hash() function. 2013-11-06 17:10:35 +01:00
Andreas Schneider
0c8984ba9f doc: Add curve25519 to features list. 2013-11-05 13:15:11 +01:00
Andreas Schneider
6f0f1ef292 doc: Fix doxygen warnings. 2013-11-04 21:55:29 +01:00
Aris Adamantiadis
b12f3f38c7 Fix cast warnings on 64bits 2013-11-04 10:49:32 +01:00
Aris Adamantiadis
cb165df64e remove warnings on OSX (workaround) 2013-11-04 10:47:22 +01:00
Aris Adamantiadis
e4c4f57f05 logging: fix wording 2013-11-04 10:31:10 +01:00
Aris Adamantiadis
c5ef5ed18f curve25519: include reference implementation 2013-11-03 14:58:10 +01:00
Aris Adamantiadis
ebf4a03908 examples: fix forktty() warning on OSX 2013-11-03 14:10:04 +01:00
Aris Adamantiadis
4f3ee2fc7e Fix examples compilation on OSX (libargp) 2013-11-03 13:49:27 +01:00
Aris Adamantiadis
f565aeebfa Compile libssh with nacl if possible
Conflicts:
	DefineOptions.cmake
2013-11-03 13:18:26 +01:00
Aris Adamantiadis
04cb94a2dd socket: Fix check for pending data.
BUG: https://red.libssh.org/issues/119

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-03 12:46:27 +01:00
Nicolas Viennot
754152aa22 server: Fix ssh_execute_server_callbacks() client execution
When the public key auth handler is executed and returns SSH_OK,
ssh_execute_server_callbacks() still runs some client callbacks,
which may set rc to SSH_AGAIN, which triggers a default reply on
auth, denying auth.

Signed-off-by: Nicolas Viennot <nicolas@viennot.biz>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-03 10:52:38 +01:00
Nicolas Viennot
1ef00045dd server kex: enable delayed compression
The code is careful to reenable compression when rekeying.

Signed-off-by: Nicolas Viennot <nicolas@viennot.biz>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-03 10:48:59 +01:00
Andreas Schneider
a466a624e2 session: Make sure we correctly burn the buffer. 2013-11-03 10:45:02 +01:00
Andreas Schneider
643a3b7cc3 wrapper: Make sure we really burn the buffer. 2013-11-03 10:39:31 +01:00
Andreas Schneider
d2dea8dc2e priv: Fix brackets of burn macros. 2013-11-03 10:24:47 +01:00
Andreas Schneider
6edb6bcca1 doc: Add missing RFCs. 2013-11-03 09:35:35 +01:00
Jon Simons
d4f5a0e6ab server: fix pubkey reply for key probes
Per RFC 4252, it is required to send back only one of either
SSH_MSG_USERAUTH_PK_OK or SSH_MSG_USERAUTH_FAILURE for public
key probes.

Update the handling of 'auth_pubkey_function' to send back PK_OK
instead of SSH_MSG_USERAUTH_SUCCESS for the case that the state
of the message at hand is SSH_PUBLICKEY_STATE_NONE.

With this change, it is now possible to process an initial key probe
and then subsequent signature validation using the server callbacks.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-02 21:02:56 +01:00
William Orr
ce1d73e0f0 ssh_options_get can now return ProxyCommand
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-11-02 21:02:56 +01:00
Jon Simons
20caa68b84 connect: fix memory leak in ssh_select
Balance 'ssh_event_add_fd' with 'ssh_event_remove_fd' in 'ssh_select'.

BUG: https://red.libssh.org/issues/128

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-10-31 12:45:21 +01:00
Andreas Schneider
b00a6e3885 tests: Add a test for ssh_channel(). 2013-10-31 12:44:48 +01:00
Jon Simons
ffc33ca28c poll: fix leak in ssh_poll_ctx_free
Fix a memory leak in 'ssh_poll_ctx_free': issue 'ssh_poll_free'
to remove the poll handle from its context and free it.

BUG: https://red.libssh.org/issues/128

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-10-31 11:55:09 +01:00
Alan Dunn
ee95c05c08 SSH_AUTH_OK -> SSH_AUTH_SUCCESS in comments
A few callback descriptions refer to a non-existent value SSH_AUTH_OK,
which should be SSH_AUTH_SUCCESS.  This commit fixes these.

Signed-off-by: Alan Dunn <amdunn@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-10-31 08:18:55 +01:00
Andreas Schneider
cfea381307 cmake: Check for isblank(). 2013-10-30 17:30:07 +01:00
Jon Simons
099b914fd9 bind: fix leak in ssh_bind_accept error path
Use 'ssh_socket_free' to cleanup if 'ssh_bind_accept_fd'
fails, to be sure to free the ssh_socket in/out buffers.
2013-10-24 10:37:37 +02:00
Andreas Schneider
afd35fa98c tests: Add a sftp_read blocking test. 2013-10-23 15:49:07 +02:00
Colin Walters
f02bc4768e auth: docs: Fix typo optoins -> options
I'm just getting my feet wet with this codebase.

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-10-23 09:55:09 +02:00
Andreas Schneider
bcb162816e doc: Improve sftp_read_sync() example. 2013-10-23 09:53:16 +02:00
Andreas Schneider
5baa6aed6b include: Fix build on platforms without ECC. 2013-10-21 07:15:59 +02:00
Andreas Schneider
6a6e85752e tests: Add a test for ssh_channel_request_env(). 2013-10-20 17:05:35 +02:00
Andreas Schneider
4421540b7b tests: We can't test the accept right now. 2013-10-20 13:28:53 +02:00
Andreas Schneider
d3c186b04c tests: Fix torture_forward. 2013-10-20 13:23:31 +02:00
Andreas Schneider
e30acdb58a channel: Reinit the buffer and reset the state on error.
BUG: https://red.libssh.org/issues/126
2013-10-20 12:46:57 +02:00
Andreas Schneider
b0cbe88b0b channel: Fix ssh_global_request_termination().
BUG: https://red.libssh.org/issues/126
2013-10-20 12:46:17 +02:00
Andreas Schneider
3afba83134 tests: Add torture forward test. 2013-10-20 12:46:17 +02:00
Andreas Schneider
b8d47a438c pki: Don't leak a buffer. 2013-10-19 10:41:57 +02:00
Andreas Schneider
5201c5850e wrapper: Fix compilation with gcrypt. 2013-10-19 10:39:00 +02:00
Andreas Schneider
bd8ab422d0 pki_crpypto: Fix ecdsa signature to blob.
BUG: https://red.libssh.org/issues/118
2013-10-18 23:48:21 +02:00
Andreas Schneider
33890daf41 pki: Add support for ECDSA private key signing. 2013-10-18 23:22:24 +02:00
Andreas Schneider
ac4c5699b1 pki: Add the type as a char pointer. 2013-10-18 23:22:24 +02:00
Andreas Schneider
15e31eb464 wrapper: Add more evp functions. 2013-10-18 23:22:24 +02:00
Andreas Schneider
2e81dd61dd client: Fix the build. 2013-10-18 21:18:36 +02:00
Oliver Stöneberg
f2c2687ca6 scp: Fixed result of ssh_scp_string_mode() to get SCP working.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-10-18 14:58:47 +02:00
Oliver Stöneberg
4c300313c3 client: Added a missing NULL pointer check.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-10-18 14:57:33 +02:00
Andreas Schneider
bec13a6ac0 doc: Make sure we have the defines to build all docs. 2013-10-14 15:39:33 +02:00
Andreas Schneider
423d8c9b6a channel: Fix packets termination timeout in global_request().
BUG: https://red.libssh.org/issues/126
2013-10-01 14:50:56 +02:00
Andreas Schneider
685fe1d0b6 session: Try the ecdsa default key first. 2013-10-01 14:45:01 +02:00
Tristan CACQUERAY
e588e2325d callbacks: add support for auth_none_function 2013-09-27 15:34:45 +02:00
Aris Adamantiadis
04fd756c49 doc: Documentation of curve25519-sha256@libssh.org 2013-09-27 15:32:52 +02:00
Aris Adamantiadis
4cb6afcbd4 kex: implement curve25519-sha256@libssh.org 2013-09-27 15:32:44 +02:00
Andreas Schneider
4eae4d592c channels: Correctly handle timeouts in channel functions. 2013-09-17 11:23:56 +02:00
Andreas Schneider
566d842405 channel: Use the correct timeout option in channel_open().
BUG: https://red.libssh.org/issues/124
2013-09-17 11:19:49 +02:00
Andreas Schneider
5e2fbbc202 callbacks: Improve the documentation of ssh_threads_set_callbacks().
BUG: https://red.libssh.org/issues/123
2013-09-16 10:54:30 +02:00
Andreas Schneider
8e703b9974 callbacks: Improve the documentation of ssh_threads_get_noop().
BUG: https://red.libssh.org/issues/123
2013-09-16 10:50:25 +02:00
Andreas Schneider
89853607c5 session: Document return value of ssh_get_serverbanner().
BUG: https://red.libssh.org/issues/122
2013-09-16 10:38:14 +02:00
Andreas Schneider
20658abc78 session: Remove obsolete status variables.
BUG: https://red.libssh.org/issues/121
2013-09-16 10:38:14 +02:00
Andreas Schneider
8823dee51a client: Add example code for ssh_get_openssh_version().
BUG: https://red.libssh.org/issues/120
2013-09-16 10:38:14 +02:00
Andreas Schneider
3e07359a35 channels: Correctly decrement timeout value in ssh_channel_accept().
BUG: https://red.libssh.org/issues/116
2013-09-16 10:38:14 +02:00
Andreas Schneider
e9242a7a31 channel: Document SSH_AGAIN in ssh_channel_read().
BUG: https://red.libssh.org/issues/115
2013-09-16 10:38:14 +02:00
Andreas Schneider
b9ada25296 cmake: Allow to build without examples.
BUG: https://red.libssh.org/issues/114
2013-09-16 10:38:14 +02:00
Andreas Schneider
33cb1bc08b doc: Improve the PKI documentation a bit. 2013-09-10 06:59:25 +02:00
Andreas Schneider
6da54688eb doc: Update documentation of ssh_set_blocking().
This should work correctly in libssh 0.6.0. If not then you hit a bug.
2013-09-09 16:43:46 +02:00
Andreas Schneider
ef6d19fbb1 clang_complete: Update definitons. 2013-08-13 12:09:59 +02:00
Andreas Schneider
acbca6a562 ecdh: Refactor ecdh_build_k to check errors codes. 2013-08-13 12:09:36 +02:00
Andreas Schneider
fc8081cd06 channel: Refactor channel_write_common() code.
This makes it easier to read and easier to debug.
2013-08-13 08:22:28 +02:00
Andreas Schneider
7a64dd1b9a channel: Make channel_write_common() static. 2013-08-13 08:17:15 +02:00
Andreas Schneider
5045133dc2 channel: Use MIN macro in channel_write_common(). 2013-08-13 08:15:37 +02:00
Andreas Schneider
7f2049b0d5 include: Add a MIN macro. 2013-08-13 08:15:16 +02:00
Andreas Schneider
aa3eeb38f9 scp: Document more scp functionts. 2013-08-12 11:24:38 +02:00
Nicolas Viennot
af99a4dc05 server kex: Fix server side compression typo
The original code had a typo (COMP was CRYPT). This fixes the zlib compression
method.

Signed-off-by: Nicolas Viennot <nicolas@viennot.biz>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-08-05 18:27:23 +02:00
Andreas Schneider
e800269013 INSTALL: Fix source directory. 2013-08-05 18:27:23 +02:00
Andreas Schneider
ad709edadb Update INSTALL. 2013-08-05 15:07:21 +02:00
Andreas Schneider
0774da3c40 Update ChangeLog. 2013-08-05 11:07:27 +02:00
Andreas Schneider
f1ec4f11e3 cmake: Add CMOCKA_ROOT_DIR with hints and paths. 2013-08-01 16:55:40 +02:00
Andreas Schneider
3eb66cba37 doc: Update Features section. 2013-08-01 14:19:25 +02:00
Andreas Schneider
514a01f3df doc: Remove obsolete Trac header and footer. 2013-08-01 14:12:33 +02:00
Andreas Schneider
9156b8c068 doc: Better explain LIBSSH_STATIC. 2013-08-01 14:12:19 +02:00
Andreas Schneider
1067591480 cmake: Fix configure check for ntohll and htonll. 2013-07-27 11:27:09 +02:00
Andreas Schneider
7375de0b05 include: Fix a build warning in MinGW. 2013-07-27 10:55:53 +02:00
Andreas Schneider
51296a0237 tests: Add suppression for getdelim with selinux. 2013-07-26 08:04:03 +02:00
Andreas Schneider
6efa55d154 session: Add parentheses to fix a build warning. 2013-07-26 07:50:37 +02:00
Andreas Schneider
f9b8395122 session: Handle session state in ssh_get_status().
BUG: https://red.libssh.org/issues/109
2013-07-25 22:43:09 +02:00
Nicolas Viennot
cdf193d8b5 session: ssh_handle_packets_termination() SSH_AGAIN bug fix
ssh_handle_packets_termination() must not return SSH_OK when exiting due to
a timeout while the termination function still returns 1.

Signed-off-by: Nicolas Viennot <nicolas@viennot.biz>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-25 22:35:03 +02:00
Nicolas Viennot
2f674aeec1 channels: allow channel_open() to return SSH_AGAIN
Signed-off-by: Nicolas Viennot <nicolas@viennot.biz>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-25 22:34:51 +02:00
Andreas Schneider
74bbcf7e29 doc: Don't generate latex documentation. 2013-07-25 12:29:07 +02:00
Andreas Schneider
26c118890f cmake: Only build with _FORTIFY_SOURCE on release builds. 2013-07-25 10:02:01 +02:00
Andreas Schneider
38420bff76 gssapi: Fix a build warning if we build without server support. 2013-07-25 10:01:38 +02:00
Andreas Schneider
1444d62d96 cmake: Document GSSAPI_FLAVOR_MIT and GSSAPI_FLAVOR_HEIMDAL. 2013-07-24 20:52:39 +02:00
Andreas Schneider
5ba88f01e8 cmake: Rewrote FindGSSAPI.cmake. 2013-07-24 20:48:14 +02:00
Andreas Schneider
6a83f9a044 gssapi: Fix include with Heimdal. 2013-07-24 20:41:41 +02:00
Andreas Schneider
61084b76f6 example: Fix a memory leak on error in tty server.
CID: #1032746
2013-07-24 17:38:27 +02:00
Andreas Schneider
c55ab44caf cmake: Update FindNSIS module. 2013-07-24 11:17:30 +02:00
Andreas Schneider
90e5ce3c3e cmake: Set HAVE_GETADDRINFO if we have libsocket.
This fixes the build on Solaris.
2013-07-24 07:54:11 +02:00
Andreas Schneider
448738eb00 cmake: Change start time to UTC. 2013-07-24 07:49:27 +02:00
Andreas Schneider
e1280ce153 gssapi: Fix a memory leak in ssh_gssapi_auth_mic().
CID: 1046708
2013-07-23 12:27:55 +02:00
Andreas Schneider
11c45b0f55 callbacks: Fix value assigning.
CID: 1046709
2013-07-23 12:25:18 +02:00
Andreas Schneider
e1576ef55a cmake: Don't build examples on Windows but on Unix. 2013-07-23 10:44:51 +02:00
Andreas Schneider
df81a05505 cmake: Check for unistd.h. 2013-07-23 10:44:51 +02:00
Andreas Schneider
7d07e1f1bd cmake: If we don't have gssapi libs, disable it. 2013-07-23 10:44:51 +02:00
Andreas Schneider
1829e9981b cmake: Check for HAVE_GCC_VOLATILE_MEMORY_PROTECTION.
This ensures that the memset call is not optimized out by the compiler
(works works with gcc and clang).
2013-07-23 10:44:39 +02:00
Andreas Schneider
5145daba69 cmake: Define HAVE_NTOHLL and HAVE_HTONLL on Windows. 2013-07-22 13:01:36 +02:00
Andreas Schneider
729a586027 cmake: Make sure we check some functions on all platforms. 2013-07-22 13:01:36 +02:00
Andreas Schneider
8ff6a7a850 cmake: Check for _strtoui64() on Windows. 2013-07-22 13:01:36 +02:00
Andreas Schneider
dbf3cdecda auth: Fix build warning if we don't build with gssapi. 2013-07-22 13:01:36 +02:00
Andreas Schneider
35d0c3a860 connect: Fix a build warning on Windows. 2013-07-22 13:01:36 +02:00
Andreas Schneider
229ef082c1 scp: Cast return value from uint64_t to size_t. 2013-07-22 13:01:36 +02:00
Andreas Schneider
da1eaea51a gassapi: Fix check if it is enabled. 2013-07-22 10:42:30 +02:00
Andreas Schneider
329f4da1e1 options: Fix compiler warning on Windows. 2013-07-22 10:42:30 +02:00
Andreas Schneider
2c9808daf8 example: Fix location of port definition.
It shouldn't be inside #ifdef HAVE_ARGP.
2013-07-22 10:42:30 +02:00
Andreas Schneider
5e7b15e2c1 pki: Fix declaration of ssh_pki_convert functions. 2013-07-22 10:20:14 +02:00
Andreas Schneider
20312e23b7 log: Make _ssh_log() public. 2013-07-21 11:53:55 +02:00
Andreas Schneider
2106db3efa tests: Don't leak memory in torture_channel_read_error(). 2013-07-21 11:27:30 +02:00
Andreas Schneider
08c31ccf31 error: Fix logging in ssh_set_error(). 2013-07-21 11:26:55 +02:00
Andreas Schneider
f3e09612b3 options: Set log level through options too. 2013-07-21 11:26:32 +02:00
Andreas Schneider
7ed5512145 clang: Add missing defines. 2013-07-21 11:03:16 +02:00
Andreas Schneider
d1bbc35f33 gssapi: Add brackets in ssh_packet_userauth_gssapi_mic(). 2013-07-21 11:03:00 +02:00
Andreas Schneider
f458055e9c gssapi: Cleanup ssh_gssapi_set_creds(). 2013-07-21 10:58:30 +02:00
Andreas Schneider
4103358daa gssapi: Replace printf with SSH_LOG. 2013-07-21 10:56:47 +02:00
Andreas Schneider
1ab4b28b00 messages: Split ssh_execute_server_callbacks() in small functions. 2013-07-21 10:53:18 +02:00
Andreas Schneider
461988b153 session: Add brackets to ssh_handle_packets_termination(). 2013-07-21 10:35:18 +02:00
Andreas Schneider
c4937cedea misc: Use the szPath variable instead of calling getenv. 2013-07-16 13:36:52 +02:00
Andreas Schneider
11c82a26a6 channels: Fix a SSH_LOG call. 2013-07-15 08:07:34 +02:00
Andreas Schneider
351e4107ed examples: Check return value of fstat().
CID #743297
2013-07-14 15:02:11 +02:00
Andreas Schneider
776ff528df examples: Make sure we have a valid scp pointer.
CID #1032343
2013-07-14 15:02:11 +02:00
Andreas Schneider
22e8858134 agent: Fix possible segfaults due to NULL pointer deref.
CID #1035578
2013-07-14 15:02:11 +02:00
Andreas Schneider
483ba8100f examples: Check return value of ssh_event_dopoll().
CID #0
2013-07-14 15:02:08 +02:00
Andreas Schneider
0138c9fd59 gssapi: Refactor ssh_gssapi_send_mic() to not leak memory.
CID #0
2013-07-14 15:02:05 +02:00
Andreas Schneider
831ed08a56 gssapi: Check return values of buffer functions.
CID #0
2013-07-14 15:02:02 +02:00
Andreas Schneider
1467e0782e gssapi: Remove dead code.
CID #0
2013-07-14 15:01:59 +02:00
Andreas Schneider
ecec2abfc7 gssapi: Refactor ssh_gssapi_build_mic() to avoid memory leaks.
CID #0
2013-07-14 15:01:57 +02:00
Andreas Schneider
8f0b6ccd66 gssapi: Fix a possible memory leak.
CID #0
2013-07-14 15:01:55 +02:00
Andreas Schneider
b4790fbdd2 gssapi: Fix a memory leak.
CID #0
2013-07-14 15:01:52 +02:00
Andreas Schneider
df373efc56 callbacks: Still support the legacy callback. 2013-07-14 14:12:08 +02:00
Andreas Schneider
e3b4f27aa9 examples: Remove ssh_log from ssh client example. 2013-07-14 13:35:25 +02:00
Andreas Schneider
c64ec43eef src: Remove enter_function() and leave_function(). 2013-07-14 13:31:24 +02:00
Andreas Schneider
0d3deeec10 options: Use the new function to use the log level. 2013-07-14 12:53:01 +02:00
Andreas Schneider
c28efb8cbc include: Mark ssh_log as depcrecated. 2013-07-14 12:44:32 +02:00
Andreas Schneider
ebdd0c6ac1 src: Migrate to SSH_LOG. 2013-07-14 12:44:26 +02:00
Andreas Schneider
dcd94de076 error: Use new logging function. 2013-07-14 12:37:12 +02:00
Andreas Schneider
a73557053e doc: Document public functions. 2013-07-14 12:37:12 +02:00
Andreas Schneider
2c91efcc68 log: Implment new logging functions. 2013-07-14 12:36:59 +02:00
Andreas Schneider
73309f19e5 cmake: Check if we have Thread Local Storage support. 2013-07-14 12:36:35 +02:00
Aris Adamantiadis
6ad80bb4b2 examples: fix warning 2013-07-14 11:18:13 +02:00
Aris Adamantiadis
365a3bba6e auth: fix warnings with missing switch() params 2013-07-14 09:35:30 +02:00
Aris Adamantiadis
e95e3b5736 examples: fix compilation warnings 2013-07-14 09:32:19 +02:00
Aris Adamantiadis
ad92740dc3 server: Fix compilation without WITH_SERVER 2013-07-14 09:30:59 +02:00
Aris Adamantiadis
bf5e5eebd7 pki: fix comments 2013-07-13 23:01:30 +02:00
Aris Adamantiadis
9d88dcab3e Server: disallow channel opening till authenticated 2013-07-13 22:56:32 +02:00
Aris Adamantiadis
dd6a0b51ac Server: fix rekeying 2013-07-13 22:56:07 +02:00
Aris Adamantiadis
3b81da21c2 DH: fix rekeying when using aes256 and bigger 2013-07-13 18:12:10 +02:00
Andreas Schneider
ed7e3c936b cmake: Don't make GSSAPI a hard requirement. 2013-07-13 15:50:57 +02:00
Andreas Schneider
1663917f71 cmake: Make GSSAPI optional. 2013-07-13 15:48:49 +02:00
Andreas Schneider
9bbbccc0e7 auth: Remove unused code. 2013-07-13 15:29:53 +02:00
Aris Adamantiadis
c44029e5ce gssapi: Fix indentation.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 15:23:33 +02:00
Aris Adamantiadis
c231029be3 gssapi: Fix ticket forwarding bug
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 15:23:33 +02:00
Aris Adamantiadis
2ab7f2be75 server: add pubkey auth callback
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 15:23:33 +02:00
Aris Adamantiadis
47a4eea827 examples: fix with new gssapi cb API
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 15:23:33 +02:00
Aris Adamantiadis
0d1ec1fa48 gssapi: Add user parameter to gssapi auth callback
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 15:03:18 +02:00
Aris Adamantiadis
0356b78ede gssapi: remove dead code
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 15:02:52 +02:00
Aris Adamantiadis
b0ab39a6f1 gssapi: gssapi callbacks serverside
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 15:02:03 +02:00
Aris Adamantiadis
31a129ee9e sftp: more flexibility on channels
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 15:01:17 +02:00
Aris Adamantiadis
7e7910a1ca sftp: added useful server APIs
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 15:00:52 +02:00
Aris Adamantiadis
55ddc3932e gssapi: more debug info
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:59:56 +02:00
Aris Adamantiadis
2a0c1e917f server: callback for channel_request_subsystem
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:59:46 +02:00
Aris Adamantiadis
db20a22e51 server: added 2 missing channel callbacks
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:59:21 +02:00
Aris Adamantiadis
560b508771 events: don't poll handles busy handling callbacks
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:58:47 +02:00
Aris Adamantiadis
f528f71920 agent: the valid request is auth-agent@openssh.com
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:58:18 +02:00
Aris Adamantiadis
458e4c07c7 server: export ssh_channel_open_x11()
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:58:06 +02:00
Aris Adamantiadis
7555f3235e client: call client callback even in non-server mode
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:57:48 +02:00
Aris Adamantiadis
3e7bd72f76 client: handle x11 channel open requests with callbacks
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:57:13 +02:00
Aris Adamantiadis
f457080d62 server: Implement X11 requests and window-change
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:56:37 +02:00
Aris Adamantiadis
37cce98f7e Doc: fix a few broken parameters
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:56:14 +02:00
Aris Adamantiadis
7e306a9ec6 server: implement server-side of agent forwarding
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:55:58 +02:00
Aris Adamantiadis
81e769ec6a channels: implement callback for agent forwarding request
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:55:47 +02:00
Aris Adamantiadis
e809fa881e examples: adapt samplesshd-cb to new callback
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:54:15 +02:00
Aris Adamantiadis
52d9e15c25 examples: adapt to the new callback format
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:51:00 +02:00
Aris Adamantiadis
e933d1e1b1 callbacks: make the channel accept callback more logical
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:51:00 +02:00
Aris Adamantiadis
e76442b650 ssh-agent: implement the clientside for agent forwarding auth.
This can only be used to authenticate the client, not to allow the
connected server to transfer agent requests

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:51:00 +02:00
Aris Adamantiadis
9bdb546852 Examples: Exemple of an SSH proxy
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:51:00 +02:00
Aris Adamantiadis
86ae29b30d gssapi: implement ticket delegation
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:51:00 +02:00
Aris Adamantiadis
65eccf1969 gssapi: retrieve forwarded (delegated) tickets
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:50:56 +02:00
Aris Adamantiadis
d944310412 auth: store client's credentials
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:41:28 +02:00
Aris Adamantiadis
7cb6b15aaa auth: implement client-side gssapi
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:41:20 +02:00
Aris Adamantiadis
212261bb10 examples:Compile samplessh on bsd too
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:25:32 +02:00
Aris Adamantiadis
fadbe80c43 options: Fix null ptr deference introduced in earlier fix.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:24:57 +02:00
Aris Adamantiadis
7fef6e817e auth: implement gssapi-with-mic server side
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:21:36 +02:00
Aris Adamantiadis
1246ad812c server: move message-specific call to ssh_*
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:21:36 +02:00
Aris Adamantiadis
3b52e38a33 auth: adapt libssh to gssapi-with-mic server
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:21:36 +02:00
Aris Adamantiadis
6bb5063046 example: adapt example for gssapi callback
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:19:23 +02:00
Aris Adamantiadis
950d8e89a9 callbacks: new callbacks for gssapi
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:19:23 +02:00
Aris Adamantiadis
6c26a23cf4 build: build with gssapi if detected
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:19:23 +02:00
Aris Adamantiadis
b69c26ad72 build: detect gssapi.h
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:19:23 +02:00
Aris Adamantiadis
cb0f886a5c cmake: Add FindGSSAPI.cmake
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:19:23 +02:00
Aris Adamantiadis
3d7b24c534 gssapi: added SSH constants
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:12:06 +02:00
Aris Adamantiadis
4c99f5de4d GSSAPI: added stub
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:11:26 +02:00
Aris Adamantiadis
a34ad5825b Added server example with callbacks impl
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:10:03 +02:00
Aris Adamantiadis
4497cd9b43 Make examples more BSD friendly
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:08:44 +02:00
Aris Adamantiadis
2b54db7603 Try to find ARGP on solaris, BSD
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:07:46 +02:00
Aris Adamantiadis
ff30a8feb0 Implement callbacks for servers in the message queue
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:06:57 +02:00
Aris Adamantiadis
82b4cffe66 bind: ssh_pki functions also return SSH_EOF error code
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:03:55 +02:00
Aris Adamantiadis
66b37c856c session: Introduce SSH_TIMEOUT_DEFAULT
The default timeout of 30seconds is very nice when connecting to a new SSH
session, however it completely breaks the synchronous blocking API.
Use SSH_TIMEOUT_DEFAULT when in blocking mode so channel reads&write are blocking
as expected

Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:03:42 +02:00
Aris Adamantiadis
6bc64c368d server: added channel callbacks
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 14:00:18 +02:00
Aris Adamantiadis
ab2e641b4a Defined SSH server callbacks interface
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-13 13:59:58 +02:00
Andreas Schneider
48b715cce0 tests: Use fstat() after the open(). 2013-07-13 13:59:58 +02:00
Andreas Schneider
97e7c95d21 cmake: Pass _FORTIFY_SOURCE directly to the preprocessor. 2013-07-13 13:54:00 +02:00
Andreas Schneider
e52cc613e4 BUG 103: Disable proxy command if set to 'none'.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2013-07-11 15:34:50 +02:00
Andreas Schneider
89be6d0309 examples: Check return value of fileno(). 2013-06-19 12:32:10 +02:00
Andreas Schneider
36e4c2e5bc messages: Fix a possible memory leak. 2013-06-19 12:29:54 +02:00
Andreas Schneider
aed9d7a84d agent: Fix a possible memory leak. 2013-06-19 12:24:00 +02:00
Andreas Schneider
f0a362fdbe agent: Fix possible memory leak. 2013-06-19 12:19:05 +02:00
Andreas Schneider
de4cb811a0 examples: Fix a possible memory leak. 2013-06-19 12:16:57 +02:00
Andreas Schneider
abb25861e5 examples: Fix a possible memory leak. 2013-06-19 12:14:25 +02:00
Andreas Schneider
b698f6361c kex1: Fix a possible null pointer dereference. 2013-06-19 12:06:43 +02:00
Andreas Schneider
e6be005236 ecdh: Add missing return in ssh_client_ecdh_init(). 2013-06-19 12:04:38 +02:00
Andreas Schneider
8a4364a99b ecdh: Avoid memory leaks in ssh_server_ecdh_init(). 2013-06-19 11:19:08 +02:00
Andreas Schneider
6dae8baefc src: Add fall trough comments. 2013-06-18 17:17:23 +02:00
Andreas Schneider
94a8c30feb pki: Fix switch statement of pki_key_generate_ecdsa(). 2013-06-18 17:16:59 +02:00
Andreas Schneider
68be73ec0d tests: Check return value of stat. 2013-06-18 17:11:34 +02:00
Andreas Schneider
485e3b4014 tests: Check return values of buffer functions. 2013-06-18 17:10:00 +02:00
Andreas Schneider
1deb3412bb connect: Use the correct close function. 2013-06-18 17:06:58 +02:00
Andreas Schneider
aaae3c4ec1 connect: Correctly fail in ssh_connect_host_nonblocking(). 2013-06-18 17:05:57 +02:00
Andreas Schneider
b31efd9ff1 ecdh: Make sure we don't leak memory in ssh_client_ecdh_init().
This also adds more checks for return values.
2013-06-18 17:02:40 +02:00
Andreas Schneider
5d05aec2ef auth: Cleanup the agent return code. 2013-06-18 16:42:33 +02:00
Nicolas Viennot
6306bee86c auth: If the agent fails, fall back to regular path
It's causing issues on MacOSX when ssh_agent_get_ident_count()
reports "Agent count: 0".
2013-06-18 16:39:31 +02:00
Andreas Schneider
59dcebd604 sample: Fix a possible buffer overrun. 2013-06-17 13:27:40 +02:00
Andreas Schneider
7ceaea479e kex1: Fix null check of hostkey. 2013-06-17 13:21:51 +02:00
Andreas Schneider
2b68728552 socket: Check if socket (non)blocking is working. 2013-06-17 13:18:55 +02:00
Andreas Schneider
42c7bc5a21 socket: Check return value of getsockopt(). 2013-06-17 13:09:50 +02:00
Andreas Schneider
ee47cab548 packet: Fix a possible segfault. 2013-06-17 13:04:27 +02:00
Andreas Schneider
a65029da5d messages: Fix a possible segfault. 2013-06-17 13:02:49 +02:00
Andreas Schneider
f31c33bb31 ecdh: Check return values of buffer_add_* functions. 2013-06-17 12:59:22 +02:00
Andreas Schneider
4255a7223c dh: Check return value of buffer_add_ssh_string(). 2013-06-17 12:53:26 +02:00
Andreas Schneider
9ee45a18d7 connect: Check return value of getsockopt(). 2013-06-17 12:47:21 +02:00
Andreas Schneider
0ba075e9ce channels1: Check return value of buffer_add_u8(). 2013-06-17 12:40:35 +02:00
Andreas Schneider
d93e38bbfe examples: Check return value of ssh_channel_read. 2013-06-17 12:35:42 +02:00
Andreas Schneider
e4bcd063b7 packet1: Don't free an invalid address. 2013-06-17 12:10:55 +02:00
Andreas Schneider
d83b3d9ebe pki: Limit privkey to 4M for now. 2013-06-17 12:07:32 +02:00
Andreas Schneider
6f8b5ed679 pki: Fix a resource leak on error. 2013-06-17 11:49:13 +02:00
Andreas Schneider
d255d1bf32 tests: Use memory assert functions. 2013-06-17 11:44:28 +02:00
Andreas Schneider
33e95792ce pki: Fix resource leak on error. 2013-06-13 15:46:53 +02:00
Andreas Schneider
a38c56370c torture: Fix a resource leak on error. 2013-06-13 15:43:50 +02:00
Andreas Schneider
01493b8d47 tests: Don't leak memory. 2013-06-13 15:42:13 +02:00
Andreas Schneider
1a894e2cf2 client: Fix possible NULL pointer dereference. 2013-06-13 11:46:17 +02:00
Andreas Schneider
b8a3e5ffe3 known_hosts: Fix readablity. 2013-06-13 11:08:37 +02:00
Andreas Schneider
09663692dd pki: Use fstat() after opening the file. 2013-06-13 11:04:59 +02:00
Andreas Schneider
a03d8f49fb examples: Fix a use after free in scp example. 2013-06-13 10:55:12 +02:00
Andreas Schneider
abd6b8004e kex: Fix a double free. 2013-06-13 10:51:12 +02:00
Andreas Schneider
e3c5096fcf server: Fix a double free. 2013-06-13 10:48:50 +02:00
Andreas Schneider
51a531f4a7 tests: Check the return value of write. 2013-06-11 09:59:22 +02:00
Andreas Schneider
fcf8af20f8 BUG 103: Fix ProxyCommand parsing. 2013-06-02 19:29:28 +02:00
Andreas Schneider
2d28ee7d22 config: Rename ssh_config_get_str(). 2013-06-02 18:54:16 +02:00
Andreas Schneider
e41482fec4 opts: Fix segfault in option parser. 2013-06-02 18:34:39 +02:00
Andreas Schneider
992f00b145 getpass: Don't fail if stdin is not a tty.
We don't need to manipulate the tty state (such as turning off echo)
when prompting for passwords if we're not reading from a tty.
2013-04-05 14:14:22 +02:00
Andreas Schneider
24e94d53e9 cmake: Fix installation path for some strange platforms. 2013-03-20 09:38:03 +01:00
Andreas Schneider
8455d79bb6 priv: Make really sure memset doesn't get optimzed out. 2013-03-13 15:37:51 +01:00
Aris Adamantiadis
222a0d78ca poll: return error on poll() when pollset is empty 2013-02-26 23:52:25 +01:00
Andreas Schneider
e471aa4e0b cmake: Fix config include dir variable name. 2013-02-13 15:30:23 +01:00
Andreas Schneider
5d6cab4b14 cmake: Add cmake config files for new find_package() mode. 2013-02-12 13:32:34 +01:00
Andreas Schneider
afe4c92bbf cmake: Fix setting -D_FORTIFY_SOURCE=2. 2013-02-07 17:02:51 +01:00
Johannes Krude
186116f34a socket: Call data handler as long as handler takes data.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2013-01-29 10:56:49 +01:00
Andreas Schneider
b2f52799c2 include: Fix the LGPL header.
This has been reported by rpmlint:
libssh-devel.x86_64: W: incorrect-fsf-address libssh.h
2013-01-23 00:22:46 +01:00
Andreas Schneider
915781381e BUG 99: Fix string function if no build type is set. 2013-01-22 16:28:25 +01:00
Andreas Schneider
21a45e89c5 options: Fix a free crash bug if we parse unknown options.
Thanks to Yong Chuan Koh, X-Force Research <kohyc@sg.ibm.com>
2013-01-22 11:32:47 +01:00
Aris Adamantiadis
de096910b3 Report according status when errors are detected 2012-12-27 22:01:37 +01:00
Aris Adamantiadis
ce33633bcb Test for bug #64, ssh_channel_read doesn't detect errors 2012-12-27 22:01:08 +01:00
Andreas Schneider
fb3f649c76 cmake: Only set -D_FORTIFY_SOURCE=2 if we have optimizations. 2012-12-25 17:35:07 +01:00
Aris Adamantiadis
5dfc474fa8 Benchmarks: parse config files 2012-12-23 23:10:52 +01:00
Aris Adamantiadis
6d61c3ce4a Fix channel_write to wait during key reexchanges 2012-12-23 23:10:29 +01:00
Aris Adamantiadis
63c3f0e736 Implement key re-exchange 2012-12-23 23:09:50 +01:00
Andreas Schneider
e934ab0816 BUG 82: Fix function names of ssh_forward_*. 2012-12-19 18:15:54 +01:00
Andreas Schneider
9fa53cd932 doc: Fix forward function names. 2012-12-19 18:10:16 +01:00
Andrew Collins
5cd7942801 Fix an invalid strlen comparison in ssh_message_auth_reply_default
During the transition to strncat in ssh_message_auth_reply_default,
an invalid strlen comparison was added which causes the function
to fail whenever it's called.

Signed-off-by: Andrew Collins <bsderandrew@gmail.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2012-12-19 16:03:49 +01:00
Andreas Schneider
de9bc1fa41 string: Fix memory leak in ssh_string_to_char().
This was probably a mistake by me fixing up a patch after merging.
2012-12-13 19:29:46 +01:00
Andreas Schneider
b14df297fa BUG 97: Fix strtoull() detection on serveral platforms. 2012-12-03 14:00:06 +01:00
Andreas Schneider
3896aa43ff BUG 96: Guard ntohll() and htonll prototypes correctly. 2012-12-03 13:44:02 +01:00
Andreas Schneider
da8d44ccba BUG 98: Use __attribute__ ((packed)) only with GCC. 2012-12-03 13:19:29 +01:00
Andreas Schneider
c6fc69fbdd BUG 97: Remove obsolete hsterror().
This function is pretty much obsolete on most platforms. The standard
errno should be used. If it is not enough on Windows we should use
WSAGetLastError() in future.
2012-12-03 13:08:17 +01:00
Andreas Schneider
ab8c7de6f8 BUG 94: Fix big endian issue. 2012-12-03 12:35:36 +01:00
Aris Adamantiadis
cd4e28e7c8 test: Try to fetch wrong values in buffer.
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2012-11-27 19:10:41 +01:00
Andreas Schneider
ea0e858de0 priv: Add BURN_BUFFER macro and make sure it isn't optimzed out. 2012-11-23 11:56:21 +01:00
Andreas Schneider
e403596d98 pki: Add a size limit for pubkey files. 2012-11-21 12:44:00 +01:00
Andreas Schneider
571dc42335 CVE-2012-4559: Make sure we don't free name and longname twice on error. 2012-11-14 17:36:24 +01:00
Andreas Schneider
68d04c8e47 CVE-2012-4559: Ensure that we don't free req twice. 2012-11-14 17:36:24 +01:00
Andreas Schneider
bd3acae4f3 CVE-2012-4560: Fix a write one past the end of 'buf'. 2012-11-14 17:36:24 +01:00
Andreas Schneider
894bbf3137 CVE-2012-4560: Fix a write one past the end of the 'u' buffer. 2012-11-14 17:36:24 +01:00
Andreas Schneider
f61813eaea CVE-2012-4562: Fix a possible infinite loop in buffer_reinit().
If needed is bigger than the highest power of two or a which fits in an
integer we will loop forever.
2012-11-14 17:36:22 +01:00
Xi Wang
ad5f306884 CVE-2012-4562: Fix multiple integer overflows in buffer-related functions. 2012-11-14 17:36:19 +01:00
Xi Wang
5ffb8c7cde CVE-2012-4562: Fix possible integer overflows. 2012-11-14 17:36:16 +01:00
Xi Wang
efaebad323 CVE-2012-4562: Fix possible integer overflow in ssh_get_hexa().
No exploit known, but it is better to check the string length.
2012-11-14 17:36:11 +01:00
Xi Wang
cab00c3bfc pki: Fix integer overflow in ssh_pki_import_privkey_file().
If the file size is ULONG_MAX, the call to malloc() may allocate a
small buffer, leading to a memory corruption.
2012-10-22 21:00:08 +02:00
Xi Wang
d404ad7152 channels: Fix integer overflow in generate_cookie().
Since the type of rnd[i] is signed char, (rnd[i] >> 4), which is
considered as arithmetic shift by gcc, could be negative, leading
to out-of-bounds read.
2012-10-22 21:00:08 +02:00
Andreas Schneider
a4ffaff550 channels1: Add missing request_state and set it to accepted.
This fixes bug #88.
2012-10-22 18:05:06 +02:00
Andreas Schneider
e164b236c6 auth1: Reset error state to no error.
This fixes bug #89.
2012-10-22 18:01:39 +02:00
Andreas Schneider
166ccef8dc session: Fix a possible use after free in ssh_free().
We need to cleanup the channels first cause we call ssh_channel_close()
on the channels which still require a working socket and poll context.

Thanks to sh4rm4!
2012-10-22 17:37:32 +02:00
Andreas Schneider
f2e498c7db cmake: Set GNU compiler flags also for clang. 2012-10-22 16:05:39 +02:00
Andreas Schneider
dde0404dfb cmake: Add message if we build with static library. 2012-10-15 11:55:42 +02:00
Andreas Schneider
f86b2bf743 doc: Update copyright policy. 2012-10-14 19:58:07 +02:00
Andreas Schneider
13c26f0733 options: Fix documentation of ssh_options_get_port(). 2012-10-14 19:53:51 +02:00
Andreas Schneider
f5d8bdf946 doc: Update doxygen config. 2012-10-14 19:52:28 +02:00
Andreas Schneider
f4f2237263 doc: Use the correct channel functions. 2012-10-14 19:44:02 +02:00
Andreas Schneider
7e93edc722 cmake: Add better check to detect -fvisibility=hidden. 2012-10-14 18:40:05 +02:00
Andreas Schneider
95ab34696b kex: Use getter functions to access kex arrays.
This should fix the build on OpenIndiana.
2012-10-12 17:46:37 +02:00
Andreas Schneider
82711acd39 cmake: Fix building with gcrypt support. 2012-10-12 17:07:20 +02:00
Andreas Schneider
e8118c5be4 tests: Add a valgrind suppression for getaddrino leak.
https://bugzilla.redhat.com/show_bug.cgi?id=859717
2012-10-12 14:45:54 +02:00
Andreas Schneider
a59a379ce4 tests: Add a valgrind suppression for OPENSSL_cleanse(). 2012-10-12 14:45:54 +02:00
Andreas Schneider
0bd2bbefa7 scp: Make sure buffer is initialzed.
Found by Coverity.
2012-10-12 14:45:54 +02:00
Andreas Schneider
3d390cf6ff pki: Make sure the key_buf is null terminated.
Found by Coverity.
2012-10-12 14:45:54 +02:00
Andreas Schneider
e04dc45f20 misc: Use a fixed buffer for getenv(). 2012-10-12 14:45:54 +02:00
Andreas Schneider
de34a64895 poll: Fix sizeof in ssh_poll_ctx_resize().
sizeof(ssh_poll_handle *) is to be equal to sizeof(ssh_poll_handle), but
this is not a portable assumption.

Found by Coverity.
2012-10-12 14:45:54 +02:00
Andreas Schneider
46f22576b0 legacy: Use snprintf instead of sprintf.
Found by Coverity.
2012-10-12 14:45:54 +02:00
Andreas Schneider
2f8ddc6e65 dh: Don't use strcat for ssh_get_hexa().
This is just hardening the code.

Found by Coverity.
2012-10-12 14:45:54 +02:00
Andreas Schneider
b1287cd946 server: Use strncat instead of strcat.
This is just hardening the code.

Found by Coverity.
2012-10-12 14:45:54 +02:00
Andreas Schneider
a660177a6e misc: Use strncpy instead of strcat.
This is just hardening the code.

Found by Coverity.
2012-10-12 14:45:36 +02:00
Andreas Schneider
0a4ea19982 pki: Fix a possible null pointer dereference.
Found by Coverity.
2012-10-12 08:07:02 +02:00
Andreas Schneider
0bf2dd81e6 messages: Fix memory leaks in user request callback. 2012-10-12 08:07:02 +02:00
Andreas Schneider
ecb6cfd053 connect: Don't leak the addressinfo on error. 2012-10-12 08:07:02 +02:00
Andreas Schneider
ba220adb84 connect: Don't leak the file descriptor on error.
Found by Coverity.
2012-10-12 08:07:02 +02:00
Andreas Schneider
802e4133cb session: Don't leak memory in ssh_send_debug().
Found by Coverity.
2012-10-12 08:07:02 +02:00
Andreas Schneider
dde3deb9ea channels: Don't leak memory in channel_rcv_request callback.
Found by Coverity.
2012-10-12 08:07:02 +02:00
Andreas Schneider
66045054f4 auth: Don't leak memory on error in info request callback.
Found by Coverity.
2012-10-12 08:07:01 +02:00
Andreas Schneider
96e0301b58 dh: Don't leak 'f' on error.
Found by Coverity.
2012-10-12 08:07:01 +02:00
Andreas Schneider
029d165b61 legacy: Don't leak the key struct on error.
Found by Coverity.
2012-10-12 08:07:01 +02:00
Andreas Schneider
4e7736444f server: Don't leak memory on calling ssh_string_from_char().
Also check the return values.

Found by Coverity.
2012-10-12 08:07:01 +02:00
Andreas Schneider
7254390ac2 pki: Don't leak the signature on error paths.
Found by Coverity.
2012-10-12 08:07:01 +02:00
Andreas Schneider
188c596803 sftp: Don't leak owner and group in sftp_parse_attr_4. 2012-10-12 08:07:01 +02:00
Andreas Schneider
0295301928 known_hosts: Don't leak memory in ssh_write_knownhost error paths.
Found by Coverity.
2012-10-12 08:07:01 +02:00
Andreas Schneider
a6e7d1f255 agent: Fix some memory leaks in error paths.
Found by Coverity.
2012-10-12 08:07:01 +02:00
Andreas Schneider
f2c183b413 include: Fix an include recursion.
It includes itself: libssh.h -> legacy.h -> libssh.h.

Found by Coverity.
2012-10-12 08:07:01 +02:00
Andreas Schneider
5e8e21d106 options: Check return code of ssh_iterator_value.
Found by Coverity.
2012-10-12 08:07:01 +02:00
Andreas Schneider
bcc00eec9b kex: Don't compare an array to null.
Found by Coverity.
2012-10-12 08:07:01 +02:00
Andreas Schneider
53008fb5d4 string: Don't compare an array to null.
Found by Coverity.
2012-10-12 08:07:01 +02:00
Andreas Schneider
9338fb8e5e message: Set correct request type.
Found by Coverity.
2012-10-12 08:07:01 +02:00
Andreas Schneider
ec5b4d377f sftpserver: Add missing break statement.
Found by Coverity.
2012-10-12 08:07:01 +02:00
Andreas Schneider
6352b3d93a server: Fix for loop to free server methods.
Found by Coverity.
2012-10-12 08:06:55 +02:00
Andreas Schneider
b8de9e75d0 client: If session is NULL we can't set an error.
Found by Coverity.
2012-10-09 11:09:34 +02:00
Andreas Schneider
ec56d1d453 match: Don't dereference 's' directly.
Found by Coverity.
2012-10-09 11:09:34 +02:00
Andreas Schneider
87036839f9 example: Simplify auth_callback of the client.
Found by Coverity.
2012-10-09 11:09:34 +02:00
Andreas Schneider
131a0de32e auth: Make error handling code reachable again.
Found by Coverity.
2012-10-09 11:09:34 +02:00
Andreas Schneider
3e93836e8b pki: Make error handling code reachable again.
Found by Coverity.
2012-10-09 11:09:34 +02:00
Andreas Schneider
21db70888a socket: Check return value of buffer function.
Found by Coverity.
2012-10-09 11:09:34 +02:00
Andreas Schneider
bb2848de5a channels: Check return values of buffer functions.
Found by Coverity.
2012-10-09 11:09:34 +02:00
Andreas Schneider
6acce40a28 scp: Check return value of ssh_channel_poll.
Found by Coverity.
2012-10-09 11:09:34 +02:00
Andreas Schneider
41269874f5 packet: Check return values of buffer functions.
Found by Coverity.
2012-10-09 11:09:34 +02:00
Andreas Schneider
9abe591843 client: Check return value of ssh_handle_packets_termination.
Found by Coverity.
2012-10-09 11:09:34 +02:00
Andreas Schneider
114cc51a10 pcap: Check return codes of buffer_add_* functions.
Found by Coverity.
2012-10-09 11:09:34 +02:00
Andreas Schneider
9fe47da903 torture: Fix keyboard interactive authentication. 2012-10-09 10:11:55 +02:00
Andreas Schneider
362be13156 tests: Make sure the array is null terminated. 2012-10-07 23:23:33 +02:00
Andreas Schneider
e17fcd70f9 torture: Use new userauth functions. 2012-10-07 23:21:17 +02:00
Andreas Schneider
5f0f334d1c pki: Don't leak memory in pubkey to blob. 2012-10-07 22:36:06 +02:00
Andreas Schneider
996b7cae26 pki: Make sure we don't double free pointers. 2012-10-07 22:35:33 +02:00
Andreas Schneider
b219d1890c tests: Don't leak memory in options test. 2012-10-07 22:15:20 +02:00
Andreas Schneider
bfa568e448 pki: Check for no memory available calling ssh_key_new(). 2012-10-07 22:04:58 +02:00
Andreas Schneider
ff53664f54 sftp: Fix a possible null pointer dereference in sftp_async_read. 2012-10-07 22:03:35 +02:00
Andreas Schneider
b811b89f57 channels1: Fix severa possible null pointer dereferences. 2012-10-07 22:01:48 +02:00
Andreas Schneider
3db2ac41eb pki: Handle error of pki_import_pubkey_buffer() correctly. 2012-10-07 21:53:37 +02:00
Andreas Schneider
ca74d91d50 example: Clear the password. 2012-10-07 21:49:45 +02:00
Andreas Schneider
956cf94f70 server: Removed unused variable keytype in the ecdsa case. 2012-10-07 21:31:49 +02:00
Andreas Schneider
191faea325 misc: Use size_t for len. 2012-10-07 18:06:33 +02:00
Andreas Schneider
0493c1fea9 tests: Don't run ecdh tests if not supported by crypto lib. 2012-10-07 12:04:58 +02:00
Andreas Schneider
ecd2ee95e7 kex: Fix supported methods index. 2012-10-07 12:03:54 +02:00
Andreas Schneider
c81010e2f7 test: Use cmocka instead of cmockery.
cmocka is the successor of cmockery.

http://git.cryptomilk.org/projects/cmocka.git/
2012-10-07 11:10:27 +02:00
Andreas Schneider
c078e36219 example: Fix a build warning. 2012-10-07 10:56:10 +02:00
Andreas Schneider
c5782b7486 session: Make sure we don't segfault on freeing id. 2012-10-07 10:52:54 +02:00
Dmitriy Kuznetsov
1e836a03d2 gcrypt: Fix simple DES support. 2012-10-05 11:22:15 +02:00
Andreas Schneider
ceb8072b34 channel: Fix a possible null pointer dereference. 2012-10-05 11:17:06 +02:00
Andreas Schneider
656fd60110 channels: Fix a possible null pointer dereference. 2012-10-05 11:16:03 +02:00
Andreas Schneider
6092596199 getpass: Fix a memory leak in ssh_gets() on error. 2012-10-05 11:12:14 +02:00
Andreas Schneider
22f607649d sftp: Harden sftp_extension_supported() against null pointers. 2012-10-05 11:12:14 +02:00
Andreas Schneider
b5c4b090da sftp: Fix a memory on error in sftp_opendir(). 2012-10-05 11:12:13 +02:00
Andreas Schneider
fd2064d0b4 messages: Fix error path of ssh_packet_userauth_info_response.
This fixes a memory leak on error.
2012-10-05 11:12:13 +02:00
Andreas Schneider
8567fc8d8c messages: Fix a possible null pointer dereference. 2012-10-05 11:12:13 +02:00
Andreas Schneider
61d032fc03 misc: Don't leak memory on ssh_path_expand_escape() on error. 2012-10-05 11:12:13 +02:00
Andreas Schneider
dc8103925c packet: Fix a possible segfault. 2012-10-05 11:12:13 +02:00
Andreas Schneider
280ce3fe93 session: Fix a memory leak in ssh_new() on error. 2012-10-05 11:12:13 +02:00
Andreas Schneider
332f1a2a51 channels: Fix a memory leak in ssh_channel_select(). 2012-10-05 11:12:13 +02:00
Andreas Schneider
213321d706 options: Fix a memory in ssh_options_copy() on error. 2012-10-05 11:12:13 +02:00
Andreas Schneider
cddfe602cc options: Fix a memory leak if we can't add an idenity. 2012-10-05 11:08:51 +02:00
Andreas Schneider
d0889dd9ea kex: Fix simpledes with gcrypt. 2012-09-25 15:29:38 +02:00
Andreas Schneider
3c5235fdc0 dh: Fix dh_generate_e() with gcrypt. 2012-09-25 15:25:52 +02:00
Andreas Schneider
ed94e7f8a8 messages: Fix a possible null pointer dereference. 2012-09-24 20:57:40 +02:00
Christophe Baribaud
9460c5906f MSVC Windows and winsock2.h
With Microsoft Visual Studio, winsock2.h shall be included before
ws2tcpip.h

Signed-off-by: Christophe Baribaud <christophe.baribaud@gmail.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2012-09-21 09:45:03 +02:00
Christophe Baribaud
160da5810f Finds zlib in a debug only build (windows)
Signed-off-by: Christophe Baribaud <christophe.baribaud@gmail.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2012-09-21 09:44:19 +02:00
Dmitriy Kuznetsov
a18106d3af channels: Fix channel_request_pty_size1 always returning an error.
Fixes bug #88.
2012-09-07 12:23:55 +02:00
Andreas Schneider
3739bd99c5 channels: Fix return value of ssh_channel_request_pty_size with SSHv1.
Thanks to Dmitriy Kuznetsov <dk@yandex.ru>.
2012-09-07 12:21:28 +02:00
Dmitriy Kuznetsov
320951f42f kex: Add simple DES support for SSHv1. 2012-09-07 12:19:43 +02:00
Andreas Schneider
a3f83e7274 changelog: Update features. 2012-09-05 17:03:26 +02:00
Dmitriy Kuznetsov
e689375e45 dh: Add support for diffie-hellman-group14-sha1. 2012-09-04 16:17:46 +02:00
Andreas Schneider
977951e96a pki: Open privkey file in binary mode.
This is needed to correctly detect carriage return.
2012-09-04 11:28:33 +02:00
Andreas Schneider
782b2e37c6 build: Fix missing struct in_addr warning. 2012-07-17 18:16:07 +02:00
Andreas Schneider
a92c97b2e1 sftp: Fix bug in sftp_mkdir not returning on error.
resolves: #84
2012-07-17 18:12:44 +02:00
Andreas Schneider
43e3a8e497 socket: Add a SSH_WRITE_PENDING socket status. 2012-07-17 18:05:51 +02:00
Andreas Schneider
8ef45e00c7 auth: Improve ssh_userauth_kbdint_setanswer() documentation.
Thanks to Arto Karppinen.
2012-07-17 18:04:55 +02:00
Andreas Schneider
e8cebc2a37 auth: Fix ssh_userauth_kbdint*() documentation.
Thanks to Arto Karppinen.
2012-07-17 18:04:55 +02:00
Andreas Schneider
8624651de3 auth: Fix ssh_userauth_password() documentation. 2012-07-17 18:04:55 +02:00
Andreas Schneider
8b8d9dc83a connect: Fix a build warning. 2012-07-17 17:34:27 +02:00
Oliver Gasser
ad24427f03 options: Add option to specify host keys string.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2012-07-06 11:04:05 +02:00
Andreas Schneider
2ed9d2160d dh: Add a doc hint to ssh_string_free_char() for ssh_get_hexa(). 2012-06-11 23:14:25 +02:00
Andreas Schneider
9bac67a05a bind: Fix build. 2012-05-09 09:04:32 +02:00
Andreas Schneider
a3cb5b0707 server: Add ecdsa hostkey support. 2012-05-08 11:34:24 +02:00
Andreas Schneider
88d6e6253c agent: Do not fail reads with EPIPE if there is not enough data to read. 2012-04-10 12:04:44 +02:00
Andreas Schneider
a3cf1e4acc Fix typo. 2012-03-09 18:14:13 +01:00
Andreas Schneider
62657d5f87 auth: Fix build warning. 2012-02-20 09:44:36 +01:00
Andreas Schneider
1973e833f2 server: Add ecdsa hostkey support. 2012-02-19 18:49:07 +01:00
Andreas Schneider
387d9e4855 examples: Fix sparse warnings in sshd examples. 2012-02-19 13:26:03 +01:00
Andreas Schneider
2ca0a9cdb2 examples: Make variabes static in client sample.
Fixes sparse warnings.
2012-02-19 13:26:03 +01:00
Andreas Schneider
29ad0d19f9 examples: Make variables static in scp example.
Fixes sparse warnings.
2012-02-19 13:26:02 +01:00
Andreas Schneider
c31004442a examples: Make variables static in scp example.
Fixes sparse warnings.
2012-02-19 13:26:02 +01:00
Andreas Schneider
e68b763a67 threads: Make libcrypto_mutexes static.
Fixes sparse warnings.
2012-02-19 13:26:02 +01:00
Andreas Schneider
72db38b31d threads: Fix function defintions.
Fixes sparse warnings.
2012-02-19 13:26:02 +01:00
Andreas Schneider
300caf9ff3 pcap: Fix definition of ssh_pcap_file_new().
Fixes sparse warnings.
2012-02-19 13:26:02 +01:00
Andreas Schneider
3888a050f8 packet: Make default_packet_handlers static.
Fixes sparse warnings.
2012-02-19 13:26:02 +01:00
Andreas Schneider
66aaa6f573 misc: Improve byte swapping of ntohll().
Fixes sparse warnings.
2012-02-19 13:26:02 +01:00
Andreas Schneider
3582e386b7 misc: Fix definitions of ssh_list_new().
Fixes sparse warnings.
2012-02-19 13:26:02 +01:00
Andreas Schneider
72001ff8cc auth: Improve doc of ssh_userauth_kbdint_getprompt(). 2012-02-19 13:25:22 +01:00
Andreas Schneider
b7507fc85e cmake: Update FindCMokery. 2012-02-08 20:10:45 +01:00
Andreas Schneider
f558c66e78 doc: Add a note about makefile generators on Windows. 2012-02-08 19:10:41 +01:00
Andreas Schneider
3bb381fad7 doc: Add more infor about Windows binaries. 2012-02-08 19:07:43 +01:00
zhengfish
88964cb541 Fixed a compiling error in src/log.c on Win32 with MSVC 2012-02-07 09:59:33 +01:00
Andreas Schneider
8fea5c7a28 tests: Fix known_hosts test. 2012-02-07 09:54:54 +01:00
Andreas Schneider
19090c5cd8 SubmittingPatches: Fix version number and typo. 2012-02-06 16:21:32 +01:00
Andreas Schneider
f0589a2caf Add SubmittingPatches document. 2012-02-06 16:12:06 +01:00
Andreas Schneider
50e9608dcd auth: Fix SSHv1 build. 2012-02-06 09:54:59 +01:00
Andreas Schneider
ee774479de session: Use a struct for all options. 2012-02-05 11:50:49 +01:00
Andreas Schneider
840f75f10c tests: Turn debug crypto on in ctest. 2012-02-05 10:53:43 +01:00
Andreas Schneider
c0a7a84e92 dh: Fix build with DEBUG_CRYPTO. 2012-02-05 10:52:39 +01:00
Andreas Schneider
4019dbed85 pki: Add ecdsa support for signature verification. 2012-02-04 23:45:01 +01:00
Andreas Schneider
216cb8b1aa crypto: Add evp hashing function. 2012-02-04 23:44:55 +01:00
Andreas Schneider
fb6855a821 pki: Fix openssl ecdsa signature from blob. 2012-02-04 23:04:26 +01:00
Andreas Schneider
0770843309 pki: Fix ssh_pki_log function. 2012-02-04 23:03:53 +01:00
Andreas Schneider
f639b8ec1f pki: Make a strcmp better readable. 2012-02-04 22:09:43 +01:00
Andreas Schneider
c209c6d5ac kex: Add support for ecdsa hostkeys. 2012-02-04 22:08:55 +01:00
Andreas Schneider
b136a986a0 kex: Add a define for the kex method size. 2012-02-04 22:08:08 +01:00
Andreas Schneider
e93f17cad8 pki: Don't free a const key! 2012-02-04 22:07:03 +01:00
Andreas Schneider
47226d9d44 sftp: Fix memory leak in sftp_free() on server.
Thanks to Tom Judge for the report.
2012-02-04 21:06:37 +01:00
Andreas Schneider
a311ec32b1 ecdh: Fix a memory leak in ecdh_build_k().
Thanks to Tom Judge for the report.
2012-02-04 21:06:33 +01:00
Andreas Schneider
4223c8a116 ecdh: Fix a memory leak in ssh_server_ecdh_init().
Thanks to Tom Judge for the report.
2012-02-04 21:06:11 +01:00
Andreas Schneider
e4d0ac7ba1 pki: Update copyright. 2012-02-04 20:37:29 +01:00
Andreas Schneider
84dfa13fe8 cmake: Disable gcrypt ECC. 2012-02-04 20:35:27 +01:00
Andreas Schneider
19f7458ed3 pki: Add ecdsa gcrypt stubs. 2012-02-04 20:25:24 +01:00
Andreas Schneider
3e83bc665f cmake: Enable ECC support for GCrypt 1.5.0 or newer. 2012-02-04 20:25:07 +01:00
Andreas Schneider
ddcfe95bbd cmake: Update GCrypt module. 2012-02-04 20:09:51 +01:00
Andreas Schneider
679cd9efd8 pki: Fix build if you don't have ECC support. 2012-02-04 18:37:05 +01:00
Andreas Schneider
ae59049347 tests: Test ecdsa key generation and signing. 2012-02-04 18:37:05 +01:00
Andreas Schneider
b1434fd09b pki: Add ecdsa support to do_sign_sessionid. 2012-02-04 18:37:04 +01:00
Andreas Schneider
79383cf8ee pki: Add ecdsa support to do_sign. 2012-02-04 18:37:04 +01:00
Andreas Schneider
33b0cfc199 pki: Add ecdsa support for signature_verify. 2012-02-04 18:37:04 +01:00
Andreas Schneider
e9f5c7421e pki: Add ecdsa support for signature_from_blob. 2012-02-04 18:37:04 +01:00
Andreas Schneider
9070b04184 pki: Add ecdsa support for signature_to_blob. 2012-02-04 18:37:04 +01:00
Andreas Schneider
b309dd8fb7 pki: Add support to generate ecdsa keys. 2012-02-04 18:37:04 +01:00
Andreas Schneider
91372e298d tests: Add duplicate ecdsa key test. 2012-02-04 18:37:04 +01:00
Andreas Schneider
14bb23ae3b tests: Add ecdsa pubkey_from_privkey test. 2012-02-04 18:37:04 +01:00
Andreas Schneider
0e1992a9cc tests: Add ecdsa publickey_from_privatekey test. 2012-02-04 18:37:04 +01:00
Andreas Schneider
ecbdc589f4 pki: Fix ecdsa key dup. 2012-02-04 18:37:04 +01:00
Andreas Schneider
fc8a182823 tests: Add a testing of importing ecdsa pubkeys. 2012-02-04 18:37:04 +01:00
Andreas Schneider
f35c284761 pki: Add support to import ecdsa pubkeys. 2012-02-04 18:37:04 +01:00
Andreas Schneider
fa37965ab0 cmake: Add a define to see if we have ecc support. 2012-02-04 18:37:04 +01:00
Andreas Schneider
3c7571e61b pki: Add support for export ecdsa pubkeys. 2012-02-04 18:37:04 +01:00
Andreas Schneider
d44a79da9b tests: Add test for reading ecdsa privkey. 2012-02-04 18:37:04 +01:00
Andreas Schneider
ea74a12b70 pki: Add support to import ecdsa private keys. 2012-02-04 18:37:03 +01:00
Andreas Schneider
b4823252ca pki: Add ECDSA for key compare. 2012-02-04 18:37:03 +01:00
Andreas Schneider
244fa0474b pki: Fix typo in error message. 2012-02-04 18:37:03 +01:00
Anthony VEREZ
9e5b3914de examples: Fix PTY allocation error. 2012-01-30 09:48:01 +01:00
Martin Drasar
31727bf33a Ignore and debug messages can be sent using public API
Signed-off-by: Martin Drasar <drasar@ics.muni.cz>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2012-01-05 11:26:53 +01:00
Lee Hambley
a15399992e Fix logic erorr with brace-less conditional statement 2012-01-03 19:41:28 +01:00
rofl0r
89733e697f patch pki_gcrypt.c to be compilable without CMake 2012-01-02 16:41:52 +01:00
rofl0r
2ffbdb0492 commit a7e14524c4f7903f607cdcd02b83782e89f0a82c 2012-01-02 16:31:37 +01:00
rofl0r
4305da29a1 session: Cleanup timeout functions.
It is possible that we get unrelated packets while waiting for
termination, thus waiting indefinitely. As a workaround we have to
check the user-supplied timeout.
2012-01-02 12:39:43 +01:00
Andreas Schneider
2f861a858b message: Fix compiler warning. 2012-01-02 09:31:40 +01:00
Andreas Schneider
74f5f43409 auth: Fix public key authentication so we can continue. 2012-01-01 23:53:21 +01:00
Andreas Schneider
0b7b699ced auth: Fix a possible double free. 2012-01-01 23:53:14 +01:00
rofl0r
c08bdf5917 message: Handle all unknown global messages.
Reply to unknown global messages as required by the RFC. Therefore
keepalive@openssh.com style messages should get treated in a sane way.
2012-01-01 20:53:13 +01:00
Andreas Schneider
7d26f7ceab torture: Fix compilation with cmockery. 2011-12-27 07:14:08 +01:00
Andreas Schneider
90893fd1a3 options: Fix typo in ssh_options_get() docs. 2011-12-14 13:45:19 +01:00
Andreas Schneider
76fad364cd sftp: Add references to sftp_get_error() to docs. 2011-11-17 19:12:31 +01:00
Andreas Schneider
ba4f10dc46 agent: Improve logging. 2011-11-16 11:32:06 +01:00
Andreas Schneider
ce0324770d kex: Fix some build warnings. 2011-11-10 14:46:22 +01:00
Andreas Schneider
bc2ab9b414 bind: Add more error messages. 2011-11-09 10:21:51 +01:00
Andreas Schneider
ce26b8d777 packet: Use a define for the macsize. 2011-11-09 10:13:26 +01:00
Andreas Schneider
99d2cf02a6 options: Add missing argument check. 2011-11-03 18:24:52 +01:00
Lee Hambley
17f396ffab Improve ssh_options_get(ssh_session, enum ssh_options_e, char**).
* Use SSH_ERROR and SSH_OK instead of `-1` and `0`.
 * Re-factor for code duplication
 * No longer call `ssh_set_error_invalid(ssh_session)` when the
   ssh_session is NULL.
2011-11-03 18:24:02 +01:00
Andreas Schneider
2c04994443 pki: Add a ssh_key_cmp() function. 2011-10-29 19:58:28 +02:00
Andreas Schneider
e799c0ce7d dh: Add ssh_get_publickey(). 2011-10-29 19:58:28 +02:00
Andreas Schneider
2cc48db673 tests: Fix build warning. 2011-10-29 19:58:10 +02:00
Lee Hambley
e797781bb5 Implement ssh_options_get_port(ssh_session, unsigned int*). 2011-10-28 12:15:12 +02:00
Lee Hambley
6bd95b50f5 Implement ssh_options_get(ssh_session, enum ssh_options_e, char**). 2011-10-28 12:14:34 +02:00
Andreas Schneider
d8d9755b7d bind: Fix ssh_bind_listen in normal case. 2011-10-17 19:27:29 +02:00
Aris Adamantiadis
1fcddebadc server: use app-provided bind socket when available 2011-10-13 22:30:27 +02:00
Aris Adamantiadis
551a0c855b server: ssh_bind_accept_fd
This function will not call accept() but use function parameter
instead
2011-10-13 22:23:48 +02:00
Andreas Schneider
85cc582d4a doc: Improve doc of ssh_get_pubkey_hash(). 2011-10-04 10:47:05 +02:00
Aris Adamantiadis
c340192144 packet: cleaner logs with less redundant info 2011-10-03 13:52:19 +03:00
Aris Adamantiadis
b6d0b531f8 server: pubkey auth doesn't work with ecdh 2011-09-25 23:47:55 +02:00
Aris Adamantiadis
5c19cda280 Fix warning 2011-09-24 14:08:52 +02:00
Aris Adamantiadis
e38f2f933b pki: ssh_pki_generate
for both gcrypt and openssl
2011-09-24 01:36:58 +02:00
Aris Adamantiadis
21d68112b8 Torture: test new ssh_pki_generate function 2011-09-24 01:36:39 +02:00
Aris Adamantiadis
3fa5293aec pki: DO actually verify signatures
Would have been an embarrassing bug...
2011-09-24 00:25:44 +02:00
Andreas Schneider
6859e4f4ec build: Fix zlib support. 2011-09-23 22:57:21 +02:00
Aris Adamantiadis
43fc7553f8 torture_algorithm: follow verbosity 2011-09-23 22:57:05 +02:00
Aris Adamantiadis
717840fc09 torture: check for presence of ssh agent 2011-09-23 22:33:21 +02:00
Aris Adamantiadis
046aa02f39 Fix bugs found by clang 2011-09-23 22:27:46 +02:00
Andreas Schneider
8a3b02f68d cmake: Fix library linking. 2011-09-23 08:00:58 +02:00
Aris Adamantiadis
dad35304b6 channels: fix embarrasing channel_read_nonblocking bug 2011-09-22 13:48:21 +03:00
Andreas Schneider
744b7720af build: Fix SSHv1 build. 2011-09-22 12:07:09 +02:00
Andreas Schneider
5083742192 packet: Move packet callbacks to packet_cb.c. 2011-09-18 21:37:18 +02:00
Andreas Schneider
dc42a1757f gzip: Fix zlib support. 2011-09-18 21:37:18 +02:00
Andreas Schneider
7202a26b6c priv: Remove dead prototype. 2011-09-18 21:37:17 +02:00
Andreas Schneider
b785014a15 crypt: Rename to packet_crypt. 2011-09-18 21:37:17 +02:00
Andreas Schneider
acfc8ea83f priv: Remove crypto.h and add correct includes to src files. 2011-09-18 21:37:17 +02:00
Andreas Schneider
c2686b8feb socket: Move socket function to right location. 2011-09-18 21:37:17 +02:00
Andreas Schneider
e7009fe8f3 priv: Create crc32.h.
As crc32 is only needed by SSHv1, build it only with SSHv1.
2011-09-18 21:37:17 +02:00
Andreas Schneider
ffb827b539 priv: Move gcrypt functions to gcrypt header. 2011-09-18 21:37:17 +02:00
Andreas Schneider
33754c391f priv: Start to remove enter_function. 2011-09-18 21:37:17 +02:00
Andreas Schneider
d7fa15df83 priv: Move kex functions to kex header. 2011-09-18 21:37:17 +02:00
Andreas Schneider
519291558d priv: Move options and config prototypes to own header. 2011-09-18 21:37:17 +02:00
Andreas Schneider
abd9856c6a priv: Move defines to the top. 2011-09-18 21:37:17 +02:00
Andreas Schneider
4a6a0987a8 client: Remove unused variable. 2011-09-18 21:36:40 +02:00
Andreas Schneider
3622ac83f6 legacy: Fix possible segfault with publickey_from_file().
This function is obsolete.
2011-09-18 21:36:23 +02:00
Aris Adamantiadis
f61269a2ef ECDH key exchange working 2011-09-18 20:34:16 +02:00
Aris Adamantiadis
d24e353e38 pki: null ptr check 2011-09-18 20:34:16 +02:00
Aris Adamantiadis
09b33b1b6e server: split dh_handsake_server 2011-09-18 20:34:16 +02:00
Aris Adamantiadis
af09313eac crypto: rename crypto_struct -> ssh_cipher_struct 2011-09-18 20:34:16 +02:00
Aris Adamantiadis
ac41a083ef kex: moved KEX structures to ssh_crypto_struct 2011-09-18 20:34:16 +02:00
Aris Adamantiadis
48980573c1 wrapper.c: cleanup 2011-09-18 20:34:15 +02:00
Aris Adamantiadis
22668bcdae kex: have server_kex use the elected methods 2011-09-18 20:34:15 +02:00
Aris Adamantiadis
07abc3406d kex: split key selection and sending 2011-09-18 20:34:15 +02:00
Aris Adamantiadis
1b10b175fc dh: fix segfault in server 2011-09-18 20:34:15 +02:00
Aris Adamantiadis
8f1161f649 scp: introduce a 64bits getter to respect ABI 2011-09-18 20:34:15 +02:00
Andreas Schneider
2cc95e1e08 doc: Fix threading documentation. 2011-09-17 21:32:29 +02:00
Andreas Schneider
fa7798833a pki: Use ssh_log_function() for ssh_pki_log(). 2011-09-17 11:09:19 +02:00
Andreas Schneider
b96943e861 log: Split do_ssh_log(). 2011-09-17 11:05:17 +02:00
Andreas Schneider
569312f7bd log: Remove unneeded ssh_log_function(). 2011-09-17 11:00:33 +02:00
Andreas Schneider
c2883c1f37 auth: Use the new SSH_LOG function. 2011-09-17 10:38:08 +02:00
Andreas Schneider
c19c638d74 error: Use macros for error functions. 2011-09-17 10:38:08 +02:00
Andreas Schneider
afa56e0102 session: Use defines for ssh_handle_packets(). 2011-09-17 10:38:08 +02:00
Andreas Schneider
544747d02c crypt: Fix function definition. 2011-09-15 11:04:00 +02:00
Aris Adamantiadis
68bab2a490 SSH1: handle exit-status message (channels would not close) 2011-09-14 22:53:01 +02:00
Aris Adamantiadis
c4701a34d3 channels1: made channel_write1 nonblocking 2011-09-14 22:39:05 +02:00
Aris Adamantiadis
36ec488663 channels: don't send SSH2 packets on SSH1 ! 2011-09-14 22:35:12 +02:00
Aris Adamantiadis
714aeca91f SSH1: fix kex bugs introduced in refactoring 2011-09-14 22:21:43 +02:00
Aris Adamantiadis
af225e68cb SSH1: make authentication nonblocking 2011-09-14 21:55:54 +02:00
Aris Adamantiadis
ebfb2a5cdb auth: fix spelling in error message 2011-09-14 20:37:30 +02:00
Aris Adamantiadis
33cf16488b Revert "auth: Check if we have any prompts."
This reverts commit 3b5bdc5db4.
It's perfectly legit to have only zero prompts.
2011-09-14 20:36:23 +02:00
Aris Adamantiadis
0fa88fdcfe Auth: fix possible off-by-one
No security impact, only triggable by specific API call
2011-09-14 17:28:41 +03:00
Andreas Schneider
49ae226b90 log: Fixed a typo. 2011-09-12 10:46:32 +02:00
Aris Adamantiadis
f3d00e4bc3 tests: nonblocking keyboard-interactive 2011-09-11 17:39:20 +02:00
Aris Adamantiadis
fa68d91869 log: remove the annoying \n between date and message 2011-09-11 17:39:20 +02:00
Aris Adamantiadis
1f31415760 auth: made keyboard-interactive nonblocking 2011-09-11 17:39:20 +02:00
Aris Adamantiadis
27dea35608 Test: added torture_auth_autopubkey_nonblocking 2011-09-11 17:22:27 +02:00
Aris Adamantiadis
ff5bf51af1 Auth: nonblocking ssh_userauth_pubkey_auto 2011-09-11 17:22:27 +02:00
Aris Adamantiadis
7b663df185 Tests: unit test for agent authentication 2011-09-11 17:22:27 +02:00
Aris Adamantiadis
33bd3d6cd9 auth: Implement nonblocking ssh_auth_agent 2011-09-11 17:22:26 +02:00
Aris Adamantiadis
28bfc7645c auth: different code for auth_agent 2011-09-11 17:22:26 +02:00
Aris Adamantiadis
ae89dfd6f2 Auth: made ssh_userauth_get_response respect timeout 2011-09-11 17:22:26 +02:00
Andreas Schneider
06e0305100 server: Fix some build warnings. 2011-09-11 15:32:39 +02:00
Andreas Schneider
3b5bdc5db4 auth: Check if we have any prompts. 2011-09-11 15:29:27 +02:00
Andreas Schneider
95ec57f2fd server: Fix compiler warning. 2011-09-11 15:12:35 +02:00
Andreas Schneider
a5d89624d5 log: Add missing include. 2011-09-11 14:38:44 +02:00
Andreas Schneider
04faa33259 kex: Fix includes. 2011-09-11 08:24:33 +02:00
Andreas Schneider
35dce7e8d1 priv: Remove obsolete ssh_keys_struct. 2011-09-10 12:47:47 +02:00
Andreas Schneider
c8f48a2478 log: Improve the logging function. 2011-09-10 12:38:42 +02:00
Andreas Schneider
08129002de log: Add new debug log levels.
These should be used in future!
2011-09-10 12:31:54 +02:00
Andreas Schneider
b3d62ecba8 agent: Add missing config.h include. 2011-09-10 11:55:50 +02:00
Andreas Schneider
bf72440eff kex: Split out SSHv1 functions to kex1.c. 2011-09-10 11:03:46 +02:00
Andreas Schneider
77e71ae3b5 dh: Use ssh_string_new() in make_bignum_string(). 2011-09-08 19:58:59 +02:00
Andreas Schneider
81017b0fc2 string: Make sure we always have the right byte order. 2011-09-08 19:57:34 +02:00
Andreas Schneider
4a5b72a535 pki: Use ssh_string_get_char(). 2011-09-08 16:14:35 +02:00
Andreas Schneider
c1f8b38b78 string: Add ssh_string_get_char(). 2011-09-08 16:14:35 +02:00
Andreas Schneider
5581323c2c string: Use the struct and array for allocating the struct. 2011-09-08 15:50:39 +02:00
Andreas Schneider
55c758d079 auth1: Fix ssh_string usage. 2011-09-08 15:29:05 +02:00
Andreas Schneider
09da9418cc known_hosts: Fix a free before last use. 2011-09-08 13:42:30 +02:00
Andreas Schneider
6d3d5a446e known_hosts: Fix a memleak. 2011-09-07 17:51:43 +02:00
Andreas Schneider
11f3b0e684 pki: Add missing ECC ifdef. 2011-09-06 09:44:45 +02:00
Andreas Schneider
ae1f87e37a options: Fix NULL value handling. 2011-09-06 09:16:54 +02:00
Andreas Schneider
3105b3c205 options: Fix the ssh_options_set() function.
This is a refactor so that we check if the values are sane the user
wants to set. If not return an error.
2011-09-05 20:15:34 +02:00
Andreas Schneider
2e83cc925d known_hosts: Migrate ssh_write_knownhost() to new pki. 2011-09-05 11:28:19 +02:00
Andreas Schneider
808c7a9be4 pki: Add ssh_pki_export_pubkey_rsa1(). 2011-09-05 11:28:19 +02:00
Andreas Schneider
6901e25085 pki_crypto: Add ecdsa support for key duplication. 2011-09-02 23:10:23 +02:00
Andreas Schneider
a0e3facac7 pki: Add ecdsa key support. 2011-09-02 23:10:23 +02:00
Andreas Schneider
6dc7ddde3f channels: Export ssh_channel_poll_timeout(). 2011-09-02 22:40:32 +02:00
Aris Adamantiadis
7e5f1edcb4 auth: fix things broken during merge 2011-09-02 14:09:12 +03:00
Aris Adamantiadis
20f8e73e3e Update libssh to ssh_handle_packets_termination
cherry-picked from 0cb5248

Should resolve all timeout problems

Conflicts:

	src/auth.c
	src/channels.c
2011-09-02 13:58:37 +03:00
Aris Adamantiadis
ef5701a535 Channels: fix the "server specified invalid channel" bug
Resolved by introducing a flag entry in channel structure.
2011-09-02 13:50:06 +03:00
Aris Adamantiadis
7d347aa6f4 channel: ssh_channel_read is nonblocking, + docfixes
cherry-picked from 6091147
Conflicts:

	src/channels.c
2011-09-02 13:49:05 +03:00
Aris Adamantiadis
6d8bb956c5 channels: replaced bugged lists with ssh_list
cherry-picked from 0aef5f
Conflicts:

	src/session.c
2011-09-02 13:46:10 +03:00
Aris Adamantiadis
3eece8ac0b SSH1: fix build 2011-09-02 11:43:12 +03:00
Aris Adamantiadis
92c8a71abb ssh_select converted to ssh_event, and bugfix to ssh_channel_select 2011-09-02 11:43:12 +03:00
Aris Adamantiadis
b5351f2809 poll: resolve use-after-free + inconsistent callbacks call
This code was weird in the first place. I suspect my change will break something else
(probably the appcode that needed it). ssh_poll_ctx_free is not a good
place to send exception callbacks imho.
2011-09-02 11:43:12 +03:00
Aris Adamantiadis
d1ebc4697a channels: ssh_channel_select implemented with ssh_poll
Should fix #56
2011-09-02 11:43:11 +03:00
Aris Adamantiadis
7f5206b8ac sample: fix ssh_channel_read 2011-09-02 11:43:11 +03:00
Aris Adamantiadis
cb2a111fa1 channel: implement ssh_channel_poll_timeout
Resolves bug #57
2011-09-02 11:43:11 +03:00
Aris Adamantiadis
555d1a4347 benchmarks: fix some bugs 2011-09-02 11:43:07 +03:00
Aris Adamantiadis
17ae216340 Channels: increase window size x10
Provides me a 3x performance boost for async sftp, 5x for sync sftp
(on localhost)
2011-09-02 11:43:07 +03:00
Aris Adamantiadis
3a5cc18b32 benchmarks: sftp_async + few changes 2011-09-02 11:43:07 +03:00
Aris Adamantiadis
b11567ed9b benchmarks: refactoring + sync sftp tests
no surprise, sync sftp is much slower, even for localhost,
especially for download.
2011-09-02 11:43:07 +03:00
Aris Adamantiadis
faaf334aa3 benchmarks: added "data" option 2011-09-02 11:43:05 +03:00
Aris Adamantiadis
5d9cd8bf39 benchmarks: added raw_download test 2011-09-02 11:43:05 +03:00
Aris Adamantiadis
a2c94abb92 channels: made the remaining calls nonblocking + fix #52 2011-09-02 11:42:59 +03:00
Aris Adamantiadis
510c741229 channels: use hard random for the X11 cookie
We are in a security library or we are not.
2011-09-02 11:42:59 +03:00
Aris Adamantiadis
f9dad9ad68 channels: made all channel requests nonblocking 2011-09-02 11:42:59 +03:00
Aris Adamantiadis
7363b29427 unittests:make sftp_dir pass on my laptop 2011-09-02 11:41:04 +03:00
Aris Adamantiadis
99e6fde751 scp: Fixed documentation bug #9 2011-09-02 11:40:52 +03:00
Andreas Schneider
5c48438dcb doc: Improve doc of ssh_message_auth_pubkey(). 2011-08-30 23:11:32 +02:00
Andreas Schneider
b5b3db6c90 pki: Check the type of the key blob earlier. 2011-08-30 22:35:01 +02:00
Andreas Schneider
e5a39a3ae9 keys: Remove keys.h where it is obsolete. 2011-08-30 12:15:20 +02:00
Andreas Schneider
fedfbf9563 keys: Remove obsolete keys.c. 2011-08-30 12:15:20 +02:00
Andreas Schneider
7093ac986d keys: Remove dead prototypes. 2011-08-30 12:15:20 +02:00
Andreas Schneider
64de14f51e keys: Move publickey_from_privatekey() to legacy.c. 2011-08-30 12:15:20 +02:00
Andreas Schneider
fe246db27d keys: Move publickey_free() to legacy.c. 2011-08-30 12:15:20 +02:00
milo
0cbbe39e4f Include stdio.h for snprintf 2011-08-30 11:39:14 +02:00
Andreas Schneider
822c68eb8e pki: Use consistent API for ssh_pki_export_privkey_to_pubkey(). 2011-08-30 10:28:57 +02:00
Andreas Schneider
60b92e458e pki: Use consistent API for ssh_pki_export_pubkey_blob(). 2011-08-30 10:16:53 +02:00
Andreas Schneider
e236577503 tests: Enable ecdh_sha2_nistp256 test only with openssl. 2011-08-30 09:34:23 +02:00
Andreas Schneider
85d12f6774 cmake: Add ec.h and ecdsa.h checks. 2011-08-30 00:44:46 +02:00
Andreas Schneider
6bf8dfa073 pki: Fix session_id hashing.
I don't understand why this code worked before. It was completly wrong.
2011-08-29 22:39:47 +02:00
rofl0r
66188f1af8 channels: Fix possible infinite loop in channel_read(). 2011-08-29 21:47:01 +02:00
Jonas Jonsson
d1df255df4 sftp: Handle short reads of sftp_async_read().
sftp_async_read() and sftp_async_read_begin() assume that the whole read
will be successful but when this is not the case, the offset will be
wrong.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-08-29 10:05:26 +02:00
Andreas Schneider
a060a235a4 pki: string_* -> ssh_string_* 2011-08-28 22:51:00 +02:00
Andreas Schneider
7a9f65dd94 pki: Refactor ssh_pki_do_sign(). 2011-08-28 22:25:33 +02:00
Andreas Schneider
246d20ef23 pki: Refactor _RSA_do_sign(). 2011-08-28 22:25:33 +02:00
Andreas Schneider
f803538d21 doc: Fix authentication docs. 2011-08-28 20:08:36 +02:00
Andreas Schneider
292ed71f09 doc: Fix a check in the doc code. 2011-08-28 20:02:27 +02:00
Andreas Schneider
2d9cd48b1d pki: Cleanup crypto includes. 2011-08-28 14:50:43 +02:00
Andreas Schneider
10d3d73039 pki: Fix gcrypt includes and update copyright. 2011-08-28 14:50:43 +02:00
Andreas Schneider
f02f889111 pki: Get rid of the string.h include in pki_gcrypt.c. 2011-08-28 14:50:43 +02:00
Andreas Schneider
a9eb0020b8 legacy: Move ssh_private_key and ssh_public_key typedefs. 2011-08-28 14:50:43 +02:00
Andreas Schneider
fb4f1412ba build: Fix the build of keyfiles torture test. 2011-08-28 14:50:28 +02:00
Andreas Schneider
561441105f pki: Add Windows defines. 2011-08-28 14:29:44 +02:00
Andreas Schneider
7c28d0ce6d pki: Compile pki_gcrypt.c only if we need it. 2011-08-28 14:29:17 +02:00
Andreas Schneider
5cf23522de keyfiles: Remove keyfiles.h. 2011-08-28 14:26:40 +02:00
Andreas Schneider
be660e801a keyfiles: Remove try_publickey_from_file(). 2011-08-28 14:24:23 +02:00
Andreas Schneider
bce2c22e45 keyfiles: Make ssh_try_publickey_from_file() legacy. 2011-08-28 14:21:56 +02:00
Andreas Schneider
29ecccb96d keyfiles: Make ssh_try_publickey_from_file() legacy. 2011-08-28 14:19:07 +02:00
Andreas Schneider
16b47496c1 sftp: Don't create file page. 2011-08-28 13:20:58 +02:00
Andreas Schneider
9379a93c98 doc: Fix some doxygen latex warnings. 2011-08-28 13:17:39 +02:00
Andreas Schneider
21875bc71e sftp: Improve documentation. 2011-08-28 13:17:27 +02:00
Andreas Schneider
0f41f21227 auth: Refactor and rename kbdauth_send(). 2011-08-28 12:54:49 +02:00
Andreas Schneider
98ada12f66 libsshpp: Remove type argument from doc. 2011-08-27 13:58:53 +02:00
Andreas Schneider
0bd99b3773 auth: Fix doc typos. 2011-08-27 13:58:08 +02:00
Andreas Schneider
e5e673bafe auth: Handle request service timeout in blocking mode. 2011-08-26 23:56:49 +02:00
Andreas Schneider
79ed1bc601 pki: Handle hash correctly.
Looks like only DSA in grypt needs a leading zero to mark the has as
positive. See

http://lists.gnupg.org/pipermail/gcrypt-devel/2005-February/000754.html
2011-08-26 23:13:57 +02:00
milo
228e2edac5 Quick fix for gcrypt DSA signature 2011-08-26 22:18:04 +02:00
Andreas Schneider
1d734f16cf legacy: Remove privatekey_from_base64().
This function has been introduced for libssh 0.6. So we can remove it
completely.
2011-08-26 21:46:56 +02:00
Andreas Schneider
5a0735d1e8 messages: Fix ssh_packet_userauth_request().
Remove useless ssh_pki_import_signature_blob().
2011-08-26 21:19:49 +02:00
milo
f1634d33da Free sig_blob if an error occurs 2011-08-26 18:17:14 +02:00
milo
4bdd831d7f Fix double free in ssh_packet_userauth_request 2011-08-26 15:49:12 +02:00
Andreas Schneider
d4424b2767 auth: Refactor and fix ssh_userauth_kbdint(). 2011-08-26 13:44:00 +02:00
Andreas Schneider
f2e08e8d7b auth: Fix ssh_userauth_agent_publickey pending state. 2011-08-26 13:34:40 +02:00
Andreas Schneider
26e624c1b7 auth: Don't fail in publickey_auto if we can't read the key.
We should go on and try the next one as it was before. Also make sure we
don't leak memory ;)
2011-08-26 13:34:40 +02:00
Andreas Schneider
f8c987d1d4 auth: Fix ssh_userauth_publickey() pending_call_state. 2011-08-26 13:32:08 +02:00
Andreas Schneider
696f574a56 keys: Remove obsolete signatue functions. 2011-08-26 10:48:37 +02:00
Andreas Schneider
ab1a66ca7b pki: Fix build with DEBUG_CRYPTO. 2011-08-26 10:44:43 +02:00
Andreas Schneider
7457937bab pki: Migrate ssh_pki_do_sign to new pki. 2011-08-26 09:51:02 +02:00
Andreas Schneider
b5db04003d auth: Fix a segfault in ssh_userauth_kbdint_init(). 2011-08-26 09:00:39 +02:00
Andreas Schneider
a51d377afe auth: Refactor kbdauth_init().
Rename it to ssh_userauth_kbdint_init.
2011-08-25 16:41:14 +02:00
Andreas Schneider
892cb92f57 auth: Prefix kbdint functions. 2011-08-25 16:26:12 +02:00
Andreas Schneider
c59939d4a2 auth: Make ssh_userauth_privatekey_file() legacy. 2011-08-25 16:14:29 +02:00
Andreas Schneider
5c601115c3 auth: Refactor ssh_userauth_password(). 2011-08-25 16:14:21 +02:00
Andreas Schneider
89253fd22a auth: Make ssh_userauth_autopubkey legacy. 2011-08-25 10:19:09 +02:00
Andreas Schneider
21261270e5 auth: Add ssh_userauth_publickey_auto(). 2011-08-25 10:13:23 +02:00
Andreas Schneider
1a56892e9f keys: Remove obsolete ssh_do_sign(). 2011-08-25 10:13:23 +02:00
Andreas Schneider
c5643c0967 agent: Remove obsolete agent_sign_data(). 2011-08-25 10:13:23 +02:00
Andreas Schneider
c5837a6c63 keys: Remove obsolete ssh_do_sign_with_agent(). 2011-08-25 10:13:23 +02:00
Andreas Schneider
c221db0f36 auth: Add ssh_userauth_agent().
This commit is pretty big cause several functions have been refactored.
2011-08-25 10:13:23 +02:00
Andreas Schneider
4c1d3b708c auth: Make ssh_userauth_pubkey legacy. 2011-08-23 21:54:02 +02:00
Andreas Schneider
379d65eaaf auth: Add ssh_userauth_publickey(). 2011-08-23 21:54:02 +02:00
Andreas Schneider
aa018c1484 auth: Make ssh_userauth_try_publickey() legacy. 2011-08-23 21:54:02 +02:00
Andreas Schneider
37df5e17c3 auth: Update copyright. 2011-08-23 21:54:02 +02:00
Andreas Schneider
609f8fbb7a auth: Add ssh_userauth_try_publickey(). 2011-08-23 21:54:01 +02:00
Andreas Schneider
5b706c7ab6 auth: Refactor ssh_userauth_none(). 2011-08-23 21:54:01 +02:00
Andreas Schneider
a15dab6c00 auth: Rename wait_auth_status. 2011-08-23 21:54:01 +02:00
Andreas Schneider
5695f92e22 auth: Update ssh_userauth_list(). 2011-08-23 21:54:01 +02:00
Andreas Schneider
2e577cecb4 auth: Move ssh_auth_list to legacy functions. 2011-08-23 21:54:01 +02:00
Andreas Schneider
058bb04396 auth: Rename ask_userauth. 2011-08-23 21:54:01 +02:00
Andreas Schneider
dc9feec005 pki: Add more return values for file importing functions. 2011-08-23 21:54:01 +02:00
Andreas Schneider
fa4378d47e poll: Just make the code a bit more readable.
Maybe this fixes a cppcheck false positive.
(cherry picked from commit 45c1a23769b63e72e895158bcab83aad31d483dd)
2011-08-23 21:52:21 +02:00
Andreas Schneider
e94b0f8c08 server: Fix a build warning.
Thanks to Tom Judge.
2011-08-23 15:15:28 +02:00
Andreas Schneider
149be78ee0 pki: We need only one signature verify blob function.
This fixes the build without server.
2011-08-23 08:19:53 +02:00
Andreas Schneider
8fb8ad0151 agent: Fix memory leak. 2011-08-22 21:57:00 +02:00
Andreas Schneider
93c4a8e427 pki: Fix memleak in gcrypt pki_publickey_to_blob(). 2011-08-22 21:56:44 +02:00
Andreas Schneider
9da331e79b dh: Remove obsolete signature functions. 2011-08-22 18:47:15 +02:00
Andreas Schneider
8edf57fbf2 client: Migrate to new signature pki. 2011-08-22 18:41:47 +02:00
Andreas Schneider
8c8a91a9b7 server: Migrate more functions to new pki. 2011-08-22 18:41:47 +02:00
Andreas Schneider
bf2f553fc3 pki: Improve pki gcrypt error reports. 2011-08-22 18:41:47 +02:00
Andreas Schneider
82ca6a6c53 pki: Add ssh_srv_pki_signature_verify_blob(). 2011-08-22 18:41:47 +02:00
Andreas Schneider
5cc98ed720 pki: Add ssh_pki_signature_verify_blob(). 2011-08-22 18:39:56 +02:00
Andreas Schneider
bcc0a6d0e0 pki: Fix gcrypt pki_signature_from_blob(). 2011-08-22 18:22:28 +02:00
Andreas Schneider
6c03b7a9c9 misc: Add ssh_match_group(). 2011-08-22 16:16:34 +02:00
Andreas Schneider
90167f09d3 server: Migrate hostkey check to new pki. 2011-08-22 15:22:58 +02:00
Andreas Schneider
9c376dd913 auth: Fix ssh_auth_list() documentation.
The server will not return SSH_AUTH_METHOD_NONE.
2011-08-22 15:03:25 +02:00
Andreas Schneider
1e019fee43 keys: Remove unused obsolete ssh_sign_session_id(). 2011-08-22 14:30:08 +02:00
Andreas Schneider
4de4520559 server: Use new pki infrastructure. 2011-08-22 14:29:39 +02:00
Andreas Schneider
245a354187 pki: Fix switch in crypto pki_signature_to_blob(). 2011-08-22 14:28:46 +02:00
Andreas Schneider
d6829d073c kex: Move ssh_encrypt_rsa1 to SSHv1 kex code. 2011-08-22 13:58:02 +02:00
Andreas Schneider
79ffd49940 pki: Add ssh_srv_pki_do_sign_sessionid(). 2011-08-22 13:48:25 +02:00
Andreas Schneider
a2e08697b1 messages: Move ssh_userauth_build_digest() and make it static. 2011-08-22 12:57:01 +02:00
Andreas Schneider
ca9b01af99 pki: Migrate signature functions to legacy code. 2011-08-22 11:23:33 +02:00
Andreas Schneider
d0d9e62611 tests: Fix torture test with zlib support. 2011-08-22 08:26:02 +02:00
Andreas Schneider
a86ac461fd pki: Ensure sig_blob isn't used uninitialized. 2011-08-22 08:04:22 +02:00
Andreas Schneider
859ed8583c ctest: Fix the ctest build script. 2011-08-21 14:08:40 +02:00
Andreas Schneider
1b57445f6b pki: Add ssh_pki_do_sign_agent(). 2011-08-21 13:43:20 +02:00
Andreas Schneider
af82d8dfab agent: Add ssh_agent_sign_data(). 2011-08-21 13:42:49 +02:00
Andreas Schneider
a98301d2b0 tests: Add pki signature test. 2011-08-21 13:17:30 +02:00
Andreas Schneider
9c9199e05f pki: Fix possible segfault in ssh_key_type_from_name(). 2011-08-21 13:13:53 +02:00
Andreas Schneider
fa4f2d8bc1 tests: Add pki torture tests for keytypes. 2011-08-21 13:13:21 +02:00
Andreas Schneider
42cea1f2f1 pki: Fix ssh_key_dup() with gcrypt. 2011-08-21 12:59:55 +02:00
Andreas Schneider
c8d06b6b1c tests: Fix memleak in torture_pki. 2011-08-21 12:41:42 +02:00
Andreas Schneider
948400ed92 cmake: Support WITH_ZLIB and WITH_LIBZ) 2011-08-21 12:39:16 +02:00
Andreas Schneider
eb65f031af pki: Fix setting flags in ssh_key_dup(). 2011-08-21 12:31:16 +02:00
Andreas Schneider
c041261921 pki: Create a pki private header file. 2011-08-21 11:15:29 +02:00
Andreas Schneider
a4b2518761 pki: Add ssh_pki_import_signature_blob(). 2011-08-21 11:03:53 +02:00
Andreas Schneider
4f19a304d1 pki: Add ssh_pki_export_signature_blob(). 2011-08-21 10:11:05 +02:00
Andreas Schneider
ab0354dbb6 priv: Add discard_const macros. 2011-08-21 10:10:27 +02:00
Andreas Schneider
ce41747fae pki: Introduce ssh_signature. 2011-08-20 18:37:43 +02:00
Andreas Schneider
8acc3dd3af pki: Add _RSA_do_sign to pki_crypto. 2011-08-20 18:08:16 +02:00
Andreas Schneider
79029854f6 tests: Added more pki tests. 2011-08-20 12:59:19 +02:00
Andreas Schneider
743a00dad4 pki: Fix build warnings. 2011-08-20 11:07:54 +02:00
Andreas Schneider
bb509ce4f7 pki: Remove unused variables. 2011-08-20 10:55:22 +02:00
Andreas Schneider
bac5f62eaf tests: Fix build warning. 2011-08-20 10:54:43 +02:00
Andreas Schneider
e3bd018465 tests: Fix the torture_pki test. 2011-08-20 10:48:34 +02:00
Andreas Schneider
5bcf36f098 session: Fix ssh_free() with NULL argument. 2011-08-20 10:47:59 +02:00
Andreas Schneider
c575de17a8 pki: Use a consistent naming scheme. 2011-08-19 11:14:23 +02:00
Andreas Schneider
3e56ac650c tests: Fix torture_pki build warnings. 2011-08-19 11:14:06 +02:00
Andreas Schneider
765b42e68a tests: Improve pki_import_privkey_base64 test. 2011-08-19 11:03:31 +02:00
Andreas Schneider
2615f8bc94 tests: Added test for pubkey from privkey. 2011-08-16 23:06:13 +02:00
Andreas Schneider
c39181437b pki: Add ssh_pki_export_publickey_file(). 2011-08-16 23:04:25 +02:00
Andreas Schneider
ddcb88070b misc: Remove session from ssh_get_local_username(). 2011-08-16 23:04:25 +02:00
Andreas Schneider
1a0fbedc2e pki: Fix and rename ssh_pki_publickey_to_base64().
Rename it to ssh_pki_export_publickey_base64().
2011-08-16 23:04:25 +02:00
Andreas Schneider
254c30be2e pki: Remove session from ssh_pki_import_pubkey_* functions. 2011-08-16 19:33:24 +02:00
Andreas Schneider
25a2108809 pki: Remove session from ssh_pki_import_privkey_* functions. 2011-08-16 18:53:18 +02:00
Andreas Schneider
9b84464748 pki: Make publickey_to_string a legacy function. 2011-08-16 17:54:10 +02:00
Andreas Schneider
a40f1d8597 pki: Make publickey_from_string a legacy function. 2011-08-16 17:47:29 +02:00
Andreas Schneider
c940918821 pki: Fix memleak in privatekey_from_file(). 2011-08-16 09:23:57 +02:00
Andreas Schneider
f7a7bf071d torture: Fix memleak in pubkey base64 tests. 2011-08-16 09:23:53 +02:00
Andreas Schneider
c5028e76ad pki: Fix memleak in pki_import_pubkey_buffer(). 2011-08-16 09:15:29 +02:00
Andreas Schneider
df29df6e35 pki: Add ssh_pki_log function.
The plan is to get rid of the session as a parameter to ssh pki key
functions. We don't need a session for it and probably don't want it.
2011-08-16 01:18:36 +02:00
Andreas Schneider
330c713fdb pki: Add test torture_pki_publickey_dsa_base64(). 2011-08-16 01:17:24 +02:00
Andreas Schneider
42dda7b958 pki: Fix ssh_pki_publickey_to_base64() warnings. 2011-08-16 00:58:20 +02:00
Andreas Schneider
614ad97c12 pki: Make ssh_type_from_name() a legacy function. 2011-08-16 00:55:47 +02:00
Andreas Schneider
04ce7967b8 pki: Make ssh_type_to_char() a legacy function. 2011-08-16 00:54:00 +02:00
Andreas Schneider
19a3f5a61d pki: Make publickey_from_file() a legacy function. 2011-08-16 00:47:43 +02:00
Andreas Schneider
9dfef44fd8 pki: Add ssh_pki_publickey_to_base64(). 2011-08-16 00:47:43 +02:00
Andreas Schneider
c085892802 pki: Add ssh_pki_import_pubkey_file(). 2011-08-16 00:47:43 +02:00
Andreas Schneider
47ebcac4cd torture: Add torture_pki_publickey_rsa_base64 test. 2011-08-16 00:47:43 +02:00
Andreas Schneider
977d6fc089 pki: Fix pki_publickey_to_string() rsa checks. 2011-08-16 00:47:43 +02:00
Andreas Schneider
3c3673d1b8 build: Add missing path to .clan_complete 2011-08-16 00:47:43 +02:00
Andreas Schneider
3f70bce373 pki: Rename ssh_pki_publickey_to_string and make it public. 2011-08-16 00:47:43 +02:00
Andreas Schneider
6c1b508efd pki: Rename ssh_pki_import_pubkey_string and make it public.
It should be named ssh_pki_import_pubkey_blob().
2011-08-16 00:47:43 +02:00
Andreas Schneider
714fa8960d pki: Move ssh_privatekey_type and privatekey_free to legacy. 2011-08-16 00:47:43 +02:00
Andreas Schneider
54a2b8a303 pki: Fix ssh_pki_import_pubkey_base64(). 2011-08-16 00:47:43 +02:00
milo
96e338ba56 Fixed typos in ssh_pki_publickey_to_string 2011-08-15 18:58:27 +02:00
Andreas Schneider
6ffee22448 pki: Add ssh_pki_publickey_to_string(). 2011-08-15 18:48:08 +02:00
Andreas Schneider
fe375132c3 bind: Add checks around key functions. 2011-08-15 18:48:08 +02:00
Andreas Schneider
2780f76247 pki: Flags are a bit mask so use hex. 2011-08-15 18:48:08 +02:00
Andreas Schneider
a983512678 pki: Fix ssh_key_dup(). 2011-08-15 18:48:08 +02:00
Andreas Schneider
c77b23b32a pki: Cleanup pki header. 2011-08-15 18:48:08 +02:00
milo
962bdb1eea Fixed missing include for FILE 2011-08-15 17:37:01 +02:00
Andreas Schneider
e06b3dba0d bind: Read only once in ssh_bind_listen() (bug #11). 2011-08-15 16:50:30 +02:00
Andreas Schneider
190ae27463 pki: Added ssh_key_dup(). 2011-08-15 16:26:58 +02:00
Andreas Schneider
481522cf63 agent: Use new pki functions. 2011-08-13 12:21:23 +02:00
Andreas Schneider
0523adf95c pki: Add ssh_pki_import_pubkey_string(). 2011-08-13 12:13:09 +02:00
Andreas Schneider
74d755873d pki: Use const. 2011-08-13 11:26:03 +02:00
Andreas Schneider
30ec1e0b05 pki: Document public key function. 2011-08-13 11:19:37 +02:00
Andreas Schneider
f421c05913 cmake: Check for argp library only on bsd and solaris. 2011-08-13 11:07:57 +02:00
Andreas Schneider
e92787395a pki: Fix doc of ssh_pki_import_privkey_base64(). 2011-08-12 11:04:30 +02:00
Andreas Schneider
a4a1af5bbf options: Allocate dest in ssh_options_copy(). 2011-08-11 12:53:02 +02:00
Andreas Schneider
1c30c2a510 pki: Fix a resource leak. 2011-08-11 12:36:01 +02:00
Andreas Schneider
8bf8a7ef49 Fix typo. 2011-08-10 19:07:42 +02:00
Andreas Schneider
37a38d4959 Added CodingStyle file. 2011-08-10 19:05:15 +02:00
Andreas Schneider
13227714f2 channels: Fix incorrect return values in ssh_channel_write(). 2011-08-10 16:58:10 +02:00
rofl0r
7949f2cdc6 session: Fix an infinite loop in the termination callback.
This happened due to the use of the buggy and obsolete timeout
funtions.
2011-08-10 15:41:36 +02:00
Andreas Schneider
2f87873642 channels: Handle SSH_AGAIN in channel_open(). 2011-08-09 22:59:17 +02:00
Mark Riordan
6c45d6dc01 Fix "status -5 inflating zlib packet"
Signed-off-by: Mark Riordan <mriordan@ipswitch.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-08-09 20:13:20 +02:00
Andreas Schneider
9c0af42dd8 pki: Use a consistent name scheme.
Rename ssh_key_import_private to ssh_pki_import_privkey_file.
2011-08-09 18:05:47 +02:00
Andreas Schneider
bec483bc18 pki: Add ssh_pki_import_pubkey_base64(). 2011-08-08 15:28:31 +02:00
Andreas Schneider
f81444bd57 pki: Add pki_do_sign(). 2011-08-08 15:28:31 +02:00
Andreas Schneider
38d00c0e7a bind: Use ssh_key_import_private(). 2011-08-08 15:28:31 +02:00
Andreas Schneider
9bed334da3 pki: Add ssh_pki_convert_key_to_privatekey(). 2011-08-08 15:28:31 +02:00
Andreas Schneider
7c302d376c pki: Move _privatekey_from_file to legacy.c. 2011-08-08 15:28:31 +02:00
Andreas Schneider
36ee2d3332 pki: Create pki_publickey_from_privatekey(). 2011-08-08 15:28:31 +02:00
Andreas Schneider
f55cd7de43 pki: Improve ssh_key_import_private(). 2011-08-08 15:28:31 +02:00
Andreas Schneider
9569d053d8 pki: Improve ssh_pki_import_privkey_base64(). 2011-08-08 15:28:31 +02:00
Andreas Schneider
028888719a pki: Add pki_privatekey_type_from_string(). 2011-08-08 15:28:31 +02:00
Andreas Schneider
d8b41bcac3 pki: Add placeholder for ecdsa and certs. 2011-08-08 15:28:31 +02:00
Andreas Schneider
6ccb3f7a82 pki: Add pki_crypto.c. 2011-08-08 15:28:31 +02:00
Andreas Schneider
37b80e9261 pki: Move keyfiles to pki_gcrypt.c. 2011-08-08 15:28:31 +02:00
Einar Floystad Dorum
01c4b713dc Fixed ssh_scp_write so it works when doing recursive copy
There where two issues with ssh_scp_write:
1) It did not write a status message after the last write and OpenSSH
   would then give up after the write finished.
2) OpenSSH would sometimes write a status message, after near ends write.
   If scp_write didn't handle it, and subsequent status message. The remote
   window would shrink to zero and ssh_channel_write would start returning 0.

Signed-off-by: Einar Floystad Dorum <einarfd@mailthief.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-08-08 15:27:23 +02:00
rofl0r
35686b4822 client: Fix another source of endless wait. 2011-08-06 11:12:02 +02:00
rofl0r
7ccd9c31b3 channels: Fix an endless loop in case of a channel_open error. 2011-08-06 11:12:02 +02:00
rofl0r
af85337f5f session: Fix timeout handling.
-2 now means to use the timeout specified in options. It wasn't used
earlier and poll only knows -1 and 0 anyway for special meanings.
2011-08-06 11:12:02 +02:00
rofl0r
563fbe4de8 channels: Fix checking for fatal errors.
We need this that we don't end up in and infinite poll loop.
2011-08-06 11:11:12 +02:00
rofl0r
39f962c91e channels: Fix ssh_channel_from_local()
It only worked if the first channel in the list was equivalent to we
were looking for.
2011-08-06 11:08:55 +02:00
rofl0r
c31cac93f3 misc: Fix ssh_timeout_update(). 2011-08-06 11:08:38 +02:00
rofl0r
a290fe33c1 gitignore: ignore object files 2011-08-06 10:53:08 +02:00
Andreas Schneider
15ebbad146 examples: Fix permissions of the file we copy.
Thanks to Baptiste Marchand.
2011-08-03 22:21:43 +02:00
Andreas Schneider
790b62bca5 channels: Set the max packet size to 32768. 2011-08-03 20:49:57 +02:00
Andreas Schneider
ca47c9b46e cmake: Make CHECK_C_COMPILER_FLAG_SSP a function. 2011-07-29 11:37:52 +02:00
Aris Adamantiadis
0943ce3a4a Fixed build on openssl 2011-07-20 09:56:43 +02:00
Aris Adamantiadis
da954c2c5e Fixes the ssh_log issue on ssh_bind handles. 2011-07-19 22:16:28 +02:00
Andreas Schneider
dc9ac022f5 doc: Add OpenSSH pub certkey auth. 2011-07-19 12:20:36 +02:00
Aris Adamantiadis
54fb43358c Workaround ssh_get_user_home_dir on LDAP users 2011-07-13 12:04:46 +02:00
Andreas Schneider
cc29fef234 build: Remove broken old Makefile. 2011-06-30 15:47:52 +02:00
Andreas Schneider
f684e76ab2 Merge branch 'pki' 2011-06-15 18:27:23 +02:00
Andreas Schneider
c75581fb93 pki: Make ssh_key_is_private() a public function. 2011-06-15 18:27:05 +02:00
Andreas Schneider
27cedaa0b6 pki: Make ssh_key_is_public() a public function. 2011-06-15 18:27:05 +02:00
Andreas Schneider
2be90be740 known_hosts: Added a log message for key type mismatch. 2011-06-15 18:27:05 +02:00
Andreas Schneider
3ba44badb0 build: Fix libssh_threads pkg-config. 2011-06-15 18:26:51 +02:00
Aris Adamantiadis
bcec7eeddc [crypto] fix pubkey authentication with ecdh 2011-06-14 23:13:20 +02:00
Aris Adamantiadis
ce03d26e03 Fix memory leak with session_id 2011-06-14 22:57:43 +02:00
Aris Adamantiadis
db2d0ebc44 Fix build with missing openssl/ecdh.h 2011-06-14 22:57:43 +02:00
Andreas Schneider
583a7f933a cmake: Added pkg-config support for libssh_treads. 2011-06-14 13:47:04 +02:00
Aris Adamantiadis
2653b31af0 [crypto] Removed ugly ifdefs on gcrypt/libcrypto 2011-06-13 14:47:17 +02:00
Aris Adamantiadis
a3c28f2558 Fix memory leak 2011-06-13 14:06:30 +02:00
Aris Adamantiadis
c5a998f47a [crypto] initial support for ecdh-sha2-nistp256
Works with openssl
Still requires work for libgcrypt and other modes
2011-06-13 13:46:34 +02:00
Aris Adamantiadis
3b72bf0880 Moved DH specific code to dh.h 2011-06-12 20:55:58 +02:00
Aris Adamantiadis
113de13543 Test for ecdh and dh-group1 2011-06-12 20:54:33 +02:00
Aris Adamantiadis
b54e8cdae5 Check for ecdsa with openssl, added log_warning 2011-06-12 19:38:42 +02:00
Andreas Schneider
fb0f125351 packet: Don't (de)compress empty buffers.
This fixes bug #50.
2011-06-11 13:15:46 +02:00
Andreas Schneider
981190f8d3 pki: Add ssh_key_type_to_char() and ssh_key_type_from_name(). 2011-06-11 13:04:22 +02:00
Andreas Schneider
88e2f17b97 pki: Make ssh_key_type a public function. 2011-06-11 13:04:22 +02:00
Andreas Schneider
29fa4b6b35 pki: Add SSH_KEYTYPE_ECDSA. 2011-06-11 13:04:22 +02:00
Aris Adamantiadis
7ff69d9c48 packet: Abort session on fatal errors on packets 2011-06-09 23:27:41 +02:00
Andreas Schneider
640e3830f2 build: Check for ntohll().
This function is available on AIX.
2011-06-06 18:56:30 +02:00
Andreas Schneider
3fa801a929 string: Added missing include. 2011-06-06 18:56:15 +02:00
Andreas Schneider
d536cc4f39 string: Added missing errno. 2011-06-06 18:50:39 +02:00
Andreas Schneider
ee83301eb3 build: Update ChangeLog. 2011-06-01 17:55:26 +02:00
Andreas Schneider
1880ef54d2 cmake: Fix static .lib overwriting on Windows. 2011-06-01 14:52:27 +02:00
Andreas Schneider
94ca5ed3df cmake: Set next version. 2011-05-30 12:38:17 +02:00
Andreas Schneider
693425afab tests: Check error of ssh_userauth_kbdint(). 2011-05-28 13:31:17 +02:00
Andreas Schneider
82798035fc tests: Remove superfluous closedir(). 2011-05-28 13:28:49 +02:00
Andreas Schneider
3c21281bf0 session: Fix return code of ssh_blocking_flush(). 2011-05-28 13:27:14 +02:00
Aris Adamantiadis
3bc46c3bf0 remove "0.5.0 is dev" in the doc 2011-05-27 13:37:52 +02:00
Aris Adamantiadis
ac167c9077 Forgot a cast to remove warnings 2011-05-27 13:36:55 +02:00
Aris Adamantiadis
c84380bad5 Fix documentation bug about threading 2011-05-27 13:26:15 +02:00
Aris Adamantiadis
17454caf64 Fix bug #5, channel_read_nonblocking that blocks 2011-05-27 13:13:02 +02:00
Mark Riordan
dcea8db6b2 Fix memory leak when compression is used
Signed-off-by: Mark Riordan <mriordan@ipswitch.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-05-27 11:45:45 +02:00
Aris Adamantiadis
809b3adeba Fix compilation without server and sftp modes 2011-05-26 21:56:42 +02:00
Aris Adamantiadis
34b05fd2dc Fix memory leaks in pki and testcase 2011-05-26 21:33:36 +02:00
Andreas Schneider
c483418b82 sftp: Reset eof on seek operations.
This fixes bug #48.
2011-05-26 11:22:11 +02:00
Andreas Schneider
ba03388031 misc: Fix compilation on Windows. 2011-05-26 11:20:04 +02:00
Andreas Schneider
8b73609e47 cmake: Remove unused regcomp check. 2011-05-25 22:09:41 +02:00
Andreas Schneider
07fb895fe9 cmake: Fix detection of clock_gettime. 2011-05-25 22:08:31 +02:00
Aris Adamantiadis
65282841e2 Replace clock_gettime with gettimeofday when missing 2011-05-25 21:27:48 +02:00
Aris Adamantiadis
59f7647cd9 Introduced ssh_timeout_elapsed functions
Functions to mesure elapsed time before and after a serie of
calls. Introduces a dependancy to clock_gettime() and librt,
hope this doesn't break anything. Porting to gettimeofday() should
not be too hard.
2011-05-24 23:26:18 +02:00
Aris Adamantiadis
4d6b1aa2c7 Added testcase for the timeout connecting problem 2011-05-24 23:25:40 +02:00
Aris Adamantiadis
79434649d0 Fix "connecting to closed port" on MacosX 2011-05-20 15:13:45 +02:00
Aris Adamantiadis
a053d819a3 Fixed warnings on MacosX with Xcode4 2011-05-20 14:31:13 +02:00
Aris Adamantiadis
837896e72d scp: Fixed documentation bugs. bug #8 2011-05-20 13:42:24 +02:00
Oliver Stöneberg
12b61a6266 doc: Small update to auth.c documentation. 2011-05-17 14:22:11 +02:00
Oliver Stöneberg
f4f4ce37f0 poll: Removed WSAPoll() support.
It was causing too many issues and the poll emulation is quite stable.
2011-05-17 14:21:17 +02:00
Oliver Stöneberg
671a982739 connect: Set timeout on connect
This also fixes error handling in ssh_poll_ctx_dopoll() and
ssh_handle_packets(), so it won't loop forever on an actual timeout.
2011-05-17 14:21:04 +02:00
Oliver Stöneberg
4e153aed8a channel: Fixed potential use-after-free in ssh_channel_get_exit_status().
If ssh_channel_get_exit_status() is called more than once and the
connection closed.
2011-05-17 14:20:56 +02:00
Oliver Stöneberg
525324b2f9 examples: Use the right cleanup functions. 2011-05-17 14:20:48 +02:00
Oliver Stöneberg
e3311d03db tests: Fixed some cppcheck warnings. 2011-05-17 14:20:28 +02:00
Oliver Stöneberg
7f0761885c keyfiles: Fixed compilation without defines.
This fixes cppcheck issues.
2011-05-17 14:20:09 +02:00
Oliver Stöneberg
9866763789 socket: Fixed use-after-free.
When s->callbacks->exception() was called in ssh_socket_pollcallback()
we had a use after free bug.
2011-05-17 14:19:51 +02:00
Andreas Schneider
32cd45612b channel: Improve the request signal documentation. 2011-05-15 13:42:38 +02:00
Andreas Schneider
d4838d4dc8 messages: Try to fix the build. 2011-05-03 10:55:14 +02:00
Oliver Stöneberg
daf1c3e0a8 Use BIO* in _privatekey_from_file [Oliver Stöneberg]
_privatekey_from_file: moved FILE* into HAVE_LIBGCRYPT code / added missing #ifdef's to default case of switch [Oliver Stöneberg]
(cherry picked from commit dcb50cc0c8)
2011-05-02 19:19:41 +02:00
milo
32ba5204b7 Delay the check for kbdint->answers in kbdint_send() 2011-05-02 18:02:56 +02:00
milo
b6e712e934 Fix segfault when ssh_userauth_kbdint_setanswer() has not been called 2011-05-02 17:30:43 +02:00
milo
7d2064c289 [socket] fix a segfault at disconnect
(cherry picked from commit 56394917b15e41603c641c22a4e29c33b096d673)
2011-05-02 17:02:25 +02:00
milo
eb5fedb685 [event] don't use sessions in event anymore
(cherry picked from commit 89d0fdbbde4cf48e783a8ee7c5907c51a83e207b)
2011-05-02 17:01:59 +02:00
milo
1979c14aac [messages] don't queue messages if callback present
(cherry picked from commit 99d0f6d7c77e064b7fd0f0f46c40988de1996f3b)
2011-05-02 16:59:52 +02:00
milo
8092541603 [poll] avoid infinite loop in ssh_poll_ctx_free()
(cherry picked from commit eace59d3eaad413fd846d1c8b4c926285f6cd5ab)
2011-05-02 16:58:40 +02:00
milo
7ba0938846 [channels] Added ssh_channel_window_size() and avoided reentrancy in channel_write_common()
(cherry picked from commit 27313334578f4acb7ccf0687bba7f76b2febd569)
2011-05-02 16:58:27 +02:00
Oliver Stöneberg
3ae01ff9f5 init: Some initialization fixes.
- Check result of ssh_init() in privatekey_from_base64()
- Moved code from ssh_finalize() to appropriate subroutines
- Only initialize sockets once (caused mismatch of WSAStartup() and
  WSACleanup() calls and potential usage of bsd_poll when win_poll
  should be used)
2011-05-01 19:42:50 +02:00
Oliver Stöneberg
040a543f57 socket: Fixed poll input event. 2011-05-01 19:42:38 +02:00
Oliver Stöneberg
a73459171b examples: Removed unnecessary \n from ssh_log() calls in samplessh. 2011-05-01 19:33:26 +02:00
Oliver Stöneberg
c3849a3cfd examples: Fixed memory leak in samplessh when using commands. 2011-05-01 19:33:09 +02:00
milo
91c9d86d45 [keyfiles] Fix two memory leaks 2011-04-18 17:49:54 +02:00
milo
6e58342abc [pki] remove unused functions 2011-04-18 17:40:27 +02:00
Andreas Schneider
8b95328b1b poll: Fix poll input events.
bug#38
2011-04-15 19:14:15 +02:00
Andreas Schneider
644145a88c examples: Fix some memory leaks. 2011-04-15 19:05:53 +02:00
Andreas Schneider
ef658b4bef Fix assertion with Visual Studio because of %zu. 2011-04-15 19:02:21 +02:00
Andreas Schneider
a6c53d51de scp: More correct fix for snprintf 64-bit format. 2011-04-15 18:56:52 +02:00
Mark Riordan
e7e4f261a6 scp: Fix snprintf format for 64-bit size on SCP push.
Signed-off-by: Mark Riordan <mriordan@ipswitch.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-04-15 16:18:26 +02:00
Mark Riordan
96d5f13813 scp: Support huge files by changing size to 64-bit type.
Signed-off-by: Mark Riordan <mriordan@ipswitch.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-04-15 16:18:26 +02:00
Aris Adamantiadis
3a77f2aebe [pki] Fix buffer overflow in pki 2011-04-15 09:11:09 +02:00
Mark Riordan
5939cfe78a scp: Fix potential infinite loop in ssh_scp_close
Signed-off-by: Mark Riordan <mriordan@ipswitch.com>
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-04-14 14:18:45 +02:00
Andreas Schneider
3e7d4534ce examples: Call correct functions on exit. 2011-04-14 14:16:58 +02:00
milo
cee8ca339b Use const for x11_auth_* strings 2011-04-14 14:05:44 +02:00
milo
7cc4471168 Implemented X11 server side 2011-04-14 14:05:44 +02:00
milo
3046a50614 Skip \r when reading private keys 2011-04-14 14:05:44 +02:00
milo
23aa58e442 Added some tortures for pki 2011-04-14 14:05:44 +02:00
milo
f8c7ad9c7a [pki] Added ssh_userauth_pki_pubkey() function 2011-04-14 14:05:44 +02:00
milo
72b53aa11e Fix error message in privatekey_from_base64() 2011-04-14 14:05:44 +02:00
milo
c96314971c [pki] Add documentation and check for NULLs 2011-04-14 14:05:44 +02:00
milo
82e3068cb7 Set freed pointers to NULL in ssh_key struct 2011-04-14 14:05:44 +02:00
milo
b308bb9d52 [pki] added ssh_pki_do_sign() function 2011-04-14 14:05:44 +02:00
milo
c1f65492f7 [pki] Added conversion functions to migrate seemlessly to ssh_key 2011-04-14 14:05:44 +02:00
milo
c5db7674ec [pki] check for NULL and small cosmetic changes 2011-04-14 14:05:44 +02:00
milo
2694853979 [pki] Added ssh_pki_publickey_from_privatekey() function 2011-04-14 14:05:44 +02:00
milo
69d2457762 [pki] Added ssh_pki_import_privkey_base64() 2011-04-14 14:05:44 +02:00
milo
c1d385f6da [pki] remove non existing function prototype 2011-04-14 14:05:44 +02:00
milo
c20afa75a2 [pki] Fixed a probable bug in privatekey_file_to_buffer() 2011-04-14 14:05:44 +02:00
milo
df3e497dbd [pki] Added privatekey_from_base64() function...
and wrapped it with privatekey_from_file()
2011-04-14 14:05:44 +02:00
milo
9a21093ab8 [pki] Added b64decode_dsa_privatekey() function 2011-04-14 14:05:44 +02:00
milo
5f54eff0be [pki] Added b64decode_rsa_privatekey() function 2011-04-14 14:05:43 +02:00
milo
43ebdbfe46 [pki] Added privatekey_string_to_buffer() function 2011-04-14 14:05:43 +02:00
milo
2be42922c8 [pki] Make ssh_key_new and ssh_key_free public 2011-04-14 14:05:43 +02:00
milo
a0a3ceeaa0 Semantic fix on malloc 2011-04-14 13:46:40 +02:00
milo
42315772b2 Fix a memleak on event poll contexts 2011-04-14 13:31:24 +02:00
milo
23b28a573c Fix a 0 bytes malloc in server kbdint implementation 2011-04-14 13:31:11 +02:00
Aris Adamantiadis
934252d6ca Fixed missing CRYPTO_cleanup_all_ex_data() in ssh_finalize 2011-04-14 13:09:09 +02:00
Andreas Schneider
94e7d345a7 wrapper: Fixed a possible NULL pointer dereference. 2011-04-14 10:17:44 +02:00
Andreas Schneider
7e4916cefc server: Fixed a possible NULL pointer dereference. 2011-04-14 10:10:19 +02:00
milo
e04d30e083 Bug fix in ssh_poll_ctx_remove() 2011-04-14 00:09:35 +02:00
Oliver Stöneberg
166ee451c5 build: Fixed some VS2010 problems. 2011-04-11 11:18:57 +02:00
Oliver Stöneberg
46475dfa2f keys: Fixed issues reported by cppcheck. 2011-04-11 11:06:32 +02:00
Andreas Schneider
7150cabafa cmake: Fixed a typo. 2011-04-08 11:02:25 +02:00
Mark Riordan
29bb718a93 sftp: Fixed double-free in sftp_unlink(). 2011-04-08 10:59:05 +02:00
Aris Adamantiadis
1c062b22bf Fixed doc of ssh_userauth_list() 2011-03-28 12:55:48 +02:00
Aris Adamantiadis
4bc9c96e4e Change session state after receiving a Disconnect 2011-03-28 12:46:08 +02:00
Andreas Schneider
0ab17a8906 doc: Extremly important README update! 2011-03-25 19:24:42 +01:00
Aris Adamantiadis
1a101a959e Fix the ssh_message_retrieve problem by anihilation 2011-03-22 12:23:02 +01:00
Aris Adamantiadis
dff4e4e6d3 Implement ssh_blocking_flush()
Based on code from Jan Willamowius
2011-03-22 11:49:57 +01:00
Aris Adamantiadis
79b74bdf64 Added a IP address test 2011-03-22 10:45:07 +01:00
Andreas Schneider
633d6532be example: Use const in auth_password from samplesshd. 2011-03-10 11:23:45 +01:00
Andreas Schneider
7e921b7afb messages: Make returned strings const. 2011-03-09 19:45:17 +01:00
Andreas Schneider
7420b0fb83 doc: More doc for messaging functions. 2011-03-09 19:39:34 +01:00
Andreas Schneider
52e223dfdd doc: Added missing doc for common message function. 2011-03-09 19:19:56 +01:00
Andreas Schneider
e2706fe21d doc: Fixed typos in messaging introduction. 2011-03-09 19:06:59 +01:00
Andreas Schneider
7daa81f3aa doc: Improve the doc of ssh_bind_set_callbacks. 2011-03-09 18:33:03 +01:00
Andreas Schneider
6754c34711 doc: Improved documentation for server options. 2011-03-06 14:25:21 +01:00
Andreas Schneider
7e9d384ec8 build: Set version to 0.5.90. 2011-03-01 21:28:50 +01:00
Andreas Schneider
d97458d640 messages: Added missing config.h include. 2011-02-25 10:22:19 +01:00
Andreas Schneider
dab8f847e6 legacy: Added missing channel_write_stderr. 2011-02-23 12:38:45 +01:00
Andreas Schneider
8d3823127c legacy: Fixed the symbol export. 2011-02-23 12:31:29 +01:00
milo
8ee8d4f913 Check for NULL channel pointers 2011-02-22 14:11:19 +01:00
milo
000d659ea2 examples: Added a event context based sshd example. 2011-02-20 14:37:43 +01:00
milo
ddb1c1838f poll: Added a function to poll the events. 2011-02-20 14:37:43 +01:00
milo
e40261c22c poll: Added function to remove fd from the event context. 2011-02-20 14:37:34 +01:00
milo
6582da1d67 poll: Added function to add an fd to the events. 2011-02-20 14:37:34 +01:00
milo
0c76156f54 poll: Added function to remove session from event loop. 2011-02-20 14:37:31 +01:00
milo
4b72953c7e poll: Added function to add session to an event. 2011-02-20 14:36:44 +01:00
milo
4ee4450a6b poll: Added a function to free an event. 2011-02-20 14:35:11 +01:00
milo
a2634ceea8 poll: Started to add a poll based event loop. 2011-02-20 14:21:45 +01:00
Andreas Schneider
ac8276c70e server: Fixed logging function name. 2011-02-18 20:57:09 +01:00
Andreas Schneider
5cc2e69d0d channel: Fixed a possible NULL pointe dereference. 2011-02-18 18:03:37 +01:00
Bernhard R. Link
23b3c46fd6 channel: Improve ssh_channel_open_reverse_forward documentation. 2011-02-18 17:50:50 +01:00
Bernhard R. Link
8a83990c16 channels: set error for new NULL pointer checks
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-02-18 17:45:28 +01:00
Bernhard R. Link
071b0034db socket: Set errors on return.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-02-14 22:48:53 +01:00
Bernhard R. Link
7ae59c571a channels: Set errors on return.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-02-14 22:48:53 +01:00
Bernhard R. Link
b1db0e54ad bind: Set errors on return.
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-02-14 22:48:53 +01:00
milo
4230509e80 Check for NULL pointers in string.c 2011-02-14 20:23:12 +01:00
milo
11e54e8221 Check for NULL pointers in channels.c 2011-02-14 20:02:02 +01:00
Andreas Schneider
eea1df3574 misc: Fixed ssh_is_ipaddr_v4() on Windows. 2011-02-13 17:36:45 +01:00
Andreas Schneider
9baa491b0b build: Try to fix the build on Solaris. 2011-02-13 13:22:25 +01:00
Andreas Schneider
cd30a1d4b1 misc: Added working ssh_is_ipaddr for Windows. 2011-02-13 11:56:47 +01:00
Andreas Schneider
ca941d6985 tests: Fixed misc and isipaddr test on Windows. 2011-02-13 11:56:47 +01:00
Andreas Schneider
cbcd5668f5 torture: Fixed torture on Windows. 2011-02-13 11:56:47 +01:00
Andreas Schneider
fdd1cb18d0 auth: Fixed a memory leak in kdbint auth.
Milo please check!
2011-02-13 11:04:09 +01:00
Andreas Schneider
a0c05c4c4e tests: Added two asserts to torture_sftp_dir. 2011-02-13 10:44:09 +01:00
Andreas Schneider
499467d362 auth: Fixed a double free error. 2011-02-13 10:43:59 +01:00
Andreas Schneider
d1ddec00d9 misc: Fixed ssh_is_ipaddr on FreeBSD. 2011-02-13 10:32:47 +01:00
Bernhard R. Link
637fc7ea59 always set error when returning error in auth.c
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-02-12 20:11:50 +01:00
Andreas Schneider
622d5a43b3 ctest: Added support for checking out a branch. 2011-02-12 20:08:23 +01:00
Aris Adamantiadis
483cdc2d2c Added ssh_userauth_[offer_]pubkey nonblocking iface 2011-02-12 19:21:13 +01:00
Andreas Schneider
5d4bd5a21d tests: Added ipv6 tests. 2011-02-12 19:16:06 +01:00
Andreas Schneider
e8c3f55751 tests: Fixed torture_isipaddr. 2011-02-12 19:12:39 +01:00
Bernhard R. Link
8d9d46ca66 use ssh_log instead of fprintf in ssh_config_parse_file
ssh_config_parse_file calls "fprintf(stderr," directly thus ignoring
a set log callback. Replacing the print with a call to ssh_log should
fix this.

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-02-12 19:08:59 +01:00
Andreas Schneider
4d38b4c848 srv_sftp: Set error messages in sftp_get_client_message(). 2011-02-12 19:08:59 +01:00
Andreas Schneider
768fbdd92e connect: Use ssh_is_ipaddr instead of regex. 2011-02-12 19:08:59 +01:00
Andreas Schneider
b313fa944a misc: Added ssh_is_ipaddr() function. 2011-02-12 19:08:59 +01:00
Aris Adamantiadis
7acc2fa607 Connect: Test the new isipaddr() function 2011-02-12 15:07:37 +01:00
Bernhard R. Link
8e0e4d8fb3 ssh_connect_host_nonblocking returns SSH_EINTR, not E_INTR, so update documentation
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-02-12 14:29:03 +01:00
Bernhard R. Link
8b51d29363 proper prototypes
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2011-02-12 12:26:33 +01:00
milo
cc76a192df New example server for kbdint authentication. 2011-02-10 14:39:58 +01:00
milo
3c0a4781e4 Added the keyboard-interactive authentication method 2011-02-10 14:39:20 +01:00
milo
32e23a25da Reverse commit 076dfb82 for the server side 2011-02-10 14:37:34 +01:00
milo
3eaf25d989 Fix NULL pointer checks in poll 2011-02-10 14:35:29 +01:00
Andreas Schneider
6f2bf91e29 build: Increased version numbers. 2011-02-10 12:54:33 +01:00
460 changed files with 118414 additions and 26715 deletions

4
.arcconfig Normal file
View File

@@ -0,0 +1,4 @@
{
"phabricator.uri" : "https://bugs.libssh.org/",
"history.immutable": true
}

View File

@@ -1 +0,0 @@
-Iinclude -Ibuild

18
.editorconfig Normal file
View File

@@ -0,0 +1,18 @@
root = true
[*]
charset = utf-8
max_line_length = 80
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true
[*.{c,h}]
indent_style = space
indent_size = 4
tab_width = 4
[{CMakeLists.txt,*.cmake}]
indent_style = space
indent_size = 4
tab_width = 4

8
.gitignore vendored
View File

@@ -1,6 +1,12 @@
*.a
*.o
.*
*.swp
*~$
build
cscope.*
compile_commands.json
/.cache
/.clangd
tags
/build
/obj*

528
.gitlab-ci.yml Normal file
View File

@@ -0,0 +1,528 @@
---
variables:
BUILD_IMAGES_PROJECT: libssh/build-images
CENTOS7_BUILD: buildenv-centos7
CENTOS9_BUILD: buildenv-c9s
COVERITY_BUILD: buildenv-coverity
FEDORA_BUILD: buildenv-fedora
MINGW_BUILD: buildenv-mingw
TUMBLEWEED_BUILD: buildenv-tumbleweed
UBUNTU_BUILD: buildenv-ubuntu
ALPINE_BUILD: buildenv-alpine
stages:
- build
- test
- analysis
.build:
stage: build
variables:
CMAKE_DEFAULT_OPTIONS: "-DCMAKE_BUILD_TYPE=RelWithDebInfo -DPICKY_DEVELOPER=ON"
CMAKE_BUILD_OPTIONS: "-DWITH_BLOWFISH_CIPHER=ON -DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON -DWITH_DEBUG_CRYPTO=ON -DWITH_DEBUG_PACKET=ON -DWITH_DEBUG_CALLTRACE=ON -DWITH_DSA=ON"
CMAKE_TEST_OPTIONS: "-DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DSERVER_TESTING=ON -DWITH_BENCHMARKS=ON"
CMAKE_OPTIONS: $CMAKE_DEFAULT_OPTIONS $CMAKE_BUILD_OPTIONS $CMAKE_TEST_OPTIONS
before_script: &build
- uname -a
- cat /etc/os-release
- mount
- df -h
- cat /proc/swaps
- free -h
- mkdir -p obj && cd obj
script:
- cmake $CMAKE_OPTIONS $CMAKE_ADDITIONAL_OPTIONS .. &&
make -j$(nproc) &&
make -j$(nproc) install
# Do not use after_script as it does not make the targets fail
tags:
- shared
except:
- tags
artifacts:
expire_in: 1 week
when: on_failure
paths:
- obj/
.tests:
extends: .build
stage: test
# This is needed to prevent passing artifacts from previous stages
dependencies: []
script:
- cmake $CMAKE_OPTIONS $CMAKE_ADDITIONAL_OPTIONS .. &&
make -j$(nproc) &&
ctest --output-on-failure
# Do not use after_script as it does not make the targets fail
.fedora:
extends: .tests
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
variables:
CMAKE_ADDITIONAL_OPTIONS: -DWITH_PKCS11_URI=ON
.tumbleweed:
extends: .tests
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
###############################################################################
# CentOS builds #
###############################################################################
# pkd tests fail on CentOS7 docker images, so we don't use -DSERVER_TESTING=ON
centos7/openssl_1.0.x/x86_64:
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS7_BUILD
extends: .tests
script:
- cmake3 $CMAKE_OPTIONS .. &&
make -j$(nproc) &&
ctest --output-on-failure
centos9s/openssl_3.0.x/x86_64:
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$CENTOS9_BUILD
extends: .tests
script:
- export OPENSSL_ENABLE_SHA1_SIGNATURES=1
- cmake3 $CMAKE_OPTIONS .. &&
make -j$(nproc) &&
ctest --output-on-failure
###############################################################################
# Fedora builds #
###############################################################################
fedora/build:
extends: .build
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
fedora/docs:
extends: .build
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
script:
- cmake .. && make docs
fedora/ninja:
extends: .fedora
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
script:
- cmake -G Ninja $CMAKE_OPTIONS ../ && ninja && ninja test
fedora/openssl_3.0.x/x86_64:
extends: .fedora
fedora/openssl_3.0.x/x86_64/fips:
extends: .fedora
before_script:
- echo "# userspace fips" > /etc/system-fips
# We do not need the kernel part, but in case we ever do:
# mkdir -p /var/tmp/userspace-fips
# echo 1 > /var/tmp/userspace-fips/fips_enabled
# mount --bind /var/tmp/userspace-fips/fips_enabled \
# /proc/sys/crypto/fips_enabled
- update-crypto-policies --show
- update-crypto-policies --set FIPS
- update-crypto-policies --show
- mkdir -p obj && cd obj && cmake
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DPICKY_DEVELOPER=ON
-DWITH_BLOWFISH_CIPHER=ON
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
-DWITH_DEBUG_CRYPTO=ON -DWITH_DEBUG_PACKET=ON -DWITH_DEBUG_CALLTRACE=ON
-DWITH_DSA=ON
-DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DSERVER_TESTING=ON ..
script:
- cmake $CMAKE_OPTIONS .. &&
make -j$(nproc) &&
OPENSSL_FORCE_FIPS_MODE=1 ctest --output-on-failure
fedora/openssl_3.0.x/x86_64/minimal:
extends: .fedora
variables:
script:
- cmake $CMAKE_DEFAULT_OPTIONS
-DWITH_SFTP=OFF
-DWITH_SERVER=OFF
-DWITH_ZLIB=OFF
-DWITH_PCAP=OFF
-DWITH_DSA=OFF
-DUNIT_TESTING=ON
-DCLIENT_TESTING=ON
-DWITH_GEX=OFF .. &&
make -j$(nproc)
# Address sanitizer doesn't mix well with LD_PRELOAD used in the testsuite
# so, this is only enabled for unit tests right now.
# TODO: add -DCLIENT_TESTING=ON -DSERVER_TESTING=ON
fedora/address-sanitizer:
extends: .fedora
stage: analysis
script:
- cmake
-DCMAKE_BUILD_TYPE=AddressSanitizer
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DPICKY_DEVELOPER=ON
$CMAKE_BUILD_OPTIONS
-DUNIT_TESTING=ON
-DFUZZ_TESTING=ON .. &&
make -j$(nproc) &&
ctest --output-on-failure
# This is disabled as it report OpenSSL issues
# It also has the same issues with cwrap as AddressSanitizer
.fedora/memory-sanitizer:
extends: .fedora
stage: analysis
script:
- cmake
-DCMAKE_BUILD_TYPE=MemorySanitizer
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DPICKY_DEVELOPER=ON
$CMAKE_BUILD_OPTIONS
-DUNIT_TESTING=ON
-DFUZZ_TESTING=ON .. &&
make -j$(nproc) &&
ctest --output-on-failure
fedora/undefined-sanitizer:
extends: .fedora
stage: analysis
script:
- cmake
-DCMAKE_BUILD_TYPE=UndefinedSanitizer
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DPICKY_DEVELOPER=ON
$CMAKE_BUILD_OPTIONS
-DUNIT_TESTING=ON
-DFUZZ_TESTING=ON .. &&
make -j$(nproc) &&
ctest --output-on-failure
fedora/libgcrypt/x86_64:
extends: .fedora
variables:
CMAKE_ADDITIONAL_OPTIONS: "-DWITH_GCRYPT=ON -DWITH_DEBUG_CRYPTO=ON"
fedora/mbedtls/x86_64:
extends: .fedora
variables:
CMAKE_ADDITIONAL_OPTIONS: "-DWITH_MBEDTLS=ON -DWITH_DEBUG_CRYPTO=ON -DWITH_DSA=OFF"
# Unit testing only, no client and pkd testing, because cwrap is not available
# for MinGW
fedora/mingw64:
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$MINGW_BUILD
extends: .tests
script:
- export WINEPATH=/usr/x86_64-w64-mingw32/sys-root/mingw/bin
- export WINEDEBUG=-all
- mingw64-cmake $CMAKE_DEFAULT_OPTIONS
-DWITH_SFTP=ON
-DWITH_SERVER=ON
-DWITH_ZLIB=ON
-DWITH_PCAP=ON
-DUNIT_TESTING=ON .. &&
make -j$(nproc) &&
ctest --output-on-failure
# Unit testing only, no client and pkd testing, because cwrap is not available
# for MinGW
fedora/mingw32:
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$MINGW_BUILD
extends: .tests
script:
- export WINEPATH=/usr/i686-w64-mingw32/sys-root/mingw/bin
- export WINEDEBUG=-all
- mingw32-cmake $CMAKE_DEFAULT_OPTIONS
-DWITH_SFTP=ON
-DWITH_SERVER=ON
-DWITH_ZLIB=ON
-DWITH_PCAP=ON
-DUNIT_TESTING=ON .. &&
make -j$(nproc) &&
ctest --output-on-failure
###############################################################################
# Fedora csbuild #
###############################################################################
.csbuild:
stage: analysis
variables:
GIT_DEPTH: "100"
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
before_script:
- |
if [[ -z "$CI_COMMIT_BEFORE_SHA" ]]; then
export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20")
fi
# Check if the commit exists in this branch
# This is not the case for a force push
git branch --contains $CI_COMMIT_BEFORE_SHA 2>/dev/null || export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20")
export CI_COMMIT_RANGE="$CI_COMMIT_BEFORE_SHA..$CI_COMMIT_SHA"
tags:
- shared
except:
- tags
artifacts:
expire_in: 1 week
when: on_failure
paths:
- obj-csbuild/
fedora/csbuild/openssl_3.0.x:
extends: .csbuild
script:
- csbuild
--build-dir=obj-csbuild
--build-cmd "rm -rf CMakeFiles CMakeCache.txt && cmake -DCMAKE_BUILD_TYPE=Debug -DPICKY_DEVELOPER=ON -DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DSERVER_TESTING=ON -DFUZZ_TESTING=ON -DWITH_DSA=ON @SRCDIR@ && make clean && make -j$(nproc)"
--git-commit-range $CI_COMMIT_RANGE
--color
--print-current --print-fixed
fedora/csbuild/libgcrypt:
extends: .csbuild
script:
- csbuild
--build-dir=obj-csbuild
--build-cmd "rm -rf CMakeFiles CMakeCache.txt && cmake -DCMAKE_BUILD_TYPE=Debug -DPICKY_DEVELOPER=ON -DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DSERVER_TESTING=ON -DFUZZ_TESTING=ON -DWITH_GCRYPT=ON -DWITH_DSA=ON @SRCDIR@ && make clean && make -j$(nproc)"
--git-commit-range $CI_COMMIT_RANGE
--color
--print-current --print-fixed
fedora/csbuild/mbedtls:
extends: .csbuild
script:
- csbuild
--build-dir=obj-csbuild
--build-cmd "rm -rf CMakeFiles CMakeCache.txt && cmake -DCMAKE_BUILD_TYPE=Debug -DPICKY_DEVELOPER=ON -DUNIT_TESTING=ON -DCLIENT_TESTING=ON -DSERVER_TESTING=ON -DFUZZ_TESTING=ON -DWITH_MBEDTLS=ON @SRCDIR@ && make clean && make -j$(nproc)"
--git-commit-range $CI_COMMIT_RANGE
--color
--print-current --print-fixed
###############################################################################
# Ubuntu builds #
###############################################################################
ubuntu/openssl_1.1.x/x86_64:
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$UBUNTU_BUILD
extends: .tests
###############################################################################
# Alpine builds #
###############################################################################
alpine/musl:
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$ALPINE_BUILD
extends: .tests
script:
- cmake $CMAKE_DEFAULT_OPTIONS
-DWITH_SFTP=ON
-DWITH_SERVER=ON
-DWITH_ZLIB=ON
-DWITH_PCAP=ON
-DUNIT_TESTING=ON .. &&
make -j$(nproc) &&
ctest --output-on-failure
###############################################################################
# Tumbleweed builds #
###############################################################################
tumbleweed/openssl_1.1.x/x86_64/gcc:
extends: .tumbleweed
variables:
CMAKE_ADDITIONAL_OPTIONS: "-DKRB5_CONFIG=/usr/lib/mit/bin/krb5-config"
tumbleweed/openssl_1.1.x/x86/gcc:
extends: .tumbleweed
script:
- cmake
-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-m32.cmake
$CMAKE_DEFAULT_OPTIONS
-DWITH_SFTP=ON
-DWITH_SERVER=ON
-DWITH_ZLIB=ON
-DWITH_PCAP=ON
-DWITH_DSA=ON
-DUNIT_TESTING=ON ..
tumbleweed/openssl_1.1.x/x86_64/gcc7:
extends: .tumbleweed
variables:
CMAKE_ADDITIONAL_OPTIONS: "-DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7 -DKRB5_CONFIG=/usr/lib/mit/bin/krb5-config"
tumbleweed/openssl_1.1.x/x86/gcc7:
extends: .tumbleweed
script:
- cmake
-DCMAKE_TOOLCHAIN_FILE=../cmake/Toolchain-cross-m32.cmake
-DCMAKE_C_COMPILER=gcc-7 -DCMAKE_CXX_COMPILER=g++-7
$CMAKE_DEFAULT_OPTIONS
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
-DWITH_DSA=ON
-DUNIT_TESTING=ON .. &&
make -j$(nproc) &&
ctest --output-on-failure
tumbleweed/openssl_1.1.x/x86_64/clang:
extends: .tumbleweed
variables:
CMAKE_ADDITIONAL_OPTIONS: "-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DKRB5_CONFIG=/usr/lib/mit/bin/krb5-config"
tumbleweed/static-analysis:
extends: .tests
stage: analysis
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$TUMBLEWEED_BUILD
script:
- export CCC_CC=clang
- export CCC_CXX=clang++
- scan-build cmake
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
-DPICKY_DEVELOPER=ON
$CMAKE_BUILD_OPTIONS
$CMAKE_TEST_OPTIONS .. &&
scan-build --status-bugs -o scan make -j$(nproc)
artifacts:
expire_in: 1 week
when: on_failure
paths:
- obj/scan
###############################################################################
# FreeBSD builds #
###############################################################################
# That is a specific runner that we cannot enable universally.
# We restrict it to builds under the $BUILD_IMAGES_PROJECT project.
freebsd/x86_64:
image:
extends: .tests
before_script:
- mkdir -p obj && cd obj && cmake
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DPICKY_DEVELOPER=ON
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
-DUNIT_TESTING=ON ..
script:
- cmake $CMAKE_DEFAULT_OPTIONS
-DWITH_SFTP=ON
-DWITH_SERVER=ON
-DWITH_ZLIB=ON
-DWITH_PCAP=ON
-DUNIT_TESTING=ON .. &&
make &&
ctest --output-on-failure
tags:
- private
- freebsd
only:
- branches@libssh/libssh-mirror
- branches@cryptomilk/libssh-mirror
- branches@jjelen/libssh-mirror
- branches@marco.fortina/libssh-mirror
###############################################################################
# Visual Studio builds #
###############################################################################
.vs:
stage: test
cache:
key: vcpkg.${CI_JOB_NAME}
paths:
- .vcpkg
variables:
ErrorActionPreference: STOP
script:
- cmake --build .
- ctest --output-on-failure
tags:
- windows
- shared-windows
except:
- tags
artifacts:
expire_in: 1 week
when: on_failure
paths:
- obj/
before_script:
- choco install --no-progress -y cmake
- $env:Path += ';C:\Program Files\CMake\bin'
- If (!(test-path .vcpkg\archives)) { mkdir -p .vcpkg\archives }
- $env:VCPKG_DEFAULT_BINARY_CACHE="$PWD\.vcpkg\archives"
- echo $env:VCPKG_DEFAULT_BINARY_CACHE
- $env:VCPKG_DEFAULT_TRIPLET="$TRIPLET-windows"
- vcpkg install cmocka
- vcpkg install openssl
- vcpkg install zlib
- vcpkg integrate install
- mkdir -p obj; if ($?) {cd obj}; if (! $?) {exit 1}
- cmake
-A $PLATFORM
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
-DPICKY_DEVELOPER=ON
-DWITH_SFTP=ON -DWITH_SERVER=ON -DWITH_ZLIB=ON -DWITH_PCAP=ON
-DUNIT_TESTING=ON ..
visualstudio/x86_64:
extends: .vs
variables:
PLATFORM: "x64"
TRIPLET: "x64"
visualstudio/x86:
extends: .vs
variables:
PLATFORM: "win32"
TRIPLET: "x86"
###############################################################################
# Coverity #
###############################################################################
#
# git push -o ci.variable="COVERITY_SCAN_TOKEN=XXXXXX" \
# -o ci.variable="COVERITY_SCAN_PROJECT_NAME=XXXXXX" \
# -o ci.variable="COVERITY_SCAN_EMAIL=XXXXXX" \
# -f gitlab
coverity:
stage: analysis
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$COVERITY_BUILD
script:
- mkdir obj && cd obj
- wget https://scan.coverity.com/download/linux64 --post-data "token=$COVERITY_SCAN_TOKEN&project=$COVERITY_SCAN_PROJECT_NAME" -O /tmp/coverity_tool.tgz
- tar xf /tmp/coverity_tool.tgz
- cmake -DCMAKE_BUILD_TYPE=Debug $CMAKE_BUILD_OPTIONS $CMAKE_TEST_OPTIONS ..
- cov-analysis-linux64-*/bin/cov-build --dir cov-int make -j$(nproc)
- tar czf cov-int.tar.gz cov-int
- curl
--form token=$COVERITY_SCAN_TOKEN
--form email=$COVERITY_SCAN_EMAIL
--form file=@cov-int.tar.gz
--form version="`git describe --tags`"
--form description="CI build"
https://scan.coverity.com/builds?project=$COVERITY_SCAN_PROJECT_NAME
tags:
- shared
only:
refs:
- master
- schedules
variables:
- $COVERITY_SCAN_TOKEN != null
- $COVERITY_SCAN_PROJECT_NAME != null
- $COVERITY_SCAN_EMAIL != null
artifacts:
expire_in: 1 week
when: on_failure
paths:
- obj/cov-int/*.txt

View File

@@ -1,7 +1,7 @@
Author(s):
Aris Adamantiadis <aris@0xbadc0de.be> (project initiator)
Andreas Schneider <mail@cynapses.org> (developer)
Andreas Schneider <asn@cryptomilk.org> (developer)
Nick Zitzmann <seiryu (at) comcast (dot) net> (mostly client SFTP stuff)

586
CHANGELOG Normal file
View File

@@ -0,0 +1,586 @@
CHANGELOG
=========
version 0.10.4 (released 2022-09-07)
* Fixed issues with KDF on big endian
version 0.10.3 (released 2022-09-05)
* Fixed possible infinite loop in known hosts checking
version 0.10.2 (released 2022-09-02)
* Fixed tilde expansion when handling include directives
* Fixed building the shared torture library
* Made rekey test more robust (fixes running on i586 build systems e.g koji)
version 0.10.1 (released 2022-08-30)
* Fixed proxycommand support
* Fixed musl libc support
version 0.10.0 (released 2022-08-26)
* Added support for OpenSSL 3.0
* Added support for mbedTLS 3
* Added support for Smart Cards (through openssl pkcs11 engine)
* Added support for chacha20-poly1305@openssh.com with libgcrypt
* Added support ed25519 keys in PEM files
* Added support for sk-ecdsa and sk-ed25519 (server side)
* Added support for limiting RSA key sizes and not accepting small one by
default
* Added support for ssh-agent on Windows
* Added ssh_userauth_publickey_auto_get_current_identity() API
* Added ssh_vlog() API
* Added ssh_send_issue_banner() API
* Added ssh_session_set_disconnect_message() API
* Added new configuration options:
+ IdentityAgent
+ ModuliFile
* Provided X11 client example
* Disabled DSA support at build time by default (will be removed in the next
release)
* Deprecated the SCP API!
* Deprecated old pubkey, privatekey API
* Avoided some needless large stack buffers to minimize memory footprint
* Removed support for OpenSSL < 1.0.1
* Fixed parsing username@host in login name
* Free global init mutex in the destructor on Windows
* Fixed PEM parsing in mbedtls to support both legacy and new PKCS8 formats
version 0.9.6 (released 2021-08-26)
* CVE-2021-3634: Fix possible heap-buffer overflow when rekeying with
different key exchange mechanism
* Fix several memory leaks on error paths
* Reset pending_call_state on disconnect
* Fix handshake bug with AEAD ciphers and no HMAC overlap
* Use OPENSSL_CRYPTO_LIBRARIES in CMake
* Ignore request success and failure message if they are not expected
* Support more identity files in configuration
* Avoid setting compiler flags directly in CMake
* Support build directories with special characters
* Include stdlib.h to avoid crash in Windows
* Fix sftp_new_channel constructs an invalid object
* Fix Ninja multiple rules error
* Several tests fixes
version 0.9.5 (released 2020-09-10)
* CVE-2020-16135: Avoid null pointer dereference in sftpserver (T232)
* Improve handling of library initialization (T222)
* Fix parsing of subsecond times in SFTP (T219)
* Make the documentation reproducible
* Remove deprecated API usage in OpenSSL
* Fix regression of ssh_channel_poll_timeout() returning SSH_AGAIN
* Define version in one place (T226)
* Prevent invalid free when using different C runtimes than OpenSSL (T229)
* Compatibility improvements to testsuite
version 0.9.4 (released 2020-04-09)
* Fixed CVE-2020-1730 - Possible DoS in client and server when handling
AES-CTR keys with OpenSSL
* Added diffie-hellman-group14-sha256
* Fixed serveral possible memory leaks
version 0.9.3 (released 2019-12-10)
* Fixed CVE-2019-14889 - SCP: Unsanitized location leads to command execution
* SSH-01-003 Client: Missing NULL check leads to crash in erroneous state
* SSH-01-006 General: Various unchecked Null-derefs cause DOS
* SSH-01-007 PKI Gcrypt: Potential UAF/double free with RSA pubkeys
* SSH-01-010 SSH: Deprecated hash function in fingerprinting
* SSH-01-013 Conf-Parsing: Recursive wildcards in hostnames lead to DOS
* SSH-01-014 Conf-Parsing: Integer underflow leads to OOB array access
* SSH-01-001 State Machine: Initial machine states should be set explicitly
* SSH-01-002 Kex: Differently bound macros used to iterate same array
* SSH-01-005 Code-Quality: Integer sign confusion during assignments
* SSH-01-008 SCP: Protocol Injection via unescaped File Names
* SSH-01-009 SSH: Update documentation which RFCs are implemented
* SSH-01-012 PKI: Information leak via uninitialized stack buffer
version 0.9.2 (released 2019-11-07)
* Fixed libssh-config.cmake
* Fixed issues with rsa algorithm negotiation (T191)
* Fixed detection of OpenSSL ed25519 support (T197)
version 0.9.1 (released 2019-10-25)
* Added support for Ed25519 via OpenSSL
* Added support for X25519 via OpenSSL
* Added support for localuser in Match keyword
* Fixed Match keyword to be case sensitive
* Fixed compilation with LibreSSL
* Fixed error report of channel open (T75)
* Fixed sftp documentation (T137)
* Fixed known_hosts parsing (T156)
* Fixed build issue with MinGW (T157)
* Fixed build with gcc 9 (T164)
* Fixed deprecation issues (T165)
* Fixed known_hosts directory creation (T166)
version 0.9.0 (released 2019-02-xx)
* Added support for AES-GCM
* Added improved rekeying support
* Added performance improvements
* Disabled blowfish support by default
* Fixed several ssh config parsing issues
* Added support for DH Group Exchange KEX
* Added support for Encrypt-then-MAC mode
* Added support for parsing server side configuration file
* Added support for ECDSA/Ed25519 certificates
* Added FIPS 140-2 compatibility
* Improved known_hosts parsing
* Improved documentation
* Improved OpenSSL API usage for KEX, DH, and signatures
version 0.8.0 (released 2018-08-10)
* Removed support for deprecated SSHv1 protocol
* Added new connector API for clients
* Added new known_hosts parsing API
* Added support for OpenSSL 1.1
* Added support for chacha20-poly1305 cipher
* Added crypto backend for mbedtls crypto library
* Added ECDSA support with gcrypt backend
* Added advanced client and server testing using cwrap.org
* Added support for curve25519-sha256 alias
* Added support for global known_hosts file
* Added support for symbol versioning
* Improved ssh_config parsing
* Improved threading support
version 0.7.5 (released 2017-04-13)
* Fixed a memory allocation issue with buffers
* Fixed PKI on Windows
* Fixed some SSHv1 functions
* Fixed config hostname expansion
version 0.7.4 (released 2017-02-03)
* Added id_ed25519 to the default identity list
* Fixed sftp EOF packet handling
* Fixed ssh_send_banner() to confirm with RFC 4253
* Fixed some memory leaks
version 0.7.3 (released 2016-01-23)
* Fixed CVE-2016-0739
* Fixed ssh-agent on big endian
* Fixed some documentation issues
version 0.7.2 (released 2015-09-15)
* Fixed OpenSSL detection on Windows
* Fixed return status for ssh_userauth_agent()
* Fixed KEX to prefer hmac-sha2-256
* Fixed sftp packet handling
* Fixed return values of ssh_key_is_(public|private)
* Fixed bug in global success reply
version 0.7.1 (released 2015-06-30)
* Fixed SSH_AUTH_PARTIAL auth with auto public key
* Fixed memory leak in session options
* Fixed allocation of ed25519 public keys
* Fixed channel exit-status and exit-signal
* Reintroduce ssh_forward_listen()
version 0.7.0 (released 2015-05-11)
* Added support for ed25519 keys
* Added SHA2 algorithms for HMAC
* Added improved and more secure buffer handling code
* Added callback for auth_none_function
* Added support for ECDSA private key signing
* Added more tests
* Fixed a lot of bugs
* Improved API documentation
version 0.6.5 (released 2015-04-29)
* Fixed CVE-2015-3146
* Fixed port handling in config file
* Fixed the build with libgcrypt
* Fixed SFTP endian issues (rlo #179)
* Fixed uninitilized sig variable (rlo #167)
* Fixed polling issues which could result in a hang
* Fixed handling of EINTR in ssh_poll() (rlo #186)
* Fixed C99 issues with __func__
* Fixed some memory leaks
* Improved macro detection on Windows
version 0.6.4 (released 2014-12-19)
* Fixed CVE-2014-8132.
* Added SHA-2 for session ID signing with ECDSA keys.
* Added support for ECDSA host keys.
* Added support for more ECDSA hostkey algorithms.
* Added ssh_pki_key_ecdsa_name() API.
* Fixed setting the bindfd only after successful listen.
* Fixed issues with user created sockets.
* Fixed several issues in libssh C++ wrapper.
* Fixed several documentation issues.
* Fixed channel exit-signal request.
* Fixed X11 request screen number in messages.
* Fixed several memory leaks.
version 0.6.3 (released 2014-03-04)
* Fixed CVE-2014-0017.
* Fixed memory leak with ecdsa signatures.
version 0.6.2 (released 2014-03-04)
* security: fix for vulnerability CVE-2014-0017
version 0.6.1 (released 2014-02-08)
* Added support for libgcrypt 1.6.
* Added ssh_channel_accept_forward().
* Added known_hosts heuristic during connection (#138).
* Added getters for session cipher names.
* Fixed decrypt of zero length buffer.
* Fixed padding in RSA signature blobs.
* Fixed DSA signature extraction.
* Fixed some memory leaks.
* Fixed read of non-connected socket.
* Fixed thread dectection.
version 0.6.0 (released 2014-01-08)
* Added new publicy key API.
* Added new userauth API.
* Added ssh_get_publickey_hash() function.
* Added ssh_get_poll_flags() function.
* Added gssapi-mic userauth.
* Added GSSAPIServerIdentity option.
* Added GSSAPIClientIdentity option.
* Added GSSAPIDelegateCredentials option.
* Added new callback based server API.
* Added Elliptic Curve DSA (ECDSA) support (with OpenSSL).
* Added Elliptic Curve Diffie Hellman (ECDH) support.
* Added Curve25519 for ECDH key exchange.
* Added improved logging system.
* Added SSH-agent forwarding.
* Added key-reexchange.
* Added more unit tests.
* Improved documentation.
* Fixed timeout handling.
version 0.5.5 (released 2013-07-26)
* BUG 103: Fix ProxyCommand parsing.
* Fix setting -D_FORTIFY_SOURCE=2.
* Fix pollset error return if emtpy.
* Fix NULL pointer checks in channel functions.
* Several bugfixes.
version 0.5.4 (released 2013-01-22)
* CVE-2013-0176 - NULL dereference leads to denial of service
* Fixed several NULL pointer dereferences in SSHv1.
* Fixed a free crash bug in options parsing.
version 0.5.3 (released 2012-11-20)
* CVE-2012-4559 Fixed multiple double free() flaws.
* CVE-2012-4560 Fixed multiple buffer overflow flaws.
* CVE-2012-4561 Fixed multiple invalid free() flaws.
* BUG #84 - Fix bug in sftp_mkdir not returning on error.
* BUG #85 - Fixed a possible channel infinite loop if the connection dropped.
* BUG #88 - Added missing channel request_state and set it to accepted.
* BUG #89 - Reset error state to no error on successful SSHv1 authentiction.
* Fixed a possible use after free in ssh_free().
* Fixed multiple possible NULL pointer dereferences.
* Fixed multiple memory leaks in error paths.
* Fixed timeout handling.
* Fixed regression in pre-connected socket setting.
* Handle all unknown global messages.
version 0.5.2 (released 2011-09-17)
* Increased window size x10.
* Fixed SSHv1.
* Fixed bugged lists.
* Fixed use-after-free + inconsistent callbacks call in poll.
* Fixed scp documentation.
* Fixed possible infinite loop in channel_read().
* Fixed handling of short reads of sftp_async_read().
* Fixed handling request service timeout in blocking mode.
* Fixed ssh_auth_list() documentation.
* Fixed incorrect return values in ssh_channel_write().
* Fixed an infinite loop in the termination callback.
* Fixed handling of SSH_AGAIN in channel_open().
* Fixed "status -5 inflating zlib packet"
version 0.5.1 (released 2011-08-09)
* Added checks for NULL pointers in string.c.
* Set the channel max packet size to 32768.
* Don't (de)compress empty buffers.
* Fixed ssh_scp_write so it works when doing recursive copy.
* Fixed another source of endless wait.
* Fixed an endless loop in case of a channel_open error.
* Fixed session timeout handling.
* Fixed ssh_channel_from_local() loop.
* Fixed permissions of scp example when we copy a file.
* Workaround ssh_get_user_home_dir on LDAP users.
* Added pkg-config support for libssh_threads.
* Fixed compilation without server and sftp modes.
* Fix static .lib overwriting on Windows.
version 0.5.0 (released 2011-06-01)
* Added ssh_ prefix to all functions.
* Added complete Windows support.
* Added improved server support.
* Added unit tests for a lot of functions.
* Added asynchronous service request.
* Added a multiplatform ssh_getpass() function.
* Added a tutorial.
* Added a lot of documentation.
* Fixed a lot of bugs.
* Fixed several memory leaks.
version 0.4.8 (released 2011-01-15)
* Fixed memory leaks in session signing.
* Fixed memory leak in ssh_print_hexa.
* Fixed problem with ssh_connect w/ timeout and fd > 1024.
* Fixed some warnings on OS/2.
* Fixed installation path for OS/2.
version 0.4.7 (released 2010-12-28)
* Fixed a possible memory leak in ssh_get_user_home().
* Fixed a memory leak in sftp_xstat.
* Fixed uninitialized fd->revents member.
* Fixed timout value in ssh_channel_accept().
* Fixed length checks in ssh_analyze_banner().
* Fixed a possible data overread and crash bug.
* Fixed setting max_fd which breaks ssh_select().
* Fixed some pedantic build warnings.
* Fixed a memory leak with session->bindaddr.
version 0.4.6 (released 2010-09-03)
* Added a cleanup function to free the ws2_32 library.
* Fixed build with gcc 3.4.
* Fixed the Windows build on Vista and newer.
* Fixed the usage of WSAPoll() on Windows.
* Fixed "@deprecated" in doxygen
* Fixed some mingw warnings.
* Fixed handling of opened channels.
* Fixed keepalive problem on older openssh servers.
* Fixed testing for big endian on Windows.
* Fixed the Windows preprocessor macros and defines.
version 0.4.5 (released 2010-07-13)
* Added option to bind a client to an ip address.
* Fixed the ssh socket polling function.
* Fixed Windows related bugs in bsd_poll().
* Fixed serveral build warnings.
version 0.4.4 (released 2010-06-01)
* Fixed a bug in the expand function for escape sequences.
* Fixed a bug in the tilde expand function.
* Fixed a bug in setting the options.
version 0.4.3 (released 2010-05-18)
* Added global/keepalive responses.
* Added runtime detection of WSAPoll().
* Added a select(2) based poll-emulation if poll(2) is not available.
* Added a function to expand an escaped string.
* Added a function to expand the tilde from a path.
* Added a proxycommand support.
* Added ssh_privatekey_type public function
* Added the possibility to define _OPENSSL_DIR and _ZLIB_DIR.
* Fixed sftp_chown.
* Fixed sftp_rename on protocol version 3.
* Fixed a blocking bug in channel_poll.
* Fixed config parsing wich has overwritten user specified values.
* Fixed hashed [host]:port format in knownhosts
* Fixed Windows build.
* Fixed doublefree happening after a negociation error.
* Fixed aes*-ctr with <= OpenSSL 0.9.7b.
* Fixed some documentation.
* Fixed exec example which has broken read usage.
* Fixed broken algorithm choice for server.
* Fixed a typo that we don't export all symbols.
* Removed the unneeded dependency to doxygen.
* Build examples only on the Linux plattform.
version 0.4.2 (released 2010-03-15)
* Added owner and group information in sftp attributes.
* Added missing SSH_OPTIONS_FD option.
* Added printout of owner and group in the sftp example.
* Added a prepend function for ssh_list.
* Added send back replies to openssh's keepalives.
* Fixed documentation in scp code
* Fixed longname parsing, this only workings with readdir.
* Fixed and added support for several identity files.
* Fixed sftp_parse_longname() on Windows.
* Fixed a race condition bug in ssh_scp_close()
* Remove config support for SSHv1 Cipher variable.
* Rename ssh_list_add to ssh_list_append.
* Rename ssh_list_get_head to ssh_list_pop_head
version 0.4.1 (released 2010-02-13)
* Added support for aes128-ctr, aes192-ctr and aes256-ctr encryption.
* Added an example for exec.
* Added private key type detection feature in privatekey_from_file().
* Fixed zlib compression fallback.
* Fixed kex bug that client preference should be prioritary
* Fixed known_hosts file set by the user.
* Fixed a memleak in channel_accept().
* Fixed underflow when leave_function() are unbalanced
* Fixed memory corruption in handle_channel_request_open().
* Fixed closing of a file handle case of errors in privatekey_from_file().
* Fixed ssh_get_user_home_dir() to be thread safe.
* Fixed the doxygen documentation.
version 0.4.0 (released 2009-12-10)
* Added scp support.
* Added support for sending signals (RFC 4254, section 6.9).
* Added MSVC support.
* Added support for ~/.ssh/config.
* Added sftp extension support.
* Added X11 forwarding support for client.
* Added forward listening.
* Added support for openssh extensions (statvfs, fstatvfs).
* Added a cleaned up interface for setting options.
* Added a generic way to handle sockets asynchronously.
* Added logging of the sftp flags used to open a file.
* Added full poll() support and poll-emulation for win32.
* Added missing 64bit functions in sftp.
* Added support for ~/ and SSH_DIR/ in filenames instead of %s/.
* Fixed Fix channel_get_exit_status bug.
* Fixed calltrace logging to make it optional.
* Fixed compilation on Solaris.
* Fixed resolving of ip addresses.
* Fixed libssh compilation without server support.
* Fixed possible memory corruptions (ticket #14).
version 0.3.4 (released 2009-09-14)
* Added ssh_basename and ssh_dirname.
* Added a portable ssh_mkdir function.
* Added a sftp_tell64() function.
* Added missing NULL pointer checks to crypt_set_algorithms_server.
* Fixed ssh_write_knownhost if ~/.ssh doesn't exist.
* Fixed a possible integer overflow in buffer_get_data().
* Fixed possible security bug in packet_decrypt().
* Fixed a possible stack overflow in agent code.
version 0.3.3 (released 2009-08-18)
* Fixed double free pointer crash in dsa_public_to_string.
* Fixed channel_get_exit_status bug.
* Fixed ssh_finalize which didn't clear the flag.
* Fixed memory leak introduced by previous bugfix.
* Fixed channel_poll broken when delayed EOF recvd.
* Fixed stupid "can't parse known host key" bug.
* Fixed possible memory corruption (ticket #14).
version 0.3.2 (released 2009-08-05)
* Added ssh_init() function.
* Added sftp_readlink() function.
* Added sftp_symlink() function.
* Fixed ssh_write_knownhost().
* Fixed compilation on Solaris.
* Fixed SSHv1 compilation.
version 0.3.1 (released 2009-07-14)
* Added return code SSH_SERVER_FILE_NOT_FOUND.
* Fixed compilation of SSHv1.
* Fixed several memory leaks.
* Fixed possible infinite loops.
* Fixed a possible crash bug.
* Fixed build warnings.
* Fixed cmake on BSD.
version 0.3 (released 2009-05-21)
* Added support for ssh-agent authentication.
* Added POSIX like sftp implementation.
* Added error checking to all functions.
* Added const to arguments where it was needed.
* Added a channel_get_exit_status() function.
* Added a channel_read_buffer() function, channel_read() is now
a POSIX like function.
* Added a more generic auth callback function.
* Added printf attribute checking for log and error functions.
* Added runtime function tracer support.
* Added NSIS build support with CPack.
* Added openssh hashed host support.
* Added API documentation for all public functions.
* Added asynchronous SFTP read function.
* Added a ssh_bind_set_fd() function.
* Fixed known_hosts parsing.
* Fixed a lot of build warnings.
* Fixed the Windows build.
* Fixed a lot of memory leaks.
* Fixed a double free corruption in the server support.
* Fixed the "ssh_accept:" bug in server support.
* Fixed important channel bugs.
* Refactored the socket handling.
* Switched to CMake build system.
* Improved performance.
version 0.2 (released 2007-11-29)
* General cleanup
* More comprehensive API
* Up-to-date Doxygen documentation of each public function
* Basic server-based support
* Libgcrypt support (alternative to openssl and its license)
* SSH1 support (disabled by default)
* Added 3des-cbc
* A lot of bugfixes
version 0.11-dev
* Server implementation development.
* Small bug corrected when connecting to sun ssh servers.
* Channel weirdness corrected (writing huge data packets)
* Channel_read_nonblocking added
* Channel bug where stderr wasn't correctly read fixed.
* Added sftp_file_set_nonblocking(), which is nonblocking SFTP IO
* Connect_status callback.
* Priv.h contains the internal functions, libssh.h the public interface
* Options_set_timeout (thx marcelo) really working.
* Tcp tunneling through channel_open_forward.
* Channel_request_exec()
* Channel_request_env()
* Ssh_get_pubkey_hash()
* Ssh_is_server_known()
* Ssh_write_known_host()
* Options_set_ssh_dir
* How could this happen ! there weren't any channel_close !
* Nasty channel_free bug resolved.
* Removed the unsigned long all around the code. use only u8,u32 & u64.
* It now compiles and runs under amd64 !
* Channel_request_pty_size
* Channel_change_pty_size
* Options_copy()
* Ported the doc to an HTML file.
* Small bugfix in packet.c
* Prefixed error constants with SSH_
* Sftp_stat, sftp_lstat, sftp_fstat. thanks Michel Bardiaux for the patch.
* Again channel number mismatch fixed.
* Fixed a bug in ssh_select making the select fail when a signal has been
caught.
* Keyboard-interactive authentication working.
version 0.1 (released 2004-03-05)
* Begining of sftp subsystem implementation.
* Some cleanup into channels implementation
* Now every channel functions is called by its CHANNEL handler.
* Added channel_poll() and channel_read().
* Changed the client so it uses the new channel_poll and channel_read interface
* Small use-after-free bug with channels resolved
* Changed stupidities in lot of function names.
* Removed a debug output file opened by default.
* Added API.txt, the libssh programmer handbook.
* Various bug fixes from Nick Zitzmann.
* Developed a cryptographic structure for handling protocols.
* An autoconf script which took me half of a day to set up.
* A ssh_select wrapper has been written.
version 0.0.4 (released 2003-10-10)
* Some terminal code (eof handling) added
* Channels bugfix (it still needs some tweaking though)
* Zlib support
* Added a wrapper.c file. The goal is to provide a similar API to every
cryptographic functions. bignums and sha/md5 are wrapped now.
* More work than it first looks.
* Support for other crypto libs planed (lighter libs)
* Fixed stupid select() bug.
* Libssh now compiles and links with openssl 0.9.6
* RSA pubkey authentication code now works !
version 0.0.3 (released 2003-09-15)
* Added install target in makefile
* Some cleanup in headers files and source code
* Change default banner and project name to libssh.
* New file auth.c to support more and more authentication ways
* Bugfix(read offbyone) in send_kex
* A base64 parser. don't read the source, it's awful. pure 0xbadc0de.
* Changed the client filename to "ssh". logic isn't it ?
* Dss publickey authentication ! still need to wait for the rsa one
* Bugfix in packet.c
* New misc.c contains misc functions
version 0.0.2 (released 2003-09-03)
* Initial release.
* Client supports both ssh and dss hostkey verification, but doesn't compare them to openssh's files. (~/.ssh/known_hosts)
* The only supported authentication method is password.
* Compiles on linux and openbsd. freebsd and netbsd should work, too
* Lot of work which hasn't been discussed here.

View File

@@ -1,17 +1,20 @@
project(libssh C)
cmake_minimum_required(VERSION 3.3.0)
cmake_policy(SET CMP0048 NEW)
# Required cmake version
cmake_minimum_required(VERSION 2.6.0)
# Specify search path for CMake modules to be loaded by include()
# and find_package()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
# global needed variables
# Add defaults for cmake
# Those need to be set before the project() call.
include(DefineCMakeDefaults)
include(DefineCompilerFlags)
project(libssh VERSION 0.10.4 LANGUAGES C)
# global needed variable
set(APPLICATION_NAME ${PROJECT_NAME})
set(APPLICATION_VERSION_MAJOR "0")
set(APPLICATION_VERSION_MINOR "5")
set(APPLICATION_VERSION_PATCH "0")
set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINOR}.${APPLICATION_VERSION_PATCH}")
# SOVERSION scheme: CURRENT.AGE.REVISION
# If there was an incompatible interface change:
# Increment CURRENT. Set AGE and REVISION to 0
@@ -19,54 +22,98 @@ set(APPLICATION_VERSION "${APPLICATION_VERSION_MAJOR}.${APPLICATION_VERSION_MINO
# Increment AGE. Set REVISION to 0
# If the source code was changed, but there were no interface changes:
# Increment REVISION.
set(LIBRARY_VERSION "4.2.0")
set(LIBRARY_VERSION "4.9.4")
set(LIBRARY_SOVERSION "4")
# where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
set(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/cmake/Modules
)
# add definitions
include(DefineCMakeDefaults)
include(DefinePlatformDefaults)
include(DefineCompilerFlags)
include(DefineInstallationPaths)
include(DefineOptions.cmake)
include(CPackConfig.cmake)
include(GNUInstallDirs)
include(CompilerChecks.cmake)
# disallow in-source build
include(MacroEnsureOutOfSourceBuild)
macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there.")
# add macros
include(MacroAddPlugin)
include(MacroCopyFile)
# Copy library files to a lib sub-directory
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
# search for libraries
if (WITH_LIBZ)
if (WITH_ZLIB)
find_package(ZLIB REQUIRED)
endif (WITH_LIBZ)
endif (WITH_ZLIB)
if (WITH_GCRYPT)
find_package(GCrypt REQUIRED)
find_package(GCrypt 1.5.0 REQUIRED)
if (NOT GCRYPT_FOUND)
message(FATAL_ERROR "Could not find GCrypt")
endif (NOT GCRYPT_FOUND)
elseif(WITH_MBEDTLS)
find_package(MbedTLS REQUIRED)
if (NOT MBEDTLS_FOUND)
message(FATAL_ERROR "Could not find mbedTLS")
endif (NOT MBEDTLS_FOUND)
else (WITH_GCRYPT)
find_package(OpenSSL)
if (NOT OPENSSL_FOUND)
find_package(OpenSSL 1.0.1)
if (OPENSSL_FOUND)
# On CMake < 3.16, OPENSSL_CRYPTO_LIBRARIES is usually a synonym for OPENSSL_CRYPTO_LIBRARY, but is not defined
# when building on Windows outside of Cygwin. We provide the synonym here, if FindOpenSSL didn't define it already.
if (NOT DEFINED OPENSSL_CRYPTO_LIBRARIES)
set(OPENSSL_CRYPTO_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
endif (NOT DEFINED OPENSSL_CRYPTO_LIBRARIES)
else (OPENSSL_FOUND)
find_package(GCrypt)
if (NOT GCRYPT_FOUND)
message(FATAL_ERROR "Could not find OpenSSL or GCrypt")
find_package(MbedTLS)
if (NOT MBEDTLS_FOUND)
message(FATAL_ERROR "Could not find OpenSSL, GCrypt or mbedTLS")
endif (NOT MBEDTLS_FOUND)
endif (NOT GCRYPT_FOUND)
endif (NOT OPENSSL_FOUND)
endif (OPENSSL_FOUND)
endif(WITH_GCRYPT)
if (UNIT_TESTING)
find_package(CMocka REQUIRED)
endif ()
# Find out if we have threading available
set(CMAKE_THREAD_PREFER_PTHREADS ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)
if (WITH_GSSAPI)
find_package(GSSAPI)
endif (WITH_GSSAPI)
if (WITH_PKCS11_URI)
find_package(softhsm)
if (NOT SOFTHSM_FOUND)
message(SEND_ERROR "Could not find softhsm module!")
endif (NOT SOFTHSM_FOUND)
endif (WITH_PKCS11_URI)
if (WITH_NACL)
find_package(NaCl)
if (NOT NACL_FOUND)
set(WITH_NACL OFF)
endif (NOT NACL_FOUND)
endif (WITH_NACL)
if (BSD OR SOLARIS OR OSX OR CYGWIN)
find_package(Argp)
endif (BSD OR SOLARIS OR OSX OR CYGWIN)
# Disable symbol versioning in non UNIX platforms
if (UNIX)
find_package(ABIMap 0.3.1)
else (UNIX)
set(WITH_SYMBOL_VERSIONING OFF)
endif (UNIX)
# config.h checks
include(ConfigureChecks.cmake)
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
@@ -77,41 +124,141 @@ add_subdirectory(include)
add_subdirectory(src)
# pkg-config file
if (UNIX OR MINGW)
configure_file(libssh.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libssh.pc)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/libssh.pc
DESTINATION
${LIB_INSTALL_DIR}/pkgconfig
${CMAKE_INSTALL_LIBDIR}/pkgconfig
COMPONENT
pkgconfig
)
endif (UNIX OR MINGW)
add_subdirectory(examples)
# CMake config files
include(CMakePackageConfigHelpers)
if (WITH_TESTING)
find_package(CMockery REQUIRED)
include(AddCMockeryTest)
add_subdirectory(tests)
endif (WITH_TESTING)
set(LIBSSH_LIBRARY_NAME ${CMAKE_SHARED_LIBRARY_PREFIX}ssh${CMAKE_SHARED_LIBRARY_SUFFIX})
# libssh-config-version.cmake
write_basic_package_version_file(libssh-config-version.cmake
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
install(
FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
DESTINATION
${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
COMPONENT
devel)
if (WITH_EXAMPLES)
add_subdirectory(examples)
endif (WITH_EXAMPLES)
if (UNIT_TESTING)
include(AddCMockaTest)
add_subdirectory(tests)
endif (UNIT_TESTING)
### SOURCE PACKAGE
if (WITH_SYMBOL_VERSIONING AND ABIMAP_FOUND)
# Get the current ABI version from source
get_filename_component(current_abi_path
"${CMAKE_SOURCE_DIR}/src/ABI/current"
ABSOLUTE)
# Check if the ABI version should be updated
file(READ ${current_abi_path} CURRENT_ABI_CONTENT)
string(STRIP "${CURRENT_ABI_CONTENT}" CURRENT_ABI_VERSION)
if (LIBRARY_VERSION VERSION_GREATER CURRENT_ABI_VERSION)
set(UPDATE_ABI TRUE)
endif ()
if (UPDATE_ABI)
message(STATUS "Library version bumped to ${LIBRARY_VERSION}: Updating ABI")
# Get the list of header files
get_file_list(${PROJECT_NAME}_header_list
DIRECTORIES "${CMAKE_SOURCE_DIR}/include/libssh"
FILES_PATTERNS "*.h")
# Extract the symbols marked as "LIBSSH_API" from the header files
extract_symbols(${PROJECT_NAME}.symbols
HEADERS_LIST ${PROJECT_NAME}_header_list
FILTER_PATTERN "LIBSSH_API"
COPY_TO "${CMAKE_SOURCE_DIR}/src/ABI/${PROJECT_NAME}-${LIBRARY_VERSION}.symbols")
if (WITH_ABI_BREAK)
set(ALLOW_ABI_BREAK "BREAK_ABI")
endif()
# Target we can depend on in 'make dist'
set(_SYMBOL_TARGET "${PROJECT_NAME}.map")
# Set the path to the current map file
set(MAP_PATH "${CMAKE_SOURCE_DIR}/src/${_SYMBOL_TARGET}")
# Generate the symbol version map file
generate_map_file(${_SYMBOL_TARGET}
SYMBOLS ${PROJECT_NAME}.symbols
RELEASE_NAME_VERSION ${PROJECT_NAME}_${LIBRARY_VERSION}
CURRENT_MAP ${MAP_PATH}
COPY_TO ${MAP_PATH}
FINAL
${ALLOW_ABI_BREAK})
# Write the current version to the source
file(WRITE ${current_abi_path} ${LIBRARY_VERSION})
endif(UPDATE_ABI)
endif (WITH_SYMBOL_VERSIONING AND ABIMAP_FOUND)
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source DEPENDS ${_SYMBOL_TARGET} VERBATIM)
# Link compile database for clangd
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
"${CMAKE_BINARY_DIR}/compile_commands.json"
"${CMAKE_SOURCE_DIR}/compile_commands.json")
message(STATUS "********************************************")
message(STATUS "********** ${PROJECT_NAME} build options : **********")
message(STATUS "zlib support: ${WITH_LIBZ}")
message(STATUS "zlib support: ${WITH_ZLIB}")
message(STATUS "libgcrypt support: ${WITH_GCRYPT}")
message(STATUS "SSH-1 support: ${WITH_SSH1}")
message(STATUS "libmbedTLS support: ${WITH_MBEDTLS}")
message(STATUS "libnacl support: ${WITH_NACL}")
message(STATUS "SFTP support: ${WITH_SFTP}")
message(STATUS "Server support : ${WITH_SERVER}")
message(STATUS "GSSAPI support : ${WITH_GSSAPI}")
message(STATUS "GEX support : ${WITH_GEX}")
message(STATUS "Support insecure none cipher and MAC : ${WITH_INSECURE_NONE}")
message(STATUS "Pcap debugging support : ${WITH_PCAP}")
message(STATUS "Unit testing: ${WITH_TESTING}")
message(STATUS "Client code Unit testing: ${WITH_CLIENT_TESTING}")
message(STATUS "Build shared library: ${BUILD_SHARED_LIBS}")
message(STATUS "Unit testing: ${UNIT_TESTING}")
message(STATUS "Client code testing: ${CLIENT_TESTING}")
message(STATUS "Blowfish cipher support: ${WITH_BLOWFISH_CIPHER}")
message(STATUS "PKCS #11 URI support: ${WITH_PKCS11_URI}")
message(STATUS "DSA support: ${WITH_DSA}")
set(_SERVER_TESTING OFF)
if (WITH_SERVER)
set(_SERVER_TESTING ${SERVER_TESTING})
endif()
message(STATUS "Server code testing: ${_SERVER_TESTING}")
if (WITH_INTERNAL_DOC)
message(STATUS "Internal documentation generation")
else (WITH_INTERNAL_DOC)
message(STATUS "Public API documentation generation")
endif (WITH_INTERNAL_DOC)
message(STATUS "Benchmarks: ${WITH_BENCHMARKS}")
message(STATUS "Symbol versioning: ${WITH_SYMBOL_VERSIONING}")
message(STATUS "Allow ABI break: ${WITH_ABI_BREAK}")
message(STATUS "Release is final: ${WITH_FINAL}")
message(STATUS "Global client config: ${GLOBAL_CLIENT_CONFIG}")
if (WITH_SERVER)
message(STATUS "Global bind config: ${GLOBAL_BIND_CONFIG}")
endif()
message(STATUS "********************************************")

484
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,484 @@
# How to contribute a patch to libssh
Please checkout the libssh source code using git.
For contributions we prefer Merge Requests on Gitlab:
https://gitlab.com/libssh/libssh-mirror/
This way you get continuous integration which runs the complete libssh
testsuite for you.
For larger code changes, breaking the changes up into a set of simple
patches, each of which does a single thing, are much easier to review.
Patch sets like that will most likely have an easier time being merged
into the libssh code than large single patches that make lots of
changes in one large diff.
Also bugfixes and new features should be covered by tests. We use the cmocka
and cwrap framework for our testing and you can simply run it locally by
calling `make test`.
## Ownership of the contributed code
libssh is a project with distributed copyright ownership, which means
we prefer the copyright on parts of libssh to be held by individuals
rather than corporations if possible. There are historical legal
reasons for this, but one of the best ways to explain it is that it's
much easier to work with individuals who have ownership than corporate
legal departments if we ever need to make reasonable compromises with
people using and working with libssh.
We track the ownership of every part of libssh via https://git.libssh.org,
our source code control system, so we know the provenance of every piece
of code that is committed to libssh.
So if possible, if you're doing libssh changes on behalf of a company
who normally owns all the work you do please get them to assign
personal copyright ownership of your changes to you as an individual,
that makes things very easy for us to work with and avoids bringing
corporate legal departments into the picture.
If you can't do this we can still accept patches from you owned by
your employer under a standard employment contract with corporate
copyright ownership. It just requires a simple set-up process first.
We use a process very similar to the way things are done in the Linux
Kernel community, so it should be very easy to get a sign off from
your corporate legal department. The only changes we've made are to
accommodate the license we use, which is LGPLv2 (or later) whereas the
Linux kernel uses GPLv2.
The process is called signing.
## How to sign your work
Once you have permission to contribute to libssh from your employer, simply
email a copy of the following text from your corporate email address to:
contributing@libssh.org
```
libssh Developer's Certificate of Origin. Version 1.0
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the appropriate
version of the GNU General Public License; or
(b) The contribution is based upon previous work that, to the best of
my knowledge, is covered under an appropriate open source license
and I have the right under that license to submit that work with
modifications, whether created in whole or in part by me, under
the GNU General Public License, in the appropriate version; or
(c) The contribution was provided directly to me by some other
person who certified (a) or (b) and I have not modified it.
(d) I understand and agree that this project and the contribution are
public and that a record of the contribution (including all
metadata and personal information I submit with it, including my
sign-off) is maintained indefinitely and may be redistributed
consistent with the libssh Team's policies and the requirements of
the GNU GPL where they are relevant.
(e) I am granting this work to this project under the terms of the
GNU Lesser General Public License as published by the
Free Software Foundation; either version 2.1 of
the License, or (at the option of the project) any later version.
https://www.gnu.org/licenses/lgpl-2.1.html
```
We will maintain a copy of that email as a record that you have the
rights to contribute code to libssh under the required licenses whilst
working for the company where the email came from.
Then when sending in a patch via the normal mechanisms described
above, add a line that states:
Signed-off-by: Random J Developer <random@developer.example.org>
using your real name and the email address you sent the original email
you used to send the libssh Developer's Certificate of Origin to us
(sorry, no pseudonyms or anonymous contributions.)
That's it! Such code can then quite happily contain changes that have
copyright messages such as:
(c) Example Corporation.
and can be merged into the libssh codebase in the same way as patches
from any other individual. You don't need to send in a copy of the
libssh Developer's Certificate of Origin for each patch, or inside each
patch. Just the sign-off message is all that is required once we've
received the initial email.
# Coding conventions in the libssh tree
## Quick Start
Coding style guidelines are about reducing the number of unnecessary
reformatting patches and making things easier for developers to work together.
You don't have to like them or even agree with them, but once put in place we
all have to abide by them (or vote to change them). However, coding style
should never outweigh coding itself and so the guidelines described here are
hopefully easy enough to follow as they are very common and supported by tools
and editors.
The basic style for C code, is the Linux kernel coding style (See
Documentation/CodingStyle in the kernel source tree). This closely matches what
libssh developers use already anyways, with a few exceptions as mentioned
below.
But to save you the trouble of reading the Linux kernel style guide, here
are the highlights.
* Maximum Line Width is 80 Characters
The reason is not about people with low-res screens but rather sticking
to 80 columns prevents you from easily nesting more than one level of
if statements or other code blocks.
* Use 4 Spaces to Indent
* No Trailing Whitespace
Clean up your files before committing.
* Follow the K&R guidelines. We won't go through all of them here. Do you
have a copy of "The C Programming Language" anyways right?
## Editor Hints
### Emacs
Add the follow to your $HOME/.emacs file:
(add-hook 'c-mode-hook
(lambda ()
(c-set-style "linux")
(c-toggle-auto-state)))
## Neovim/VIM
For the basic vi editor included with all variants of \*nix, add the
following to ~/.config/nvim/init.rc or ~/.vimrc:
set ts=4 sw=4 et cindent
You can use the Vim gitmodline plugin to store this in the git config:
https://git.cryptomilk.org/projects/vim-gitmodeline.git/
For Vim, the following settings in $HOME/.vimrc will also deal with
displaying trailing whitespace:
if has("syntax") && (&t_Co > 2 || has("gui_running"))
syntax on
function! ActivateInvisibleCharIndicator()
syntax match TrailingSpace "[ \t]\+$" display containedin=ALL
highlight TrailingSpace ctermbg=Red
endf
autocmd BufNewFile,BufRead * call ActivateInvisibleCharIndicator()
endif
" Show tabs, trailing whitespace, and continued lines visually
set list listchars=tab:»·,trail:·,extends:…
" highlight overly long lines same as TODOs.
set textwidth=80
autocmd BufNewFile,BufRead *.c,*.h exec 'match Todo /\%>' . &textwidth . 'v.\+/'
## FAQ & Statement Reference
### Comments
Comments should always use the standard C syntax. C++ style comments are not
currently allowed.
The lines before a comment should be empty. If the comment directly belongs to
the following code, there should be no empty line after the comment, except if
the comment contains a summary of multiple following code blocks.
This is good:
...
int i;
/*
* This is a multi line comment,
* which explains the logical steps we have to do:
*
* 1. We need to set i=5, because...
* 2. We need to call complex_fn1
*/
/* This is a one line comment about i = 5. */
i = 5;
/*
* This is a multi line comment,
* explaining the call to complex_fn1()
*/
ret = complex_fn1();
if (ret != 0) {
...
/**
* @brief This is a doxygen comment.
*
* This is a more detailed explanation of
* this simple function.
*
* @param[in] param1 The parameter value of the function.
*
* @param[out] result1 The result value of the function.
*
* @return 0 on success and -1 on error.
*/
int example(int param1, int *result1);
This is bad:
...
int i;
/*
* This is a multi line comment,
* which explains the logical steps we have to do:
*
* 1. We need to set i=5, because...
* 2. We need to call complex_fn1
*/
/* This is a one line comment about i = 5. */
i = 5;
/*
* This is a multi line comment,
* explaining the call to complex_fn1()
*/
ret = complex_fn1();
if (ret != 0) {
...
/*This is a one line comment.*/
/* This is a multi line comment,
with some more words...*/
/*
* This is a multi line comment,
* with some more words...*/
### Indention & Whitespace & 80 columns
To avoid confusion, indentations have to be 4 spaces. Do not use tabs!. When
wrapping parameters for function calls, align the parameter list with the first
parameter on the previous line. For example,
var1 = foo(arg1,
arg2,
arg3);
The previous example is intended to illustrate alignment of function
parameters across lines and not as encourage for gratuitous line
splitting. Never split a line before columns 70 - 79 unless you
have a really good reason. Be smart about formatting.
### If, switch, & Code blocks
Always follow an 'if' keyword with a space but don't include additional
spaces following or preceding the parentheses in the conditional.
This is good:
if (x == 1)
This is bad:
if ( x == 1 )
or
if (x==1)
Yes we have a lot of code that uses the second and third form and we are trying
to clean it up without being overly intrusive.
Note that this is a rule about parentheses following keywords and not
functions. Don't insert a space between the name and left parentheses when
invoking functions.
Braces for code blocks used by for, if, switch, while, do..while, etc. should
begin on the same line as the statement keyword and end on a line of their own.
You should always include braces, even if the block only contains one
statement. **NOTE**: Functions are different and the beginning left brace should
be located in the first column on the next line.
If the beginning statement has to be broken across lines due to length, the
beginning brace should be on a line of its own.
The exception to the ending rule is when the closing brace is followed by
another language keyword such as else or the closing while in a do..while loop.
Good examples:
if (x == 1) {
printf("good\n");
}
for (x = 1; x < 10; x++) {
print("%d\n", x);
}
for (really_really_really_really_long_var_name = 0;
really_really_really_really_long_var_name < 10;
really_really_really_really_long_var_name++)
{
print("%d\n", really_really_really_really_long_var_name);
}
do {
printf("also good\n");
} while (1);
Bad examples:
while (1)
{
print("I'm in a loop!\n"); }
for (x=1;
x<10;
x++)
{
print("no good\n");
}
if (i < 10)
print("I should be in braces.\n");
### Goto
While many people have been academically taught that "goto"s are fundamentally
evil, they can greatly enhance readability and reduce memory leaks when used as
the single exit point from a function. But in no libssh world what so ever is a
goto outside of a function or block of code a good idea.
Good Examples:
int function foo(int y)
{
int *z = NULL;
int rc = 0;
if (y < 10) {
z = malloc(sizeof(int)*y);
if (z == NULL) {
rc = 1;
goto done;
}
}
print("Allocated %d elements.\n", y);
done:
if (z != NULL) {
free(z);
}
return rc;
}
### Initialize pointers
All pointer variables **MUST** be initialized to `NULL`. History has
demonstrated that uninitialized pointer variables have lead to various
bugs and security issues.
Pointers **MUST** be initialized even if the assignment directly follows
the declaration, like pointer2 in the example below, because the
instructions sequence may change over time.
Good Example:
char *pointer1 = NULL;
char *pointer2 = NULL;
pointer2 = some_func2();
...
pointer1 = some_func1();
### Typedefs
libssh tries to avoid `typedef struct { .. } x_t;` so we do always try to use
`struct x { .. };`. We know there are still such typedefs in the code, but for
new code, please don't do that anymore.
### Make use of helper variables
Please try to avoid passing function calls as function parameters in new code.
This makes the code much easier to read and it's also easier to use the "step"
command within gdb.
Good Example:
char *name;
name = get_some_name();
if (name == NULL) {
...
}
rc = some_function_my_name(name);
...
Bad Example:
rc = some_function_my_name(get_some_name());
...
Please try to avoid passing function return values to if- or while-conditions.
The reason for this is better handling of code under a debugger.
Good example:
x = malloc(sizeof(short) * 10);
if (x == NULL) {
fprintf(stderr, "Unable to alloc memory!\n");
}
Bad example:
if ((x = malloc(sizeof(short)*10)) == NULL ) {
fprintf(stderr, "Unable to alloc memory!\n");
}
There are exceptions to this rule. One example is walking a data structure in
an iterator style:
while ((opt = poptGetNextOpt(pc)) != -1) {
... do something with opt ...
}
But in general, please try to avoid this pattern.
### Control-Flow changing macros
Macros like `STATUS_NOT_OK_RETURN` that change control flow (return/goto/etc)
from within the macro are considered bad, because they look like function calls
that never change control flow. Please do not introduce them.
Have fun and happy libssh hacking!
The libssh Team

13
COPYING
View File

@@ -455,6 +455,15 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
Linking with OpenSSL
17. In addition, as a special exception, we give permission to link the code of its release of libssh with the OpenSSL project's "OpenSSL" library (or with modified versions of it that use the same license as the "OpenSSL" library), and distribute the linked executables. You must obey the GNU Lesser General Public License in all respects for all of the code used other than "OpenSSL". If you modify this file, you may extend this exception to your version of the file, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.
Linking with OpenSSL
17. In addition, as a special exception, we give permission to link the code
of its release of libssh with the OpenSSL project's "OpenSSL" library (or with
modified versions of it that use the same license as the "OpenSSL" library),
and distribute the linked executables. You must obey the GNU Lesser General
Public License in all respects for all of the code used other than "OpenSSL".
If you modify this file, you may extend this exception to your version of the
file, but you are not obligated to do so. If you do not wish to do so, delete
this exception statement from your version.
END OF TERMS AND CONDITIONS

View File

@@ -1,27 +1,19 @@
# For help take a look at:
# http://www.cmake.org/Wiki/CMake:CPackConfiguration
### general settings
set(CPACK_PACKAGE_NAME ${APPLICATION_NAME})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The SSH library")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README")
### GENERAL SETTINGS
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "The SSH Library")
set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
set(CPACK_PACKAGE_VENDOR "The SSH Library Development Team")
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
### versions
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "4")
set(CPACK_PACKAGE_VERSION_PATCH "90")
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
### source generator
set(CPACK_SOURCE_GENERATOR "TGZ")
set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]svn/;/[.]git/;.gitignore;/build/;tags;cscope.*")
# SOURCE GENERATOR
set(CPACK_SOURCE_GENERATOR "TXZ")
set(CPACK_SOURCE_IGNORE_FILES "~$;[.]swp$;/[.]git/;/[.]clangd/;/[.]cache/;.gitignore;/build*;/obj*;tags;cscope.*;compile_commands.json;.*\.patch")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
### NSIS INSTALLER
if (WIN32)
set(CPACK_GENERATOR "ZIP")
@@ -31,7 +23,7 @@ if (WIN32)
set(CPACK_GENERATOR "${CPACK_GENERATOR};NSIS")
set(CPACK_NSIS_DISPLAY_NAME "The SSH Library")
set(CPACK_NSIS_COMPRESSOR "/SOLID zlib")
set(CPACK_NSIS_MENU_LINKS "http://www.libssh.org/" "libssh homepage")
set(CPACK_NSIS_MENU_LINKS "https://www.libssh.org/" "libssh homepage")
endif (NSIS_MAKE)
endif (WIN32)
@@ -46,7 +38,6 @@ set(CPACK_COMPONENT_LIBRARIES_DESCRIPTION
set(CPACK_COMPONENT_HEADERS_DESCRIPTION
"C/C++ header files for use with libssh")
set(CPACK_COMPONENT_HEADERS_DEPENDS libraries)
#set(CPACK_COMPONENT_APPLICATIONS_GROUP "Runtime")
set(CPACK_COMPONENT_LIBRARIES_GROUP "Development")
set(CPACK_COMPONENT_HEADERS_GROUP "Development")

View File

@@ -1,9 +1,9 @@
set(UPDATE_TYPE "true")
set(CTEST_PROJECT_NAME "libssh")
set(CTEST_NIGHTLY_START_TIME "01:00:00 CET")
set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_METHOD "https")
set(CTEST_DROP_SITE "test.libssh.org")
set(CTEST_DROP_LOCATION "/submit.php?project=libssh")
set(CTEST_DROP_SITE_CDASH TRUE)

288
ChangeLog
View File

@@ -1,288 +0,0 @@
ChangeLog
==========
version 0.5.0 (released xxxx-xx-xx)
* Added ssh_ prefix to all functions.
* Added complete Windows support.
* Added improved server support.
* Added unit tests for a lot of functions.
* Added asynchronous service request.
* Added a multiplatform ssh_getpass() function.
* Added a tutorial.
* Added a lot of documentation.
version 0.4.8 (released 2011-01-15)
* Fixed memory leaks in session signing.
* Fixed memory leak in ssh_print_hexa.
* Fixed problem with ssh_connect w/ timeout and fd > 1024.
* Fixed some warnings on OS/2.
* Fixed installation path for OS/2.
version 0.4.7 (released 2010-12-28)
* Fixed a possible memory leak in ssh_get_user_home().
* Fixed a memory leak in sftp_xstat.
* Fixed uninitialized fd->revents member.
* Fixed timout value in ssh_channel_accept().
* Fixed length checks in ssh_analyze_banner().
* Fixed a possible data overread and crash bug.
* Fixed setting max_fd which breaks ssh_select().
* Fixed some pedantic build warnings.
* Fixed a memory leak with session->bindaddr.
version 0.4.6 (released 2010-09-03)
* Added a cleanup function to free the ws2_32 library.
* Fixed build with gcc 3.4.
* Fixed the Windows build on Vista and newer.
* Fixed the usage of WSAPoll() on Windows.
* Fixed "@deprecated" in doxygen
* Fixed some mingw warnings.
* Fixed handling of opened channels.
* Fixed keepalive problem on older openssh servers.
* Fixed testing for big endian on Windows.
* Fixed the Windows preprocessor macros and defines.
version 0.4.5 (released 2010-07-13)
* Added option to bind a client to an ip address.
* Fixed the ssh socket polling function.
* Fixed Windows related bugs in bsd_poll().
* Fixed serveral build warnings.
version 0.4.4 (released 2010-06-01)
* Fixed a bug in the expand function for escape sequences.
* Fixed a bug in the tilde expand function.
* Fixed a bug in setting the options.
version 0.4.3 (released 2010-05-18)
* Added global/keepalive responses.
* Added runtime detection of WSAPoll().
* Added a select(2) based poll-emulation if poll(2) is not available.
* Added a function to expand an escaped string.
* Added a function to expand the tilde from a path.
* Added a proxycommand support.
* Added ssh_privatekey_type public function
* Added the possibility to define _OPENSSL_DIR and _ZLIB_DIR.
* Fixed sftp_chown.
* Fixed sftp_rename on protocol version 3.
* Fixed a blocking bug in channel_poll.
* Fixed config parsing wich has overwritten user specified values.
* Fixed hashed [host]:port format in knownhosts
* Fixed Windows build.
* Fixed doublefree happening after a negociation error.
* Fixed aes*-ctr with <= OpenSSL 0.9.7b.
* Fixed some documentation.
* Fixed exec example which has broken read usage.
* Fixed broken algorithm choice for server.
* Fixed a typo that we don't export all symbols.
* Removed the unneeded dependency to doxygen.
* Build examples only on the Linux plattform.
version 0.4.2 (released 2010-03-15)
* Added owner and group information in sftp attributes.
* Added missing SSH_OPTIONS_FD option.
* Added printout of owner and group in the sftp example.
* Added a prepend function for ssh_list.
* Added send back replies to openssh's keepalives.
* Fixed documentation in scp code
* Fixed longname parsing, this only workings with readdir.
* Fixed and added support for several identity files.
* Fixed sftp_parse_longname() on Windows.
* Fixed a race condition bug in ssh_scp_close()
* Remove config support for SSHv1 Cipher variable.
* Rename ssh_list_add to ssh_list_append.
* Rename ssh_list_get_head to ssh_list_pop_head
version 0.4.1 (released 2010-02-13)
* Added support for aes128-ctr, aes192-ctr and aes256-ctr encryption.
* Added an example for exec.
* Added private key type detection feature in privatekey_from_file().
* Fixed zlib compression fallback.
* Fixed kex bug that client preference should be prioritary
* Fixed known_hosts file set by the user.
* Fixed a memleak in channel_accept().
* Fixed underflow when leave_function() are unbalanced
* Fixed memory corruption in handle_channel_request_open().
* Fixed closing of a file handle case of errors in privatekey_from_file().
* Fixed ssh_get_user_home_dir() to be thread safe.
* Fixed the doxygen documentation.
version 0.4.0 (released 2009-12-10)
* Added scp support.
* Added support for sending signals (RFC 4254, section 6.9).
* Added MSVC support.
* Added support for ~/.ssh/config.
* Added sftp extension support.
* Added X11 forwarding support for client.
* Added forward listening.
* Added support for openssh extensions (statvfs, fstatvfs).
* Added a cleaned up interface for setting options.
* Added a generic way to handle sockets asynchronously.
* Added logging of the sftp flags used to open a file.
* Added full poll() support and poll-emulation for win32.
* Added missing 64bit functions in sftp.
* Added support for ~/ and SSH_DIR/ in filenames instead of %s/.
* Fixed Fix channel_get_exit_status bug.
* Fixed calltrace logging to make it optional.
* Fixed compilation on Solaris.
* Fixed resolving of ip addresses.
* Fixed libssh compilation without server support.
* Fixed possible memory corruptions (ticket #14).
version 0.3.4 (released 2009-09-14)
* Added ssh_basename and ssh_dirname.
* Added a portable ssh_mkdir function.
* Added a sftp_tell64() function.
* Added missing NULL pointer checks to crypt_set_algorithms_server.
* Fixed ssh_write_knownhost if ~/.ssh doesn't exist.
* Fixed a possible integer overflow in buffer_get_data().
* Fixed possible security bug in packet_decrypt().
* Fixed a possible stack overflow in agent code.
version 0.3.3 (released 2009-08-18)
* Fixed double free pointer crash in dsa_public_to_string.
* Fixed channel_get_exit_status bug.
* Fixed ssh_finalize which didn't clear the flag.
* Fixed memory leak introduced by previous bugfix.
* Fixed channel_poll broken when delayed EOF recvd.
* Fixed stupid "can't parse known host key" bug.
* Fixed possible memory corruption (ticket #14).
version 0.3.2 (released 2009-08-05)
* Added ssh_init() function.
* Added sftp_readlink() function.
* Added sftp_symlink() function.
* Fixed ssh_write_knownhost().
* Fixed compilation on Solaris.
* Fixed SSHv1 compilation.
version 0.3.1 (released 2009-07-14)
* Added return code SSH_SERVER_FILE_NOT_FOUND.
* Fixed compilation of SSHv1.
* Fixed several memory leaks.
* Fixed possible infinite loops.
* Fixed a possible crash bug.
* Fixed build warnings.
* Fixed cmake on BSD.
version 0.3.1 (released 2009-07-14)
* Added return code SSH_SERVER_FILE_NOT_FOUND.
* Fixed compilation of SSHv1.
* Fixed several memory leaks.
* Fixed possible infinite loops.
* Fixed a possible crash bug.
* Fixed build warnings.
* Fixed cmake on BSD.
version 0.3 (released 2009-05-21)
* Added support for ssh-agent authentication.
* Added POSIX like sftp implementation.
* Added error checking to all functions.
* Added const to arguments where it was needed.
* Added a channel_get_exit_status() function.
* Added a channel_read_buffer() function, channel_read() is now
a POSIX like function.
* Added a more generic auth callback function.
* Added printf attribute checking for log and error functions.
* Added runtime function tracer support.
* Added NSIS build support with CPack.
* Added openssh hashed host support.
* Added API documentation for all public functions.
* Added asynchronous SFTP read function.
* Added a ssh_bind_set_fd() function.
* Fixed known_hosts parsing.
* Fixed a lot of build warnings.
* Fixed the Windows build.
* Fixed a lot of memory leaks.
* Fixed a double free corruption in the server support.
* Fixed the "ssh_accept:" bug in server support.
* Fixed important channel bugs.
* Refactored the socket handling.
* Switched to CMake build system.
* Improved performance.
version 0.2 (released 2007-11-29)
* General cleanup
* More comprehensive API
* Up-to-date Doxygen documentation of each public function
* Basic server-based support
* Libgcrypt support (alternative to openssl and its license)
* SSH1 support (disabled by default)
* Added 3des-cbc
* A lot of bugfixes
version 0.11-dev
* Server implementation development.
* Small bug corrected when connecting to sun ssh servers.
* Channel wierdness corrected (writing huge data packets)
* Channel_read_nonblocking added
* Channel bug where stderr wasn't correctly read fixed.
* Added sftp_file_set_nonblocking(), which is nonblocking SFTP IO
* Connect_status callback.
* Priv.h contains the internal functions, libssh.h the public interface
* Options_set_timeout (thx marcelo) really working.
* Tcp tunneling through channel_open_forward.
* Channel_request_exec()
* Channel_request_env()
* Ssh_get_pubkey_hash()
* Ssh_is_server_known()
* Ssh_write_known_host()
* Options_set_ssh_dir
* How could this happen ! there weren't any channel_close !
* Nasty channel_free bug resolved.
* Removed the unsigned long all around the code. use only u8,u32 & u64.
* It now compiles and runs under amd64 !
* Channel_request_pty_size
* Channel_change_pty_size
* Options_copy()
* Ported the doc to an HTML file.
* Small bugfix in packet.c
* Prefixed error constants with SSH_
* Sftp_stat, sftp_lstat, sftp_fstat. thanks Michel Bardiaux for the patch.
* Again channel number mismatch fixed.
* Fixed a bug in ssh_select making the select fail when a signal has been
caught.
* Keyboard-interactive authentication working.
version 0.1 (released 2004-03-05)
* Begining of sftp subsystem implementation.
* Some cleanup into channels implementation
* Now every channel functions is called by its CHANNEL handler.
* Added channel_poll() and channel_read().
* Changed the client so it uses the new channel_poll and channel_read interface
* Small use-after-free bug with channels resolved
* Changed stupidities in lot of function names.
* Removed a debug output file opened by default.
* Added API.txt, the libssh programmer handbook.
* Various bug fixes from Nick Zitzmann.
* Developed a cryptographic structure for handling protocols.
* An autoconf script which took me half of a day to set up.
* A ssh_select wrapper has been written.
version 0.0.4 (released 2003-10-10)
* Some terminal code (eof handling) added
* Channels bugfix (it still needs some tweaking though)
* Zlib support
* Added a wrapper.c file. The goal is to provide a similar API to every
cryptographic functions. bignums and sha/md5 are wrapped now.
* More work than it first looks.
* Support for other crypto libs planed (lighter libs)
* Fixed stupid select() bug.
* Libssh now compiles and links with openssl 0.9.6
* RSA pubkey authentication code now works !
version 0.0.3 (released 2003-09-15)
* Added install target in makefile
* Some cleanup in headers files and source code
* Change default banner and project name to libssh.
* New file auth.c to support more and more authentication ways
* Bugfix(read offbyone) in send_kex
* A base64 parser. don't read the source, it's awful. pure 0xbadc0de.
* Changed the client filename to "ssh". logic isn't it ?
* Dss publickey authentication ! still need to wait for the rsa one
* Bugfix in packet.c
* New misc.c contains misc functions
version 0.0.2 (released 2003-09-03)
* Initial release.
* Client supports both ssh and dss hostkey verification, but doesn't compare them to openssh's files. (~/.ssh/known_hosts)
* The only supported authentication method is password.
* Compiles on linux and openbsd. freebsd and netbsd should work, too
* Lot of work which hasn't been discussed here.

124
CompilerChecks.cmake Normal file
View File

@@ -0,0 +1,124 @@
include(AddCCompilerFlag)
include(CheckCCompilerFlagSSP)
if (UNIX)
#
# Check for -Werror turned on if possible
#
# This will prevent that compiler flags are detected incorrectly.
#
check_c_compiler_flag("-Werror" REQUIRED_FLAGS_WERROR)
if (REQUIRED_FLAGS_WERROR)
set(CMAKE_REQUIRED_FLAGS "-Werror")
if (PICKY_DEVELOPER)
list(APPEND SUPPORTED_COMPILER_FLAGS "-Werror")
endif()
endif()
add_c_compiler_flag("-std=gnu99" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wpedantic" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wall" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wshadow" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wmissing-prototypes" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wcast-align" SUPPORTED_COMPILER_FLAGS)
#add_c_compiler_flag("-Wcast-qual" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Werror=address" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wstrict-prototypes" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Werror=strict-prototypes" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wwrite-strings" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Werror=write-strings" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Werror-implicit-function-declaration" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wpointer-arith" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Werror=pointer-arith" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wdeclaration-after-statement" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Werror=declaration-after-statement" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wreturn-type" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Werror=return-type" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wuninitialized" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Werror=uninitialized" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wimplicit-fallthrough" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Werror=strict-overflow" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wstrict-overflow=2" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wno-format-zero-length" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wmissing-field-initializers" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wsign-compare" SUPPORTED_COMPILER_FLAGS)
check_c_compiler_flag("-Wformat" REQUIRED_FLAGS_WFORMAT)
if (REQUIRED_FLAGS_WFORMAT)
list(APPEND SUPPORTED_COMPILER_FLAGS "-Wformat")
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wformat")
endif()
add_c_compiler_flag("-Wformat-security" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Werror=format-security" SUPPORTED_COMPILER_FLAGS)
# Allow zero for a variadic macro argument
string(TOLOWER "${CMAKE_C_COMPILER_ID}" _C_COMPILER_ID)
if ("${_C_COMPILER_ID}" STREQUAL "clang")
add_c_compiler_flag("-Wno-gnu-zero-variadic-macro-arguments" SUPPORTED_COMPILER_FLAGS)
endif()
add_c_compiler_flag("-fno-common" SUPPORTED_COMPILER_FLAGS)
if (CMAKE_BUILD_TYPE)
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_LOWER)
if (CMAKE_BUILD_TYPE_LOWER MATCHES (release|relwithdebinfo|minsizerel))
add_c_compiler_flag("-Wp,-D_FORTIFY_SOURCE=2" SUPPORTED_COMPILER_FLAGS)
endif()
endif()
check_c_compiler_flag_ssp("-fstack-protector-strong" WITH_STACK_PROTECTOR_STRONG)
if (WITH_STACK_PROTECTOR_STRONG)
list(APPEND SUPPORTED_COMPILER_FLAGS "-fstack-protector-strong")
# This is needed as Solaris has a seperate libssp
if (SOLARIS)
list(APPEND SUPPORTED_LINKER_FLAGS "-fstack-protector-strong")
endif()
else (WITH_STACK_PROTECTOR_STRONG)
check_c_compiler_flag_ssp("-fstack-protector" WITH_STACK_PROTECTOR)
if (WITH_STACK_PROTECTOR)
list(APPEND SUPPORTED_COMPILER_FLAGS "-fstack-protector")
# This is needed as Solaris has a seperate libssp
if (SOLARIS)
list(APPEND SUPPORTED_LINKER_FLAGS "-fstack-protector")
endif()
endif()
endif (WITH_STACK_PROTECTOR_STRONG)
if (NOT WINDOWS AND NOT CYGWIN)
check_c_compiler_flag_ssp("-fstack-clash-protection" WITH_STACK_CLASH_PROTECTION)
if (WITH_STACK_CLASH_PROTECTION)
list(APPEND SUPPORTED_COMPILER_FLAGS "-fstack-clash-protection")
endif()
endif()
if (PICKY_DEVELOPER)
add_c_compiler_flag("-Wno-error=deprecated-declarations" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("-Wno-error=tautological-compare" SUPPORTED_COMPILER_FLAGS)
endif()
add_c_compiler_flag("-Wno-deprecated-declarations" DEPRECATION_COMPILER_FLAGS)
# Unset CMAKE_REQUIRED_FLAGS
unset(CMAKE_REQUIRED_FLAGS)
endif()
if (MSVC)
add_c_compiler_flag("/D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("/D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT=1" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("/D _CRT_NONSTDC_NO_WARNINGS=1" SUPPORTED_COMPILER_FLAGS)
add_c_compiler_flag("/D _CRT_SECURE_NO_WARNINGS=1" SUPPORTED_COMPILER_FLAGS)
endif()
# This removes this annoying warning
# "warning: 'BN_CTX_free' is deprecated: first deprecated in OS X 10.7 [-Wdeprecated-declarations]"
if (OSX)
add_c_compiler_flag("-Wno-deprecated-declarations" SUPPORTED_COMPILER_FLAGS)
endif()
set(DEFAULT_C_COMPILE_FLAGS ${SUPPORTED_COMPILER_FLAGS} CACHE INTERNAL "Default C Compiler Flags" FORCE)
set(DEFAULT_LINK_FLAGS ${SUPPORTED_LINKER_FLAGS} CACHE INTERNAL "Default C Linker Flags" FORCE)
if (DEPRECATION_COMPILER_FLAGS)
set(DEFAULT_C_NO_DEPRECATION_FLAGS ${DEPRECATION_COMPILER_FLAGS} CACHE INTERNAL "Default no deprecation flags" FORCE)
endif()

View File

@@ -1,17 +1,15 @@
include(CheckIncludeFile)
include(CheckIncludeFiles)
include(CheckSymbolExists)
include(CheckFunctionExists)
include(CheckLibraryExists)
include(CheckTypeSize)
include(CheckCXXSourceCompiles)
include(CheckStructHasMember)
include(TestBigEndian)
set(PACKAGE ${APPLICATION_NAME})
set(VERSION ${APPLICATION_VERSION})
set(DATADIR ${DATA_INSTALL_DIR})
set(LIBDIR ${LIB_INSTALL_DIR})
set(PLUGINDIR "${PLUGIN_INSTALL_DIR}-${LIBRARY_SOVERSION}")
set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
set(PACKAGE ${PROJECT_NAME})
set(VERSION ${PROJECT_VERSION})
set(SYSCONFDIR ${CMAKE_INSTALL_SYSCONFDIR})
set(BINARYDIR ${CMAKE_BINARY_DIR})
set(SOURCEDIR ${CMAKE_SOURCE_DIR})
@@ -36,81 +34,233 @@ endfunction()
if(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW AND NOT OS2)
compiler_dumpversion(GNUCC_VERSION)
if (NOT GNUCC_VERSION EQUAL 34)
check_c_compiler_flag("-fvisibility=hidden" WITH_VISIBILITY_HIDDEN)
set(CMAKE_REQUIRED_FLAGS "-fvisibility=hidden")
check_c_source_compiles(
"void __attribute__((visibility(\"default\"))) test() {}
int main(void){ return 0; }
" WITH_VISIBILITY_HIDDEN)
unset(CMAKE_REQUIRED_FLAGS)
endif (NOT GNUCC_VERSION EQUAL 34)
endif(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW AND NOT OS2)
# HEADER FILES
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ARGP_INCLUDE_DIR})
check_include_file(argp.h HAVE_ARGP_H)
unset(CMAKE_REQUIRED_INCLUDES)
check_include_file(pty.h HAVE_PTY_H)
check_include_file(terminos.h HAVE_TERMIOS_H)
check_include_file(utmp.h HAVE_UTMP_H)
check_include_file(termios.h HAVE_TERMIOS_H)
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(util.h HAVE_UTIL_H)
check_include_file(libutil.h HAVE_LIBUTIL_H)
check_include_file(sys/time.h HAVE_SYS_TIME_H)
check_include_file(sys/utime.h HAVE_SYS_UTIME_H)
check_include_file(sys/param.h HAVE_SYS_PARAM_H)
check_include_file(arpa/inet.h HAVE_ARPA_INET_H)
check_include_file(byteswap.h HAVE_BYTESWAP_H)
check_include_file(glob.h HAVE_GLOB_H)
check_include_file(valgrind/valgrind.h HAVE_VALGRIND_VALGRIND_H)
if (WIN32)
check_include_file(wspiapi.h HAVE_WSPIAPI_H)
check_include_file(io.h HAVE_IO_H)
check_include_files("winsock2.h;ws2tcpip.h;wspiapi.h" HAVE_WSPIAPI_H)
if (NOT HAVE_WSPIAPI_H)
message(STATUS "WARNING: Without wspiapi.h, this build will only work on Windows XP and newer versions")
endif (NOT HAVE_WSPIAPI_H)
check_include_file(ws2tcpip.h HAVE_WS2TCPIP_H)
if (HAVE_WSPIAPI_H OR HAVE_WS2TCPIP_H)
set(HAVE_GETADDRINFO TRUE)
set(HAVE_GETHOSTBYNAME TRUE)
endif (HAVE_WSPIAPI_H OR HAVE_WS2TCPIP_H)
set(HAVE_SELECT TRUE)
check_include_files("winsock2.h;ws2tcpip.h" HAVE_WS2TCPIP_H)
endif (WIN32)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIRS})
check_include_file(openssl/aes.h HAVE_OPENSSL_AES_H)
if (OPENSSL_FOUND)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
check_include_file(openssl/des.h HAVE_OPENSSL_DES_H)
if (NOT HAVE_OPENSSL_DES_H)
message(FATAL_ERROR "Could not detect openssl/des.h")
endif()
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIRS})
check_include_file(openssl/blowfish.h HAVE_OPENSSL_BLOWFISH_H)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
check_include_file(openssl/aes.h HAVE_OPENSSL_AES_H)
if (NOT HAVE_OPENSSL_AES_H)
message(FATAL_ERROR "Could not detect openssl/aes.h")
endif()
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIRS})
check_include_file(openssl/des.h HAVE_OPENSSL_DES_H)
if (WITH_BLOWFISH_CIPHER)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
check_include_file(openssl/blowfish.h HAVE_OPENSSL_BLOWFISH_H)
endif()
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
check_include_file(openssl/ecdh.h HAVE_OPENSSL_ECDH_H)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
check_include_file(openssl/ec.h HAVE_OPENSSL_EC_H)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
check_include_file(openssl/ecdsa.h HAVE_OPENSSL_ECDSA_H)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
check_function_exists(EVP_KDF_CTX_new_id HAVE_OPENSSL_EVP_KDF_CTX_NEW_ID)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
check_function_exists(EVP_KDF_CTX_new HAVE_OPENSSL_EVP_KDF_CTX_NEW)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
check_function_exists(FIPS_mode HAVE_OPENSSL_FIPS_MODE)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
check_function_exists(RAND_priv_bytes HAVE_OPENSSL_RAND_PRIV_BYTES)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
check_function_exists(EVP_DigestSign HAVE_OPENSSL_EVP_DIGESTSIGN)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
check_function_exists(EVP_DigestVerify HAVE_OPENSSL_EVP_DIGESTVERIFY)
check_function_exists(OPENSSL_ia32cap_loc HAVE_OPENSSL_IA32CAP_LOC)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
check_symbol_exists(EVP_PKEY_ED25519 "openssl/evp.h" FOUND_OPENSSL_ED25519)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
check_function_exists(EVP_chacha20 HAVE_OPENSSL_EVP_CHACHA20)
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
check_symbol_exists(EVP_PKEY_POLY1305 "openssl/evp.h" HAVE_OPENSSL_EVP_POLY1305)
if (HAVE_OPENSSL_EVP_DIGESTSIGN AND HAVE_OPENSSL_EVP_DIGESTVERIFY AND
FOUND_OPENSSL_ED25519)
set(HAVE_OPENSSL_ED25519 1)
endif()
set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARIES})
check_symbol_exists(EVP_PKEY_X25519 "openssl/evp.h" HAVE_OPENSSL_X25519)
unset(CMAKE_REQUIRED_INCLUDES)
unset(CMAKE_REQUIRED_LIBRARIES)
endif()
if (CMAKE_HAVE_PTHREAD_H)
set(HAVE_PTHREAD_H 1)
endif (CMAKE_HAVE_PTHREAD_H)
if (NOT WITH_GCRYPT AND NOT WITH_MBEDTLS)
if (HAVE_OPENSSL_EC_H AND HAVE_OPENSSL_ECDSA_H)
set(HAVE_OPENSSL_ECC 1)
endif (HAVE_OPENSSL_EC_H AND HAVE_OPENSSL_ECDSA_H)
if (HAVE_OPENSSL_ECC)
set(HAVE_ECC 1)
endif (HAVE_OPENSSL_ECC)
if (HAVE_OPENSSL_EVP_KDF_CTX_NEW_ID OR HAVE_OPENSSL_EVP_KDF_CTX_NEW)
set(HAVE_OPENSSL_EVP_KDF_CTX 1)
endif (HAVE_OPENSSL_EVP_KDF_CTX_NEW_ID OR HAVE_OPENSSL_EVP_KDF_CTX_NEW)
endif ()
if (WITH_DSA)
if (NOT WITH_MBEDTLS)
set(HAVE_DSA 1)
endif (NOT WITH_MBEDTLS)
endif()
# FUNCTIONS
check_function_exists(isblank HAVE_ISBLANK)
check_function_exists(strncpy HAVE_STRNCPY)
check_function_exists(vsnprintf HAVE_VSNPRINTF)
check_function_exists(snprintf HAVE_SNPRINTF)
check_function_exists(strndup HAVE_STRNDUP)
check_function_exists(strtoull HAVE_STRTOULL)
check_function_exists(explicit_bzero HAVE_EXPLICIT_BZERO)
check_function_exists(memset_s HAVE_MEMSET_S)
if (HAVE_GLOB_H)
check_struct_has_member(glob_t gl_flags glob.h HAVE_GLOB_GL_FLAGS_MEMBER)
check_function_exists(glob HAVE_GLOB)
endif (HAVE_GLOB_H)
if (NOT WIN32)
check_function_exists(vsnprintf HAVE_VSNPRINTF)
check_function_exists(snprintf HAVE_SNPRINTF)
endif (NOT WIN32)
if (WIN32)
check_function_exists(_vsnprintf_s HAVE__VSNPRINTF_S)
check_function_exists(_vsnprintf HAVE__VSNPRINTF)
check_function_exists(_snprintf HAVE__SNPRINTF)
check_function_exists(_snprintf_s HAVE__SNPRINTF_S)
check_symbol_exists(vsnprintf "stdio.h" HAVE_VSNPRINTF)
check_symbol_exists(snprintf "stdio.h" HAVE_SNPRINTF)
check_symbol_exists(_vsnprintf_s "stdio.h" HAVE__VSNPRINTF_S)
check_symbol_exists(_vsnprintf "stdio.h" HAVE__VSNPRINTF)
check_symbol_exists(_snprintf "stdio.h" HAVE__SNPRINTF)
check_symbol_exists(_snprintf_s "stdio.h" HAVE__SNPRINTF_S)
if (HAVE_WSPIAPI_H OR HAVE_WS2TCPIP_H)
check_symbol_exists(ntohll winsock2.h HAVE_NTOHLL)
check_symbol_exists(htonll winsock2.h HAVE_HTONLL)
set(CMAKE_REQUIRED_LIBRARIES ws2_32)
check_symbol_exists(select "winsock2.h;ws2tcpip.h" HAVE_SELECT)
check_symbol_exists(poll "winsock2.h;ws2tcpip.h" HAVE_SELECT)
# The getaddrinfo function is defined to the WspiapiGetAddrInfo inline function
check_symbol_exists(getaddrinfo "winsock2.h;ws2tcpip.h" HAVE_GETADDRINFO)
unset(CMAKE_REQUIRED_LIBRARIES)
endif (HAVE_WSPIAPI_H OR HAVE_WS2TCPIP_H)
check_function_exists(_strtoui64 HAVE__STRTOUI64)
set(HAVE_SELECT TRUE)
check_symbol_exists(SecureZeroMemory "windows.h" HAVE_SECURE_ZERO_MEMORY)
else (WIN32)
check_function_exists(poll HAVE_POLL)
check_function_exists(select HAVE_SELECT)
check_function_exists(getaddrinfo HAVE_GETADDRINFO)
check_symbol_exists(ntohll arpa/inet.h HAVE_NTOHLL)
check_symbol_exists(htonll arpa/inet.h HAVE_HTONLL)
endif (WIN32)
if (UNIX)
if (NOT LINUX)
# libsocket (Solaris)
check_library_exists(socket getaddrinfo "" HAVE_LIBSOCKET)
if (HAVE_LIBSOCKET)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} socket)
set(HAVE_GETADDRINFO TRUE)
set(_REQUIRED_LIBRARIES ${_REQUIRED_LIBRARIES} socket)
endif (HAVE_LIBSOCKET)
# libresolv
check_library_exists(resolv hstrerror "" HAVE_LIBRESOLV)
if (HAVE_LIBRESOLV)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} resolv)
endif (HAVE_LIBRESOLV)
check_library_exists(rt nanosleep "" HAVE_LIBRT)
# libnsl/inet_pton (Solaris)
check_library_exists(nsl inet_pton "" HAVE_LIBNSL)
if (HAVE_LIBNSL)
set(_REQUIRED_LIBRARIES ${_REQUIRED_LIBRARIES} nsl)
endif (HAVE_LIBNSL)
# librt
if (HAVE_LIBRT)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} rt)
endif (HAVE_LIBRT)
check_library_exists(rt nanosleep "" HAVE_LIBRT)
endif (NOT LINUX)
check_function_exists(getaddrinfo HAVE_GETADDRINFO)
check_function_exists(poll HAVE_POLL)
check_function_exists(select HAVE_SELECT)
check_library_exists(rt clock_gettime "" HAVE_CLOCK_GETTIME)
if (HAVE_LIBRT OR HAVE_CLOCK_GETTIME)
set(_REQUIRED_LIBRARIES ${_REQUIRED_LIBRARIES} rt)
endif (HAVE_LIBRT OR HAVE_CLOCK_GETTIME)
check_library_exists(util forkpty "" HAVE_LIBUTIL)
check_function_exists(cfmakeraw HAVE_CFMAKERAW)
check_function_exists(regcomp HAVE_REGCOMP)
check_function_exists(__strtoull HAVE___STRTOULL)
endif (UNIX)
set(LIBSSH_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} CACHE INTERNAL "libssh required system libraries")
set(LIBSSH_REQUIRED_LIBRARIES ${_REQUIRED_LIBRARIES} CACHE INTERNAL "libssh required system libraries")
# LIBRARIES
if (OPENSSL_FOUND)
@@ -118,28 +268,245 @@ if (OPENSSL_FOUND)
endif (OPENSSL_FOUND)
if (GCRYPT_FOUND)
set(HAVE_LIBGCRYPT 1)
set(HAVE_LIBGCRYPT 1)
if (GCRYPT_VERSION VERSION_GREATER "1.4.6")
set(HAVE_GCRYPT_ECC 1)
set(HAVE_ECC 1)
endif (GCRYPT_VERSION VERSION_GREATER "1.4.6")
if (NOT GCRYPT_VERSION VERSION_LESS "1.7.0")
set(HAVE_GCRYPT_CHACHA_POLY 1)
endif (NOT GCRYPT_VERSION VERSION_LESS "1.7.0")
endif (GCRYPT_FOUND)
if (ZLIB_LIBRARY)
set(HAVE_LIBZ 1)
endif (ZLIB_LIBRARY)
if (MBEDTLS_FOUND)
set(HAVE_LIBMBEDCRYPTO 1)
set(HAVE_ECC 1)
if (CMAKE_HAVE_THREADS_LIBRARY)
if (CMAKE_USE_PTHREADS_INIT)
set(HAVE_PTHREAD 1)
endif (CMAKE_USE_PTHREADS_INIT)
endif (CMAKE_HAVE_THREADS_LIBRARY)
set(CMAKE_REQUIRED_INCLUDES "${MBEDTLS_INCLUDE_DIR}/mbedtls")
check_include_file(chacha20.h HAVE_MBEDTLS_CHACHA20_H)
check_include_file(poly1305.h HAVE_MBEDTLS_POLY1305_H)
unset(CMAKE_REQUIRED_INCLUDES)
endif (MBEDTLS_FOUND)
if (CMAKE_USE_PTHREADS_INIT)
set(HAVE_PTHREAD 1)
endif (CMAKE_USE_PTHREADS_INIT)
if (UNIT_TESTING)
if (CMOCKA_FOUND)
set(CMAKE_REQUIRED_LIBRARIES ${CMOCKA_LIBRARIES})
check_function_exists(cmocka_set_test_filter HAVE_CMOCKA_SET_TEST_FILTER)
unset(CMAKE_REQUIRED_LIBRARIES)
endif ()
endif ()
# OPTIONS
check_c_source_compiles("
__thread int tls;
int main(void) {
return 0;
}" HAVE_GCC_THREAD_LOCAL_STORAGE)
check_c_source_compiles("
__declspec(thread) int tls;
int main(void) {
return 0;
}" HAVE_MSC_THREAD_LOCAL_STORAGE)
###########################################################
# For detecting attributes we need to treat warnings as
# errors
if (UNIX OR MINGW)
# Get warnings for attributs
check_c_compiler_flag("-Wattributes" REQUIRED_FLAGS_WERROR)
if (REQUIRED_FLAGS_WERROR)
string(APPEND CMAKE_REQUIRED_FLAGS "-Wattributes ")
endif()
# Turn warnings into errors
check_c_compiler_flag("-Werror" REQUIRED_FLAGS_WERROR)
if (REQUIRED_FLAGS_WERROR)
string(APPEND CMAKE_REQUIRED_FLAGS "-Werror ")
endif()
endif ()
check_c_source_compiles("
void test_constructor_attribute(void) __attribute__ ((constructor));
void test_constructor_attribute(void)
{
return;
}
int main(void) {
return 0;
}" HAVE_CONSTRUCTOR_ATTRIBUTE)
check_c_source_compiles("
void test_destructor_attribute(void) __attribute__ ((destructor));
void test_destructor_attribute(void)
{
return;
}
int main(void) {
return 0;
}" HAVE_DESTRUCTOR_ATTRIBUTE)
check_c_source_compiles("
#define FALL_THROUGH __attribute__((fallthrough))
int main(void) {
int i = 2;
switch (i) {
case 0:
FALL_THROUGH;
case 1:
break;
default:
break;
}
return 0;
}" HAVE_FALLTHROUGH_ATTRIBUTE)
check_c_source_compiles("
#define WEAK __attribute__((weak))
WEAK int sum(int a, int b)
{
return a + b;
}
int main(void)
{
int i = sum(2, 2);
(void)i;
return 0;
}" HAVE_WEAK_ATTRIBUTE)
if (NOT WIN32)
check_c_source_compiles("
#define __unused __attribute__((unused))
static int do_nothing(int i __unused)
{
return 0;
}
int main(void)
{
int i;
i = do_nothing(5);
if (i > 5) {
return 1;
}
return 0;
}" HAVE_UNUSED_ATTRIBUTE)
endif()
check_c_source_compiles("
#include <string.h>
int main(void)
{
char buf[] = \"This is some content\";
memset(buf, '\\\\0', sizeof(buf)); __asm__ volatile(\"\" : : \"g\"(&buf) : \"memory\");
return 0;
}" HAVE_GCC_VOLATILE_MEMORY_PROTECTION)
check_c_source_compiles("
#include <stdio.h>
int main(void) {
printf(\"%s\", __func__);
return 0;
}" HAVE_COMPILER__FUNC__)
check_c_source_compiles("
#include <stdio.h>
int main(void) {
printf(\"%s\", __FUNCTION__);
return 0;
}" HAVE_COMPILER__FUNCTION__)
# This is only available with OpenBSD's gcc implementation */
if (OPENBSD)
check_c_source_compiles("
#define ARRAY_LEN 16
void test_attr(const unsigned char *k)
__attribute__((__bounded__(__minbytes__, 2, 16)));
int main(void) {
return 0;
}" HAVE_GCC_BOUNDED_ATTRIBUTE)
endif(OPENBSD)
# Stop treating warnings as errors
unset(CMAKE_REQUIRED_FLAGS)
# Check for version script support
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 {
global: sym;
};
VERS_2 {
global: sym;
} VERS_1;
")
set(CMAKE_REQUIRED_FLAGS "-Wl,--version-script=\"${CMAKE_CURRENT_BINARY_DIR}/conftest.map\"")
check_c_source_compiles("int main(void) { return 0; }" HAVE_LD_VERSION_SCRIPT)
unset(CMAKE_REQUIRED_FLAGS)
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
if (WITH_DEBUG_CRYPTO)
set(DEBUG_CRYPTO 1)
endif (WITH_DEBUG_CRYPTO)
if (WITH_DEBUG_PACKET)
set(DEBUG_PACKET 1)
endif (WITH_DEBUG_PACKET)
if (WITH_DEBUG_CALLTRACE)
set(DEBUG_CALLTRACE 1)
endif (WITH_DEBUG_CALLTRACE)
if (WITH_GSSAPI AND NOT GSSAPI_FOUND)
set(WITH_GSSAPI 0)
endif (WITH_GSSAPI AND NOT GSSAPI_FOUND)
if (WITH_PKCS11_URI)
if (WITH_GCRYPT)
message(FATAL_ERROR "PKCS #11 is not supported for gcrypt.")
set(WITH_PKCS11_URI 0)
endif()
if (WITH_MBEDTLS)
message(FATAL_ERROR "PKCS #11 is not supported for mbedcrypto")
set(WITH_PKCS11_URI 0)
endif()
if (HAVE_OPENSSL AND NOT OPENSSL_VERSION VERSION_GREATER_EQUAL "1.1.1")
message(FATAL_ERROR "PKCS #11 requires at least OpenSSL 1.1.1")
set(WITH_PKCS11_URI 0)
endif()
endif()
if (WITH_MBEDTLS)
if (WITH_DSA)
message(FATAL_ERROR "DSA is not supported with mbedTLS crypto")
set(HAVE_DSA 0)
endif()
endif()
# ENDIAN
if (NOT WIN32)
test_big_endian(WORDS_BIGENDIAN)

View File

@@ -1,21 +1,62 @@
option(WITH_LIBZ "Build with ZLIB support" ON)
option(WITH_SSH1 "Build with SSH1 support" OFF)
option(WITH_GSSAPI "Build with GSSAPI support" ON)
option(WITH_ZLIB "Build with ZLIB support" ON)
option(WITH_SFTP "Build with SFTP support" ON)
option(WITH_SERVER "Build with SSH server support" ON)
option(WITH_STATIC_LIB "Build with a static library" OFF)
option(WITH_DEBUG_CRYPTO "Build with cryto debug output" OFF)
option(WITH_DEBUG_PACKET "Build with packet debug output" OFF)
option(WITH_DEBUG_CALLTRACE "Build with calltrace debug output" ON)
option(WITH_DSA "Build with DSA" OFF)
option(WITH_GCRYPT "Compile against libgcrypt" OFF)
option(WITH_MBEDTLS "Compile against libmbedtls" OFF)
option(WITH_BLOWFISH_CIPHER "Compile with blowfish support" OFF)
option(WITH_PCAP "Compile with Pcap generation support" ON)
option(WITH_INTERNAL_DOC "Compile doxygen internal documentation" OFF)
option(WITH_TESTING "Build with unit tests" OFF)
option(WITH_CLIENT_TESTING "Build with client tests; requires a running sshd" OFF)
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
option(WITH_PKCS11_URI "Build with PKCS#11 URI support" OFF)
option(UNIT_TESTING "Build with unit tests" OFF)
option(CLIENT_TESTING "Build with client tests; requires openssh" OFF)
option(SERVER_TESTING "Build with server tests; requires openssh and dropbear" OFF)
option(WITH_BENCHMARKS "Build benchmarks tools" OFF)
option(WITH_EXAMPLES "Build examples" ON)
option(WITH_NACL "Build with libnacl (curve25519)" ON)
option(WITH_SYMBOL_VERSIONING "Build with symbol versioning" ON)
option(WITH_ABI_BREAK "Allow ABI break" OFF)
option(WITH_GEX "Enable DH Group exchange mechanisms" ON)
option(WITH_INSECURE_NONE "Enable insecure none cipher and MAC algorithms (not suitable for production!)" OFF)
option(FUZZ_TESTING "Build with fuzzer for the server and client (automatically enables none cipher!)" OFF)
option(PICKY_DEVELOPER "Build with picky developer flags" OFF)
if(WITH_BENCHMARKS)
set(WITH_TESTING ON)
endif(WITH_BENCHMARKS)
if (WITH_ZLIB)
set(WITH_LIBZ ON)
else (WITH_ZLIB)
set(WITH_LIBZ OFF)
endif (WITH_ZLIB)
if (WITH_TESTING)
set(WITH_STATIC_LIB ON)
endif (WITH_TESTING)
if (WITH_BENCHMARKS)
set(UNIT_TESTING ON)
set(CLIENT_TESTING ON)
endif()
if (UNIT_TESTING OR CLIENT_TESTING OR SERVER_TESTING)
set(BUILD_STATIC_LIB ON)
endif()
if (WITH_NACL)
set(WITH_NACL ON)
endif (WITH_NACL)
if (WITH_ABI_BREAK)
set(WITH_SYMBOL_VERSIONING ON)
endif (WITH_ABI_BREAK)
if (NOT GLOBAL_BIND_CONFIG)
set(GLOBAL_BIND_CONFIG "/etc/ssh/libssh_server_config")
endif (NOT GLOBAL_BIND_CONFIG)
if (NOT GLOBAL_CLIENT_CONFIG)
set(GLOBAL_CLIENT_CONFIG "/etc/ssh/ssh_config")
endif (NOT GLOBAL_CLIENT_CONFIG)
if (FUZZ_TESTING)
set(WITH_INSECURE_NONE ON)
endif (FUZZ_TESTING)

58
INSTALL
View File

@@ -7,27 +7,56 @@
In order to build libssh, you need to install several components:
- A C compiler
- [CMake](http://www.cmake.org) >= 2.6.0.
- [openssl](http://www.openssl.org) >= 0.9.8
- [CMake](https://www.cmake.org) >= 3.3.0
- [openssl](https://www.openssl.org) >= 1.0.1
or
- [gcrypt](http://www.gnu.org/directory/Security/libgcrypt.html) >= 1.4
- [gcrypt](https://www.gnu.org/directory/Security/libgcrypt.html) >= 1.4
- [libz](https://www.zlib.net) >= 1.2
optional:
- [libz](http://www.zlib.net) >= 1.2
- [cmocka](https://cmocka.org/) >= 1.1.0
- [socket_wrapper](https://cwrap.org/) >= 1.1.5
- [nss_wrapper](https://cwrap.org/) >= 1.1.2
- [uid_wrapper](https://cwrap.org/) >= 1.2.0
- [pam_wrapper](https://cwrap.org/) >= 1.0.1
Note that these version numbers are version we know works correctly. If you
build and run libssh successfully with an older version, please let us know.
For Windows use vcpkg:
https://github.com/Microsoft/vcpkg
which you can use to install openssl and zlib. libssh itself is also part of
vcpkg!
## Building
First, you need to configure the compilation, using CMake. Go inside the
`build` dir. Create it if it doesn't exist.
GNU/Linux and MacOS X:
GNU/Linux, MacOS X, MSYS/MinGW:
cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug ..
cmake -DUNIT_TESTING=ON -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug ..
make
On Windows you should choose a makefile gernerator with -G or use
cmake-gui.exe ..
To enable additional client tests against a local OpenSSH server, add the
compile option -DCLIENT_TESTING=ON. These tests require an OpenSSH
server package and some wrapper libraries (see optional requirements) to
be installed.
If you're interested in server testing, then a OpenSSH client should be
installed on the system and if possible also dropbear. Once that is done
enable server support with -DWITH_SERVER=ON and enable testing of it with
-DSERVER_TESTING=ON.
## Testing build
make test
### CMake standard options
Here is a list of the most interesting options provided out of the box by
CMake.
@@ -47,7 +76,7 @@ Options are defined in the following files:
They can be changed with the -D option:
`cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DWITH_LIBZ=OFF ..`
`cmake -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DWITH_ZLIB=OFF ..`
### Browsing/editing CMake options
@@ -59,6 +88,17 @@ and MacOS X).
- On Windows: run `cmakesetup`
- On GNU/Linux and MacOS X: run `ccmake ..`
### Useful Windows options:
If you have installed OpenSSL or ZLIB in non standard directories, maybe you
want to set:
OPENSSL_ROOT_DIR
and
ZLIB_ROOT_DIR
## Installing
If you want to install libssh after compilation run:
@@ -67,7 +107,7 @@ If you want to install libssh after compilation run:
## Running
The libssh binary can be found in the `build/libssh` directory.
The libssh binary can be found in the `build/src` directory.
You can use `build/examples/samplessh` which is a sample client to
test libssh on UNIX.
@@ -77,4 +117,4 @@ This document is written using [Markdown][] syntax, making it possible to
provide usable information in both plain text and HTML format. Whenever
modifying this document please use [Markdown][] syntax.
[markdown]: http://www.daringfireball.net/projects/markdown
[markdown]: https://www.daringfireball.net/projects/markdown

57
README
View File

@@ -1,5 +1,12 @@
libssh: the SSH library
~~~~~~~~~~~~~~~~~~~~~~~
_ _ _ _
(_) (_) (_) (_)
(_) _ (_) _ _ _ _ _ (_) _
(_) (_) (_)(_) _ (_)(_) (_)(_) (_)(_) _
(_) (_) (_) (_) _ (_) _ (_) (_) (_)
(_) (_) (_)(_)(_) (_)(_) (_)(_) (_) (_).org
The SSH library
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1* Why ?
-_-_-_-_-_
@@ -24,48 +31,14 @@ If you ask yourself how to compile libssh, please read INSTALL before anything.
3* Where ?
-_-_-_-_-_-_
http://www.libssh.org
https://www.libssh.org
4* API Changes !
4* Contributing
-_-_-_-_-_-_-_-_-_
Changes between 0.4 and 0.5
---------------------------
Please read the file 'CONTRIBUTING.md' next to this README file. It explains
our copyright policy and how you should send patches for upstream inclusion.
We use the ssh_ prefix as namespace for every function now. There is a legacy.h
which could be used to get the old function names.
Have fun and happy libssh hacking!
Changes between 0.3 and 0.4
---------------------------
We changed libssh to be typesafe now:
SSH_SESSION *session -> ssh_session session
SFTP_SESSION *sftp -> sftp_session sftp
CHANNEL *channel -> ssh_channel channel
STRING *string -> ssh_string string
...
The options structure has been removed and there is a new function. This
function can set all available options now. You can find the enum in the
header file and it is documented. Example:
ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
5* Copyright policy
-_-_-_-_-_-_-_-_-_-_
The developers of libssh have a policy of asking for contributions to be made
under the personal copyright of the contributor, instead of a corporate
copyright.
There are some reasons for the establishment of this policy:
* Individual copyrights make copyright registration in the US a simpler
process.
* If libssh is copyrighted by individuals rather than corporations,
decisions regarding enforcement and protection of copyright will, more
likely, be made in the interests of the project, and not in the interests
of any corporations shareholders.
* If we ever need to relicense a portion of the code contacting individuals
for permission to do so is much easier than contacting a company.
The libssh Team

11
README.mbedtls Normal file
View File

@@ -0,0 +1,11 @@
mbedTLS and libssh in multithreaded applications
==================================================
To use libssh with mbedTLS in a multithreaded application, mbedTLS has to be
built with threading support enabled.
If threading support is not available and multi threading is used, ssh_init
will fail.
More information about building mbedTLS with threading support can be found
in the mbedTLS documentation.

45
README.md Normal file
View File

@@ -0,0 +1,45 @@
[![pipeline status](https://gitlab.com/libssh/libssh-mirror/badges/master/pipeline.svg)](https://gitlab.com/libssh/libssh-mirror/commits/master)
[![Fuzzing Status](https://oss-fuzz-build-logs.storage.googleapis.com/badges/libssh.svg)](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:libssh)
```
_ _ _ _
(_) (_) (_) (_)
(_) _ (_) _ _ _ _ _ (_) _
(_) (_) (_)(_) _ (_)(_) (_)(_) (_)(_) _
(_) (_) (_) (_) _ (_) _ (_) (_) (_)
(_) (_) (_)(_)(_) (_)(_) (_)(_) (_) (_).org
The SSH library
```
# Why?
Why not ? :) I've began to work on my own implementation of the ssh protocol
because i didn't like the currently public ones.
Not any allowed you to import and use the functions as a powerful library,
and so i worked on a library-based SSH implementation which was non-existing
in the free and open source software world.
# How/Who?
If you downloaded this file, you must know what it is : a library for
accessing ssh client services through C libraries calls in a simple manner.
Everybody can use this software under the terms of the LGPL - see the COPYING
file
If you ask yourself how to compile libssh, please read INSTALL before anything.
# Where ?
https://www.libssh.org
# Contributing
Please read the file 'CONTRIBUTING.md' next to this README file. It explains
our copyright policy and how you should send patches for upstream inclusion.
Have fun and happy libssh hacking!
The libssh Team

View File

@@ -1,197 +0,0 @@
#!/bin/bash
#
# Last Change: 2008-06-18 14:13:46
#
# Script to build libssh on UNIX.
#
# Copyright (c) 2006-2007 Andreas Schneider <mail@cynapses.org>
#
SOURCE_DIR=".."
LANG=C
export LANG
SCRIPT="$0"
COUNT=0
while [ -L "${SCRIPT}" ]
do
SCRIPT=$(readlink ${SCRIPT})
COUNT=$(expr ${COUNT} + 1)
if [ ${COUNT} -gt 100 ]; then
echo "Too many symbolic links"
exit 1
fi
done
BUILDDIR=$(dirname ${SCRIPT})
cleanup_and_exit () {
if test "$1" = 0 -o -z "$1" ; then
exit 0
else
exit $1
fi
}
function configure() {
if [ -n "${CMAKEDIR}" ]; then
${CMAKEDIR}/bin/cmake "$@" ${SOURCE_DIR} || cleanup_and_exit $?
else
cmake "$@" ${SOURCE_DIR} || cleanup_and_exit $?
fi
}
function compile() {
if [ -f /proc/cpuinfo ]; then
CPUCOUNT=$(grep -c processor /proc/cpuinfo)
elif test `uname` = "SunOS" ; then
CPUCOUNT=$(psrinfo -p)
else
CPUCOUNT="1"
fi
if [ "${CPUCOUNT}" -gt "1" ]; then
${MAKE} -j${CPUCOUNT} $1 || cleanup_and_exit $?
else
${MAKE} $1 || exit $?
fi
}
function clean_build_dir() {
find ! -path "*.svn*" ! -name "*.bat" ! -name "*.sh" ! -name "." -print0 | xargs -0 rm -rf
}
function usage () {
echo "Usage: `basename $0` [--prefix /install_prefix|--build [debug|final]|--clean|--verbose|--libsuffix (32|64)|--help|--clang|--cmakedir /directory|--make
(gmake|make)|--ccompiler (gcc|cc)|--withstaticlib|--unittesting|--clientunittesting|--withssh1|--withserver]"
cleanup_and_exit
}
cd ${BUILDDIR}
# the default CMake options:
OPTIONS="--graphviz=${BUILDDIR}/libssh.dot"
# the default 'make' utility:
MAKE="make"
while test -n "$1"; do
PARAM="$1"
ARG="$2"
shift
case ${PARAM} in
*-*=*)
ARG=${PARAM#*=}
PARAM=${PARAM%%=*}
set -- "----noarg=${PARAM}" "$@"
esac
case ${PARAM} in
*-help|-h)
#echo_help
usage
cleanup_and_exit
;;
*-build)
DOMAKE="1"
BUILD_TYPE="${ARG}"
test -n "${BUILD_TYPE}" && shift
;;
*-clean)
clean_build_dir
cleanup_and_exit
;;
*-clang)
OPTIONS="${OPTIONS} -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++"
;;
*-verbose)
DOVERBOSE="1"
;;
*-memtest)
OPTIONS="${OPTIONS} -DMEM_NULL_TESTS=ON"
;;
*-libsuffix)
OPTIONS="${OPTIONS} -DLIB_SUFFIX=${ARG}"
shift
;;
*-prefix)
OPTIONS="${OPTIONS} -DCMAKE_INSTALL_PREFIX=${ARG}"
shift
;;
*-sysconfdir)
OPTIONS="${OPTIONS} -DSYSCONF_INSTALL_DIR=${ARG}"
shift
;;
*-cmakedir)
CMAKEDIR="${ARG}"
shift
;;
*-make)
MAKE="${ARG}"
shift
;;
*-ccompiler)
OPTIONS="${OPTIONS} -DCMAKE_C_COMPILER=${ARG}"
shift
;;
*-withstaticlib)
OPTIONS="${OPTIONS} -DWITH_STATIC_LIB=ON"
;;
*-unittesting)
OPTIONS="${OPTIONS} -DWITH_TESTING=ON"
;;
*-clientunittesting)
OPTIONS="${OPTIONS} -DWITH_CLIENT_TESTING=ON"
;;
*-withssh1)
OPTIONS="${OPTIONS} -DWITH_SSH1=ON"
;;
*-withserver)
OPTIONS="${OPTIONS} -DWITH_SERVER=ON"
;;
----noarg)
echo "$ARG does not take an argument"
cleanup_and_exit
;;
-*)
echo Unknown Option "$PARAM". Exit.
cleanup_and_exit 1
;;
*)
usage
;;
esac
done
if [ "${DOMAKE}" == "1" ]; then
OPTIONS="${OPTIONS} -DCMAKE_BUILD_TYPE=${BUILD_TYPE}"
fi
if [ -n "${DOVERBOSE}" ]; then
OPTIONS="${OPTIONS} -DCMAKE_VERBOSE_MAKEFILE=1"
else
OPTIONS="${OPTIONS} -DCMAKE_VERBOSE_MAKEFILE=0"
fi
test -f "${BUILDDIR}/.build.log" && rm -f ${BUILDDIR}/.build.log
touch ${BUILDDIR}/.build.log
# log everything from here to .build.log
exec 1> >(exec -a 'build logging tee' tee -a ${BUILDDIR}/.build.log) 2>&1
echo "${HOST} started build at $(date)."
echo
configure ${OPTIONS} "$@"
if [ -n "${DOMAKE}" ]; then
test -n "${DOVERBOSE}" && compile VERBOSE=1 || compile
fi
DOT=$(which dot 2>/dev/null)
if [ -n "${DOT}" ]; then
${DOT} -Tpng -o${BUILDDIR}/libssh.png ${BUILDDIR}/libssh.dot
${DOT} -Tsvg -o${BUILDDIR}/libssh.svg ${BUILDDIR}/libssh.dot
fi
exec >&0 2>&0 # so that the logging tee finishes
sleep 1 # wait till tee terminates
cleanup_and_exit 0

View File

@@ -0,0 +1,21 @@
#
# add_c_compiler_flag("-Werror" SUPPORTED_CFLAGS)
#
# Copyright (c) 2018 Andreas Schneider <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
include(CheckCCompilerFlag)
macro(add_c_compiler_flag _COMPILER_FLAG _OUTPUT_VARIABLE)
string(TOUPPER ${_COMPILER_FLAG} _COMPILER_FLAG_NAME)
string(REGEX REPLACE "^-" "" _COMPILER_FLAG_NAME "${_COMPILER_FLAG_NAME}")
string(REGEX REPLACE "(-|=|\ )" "_" _COMPILER_FLAG_NAME "${_COMPILER_FLAG_NAME}")
check_c_compiler_flag("${_COMPILER_FLAG}" WITH_${_COMPILER_FLAG_NAME}_FLAG)
if (WITH_${_COMPILER_FLAG_NAME}_FLAG)
#string(APPEND ${_OUTPUT_VARIABLE} "${_COMPILER_FLAG} ")
list(APPEND ${_OUTPUT_VARIABLE} ${_COMPILER_FLAG})
endif()
endmacro()

View File

@@ -0,0 +1,120 @@
#
# Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
# Copyright (c) 2007-2018 Andreas Schneider <asn@cryptomilk.org>
# Copyright (c) 2018 Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#.rst:
# AddCMockaTest
# -------------
#
# This file provides a function to add a test
#
# Functions provided
# ------------------
#
# ::
#
# add_cmocka_test(target_name
# SOURCES src1 src2 ... srcN
# [COMPILE_OPTIONS opt1 opt2 ... optN]
# [LINK_LIBRARIES lib1 lib2 ... libN]
# [LINK_OPTIONS lopt1 lop2 .. loptN]
# )
#
# ``target_name``:
# Required, expects the name of the test which will be used to define a target
#
# ``SOURCES``:
# Required, expects one or more source files names
#
# ``COMPILE_OPTIONS``:
# Optional, expects one or more options to be passed to the compiler
#
# ``LINK_LIBRARIES``:
# Optional, expects one or more libraries to be linked with the test
# executable.
#
# ``LINK_OPTIONS``:
# Optional, expects one or more options to be passed to the linker
#
#
# Example:
#
# .. code-block:: cmake
#
# add_cmocka_test(my_test
# SOURCES my_test.c other_source.c
# COMPILE_OPTIONS -g -Wall
# LINK_LIBRARIES mylib
# LINK_OPTIONS -Wl,--enable-syscall-fixup
# )
#
# Where ``my_test`` is the name of the test, ``my_test.c`` and
# ``other_source.c`` are sources for the binary, ``-g -Wall`` are compiler
# options to be used, ``mylib`` is a target of a library to be linked, and
# ``-Wl,--enable-syscall-fixup`` is an option passed to the linker.
#
enable_testing()
include(CTest)
if (CMAKE_CROSSCOMPILING)
if (WIN32)
find_program(WINE_EXECUTABLE
NAMES wine)
set(TARGET_SYSTEM_EMULATOR ${WINE_EXECUTABLE})
endif()
endif()
function(ADD_CMOCKA_TEST _TARGET_NAME)
set(one_value_arguments
)
set(multi_value_arguments
SOURCES
COMPILE_OPTIONS
LINK_LIBRARIES
LINK_OPTIONS
)
cmake_parse_arguments(_add_cmocka_test
""
"${one_value_arguments}"
"${multi_value_arguments}"
${ARGN}
)
if (NOT DEFINED _add_cmocka_test_SOURCES)
message(FATAL_ERROR "No sources provided for target ${_TARGET_NAME}")
endif()
add_executable(${_TARGET_NAME} ${_add_cmocka_test_SOURCES})
if (DEFINED _add_cmocka_test_COMPILE_OPTIONS)
target_compile_options(${_TARGET_NAME}
PRIVATE ${_add_cmocka_test_COMPILE_OPTIONS}
)
endif()
if (DEFINED _add_cmocka_test_LINK_LIBRARIES)
target_link_libraries(${_TARGET_NAME}
PRIVATE ${_add_cmocka_test_LINK_LIBRARIES}
)
endif()
if (DEFINED _add_cmocka_test_LINK_OPTIONS)
set_target_properties(${_TARGET_NAME}
PROPERTIES LINK_FLAGS
${_add_cmocka_test_LINK_OPTIONS}
)
endif()
add_test(${_TARGET_NAME}
${TARGET_SYSTEM_EMULATOR} ${_TARGET_NAME}
)
endfunction (ADD_CMOCKA_TEST)

View File

@@ -1,23 +0,0 @@
# - ADD_CHECK_TEST(test_name test_source linklib1 ... linklibN)
# Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
# Copyright (c) 2007-2010 Andreas Schneider <asn@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
enable_testing()
include(CTest)
if(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
set(CMAKE_C_FLAGS_PROFILING "-g -O0 -Wall -W -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wwrite-strings -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Compiler Flags")
set(CMAKE_SHARED_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
set(CMAKE_MODULE_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
set(CMAKE_EXEC_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
endif(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
function (ADD_CMOCKERY_TEST _testName _testSource)
add_executable(${_testName} ${_testSource})
target_link_libraries(${_testName} ${ARGN})
add_test(${_testName} ${CMAKE_CURRENT_BINARY_DIR}/${_testName})
endfunction (ADD_CMOCKERY_TEST)

View File

@@ -1,11 +1,12 @@
# - Check whether the C compiler supports a given flag in the
# context of a stack checking compiler option.
# CHECK_C_COMPILER_FLAG_SSP(FLAG VARIABLE)
#
# FLAG - the compiler flag
# VARIABLE - variable to store the result
#
# This actually calls the check_c_source_compiles macro.
#
# This actually calls check_c_source_compiles.
# See help for CheckCSourceCompiles for a listing of variables
# that can modify the build.
@@ -14,13 +15,15 @@
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
# Requires cmake 3.10
#include_guard(GLOBAL)
include(CheckCSourceCompiles)
INCLUDE(CheckCSourceCompiles)
macro(CHECK_C_COMPILER_FLAG_SSP _FLAG _RESULT)
set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
set(CMAKE_REQUIRED_FLAGS "${_FLAG}")
MACRO (CHECK_C_COMPILER_FLAG_SSP _FLAG _RESULT)
SET(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}")
SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}")
CHECK_C_SOURCE_COMPILES("int main(int argc, char **argv) { char buffer[256]; return buffer[argc]=0;}" ${_RESULT})
SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}")
ENDMACRO (CHECK_C_COMPILER_FLAG_SSP)
check_c_source_compiles("int main(int argc, char **argv) { char buffer[256]; return buffer[argc]=0;}" ${_RESULT})
set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
endmacro(CHECK_C_COMPILER_FLAG_SSP)

View File

@@ -14,14 +14,8 @@ set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
# since cmake 2.4.0
set(CMAKE_COLOR_MAKEFILE ON)
# Define the generic version of the libraries here
set(GENERIC_LIB_VERSION "0.1.0")
set(GENERIC_LIB_SOVERSION "0")
# Create the compile command database for clang by default
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Set the default build type to release with debug info
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo
CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
)
endif (NOT CMAKE_BUILD_TYPE)
# Always build with -fPIC
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

View File

@@ -1,71 +1,49 @@
# define system dependent compiler flags
include(CheckCCompilerFlag)
include(MacroCheckCCompilerFlagSSP)
if (UNIX AND NOT WIN32)
#
# Define GNUCC compiler flags
#
if (${CMAKE_C_COMPILER_ID} MATCHES GNU)
# add -Wconversion ?
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 -pedantic -pedantic-errors")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wshadow -Wmissing-prototypes -Wdeclaration-after-statement")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused -Wfloat-equal -Wpointer-arith -Wwrite-strings -Wformat-security")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wmissing-format-attribute")
# Activate with: -DCMAKE_BUILD_TYPE=Profiling
set(CMAKE_C_FLAGS_PROFILING "-O0 -g -fprofile-arcs -ftest-coverage"
CACHE STRING "Flags used by the C compiler during PROFILING builds.")
set(CMAKE_CXX_FLAGS_PROFILING "-O0 -g -fprofile-arcs -ftest-coverage"
CACHE STRING "Flags used by the CXX compiler during PROFILING builds.")
set(CMAKE_SHARED_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage"
CACHE STRING "Flags used by the linker during the creation of shared libraries during PROFILING builds.")
set(CMAKE_MODULE_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage"
CACHE STRING "Flags used by the linker during the creation of shared libraries during PROFILING builds.")
set(CMAKE_EXEC_LINKER_FLAGS_PROFILING "-fprofile-arcs -ftest-coverage"
CACHE STRING "Flags used by the linker during PROFILING builds.")
# with -fPIC
check_c_compiler_flag("-fPIC" WITH_FPIC)
if (WITH_FPIC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
endif (WITH_FPIC)
# Activate with: -DCMAKE_BUILD_TYPE=AddressSanitizer
set(CMAKE_C_FLAGS_ADDRESSSANITIZER "-g -O1 -fsanitize=address -fno-omit-frame-pointer"
CACHE STRING "Flags used by the C compiler during ADDRESSSANITIZER builds.")
set(CMAKE_CXX_FLAGS_ADDRESSSANITIZER "-g -O1 -fsanitize=address -fno-omit-frame-pointer"
CACHE STRING "Flags used by the CXX compiler during ADDRESSSANITIZER builds.")
set(CMAKE_SHARED_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address"
CACHE STRING "Flags used by the linker during the creation of shared libraries during ADDRESSSANITIZER builds.")
set(CMAKE_MODULE_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address"
CACHE STRING "Flags used by the linker during the creation of shared libraries during ADDRESSSANITIZER builds.")
set(CMAKE_EXEC_LINKER_FLAGS_ADDRESSSANITIZER "-fsanitize=address"
CACHE STRING "Flags used by the linker during ADDRESSSANITIZER builds.")
check_c_compiler_flag_ssp("-fstack-protector" WITH_STACK_PROTECTOR)
if (WITH_STACK_PROTECTOR)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fstack-protector")
endif (WITH_STACK_PROTECTOR)
# Activate with: -DCMAKE_BUILD_TYPE=MemorySanitizer
set(CMAKE_C_FLAGS_MEMORYSANITIZER "-g -O2 -fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer"
CACHE STRING "Flags used by the C compiler during MEMORYSANITIZER builds.")
set(CMAKE_CXX_FLAGS_MEMORYSANITIZER "-g -O2 -fsanitize=memory -fsanitize-memory-track-origins=2 -fno-omit-frame-pointer"
CACHE STRING "Flags used by the CXX compiler during MEMORYSANITIZER builds.")
set(CMAKE_SHARED_LINKER_FLAGS_MEMORYSANITIZER "-fsanitize=memory"
CACHE STRING "Flags used by the linker during the creation of shared libraries during MEMORYSANITIZER builds.")
set(CMAKE_MODULE_LINKER_FLAGS_MEMORYSANITIZER "-fsanitize=memory"
CACHE STRING "Flags used by the linker during the creation of shared libraries during MEMORYSANITIZER builds.")
set(CMAKE_EXEC_LINKER_FLAGS_MEMORYSANITIZER "-fsanitize=memory"
CACHE STRING "Flags used by the linker during MEMORYSANITIZER builds.")
check_c_compiler_flag("-D_FORTIFY_SOURCE=2" WITH_FORTIFY_SOURCE)
if (WITH_FORTIFY_SOURCE)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FORTIFY_SOURCE=2")
endif (WITH_FORTIFY_SOURCE)
endif (${CMAKE_C_COMPILER_ID} MATCHES GNU)
#
# Check for large filesystem support
#
if (CMAKE_SIZEOF_VOID_P MATCHES "8")
# with large file support
execute_process(
COMMAND
getconf LFS64_CFLAGS
OUTPUT_VARIABLE
_lfs_CFLAGS
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
else (CMAKE_SIZEOF_VOID_P MATCHES "8")
# with large file support
execute_process(
COMMAND
getconf LFS_CFLAGS
OUTPUT_VARIABLE
_lfs_CFLAGS
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif (CMAKE_SIZEOF_VOID_P MATCHES "8")
if (_lfs_CFLAGS)
string(REGEX REPLACE "[\r\n]" " " "${_lfs_CFLAGS}" "${${_lfs_CFLAGS}}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_lfs_CFLAGS}")
endif (_lfs_CFLAGS)
endif (UNIX AND NOT WIN32)
if (MSVC)
# Use secure functions by defaualt and suppress warnings about
#"deprecated" functions
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_SECURE_CPP_OVERLOAD_STANDARD_NAMES_COUNT=1")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _CRT_NONSTDC_NO_WARNINGS=1 /D _CRT_SECURE_NO_WARNINGS=1")
endif (MSVC)
# Activate with: -DCMAKE_BUILD_TYPE=UndefinedSanitizer
set(CMAKE_C_FLAGS_UNDEFINEDSANITIZER "-g -O1 -fsanitize=undefined -fsanitize=null -fsanitize=alignment -fno-sanitize-recover=undefined,integer"
CACHE STRING "Flags used by the C compiler during UNDEFINEDSANITIZER builds.")
set(CMAKE_CXX_FLAGS_UNDEFINEDSANITIZER "-g -O1 -fsanitize=undefined -fsanitize=null -fsanitize=alignment -fno-sanitize-recover=undefined,integer"
CACHE STRING "Flags used by the CXX compiler during UNDEFINEDSANITIZER builds.")
set(CMAKE_SHARED_LINKER_FLAGS_UNDEFINEDSANITIZER "-fsanitize=undefined"
CACHE STRING "Flags used by the linker during the creation of shared libraries during UNDEFINEDSANITIZER builds.")
set(CMAKE_MODULE_LINKER_FLAGS_UNDEFINEDSANITIZER "-fsanitize=undefined"
CACHE STRING "Flags used by the linker during the creation of shared libraries during UNDEFINEDSANITIZER builds.")
set(CMAKE_EXEC_LINKER_FLAGS_UNDEFINEDSANITIZER "-fsanitize=undefined"
CACHE STRING "Flags used by the linker during UNDEFINEDSANITIZER builds.")
endif()

View File

@@ -1,104 +0,0 @@
if (WIN32)
# Same same
set(BIN_INSTALL_DIR "bin" CACHE PATH "-")
set(SBIN_INSTALL_DIR "." CACHE PATH "-")
set(LIB_INSTALL_DIR "lib" CACHE PATH "-")
set(INCLUDE_INSTALL_DIR "include" CACHE PATH "-")
set(PLUGIN_INSTALL_DIR "plugins" CACHE PATH "-")
set(HTML_INSTALL_DIR "doc/HTML" CACHE PATH "-")
set(ICON_INSTALL_DIR "." CACHE PATH "-")
set(SOUND_INSTALL_DIR "." CACHE PATH "-")
set(LOCALE_INSTALL_DIR "lang" CACHE PATH "-")
elseif (UNIX OR OS2)
IF (NOT APPLICATION_NAME)
MESSAGE(STATUS "${PROJECT_NAME} is used as APPLICATION_NAME")
SET(APPLICATION_NAME ${PROJECT_NAME})
ENDIF (NOT APPLICATION_NAME)
# Suffix for Linux
SET(LIB_SUFFIX
CACHE STRING "Define suffix of directory name (32/64)"
)
SET(EXEC_INSTALL_PREFIX
"${CMAKE_INSTALL_PREFIX}"
CACHE PATH "Base directory for executables and libraries"
)
SET(SHARE_INSTALL_PREFIX
"${CMAKE_INSTALL_PREFIX}/share"
CACHE PATH "Base directory for files which go to share/"
)
SET(DATA_INSTALL_PREFIX
"${SHARE_INSTALL_PREFIX}/${APPLICATION_NAME}"
CACHE PATH "The parent directory where applications can install their data")
# The following are directories where stuff will be installed to
SET(BIN_INSTALL_DIR
"${EXEC_INSTALL_PREFIX}/bin"
CACHE PATH "The ${APPLICATION_NAME} binary install dir (default prefix/bin)"
)
SET(SBIN_INSTALL_DIR
"${EXEC_INSTALL_PREFIX}/sbin"
CACHE PATH "The ${APPLICATION_NAME} sbin install dir (default prefix/sbin)"
)
SET(LIB_INSTALL_DIR
"${EXEC_INSTALL_PREFIX}/lib${LIB_SUFFIX}"
CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is prefix/lib)"
)
SET(LIBEXEC_INSTALL_DIR
"${EXEC_INSTALL_PREFIX}/libexec"
CACHE PATH "The subdirectory relative to the install prefix where libraries will be installed (default is prefix/libexec)"
)
SET(PLUGIN_INSTALL_DIR
"${LIB_INSTALL_DIR}/${APPLICATION_NAME}"
CACHE PATH "The subdirectory relative to the install prefix where plugins will be installed (default is prefix/lib/${APPLICATION_NAME})"
)
SET(INCLUDE_INSTALL_DIR
"${CMAKE_INSTALL_PREFIX}/include"
CACHE PATH "The subdirectory to the header prefix (default prefix/include)"
)
SET(DATA_INSTALL_DIR
"${DATA_INSTALL_PREFIX}"
CACHE PATH "The parent directory where applications can install their data (default prefix/share/${APPLICATION_NAME})"
)
SET(HTML_INSTALL_DIR
"${DATA_INSTALL_PREFIX}/doc/HTML"
CACHE PATH "The HTML install dir for documentation (default data/doc/html)"
)
SET(ICON_INSTALL_DIR
"${DATA_INSTALL_PREFIX}/icons"
CACHE PATH "The icon install dir (default data/icons/)"
)
SET(SOUND_INSTALL_DIR
"${DATA_INSTALL_PREFIX}/sounds"
CACHE PATH "The install dir for sound files (default data/sounds)"
)
SET(LOCALE_INSTALL_DIR
"${SHARE_INSTALL_PREFIX}/locale"
CACHE PATH "The install dir for translations (default prefix/share/locale)"
)
SET(XDG_APPS_DIR
"${SHARE_INSTALL_PREFIX}/applications/"
CACHE PATH "The XDG apps dir"
)
SET(XDG_DIRECTORY_DIR
"${SHARE_INSTALL_PREFIX}/desktop-directories"
CACHE PATH "The XDG directory"
)
SET(SYSCONF_INSTALL_DIR
"${EXEC_INSTALL_PREFIX}/etc"
CACHE PATH "The ${APPLICATION_NAME} sysconfig install dir (default prefix/etc)"
)
SET(MAN_INSTALL_DIR
"${SHARE_INSTALL_PREFIX}/man"
CACHE PATH "The ${APPLICATION_NAME} man install dir (default prefix/man)"
)
SET(INFO_INSTALL_DIR
"${SHARE_INSTALL_PREFIX}/info"
CACHE PATH "The ${APPLICATION_NAME} info install dir (default prefix/info)"
)
endif ()

View File

@@ -26,3 +26,7 @@ endif (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
if (CMAKE_SYSTEM_NAME MATCHES "OS2")
set(OS2 TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "OS2")
if (CMAKE_SYSTEM_NAME MATCHES "Darwin")
set (OSX TRUE)
endif (CMAKE_SYSTEM_NAME MATCHES "Darwin")

View File

@@ -0,0 +1,92 @@
#
# Copyright (c) 2018 Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
#.rst:
# ExtractSymbols
# --------------
#
# This is a helper script for FindABImap.cmake.
#
# Extract symbols from header files and output a list to a file.
# This script is run in build time to extract symbols from the provided header
# files. This way, symbols added or removed can be checked and used to update
# the symbol version script.
#
# All symbols followed by the character ``'('`` are extracted. If a
# ``FILTER_PATTERN`` is provided, only the lines containing the given string are
# considered.
#
# Expected defined variables
# --------------------------
#
# ``HEADERS_LIST_FILE``:
# Required, expects a file containing the list of header files to be parsed.
#
# ``OUTPUT_PATH``:
# Required, expects the output file path.
#
# Optionally defined variables
# ----------------------------
#
# ``FILTER_PATTERN``:
# Expects a string. Only lines containing the given string will be considered
# when extracting symbols.
#
if (NOT DEFINED OUTPUT_PATH)
message(SEND_ERROR "OUTPUT_PATH not defined")
endif()
if (NOT DEFINED HEADERS_LIST_FILE)
message(SEND_ERROR "HEADERS not defined")
endif()
file(READ ${HEADERS_LIST_FILE} HEADERS_LIST)
set(symbols)
foreach(header ${HEADERS_LIST})
# Filter only lines containing the FILTER_PATTERN
file(STRINGS ${header} contain_filter
REGEX "^.*${FILTER_PATTERN}.*[(]"
)
# Remove function-like macros
foreach(line ${contain_filter})
if (NOT ${line} MATCHES ".*#[ ]*define")
list(APPEND not_macro ${line})
endif()
endforeach()
set(functions)
# Get only the function names followed by '('
foreach(line ${not_macro})
string(REGEX MATCHALL "[a-zA-Z0-9_]+[ ]*[(]" func ${line})
list(APPEND functions ${func})
endforeach()
set(extracted_symbols)
# Remove '('
foreach(line ${functions})
string(REGEX REPLACE "[(]" "" symbol ${line})
string(STRIP "${symbol}" symbol)
list(APPEND extracted_symbols ${symbol})
endforeach()
list(APPEND symbols ${extracted_symbols})
endforeach()
list(REMOVE_DUPLICATES symbols)
list(SORT symbols)
string(REPLACE ";" "\n" symbols_list "${symbols}")
file(WRITE ${OUTPUT_PATH} "${symbols_list}")

View File

@@ -0,0 +1,492 @@
#
# Copyright (c) 2018 Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
#.rst:
# FindABIMap
# ----------
#
# This file provides functions to generate the symbol version script. It uses
# the ``abimap`` tool to generate and update the linker script file. It can be
# installed by calling::
#
# $ pip install abimap
#
# The ``function generate_map_file`` generates a symbol version script
# containing the provided symbols. It defines a custom command which sets
# ``target_name`` as its ``OUTPUT``.
#
# The experimental function ``extract_symbols()`` is provided as a simple
# parser to extract the symbols from C header files. It simply extracts symbols
# followed by an opening '``(``'. It is recommended to use a filter pattern to
# select the lines to be considered. It defines a custom command which sets
# ``target_name`` as its output.
#
# The helper function ``get_files_list()`` is provided to find files given a
# name pattern. It defines a custom command which sets ``target_name`` as its
# output.
#
# Functions provided
# ------------------
#
# ::
#
# generate_map_file(target_name
# RELEASE_NAME_VERSION release_name
# SYMBOLS symbols_target
# [CURRENT_MAP cur_map]
# [FINAL]
# [BREAK_ABI]
# [COPY_TO output]
# )
#
# ``target_name``:
# Required, expects the name of the file to receive the generated symbol
# version script. It should be added as a dependency for the library. Use the
# linker option ``--version-script filename`` to add the version information
# to the symbols when building the library.
#
# ``RELEASE_NAME_VERSION``:
# Required, expects a string containing the name and version information to be
# added to the symbols in the format ``lib_name_1_2_3``.
#
# ``SYMBOLS``:
# Required, expects a target with the property ``LIST_FILE`` containing a path
# to a file containing the list of symbols to be added to the symbol version
# script.
#
# ``CURRENT_MAP``:
# Optional. If given, the new set of symbols will be checked against the
# ones contained in the ``cur_map`` file and updated properly. If an
# incompatible change is detected and ``BREAK_ABI`` is not defined, the build
# will fail.
#
# ``FINAL``:
# Optional. If given, will provide the ``--final`` option to ``abimap`` tool,
# which will mark the modified release in the symbol version script with a
# special comment, preventing later changes. This option should be set when
# creating a library release and the resulting map file should be stored with
# the source code.
#
# ``BREAK_ABI``:
# Optional. If provided, will use ``abimap`` ``--allow-abi-break`` option, which
# accepts incompatible changes to the set of symbols. This is necessary if any
# previously existing symbol were removed.
#
# ``COPY_TO``:
# Optional, expects a string containing the path to where the generated
# map file will be copied.
#
# Example:
#
# .. code-block:: cmake
#
# find_package(ABIMap)
# generate_map_file("lib.map"
# RELEASE_NAME_VERSION "lib_1_0_0"
# SYMBOLS symbols
# )
#
# Where the target ``symbols`` has its property ``LIST_FILE`` set to the path to
# a file containing::
#
# ``symbol1``
# ``symbol2``
#
# This example would result in the symbol version script to be created in
# ``${CMAKE_CURRENT_BINARY_DIR}/lib.map`` containing the provided symbols.
#
# ::
#
# get_files_list(target_name
# DIRECTORIES dir1 [dir2 ...]
# FILES_PATTERNS exp1 [exp2 ...]
# [COPY_TO output]
# )
#
# ``target_name``:
# Required, expects the name of the target to be created. A file named as
# ``${target_name}.list`` will be created in
# ``${CMAKE_CURRENT_BINARY_DIR}`` to receive the list of files found.
#
# ``DIRECTORIES``:
# Required, expects a list of directories paths. Only absolute paths are
# supported.
#
# ``FILES_PATTERN``:
# Required, expects a list of matching expressions to find the files to be
# considered in the directories.
#
# ``COPY_TO``:
# Optional, expects a string containing the path to where the file containing
# the list of files will be copied.
#
# This command searches the directories provided in ``DIRECTORIES`` for files
# matching any of the patterns provided in ``FILES_PATTERNS``. The obtained list
# is written to the path specified by ``output``. A target named ``target_name``
# will be created and its property ``LIST_FILE`` will be set to contain
# ``${CMAKE_CURRENT_BINARY_DIR}/${target_name}.list``
#
# Example:
#
# .. code-block:: cmake
#
# find_package(ABIMap)
# get_files_list(target
# DIRECTORIES "/include/mylib"
# FILES_PATTERNS "*.h"
# COPY_TO "my_list.txt"
# )
#
# Consider that ``/include/mylib`` contains 3 files, ``h1.h``, ``h2.h``, and
# ``h3.hpp``
#
# Will result in a file ``my_list.txt`` containing::
#
# ``h1.h;h2.h``
#
# And the target ``target`` will have its property ``LIST_FILE`` set to contain
# ``${CMAKE_CURRENT_BINARY_DIR}/target.list``
#
# ::
#
# extract_symbols(target_name
# HEADERS_LIST headers_list_target
# [FILTER_PATTERN pattern]
# [COPY_TO output]
# )
#
# ``target_name``:
# Required, expects the name of the target to be created. A file named after
# the string given in ``target_name`` will be created in
# ``${CMAKE_CURRENT_BINARY_DIR}`` to receive the list of symbols.
#
# ``HEADERS_LIST``:
# Required, expects a target with the property ``LIST_FILE`` set, containing a
# file path. Such file must contain a list of files paths.
#
# ``FILTER_PATTERN``:
# Optional, expects a string. Only the lines containing the filter pattern
# will be considered.
#
# ``COPY_TO``:
# Optional, expects a string containing the path to where the file containing
# the found symbols will be copied.
#
# This command extracts the symbols from the files listed in
# ``headers_list`` and write them on the ``output`` file. If ``pattern``
# is provided, then only the lines containing the string given in ``pattern``
# will be considered. It is recommended to provide a ``FILTER_PATTERN`` to mark
# the lines containing exported function declaration, since this function is
# experimental and can return wrong symbols when parsing the header files. A
# target named ``target_name`` will be created with the property ``LIST_FILE``
# set to contain ``${CMAKE_CURRENT_BINARY_DIR}/${target_name}.list``.
#
# Example:
#
# .. code-block:: cmake
#
# find_package(ABIMap)
# extract_symbols("lib.symbols"
# HEADERS_LIST "headers_target"
# FILTER_PATTERN "API_FUNCTION"
# )
#
# Where ``LIST_FILE`` property in ``headers_target`` points to a file
# containing::
#
# header1.h;header2.h
#
# Where ``header1.h`` contains::
#
# API_FUNCTION int exported_func1(int a, int b);
#
# ``header2.h`` contains::
#
# API_FUNCTION int exported_func2(int a);
#
# int private_func2(int b);
#
# Will result in a file ``lib.symbols.list`` in ``${CMAKE_CURRENT_BINARY_DIR}``
# containing::
#
# ``exported_func1``
# ``exported_func2``
#
# Search for python which is required
if (ABIMap_FIND_REQURIED)
find_package(PythonInterp REQUIRED)
else()
find_package(PythonInterp)
endif()
if (PYTHONINTERP_FOUND)
# Search for abimap tool used to generate the map files
find_program(ABIMAP_EXECUTABLE NAMES abimap DOC "path to the abimap executable")
mark_as_advanced(ABIMAP_EXECUTABLE)
if (NOT ABIMAP_EXECUTABLE AND UNIX)
message(STATUS "Could not find `abimap` in PATH."
" It can be found in PyPI as `abimap`"
" (try `pip install abimap`)")
endif ()
if (ABIMAP_EXECUTABLE)
# Get the abimap version
execute_process(COMMAND ${ABIMAP_EXECUTABLE} version
OUTPUT_VARIABLE ABIMAP_VERSION_STRING
OUTPUT_STRIP_TRAILING_WHITESPACE)
# If the version string starts with abimap-, strip it
if ("abimap" STRLESS_EQUAL ${ABIMAP_VERSION_STRING})
string(REGEX REPLACE "abimap-" "" ABIMAP_VERSION_STRING "${ABIMAP_VERSION_STRING}")
endif()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ABIMap
REQUIRED_VARS ABIMAP_EXECUTABLE
VERSION_VAR ABIMAP_VERSION_STRING)
endif()
if (ABIMAP_FOUND)
# Define helper scripts
set(_EXTRACT_SYMBOLS_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/ExtractSymbols.cmake)
set(_GENERATE_MAP_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/GenerateMap.cmake)
set(_GET_FILES_LIST_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/GetFilesList.cmake)
function(get_file_list _TARGET_NAME)
set(one_value_arguments
COPY_TO
)
set(multi_value_arguments
DIRECTORIES
FILES_PATTERNS
)
cmake_parse_arguments(_get_files_list
""
"${one_value_arguments}"
"${multi_value_arguments}"
${ARGN}
)
# The DIRS argument is required
if (NOT DEFINED _get_files_list_DIRECTORIES)
message(FATAL_ERROR "No directories paths provided. Provide a list of"
" directories paths containing header files.")
endif()
# The FILES_PATTERNS argument is required
if (NOT DEFINED _get_files_list_FILES_PATTERNS)
message(FATAL_ERROR "No matching expressions provided. Provide a list"
" of matching patterns for the header files.")
endif()
set(_FILES_LIST_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${_TARGET_NAME}.list)
get_filename_component(_get_files_list_OUTPUT_PATH
"${_FILES_LIST_OUTPUT_PATH}"
ABSOLUTE)
add_custom_target(
${_TARGET_NAME}_int ALL
COMMAND ${CMAKE_COMMAND}
-DOUTPUT_PATH=${_get_files_list_OUTPUT_PATH}
-DDIRECTORIES=${_get_files_list_DIRECTORIES}
-DFILES_PATTERNS=${_get_files_list_FILES_PATTERNS}
-P ${_GET_FILES_LIST_SCRIPT}
COMMENT
"Searching for files"
VERBATIM
)
if (DEFINED _get_files_list_COPY_TO)
# Copy the generated file back to the COPY_TO
add_custom_target(${_TARGET_NAME} ALL
COMMAND
${CMAKE_COMMAND} -E copy_if_different
${_FILES_LIST_OUTPUT_PATH} ${_get_files_list_COPY_TO}
DEPENDS ${_TARGET_NAME}_int
COMMENT "Copying ${_TARGET_NAME} to ${_get_files_list_COPY_TO}"
VERBATIM
)
else()
add_custom_target(${_TARGET_NAME} ALL
DEPENDS ${_TARGET_NAME}_int
)
endif()
set_target_properties(${_TARGET_NAME}
PROPERTIES LIST_FILE ${_FILES_LIST_OUTPUT_PATH}
)
endfunction()
function(extract_symbols _TARGET_NAME)
set(one_value_arguments
FILTER_PATTERN
HEADERS_LIST
COPY_TO
)
set(multi_value_arguments
)
cmake_parse_arguments(_extract_symbols
""
"${one_value_arguments}"
"${multi_value_arguments}"
${ARGN}
)
# The HEADERS_LIST_FILE argument is required
if (NOT DEFINED _extract_symbols_HEADERS_LIST)
message(FATAL_ERROR "No target provided in HEADERS_LIST. Provide a"
" target with the property LIST_FILE set as the"
" path to the file containing the list of headers.")
endif()
get_filename_component(_SYMBOLS_OUTPUT_PATH
"${CMAKE_CURRENT_BINARY_DIR}/${_TARGET_NAME}.list"
ABSOLUTE
)
get_target_property(_HEADERS_LIST_FILE
${_extract_symbols_HEADERS_LIST}
LIST_FILE
)
add_custom_target(
${_TARGET_NAME}_int ALL
COMMAND ${CMAKE_COMMAND}
-DOUTPUT_PATH=${_SYMBOLS_OUTPUT_PATH}
-DHEADERS_LIST_FILE=${_HEADERS_LIST_FILE}
-DFILTER_PATTERN=${_extract_symbols_FILTER_PATTERN}
-P ${_EXTRACT_SYMBOLS_SCRIPT}
DEPENDS ${_extract_symbols_HEADERS_LIST}
COMMENT "Extracting symbols from headers"
VERBATIM
)
if (DEFINED _extract_symbols_COPY_TO)
# Copy the generated file back to the COPY_TO
add_custom_target(${_TARGET_NAME} ALL
COMMAND
${CMAKE_COMMAND} -E copy_if_different
${_SYMBOLS_OUTPUT_PATH} ${_extract_symbols_COPY_TO}
DEPENDS ${_TARGET_NAME}_int
COMMENT "Copying ${_TARGET_NAME} to ${_extract_symbols_COPY_TO}"
VERBATIM
)
else()
add_custom_target(${_TARGET_NAME} ALL
DEPENDS ${_TARGET_NAME}_int
)
endif()
set_target_properties(${_TARGET_NAME}
PROPERTIES LIST_FILE ${_SYMBOLS_OUTPUT_PATH}
)
endfunction()
function(generate_map_file _TARGET_NAME)
set(options
FINAL
BREAK_ABI
)
set(one_value_arguments
RELEASE_NAME_VERSION
SYMBOLS
CURRENT_MAP
COPY_TO
)
set(multi_value_arguments
)
cmake_parse_arguments(_generate_map_file
"${options}"
"${one_value_arguments}"
"${multi_value_arguments}"
${ARGN}
)
if (NOT DEFINED _generate_map_file_SYMBOLS)
message(FATAL_ERROR "No target provided in SYMBOLS. Provide a target"
" with the property LIST_FILE set as the path to"
" the file containing the list of symbols.")
endif()
if (NOT DEFINED _generate_map_file_RELEASE_NAME_VERSION)
message(FATAL_ERROR "Release name and version not provided."
" (e.g. libname_1_0_0)")
endif()
get_target_property(_SYMBOLS_FILE
${_generate_map_file_SYMBOLS}
LIST_FILE
)
# Set generated map file path
get_filename_component(_MAP_OUTPUT_PATH
"${CMAKE_CURRENT_BINARY_DIR}/${_TARGET_NAME}"
ABSOLUTE
)
add_custom_target(
${_TARGET_NAME}_int ALL
COMMAND ${CMAKE_COMMAND}
-DABIMAP_EXECUTABLE=${ABIMAP_EXECUTABLE}
-DSYMBOLS=${_SYMBOLS_FILE}
-DCURRENT_MAP=${_generate_map_file_CURRENT_MAP}
-DOUTPUT_PATH=${_MAP_OUTPUT_PATH}
-DFINAL=${_generate_map_file_FINAL}
-DBREAK_ABI=${_generate_map_file_BREAK_ABI}
-DRELEASE_NAME_VERSION=${_generate_map_file_RELEASE_NAME_VERSION}
-P ${_GENERATE_MAP_SCRIPT}
DEPENDS ${_generate_map_file_SYMBOLS}
COMMENT "Generating the map ${_TARGET_NAME}"
VERBATIM
)
# Add a custom command setting the map as OUTPUT to allow it to be added as
# a generated source
add_custom_command(
OUTPUT ${_MAP_OUTPUT_PATH}
DEPENDS ${_TARGET_NAME}_copy
)
if (DEFINED _generate_map_file_COPY_TO)
# Copy the generated map back to the COPY_TO
add_custom_target(${_TARGET_NAME}_copy ALL
COMMAND
${CMAKE_COMMAND} -E copy_if_different ${_MAP_OUTPUT_PATH}
${_generate_map_file_COPY_TO}
DEPENDS ${_TARGET_NAME}_int
COMMENT "Copying ${_MAP_OUTPUT_PATH} to ${_generate_map_file_COPY_TO}"
VERBATIM
)
else()
add_custom_target(${_TARGET_NAME}_copy ALL
DEPENDS ${_TARGET_NAME}_int
)
endif()
endfunction()
endif (ABIMAP_FOUND)

View File

@@ -1,60 +1,66 @@
# - Try to find Argp
# - Try to find ARGP
# Once done this will define
#
# ARGP_FOUND - system has Argp
# ARGP_INCLUDE_DIRS - the Argp include directory
# ARGP_LIBRARIES - Link these to use Argp
# ARGP_DEFINITIONS - Compiler switches required for using Argp
# ARGP_ROOT_DIR - Set this variable to the root installation of ARGP
#
# Copyright (c) 2010 Andreas Schneider <asn@cynapses.org>
# Read-Only variables:
# ARGP_FOUND - system has ARGP
# ARGP_INCLUDE_DIR - the ARGP include directory
# ARGP_LIBRARIES - Link these to use ARGP
# ARGP_DEFINITIONS - Compiler switches required for using ARGP
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#=============================================================================
# Copyright (c) 2011-2016 Andreas Schneider <asn@cryptomilk.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
#
set(_ARGP_ROOT_HINTS
)
if (ARGP_LIBRARIES AND ARGP_INCLUDE_DIRS)
# in cache already
set(ARGP_FOUND TRUE)
else (ARGP_LIBRARIES AND ARGP_INCLUDE_DIRS)
set(_ARGP_ROOT_PATHS
"$ENV{PROGRAMFILES}/argp"
)
find_path(ARGP_INCLUDE_DIR
find_path(ARGP_ROOT_DIR
NAMES
argp.h
include/argp.h
HINTS
${_ARGP_ROOT_HINTS}
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
)
${_ARGP_ROOT_PATHS}
)
mark_as_advanced(ARGP_ROOT_DIR)
find_library(ARGP_LIBRARY
find_path(ARGP_INCLUDE_DIR
NAMES
argp
argp.h
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
${ARGP_ROOT_DIR}/include
)
find_library(ARGP_LIBRARY
NAMES
argp
PATHS
${ARGP_ROOT_DIR}/lib
)
if (ARGP_LIBRARY)
set(ARGP_LIBRARIES
${ARGP_LIBRARIES}
${ARGP_LIBRARY}
)
endif (ARGP_LIBRARY)
set(ARGP_INCLUDE_DIRS
${ARGP_INCLUDE_DIR}
)
if (ARGP_LIBRARY)
set(ARGP_LIBRARIES
${ARGP_LIBRARIES}
${ARGP_LIBRARY}
)
endif (ARGP_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Argp DEFAULT_MSG ARGP_LIBRARIES ARGP_INCLUDE_DIRS)
# show the ARGP_INCLUDE_DIRS and ARGP_LIBRARIES variables only in the advanced view
mark_as_advanced(ARGP_INCLUDE_DIRS ARGP_LIBRARIES)
endif (ARGP_LIBRARIES AND ARGP_INCLUDE_DIRS)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ARGP DEFAULT_MSG ARGP_LIBRARIES ARGP_INCLUDE_DIR)
# show the ARGP_INCLUDE_DIR and ARGP_LIBRARIES variables only in the advanced view
mark_as_advanced(ARGP_INCLUDE_DIR ARGP_LIBRARIES)

View File

@@ -0,0 +1,66 @@
# - Try to find CMocka
# Once done this will define
#
# CMOCKA_ROOT_DIR - Set this variable to the root installation of CMocka
#
# Read-Only variables:
# CMOCKA_FOUND - system has CMocka
# CMOCKA_INCLUDE_DIR - the CMocka include directory
# CMOCKA_LIBRARIES - Link these to use CMocka
# CMOCKA_DEFINITIONS - Compiler switches required for using CMocka
#
#=============================================================================
# Copyright (c) 2011-2012 Andreas Schneider <asn@cryptomilk.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
#
set(_CMOCKA_ROOT_HINTS
)
set(_CMOCKA_ROOT_PATHS
"$ENV{PROGRAMFILES}/cmocka"
)
find_path(CMOCKA_ROOT_DIR
NAMES
include/cmocka.h
HINTS
${_CMOCKA_ROOT_HINTS}
PATHS
${_CMOCKA_ROOT_PATHS}
)
mark_as_advanced(CMOCKA_ROOT_DIR)
find_path(CMOCKA_INCLUDE_DIR
NAMES
cmocka.h
PATHS
${CMOCKA_ROOT_DIR}/include
)
find_library(CMOCKA_LIBRARY
NAMES
cmocka
PATHS
${CMOCKA_ROOT_DIR}/lib
)
if (CMOCKA_LIBRARY)
set(CMOCKA_LIBRARIES
${CMOCKA_LIBRARIES}
${CMOCKA_LIBRARY}
)
endif (CMOCKA_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CMocka DEFAULT_MSG CMOCKA_LIBRARIES CMOCKA_INCLUDE_DIR)
# show the CMOCKA_INCLUDE_DIR and CMOCKA_LIBRARIES variables only in the advanced view
mark_as_advanced(CMOCKA_INCLUDE_DIR CMOCKA_LIBRARIES)

View File

@@ -1,63 +0,0 @@
# - Try to find CMockery
# Once done this will define
#
# CMOCKERY_FOUND - system has CMockery
# CMOCKERY_INCLUDE_DIRS - the CMockery include directory
# CMOCKERY_LIBRARIES - Link these to use CMockery
# CMOCKERY_DEFINITIONS - Compiler switches required for using CMockery
#
# Copyright (c) 2010 Andreas Schneider <asn@cryptomilk.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (CMOCKERY_LIBRARIES AND CMOCKERY_INCLUDE_DIRS)
# in cache already
set(CMOCKERY_FOUND TRUE)
else (CMOCKERY_LIBRARIES AND CMOCKERY_INCLUDE_DIRS)
find_path(CMOCKERY_INCLUDE_DIR
NAMES
google/cmockery.h
PATHS
${_CMOCKERY_DIR}/include
/usr/include
/usr/local/include
/opt/local/include
/sw/include
$ENV{PROGRAMFILES}/cmockery/include
)
find_library(CMOCKERY_LIBRARY
NAMES
cmockery
PATHS
${_CMOCKERY_DIR}/lib
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
$ENV{PROGRAMFILES}/cmockery/lib
)
set(CMOCKERY_INCLUDE_DIRS
${CMOCKERY_INCLUDE_DIR}
)
if (CMOCKERY_LIBRARY)
set(CMOCKERY_LIBRARIES
${CMOCKERY_LIBRARIES}
${CMOCKERY_LIBRARY}
)
endif (CMOCKERY_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(CMockery DEFAULT_MSG CMOCKERY_LIBRARIES CMOCKERY_INCLUDE_DIRS)
# show the CMOCKERY_INCLUDE_DIRS and CMOCKERY_LIBRARIES variables only in the advanced view
mark_as_advanced(CMOCKERY_INCLUDE_DIRS CMOCKERY_LIBRARIES)
endif (CMOCKERY_LIBRARIES AND CMOCKERY_INCLUDE_DIRS)

View File

@@ -7,7 +7,7 @@
# GCRYPT_DEFINITIONS - Compiler switches required for using GCrypt
#
#=============================================================================
# Copyright (c) 2009-2011 Andreas Schneider <asn@cryptomilk.org>
# Copyright (c) 2009-2012 Andreas Schneider <asn@cryptomilk.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
@@ -18,53 +18,70 @@
#=============================================================================
#
if (GCRYPT_LIBRARIES AND GCRYPT_INCLUDE_DIRS)
# in cache already
# set(GCRYPT_FOUND TRUE)
else (GCRYPT_LIBRARIES AND GCRYPT_INCLUDE_DIRS)
set(_GCRYPT_ROOT_HINTS
$ENV{GCRYTPT_ROOT_DIR}
${GCRYPT_ROOT_DIR})
set(_GCRYPT_ROOT_PATHS
"$ENV{PROGRAMFILES}/libgcrypt"
set(_GCRYPT_ROOT_PATHS
"$ENV{PROGRAMFILES}/libgcrypt")
set(_GCRYPT_ROOT_HINTS_AND_PATHS
HINTS ${_GCRYPT_ROOT_HINTS}
PATHS ${_GCRYPT_ROOT_PATHS})
find_path(GCRYPT_INCLUDE_DIR
NAMES
gcrypt.h
HINTS
${_GCRYPT_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
include
)
find_library(GCRYPT_LIBRARY
NAMES
gcrypt
gcrypt11
libgcrypt-11
HINTS
${_GCRYPT_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
lib
)
find_library(GCRYPT_ERROR_LIBRARY
NAMES
gpg-error
libgpg-error-0
libgpg-error6-0
HINTS
${_GCRYPT_ROOT_HINTS_AND_PATHS}
)
set(GCRYPT_LIBRARIES ${GCRYPT_LIBRARY} ${GCRYPT_ERROR_LIBRARY})
if (GCRYPT_INCLUDE_DIR)
file(STRINGS "${GCRYPT_INCLUDE_DIR}/gcrypt.h" _gcrypt_version_str REGEX "^#define GCRYPT_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]")
string(REGEX REPLACE "^.*GCRYPT_VERSION.*([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" GCRYPT_VERSION "${_gcrypt_version_str}")
endif (GCRYPT_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
if (GCRYPT_VERSION)
find_package_handle_standard_args(GCrypt
REQUIRED_VARS
GCRYPT_INCLUDE_DIR
GCRYPT_LIBRARIES
VERSION_VAR
GCRYPT_VERSION
FAIL_MESSAGE
"Could NOT find GCrypt, try to set the path to GCrypt root folder in the system variable GCRYPT_ROOT_DIR"
)
else (GCRYPT_VERSION)
find_package_handle_standard_args(GCrypt
"Could NOT find GCrypt, try to set the path to GCrypt root folder in the system variable GCRYPT_ROOT_DIR"
GCRYPT_INCLUDE_DIR
GCRYPT_LIBRARIES)
endif (GCRYPT_VERSION)
find_path(GCRYPT_ROOT_DIR
NAMES
include/gcrypt.h
PATHS
${_GCRYPT_ROOT_PATHS}
)
mark_as_advanced(ZLIB_ROOT_DIR)
find_path(GCRYPT_INCLUDE_DIR
NAMES
gcrypt.h
PATHS
/usr/local/include
/opt/local/include
/sw/include
/usr/lib/sfw/include
${GCRYPT_ROOT_DIR}/include
)
set(GCRYPT_INCLUDE_DIRS ${GCRYPT_INCLUDE_DIR})
find_library(GCRYPT_LIBRARY
NAMES
gcrypt
gcrypt11
libgcrypt-11
PATHS
/opt/local/lib
/sw/lib
/usr/sfw/lib/64
/usr/sfw/lib
${GCRYPT_ROOT_DIR}/lib
)
set(GCRYPT_LIBRARIES ${GCRYPT_LIBRARY})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GCrypt DEFAULT_MSG GCRYPT_LIBRARIES GCRYPT_INCLUDE_DIRS)
# show the GCRYPT_INCLUDE_DIRS and GCRYPT_LIBRARIES variables only in the advanced view
mark_as_advanced(GCRYPT_INCLUDE_DIRS GCRYPT_LIBRARIES)
endif (GCRYPT_LIBRARIES AND GCRYPT_INCLUDE_DIRS)
# show the GCRYPT_INCLUDE_DIRS and GCRYPT_LIBRARIES variables only in the advanced view
mark_as_advanced(GCRYPT_INCLUDE_DIR GCRYPT_LIBRARIES)

View File

@@ -0,0 +1,325 @@
# - Try to find GSSAPI
# Once done this will define
#
# KRB5_CONFIG - Path to krb5-config
# GSSAPI_ROOT_DIR - Set this variable to the root installation of GSSAPI
#
# Read-Only variables:
# GSSAPI_FLAVOR_MIT - set to TURE if MIT Kerberos has been found
# GSSAPI_FLAVOR_HEIMDAL - set to TRUE if Heimdal Keberos has been found
# GSSAPI_FOUND - system has GSSAPI
# GSSAPI_INCLUDE_DIR - the GSSAPI include directory
# GSSAPI_LIBRARIES - Link these to use GSSAPI
# GSSAPI_DEFINITIONS - Compiler switches required for using GSSAPI
#
#=============================================================================
# Copyright (c) 2013 Andreas Schneider <asn@cryptomilk.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
#
find_path(GSSAPI_ROOT_DIR
NAMES
include/gssapi.h
include/gssapi/gssapi.h
HINTS
${_GSSAPI_ROOT_HINTS}
PATHS
${_GSSAPI_ROOT_PATHS}
)
mark_as_advanced(GSSAPI_ROOT_DIR)
if (UNIX)
find_program(KRB5_CONFIG
NAMES
krb5-config
PATHS
${GSSAPI_ROOT_DIR}/bin
/opt/local/bin)
mark_as_advanced(KRB5_CONFIG)
if (KRB5_CONFIG)
# Check if we have MIT KRB5
execute_process(
COMMAND
${KRB5_CONFIG} --vendor
RESULT_VARIABLE
_GSSAPI_VENDOR_RESULT
OUTPUT_VARIABLE
_GSSAPI_VENDOR_STRING)
if ((_GSSAPI_VENDOR_STRING MATCHES ".*Massachusetts.*") OR (_GSSAPI_VENDOR_STRING
MATCHES ".*MITKerberosShim.*"))
set(GSSAPI_FLAVOR_MIT TRUE)
else()
execute_process(
COMMAND
${KRB5_CONFIG} --libs gssapi
RESULT_VARIABLE
_GSSAPI_LIBS_RESULT
OUTPUT_VARIABLE
_GSSAPI_LIBS_STRING)
if (_GSSAPI_LIBS_STRING MATCHES ".*roken.*")
set(GSSAPI_FLAVOR_HEIMDAL TRUE)
endif()
endif()
# Get the include dir
execute_process(
COMMAND
${KRB5_CONFIG} --cflags gssapi
RESULT_VARIABLE
_GSSAPI_INCLUDE_RESULT
OUTPUT_VARIABLE
_GSSAPI_INCLUDE_STRING)
string(REGEX REPLACE "(\r?\n)+$" "" _GSSAPI_INCLUDE_STRING "${_GSSAPI_INCLUDE_STRING}")
string(REGEX REPLACE " *-I" "" _GSSAPI_INCLUDEDIR "${_GSSAPI_INCLUDE_STRING}")
endif()
if (NOT GSSAPI_FLAVOR_MIT AND NOT GSSAPI_FLAVOR_HEIMDAL)
# Check for HEIMDAL
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_GSSAPI heimdal-gssapi)
endif (PKG_CONFIG_FOUND)
if (_GSSAPI_FOUND)
set(GSSAPI_FLAVOR_HEIMDAL TRUE)
else()
find_path(_GSSAPI_ROKEN
NAMES
roken.h
PATHS
${GSSAPI_ROOT_DIR}/include
${_GSSAPI_INCLUDEDIR})
if (_GSSAPI_ROKEN)
set(GSSAPI_FLAVOR_HEIMDAL TRUE)
endif()
endif ()
endif()
endif (UNIX)
find_path(GSSAPI_INCLUDE_DIR
NAMES
gssapi.h
gssapi/gssapi.h
PATHS
${GSSAPI_ROOT_DIR}/include
${_GSSAPI_INCLUDEDIR}
)
if (GSSAPI_FLAVOR_MIT)
find_library(GSSAPI_LIBRARY
NAMES
gssapi_krb5
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(KRB5_LIBRARY
NAMES
krb5
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(K5CRYPTO_LIBRARY
NAMES
k5crypto
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(COM_ERR_LIBRARY
NAMES
com_err
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
if (GSSAPI_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${GSSAPI_LIBRARY}
)
endif (GSSAPI_LIBRARY)
if (KRB5_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${KRB5_LIBRARY}
)
endif (KRB5_LIBRARY)
if (K5CRYPTO_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${K5CRYPTO_LIBRARY}
)
endif (K5CRYPTO_LIBRARY)
if (COM_ERR_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${COM_ERR_LIBRARY}
)
endif (COM_ERR_LIBRARY)
endif (GSSAPI_FLAVOR_MIT)
if (GSSAPI_FLAVOR_HEIMDAL)
find_library(GSSAPI_LIBRARY
NAMES
gssapi
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(KRB5_LIBRARY
NAMES
krb5
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(HCRYPTO_LIBRARY
NAMES
hcrypto
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(COM_ERR_LIBRARY
NAMES
com_err
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(HEIMNTLM_LIBRARY
NAMES
heimntlm
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(HX509_LIBRARY
NAMES
hx509
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(ASN1_LIBRARY
NAMES
asn1
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(WIND_LIBRARY
NAMES
wind
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
find_library(ROKEN_LIBRARY
NAMES
roken
PATHS
${GSSAPI_ROOT_DIR}/lib
${_GSSAPI_LIBDIR}
)
if (GSSAPI_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${GSSAPI_LIBRARY}
)
endif (GSSAPI_LIBRARY)
if (KRB5_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${KRB5_LIBRARY}
)
endif (KRB5_LIBRARY)
if (HCRYPTO_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${HCRYPTO_LIBRARY}
)
endif (HCRYPTO_LIBRARY)
if (COM_ERR_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${COM_ERR_LIBRARY}
)
endif (COM_ERR_LIBRARY)
if (HEIMNTLM_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${HEIMNTLM_LIBRARY}
)
endif (HEIMNTLM_LIBRARY)
if (HX509_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${HX509_LIBRARY}
)
endif (HX509_LIBRARY)
if (ASN1_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${ASN1_LIBRARY}
)
endif (ASN1_LIBRARY)
if (WIND_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${WIND_LIBRARY}
)
endif (WIND_LIBRARY)
if (ROKEN_LIBRARY)
set(GSSAPI_LIBRARIES
${GSSAPI_LIBRARIES}
${WIND_LIBRARY}
)
endif (ROKEN_LIBRARY)
endif (GSSAPI_FLAVOR_HEIMDAL)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GSSAPI DEFAULT_MSG GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIR)
if (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
set(GSSAPI_FOUND TRUE)
endif (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
# show the GSSAPI_INCLUDE_DIRS and GSSAPI_LIBRARIES variables only in the advanced view
mark_as_advanced(GSSAPI_INCLUDE_DIRS GSSAPI_LIBRARIES)

View File

@@ -0,0 +1,104 @@
# - Try to find mbedTLS
# Once done this will define
#
# MBEDTLS_FOUND - system has mbedTLS
# MBEDTLS_INCLUDE_DIRS - the mbedTLS include directory
# MBEDTLS_LIBRARIES - Link these to use mbedTLS
# MBEDTLS_DEFINITIONS - Compiler switches required for using mbedTLS
#=============================================================================
# Copyright (c) 2017 Sartura d.o.o.
#
# Author: Juraj Vijtiuk <juraj.vijtiuk@sartura.hr>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
#
set(_MBEDTLS_ROOT_HINTS
$ENV{MBEDTLS_ROOT_DIR}
${MBEDTLS_ROOT_DIR})
set(_MBEDTLS_ROOT_PATHS
"$ENV{PROGRAMFILES}/libmbedtls")
set(_MBEDTLS_ROOT_HINTS_AND_PATHS
HINTS ${_MBEDTLS_ROOT_HINTS}
PATHS ${_MBEDTLS_ROOT_PATHS})
find_path(MBEDTLS_INCLUDE_DIR
NAMES
mbedtls/config.h
HINTS
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
include
)
find_library(MBEDTLS_SSL_LIBRARY
NAMES
mbedtls
HINTS
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
lib
)
find_library(MBEDTLS_CRYPTO_LIBRARY
NAMES
mbedcrypto
HINTS
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
lib
)
find_library(MBEDTLS_X509_LIBRARY
NAMES
mbedx509
HINTS
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
PATH_SUFFIXES
lib
)
set(MBEDTLS_LIBRARIES ${MBEDTLS_SSL_LIBRARY} ${MBEDTLS_CRYPTO_LIBRARY}
${MBEDTLS_X509_LIBRARY})
if (MBEDTLS_INCLUDE_DIR AND EXISTS "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h")
file(STRINGS "${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h" _mbedtls_version_str REGEX
"^#[\t ]*define[\t ]+MBEDTLS_VERSION_STRING[\t ]+\"[0-9]+.[0-9]+.[0-9]+\"")
string(REGEX REPLACE "^.*MBEDTLS_VERSION_STRING.*([0-9]+.[0-9]+.[0-9]+).*"
"\\1" MBEDTLS_VERSION "${_mbedtls_version_str}")
endif ()
include(FindPackageHandleStandardArgs)
if (MBEDTLS_VERSION)
find_package_handle_standard_args(MbedTLS
REQUIRED_VARS
MBEDTLS_INCLUDE_DIR
MBEDTLS_LIBRARIES
VERSION_VAR
MBEDTLS_VERSION
FAIL_MESSAGE
"Could NOT find mbedTLS, try to set the path to mbedTLS root folder
in the system variable MBEDTLS_ROOT_DIR"
)
else (MBEDTLS_VERSION)
find_package_handle_standard_args(MBedTLS
"Could NOT find mbedTLS, try to set the path to mbedLS root folder in
the system variable MBEDTLS_ROOT_DIR"
MBEDTLS_INCLUDE_DIR
MBEDTLS_LIBRARIES)
endif (MBEDTLS_VERSION)
# show the MBEDTLS_INCLUDE_DIRS and MBEDTLS_LIBRARIES variables only in the advanced view
mark_as_advanced(MBEDTLS_INCLUDE_DIR MBEDTLS_LIBRARIES)

View File

@@ -1,14 +1,15 @@
# - Try to find NSIS
# Once done this will define
#
# NSIS_ROOT_DIR - Set this variable to the root installation of ZLIB
# NSIS_ROOT_PATH - Set this variable to the root installation of NSIS
#
# Read-Only variables:
#
# NSIS_FOUND - system has NSIS
# NSIS_MAKE - NSIS creator executable
#
#=============================================================================
# Copyright (c) 2010-2011 Andreas Schneider <asn@cryptomilk.org>
# Copyright (c) 2010-2013 Andreas Schneider <asn@cryptomilk.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
@@ -19,21 +20,35 @@
#=============================================================================
#
set(_NSIS_ROOT_PATHS
C:/NSIS/Bin
"$ENV{PROGRAMFILES}/NSIS"
)
if (WIN32)
set(_x86 "(x86)")
set(_NSIS_ROOT_PATHS
"$ENV{ProgramFiles}/NSIS"
"$ENV{ProgramFiles${_x86}}/NSIS"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\NSIS;Default]")
find_path(NSIS_ROOT_PATH
NAMES
Include/Library.nsh
PATHS
${_NSIS_ROOT_PATHS}
)
mark_as_advanced(NSIS_ROOT_PATH)
endif (WIN32)
find_program(NSIS_MAKE
NAMES
makensis
PATHS
${NSIS_ROOT_PATH}
${NSIS_ROOT_PATH}/Bin
${_NSIS_ROOT_PATHS}
)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NSIS DEFAULT_MSG NSIS_MAKE)
if (NSIS_MAKE)
set(NSIS_FOUND TRUE)
endif (NSIS_MAKE)
mark_as_advanced(NSIS_MAKE)

View File

@@ -0,0 +1,61 @@
# - Try to find NaCl
# Once done this will define
#
# NACL_FOUND - system has NaCl
# NACL_INCLUDE_DIRS - the NaCl include directory
# NACL_LIBRARIES - Link these to use NaCl
# NACL_DEFINITIONS - Compiler switches required for using NaCl
#
# Copyright (c) 2010 Andreas Schneider <asn@cryptomilk.org>
# Copyright (c) 2013 Aris Adamantiadis <aris@badcode.be>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
if (NACL_LIBRARIES AND NACL_INCLUDE_DIRS)
# in cache already
set(NACL_FOUND TRUE)
else (NACL_LIBRARIES AND NACL_INCLUDE_DIRS)
find_path(NACL_INCLUDE_DIR
NAMES
nacl/crypto_box_curve25519xsalsa20poly1305.h
PATHS
/usr/include
/usr/local/include
/opt/local/include
/sw/include
)
find_library(NACL_LIBRARY
NAMES
nacl
PATHS
/usr/lib
/usr/local/lib
/opt/local/lib
/sw/lib
)
set(NACL_INCLUDE_DIRS
${NACL_INCLUDE_DIR}
)
if (NACL_LIBRARY)
set(NACL_LIBRARIES
${NACL_LIBRARIES}
${NACL_LIBRARY}
)
endif (NACL_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(NaCl DEFAULT_MSG NACL_LIBRARIES NACL_INCLUDE_DIRS)
# show the NACL_INCLUDE_DIRS and NACL_LIBRARIES variables only in the advanced view
mark_as_advanced(NACL_INCLUDE_DIRS NACL_LIBRARIES)
endif (NACL_LIBRARIES AND NACL_INCLUDE_DIRS)

View File

@@ -1,208 +0,0 @@
# - Try to find OpenSSL
# Once done this will define
#
# OPENSSL_ROOT_DIR - Set this variable to the root installation of OpenSSL
#
# Read-Only variables:
# OPENSSL_FOUND - system has OpenSSL
# OPENSSL_INCLUDE_DIRS - the OpenSSL include directory
# OPENSSL_LIBRARIES - Link these to use OpenSSL
# OPENSSL_DEFINITIONS - Compiler switches required for using OpenSSL
#
#=============================================================================
# Copyright (c) 2006-2009 Kitware, Inc.
# Copyright (c) 2006 Alexander Neundorf <neundorf@kde.org>
# Copyright (c) 2009-2010 Mathieu Malaterre <mathieu.malaterre@gmail.com>
# Copyright (c) 2011 Andreas Schneider <asn@cryptomilk.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
#
if (OPENSSL_LIBRARIES AND OPENSSL_INCLUDE_DIRS)
# in cache already
set(OPENSSL_FOUND TRUE)
else (OPENSSL_LIBRARIES AND OPENSSL_INCLUDE_DIRS)
if (UNIX)
find_package(PkgConfig)
if (PKG_CONFIG_FOUND)
pkg_check_modules(_OPENSSL openssl)
endif (PKG_CONFIG_FOUND)
endif (UNIX)
# http://www.slproweb.com/products/Win32OpenSSL.html
set(_OPENSSL_ROOT_HINTS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (32-bit)_is1;Inno Setup: App Path]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL (64-bit)_is1;Inno Setup: App Path]"
)
set(_OPENSSL_ROOT_PATHS
"C:/OpenSSL/"
"C:/OpenSSL-Win32/"
"C:/OpenSSL-Win64/"
"$ENV{PROGRAMFILES}/OpenSSL"
"$ENV{PROGRAMFILES}/OpenSSL-Win32"
"$ENV{PROGRAMFILES}/OpenSSL-Win64"
)
find_path(OPENSSL_ROOT_DIR
NAMES
include/openssl/ssl.h
HINTS
${_OPENSSL_ROOT_HINTS}
PATHS
${_OPENSSL_ROOT_PATHS}
)
mark_as_advanced(OPENSSL_ROOT_DIR)
find_path(OPENSSL_INCLUDE_DIR
NAMES
openssl/ssl.h
PATHS
/usr/local/include
/opt/local/include
/sw/include
/usr/lib/sfw/include
${OPENSSL_ROOT_DIR}/include
)
set(OPENSSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
mark_as_advanced(OPENSSL_INCLUDE_DIRS)
if (WIN32 AND NOT CYGWIN)
# MINGW should go here too
if (MSVC)
# /MD and /MDd are the standard values - if someone wants to use
# others, the libnames have to change here too
# use also ssl and ssleay32 in debug as fallback for openssl < 0.9.8b
# TODO: handle /MT and static lib
# In Visual C++ naming convention each of these four kinds of Windows libraries has it's standard suffix:
# * MD for dynamic-release
# * MDd for dynamic-debug
# * MT for static-release
# * MTd for static-debug
# Implementation details:
# We are using the libraries located in the VC subdir instead of the parent directory eventhough :
# libeay32MD.lib is identical to ../libeay32.lib, and
# ssleay32MD.lib is identical to ../ssleay32.lib
find_library(LIB_EAY_DEBUG
NAMES
libeay32MDd
libeay32
PATHS
${OPENSSL_ROOT_DIR}/lib/VC
)
find_library(LIB_EAY_RELEASE
NAMES
libeay32MD
libeay32
PATHS
${OPENSSL_ROOT_DIR}/lib/VC
)
find_library(SSL_EAY_DEBUG
NAMES
ssleay32MDd
ssleay32
ssl
PATHS ${OPENSSL_ROOT_DIR}/lib/VC
)
find_library(SSL_EAY_RELEASE
NAMES
ssleay32MD
ssleay32
ssl
PATHS
${OPENSSL_ROOT_DIR}/lib/VC
)
if (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
set(OPENSSL_LIBRARIES
optimized ${SSL_EAY_RELEASE} debug ${SSL_EAY_DEBUG}
optimized ${LIB_EAY_RELEASE} debug ${LIB_EAY_DEBUG}
)
else (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
set( OPENSSL_LIBRARIES ${SSL_EAY_RELEASE} ${LIB_EAY_RELEASE} )
endif (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
mark_as_advanced(SSL_EAY_DEBUG SSL_EAY_RELEASE)
mark_as_advanced(LIB_EAY_DEBUG LIB_EAY_RELEASE)
elseif (MINGW)
# same player, for MingW
find_library(LIB_EAY
NAMES
libeay32
PATHS
${OPENSSL_ROOT_DIR}/lib/MinGW
)
find_library(SSL_EAY
NAMES
ssleay32
PATHS
${OPENSSL_ROOT_DIR}/lib/MinGW
)
mark_as_advanced(SSL_EAY LIB_EAY)
set(OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY})
else(MSVC)
# Not sure what to pick for -say- intel, let's use the toplevel ones and hope someone report issues:
find_library(LIB_EAY
NAMES
libeay32
PATHS
${OPENSSL_ROOT_DIR}/lib
)
find_library(SSL_EAY
NAMES
ssleay32
PATHS
${OPENSSL_ROOT_DIR}/lib
)
mark_as_advanced(SSL_EAY LIB_EAY)
set(OPENSSL_LIBRARIES ${SSL_EAY} ${LIB_EAY})
endif(MSVC)
else (WIN32 AND NOT CYGWIN)
find_library(OPENSSL_SSL_LIBRARIES
NAMES
ssl
ssleay32
ssleay32MD
PATHS
${_OPENSSL_LIBDIR}
/opt/local/lib
/sw/lib
/usr/sfw/lib/64
/usr/sfw/lib
)
find_library(OPENSSL_CRYPTO_LIBRARIES
NAMES
crypto
PATHS
${_OPENSSL_LIBDIR}
/opt/local/lib
/sw/lib
/usr/sfw/lib/64
/usr/sfw/lib
)
mark_as_advanced(OPENSSL_CRYPTO_LIBRARIES OPENSSL_SSL_LIBRARIES)
set(OPENSSL_LIBRARIES ${OPENSSL_SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES})
endif (WIN32 AND NOT CYGWIN)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpenSSL DEFAULT_MSG OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIRS)
endif (OPENSSL_LIBRARIES AND OPENSSL_INCLUDE_DIRS)

View File

@@ -1,119 +0,0 @@
# - Try to find ZLIB
# Once done this will define
#
# ZLIB_ROOT_DIR - Set this variable to the root installation of ZLIB
#
# Read-Only variables:
# ZLIB_FOUND - system has ZLIB
# ZLIB_INCLUDE_DIRS - the ZLIB include directory
# ZLIB_LIBRARIES - Link these to use ZLIB
#
# ZLIB_VERSION_STRING - The version of zlib found (x.y.z)
# ZLIB_VERSION_MAJOR - The major version of zlib
# ZLIB_VERSION_MINOR - The minor version of zlib
# ZLIB_VERSION_PATCH - The patch version of zlib
# ZLIB_VERSION_TWEAK - The tweak version of zlib
#
# The following variable are provided for backward compatibility
#
# ZLIB_MAJOR_VERSION - The major version of zlib
# ZLIB_MINOR_VERSION - The minor version of zlib
# ZLIB_PATCH_VERSION - The patch version of zlib
#
#=============================================================================
# Copyright (c) 2001-2009 Kitware, Inc.
# Copyright (c) 2011 Andreas Schneider <asn@cryptomilk.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
#
if (ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS)
# in cache already
set(ZLIB_FOUND TRUE)
else (ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS)
set(_ZLIB_ROOT_HINTS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath]/include"
)
set(_ZLIB_ROOT_PATHS
"$ENV{PROGRAMFILES}/zlib"
)
find_path(ZLIB_ROOT_DIR
NAMES
include/zlib.h
HINTS
${_ZLIB_ROOT_HINTS}
PATHS
${_ZLIB_ROOT_PATHS}
)
mark_as_advanced(ZLIB_ROOT_DIR)
# check for header file
find_path(ZLIB_INCLUDE_DIR
NAMES
zlib.h
PATHS
/usr/local/include
/opt/local/include
/sw/include
/usr/lib/sfw/include
${ZLIB_ROOT_DIR}/include
)
mark_as_advanced(ZLIB_INCLUDE_DIR)
# check version number
if (ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")
file(STRINGS "${ZLIB_INCLUDE_DIR}/zlib.h" ZLIB_H REGEX "^#define ZLIB_VERSION \"[^\"]*\"$")
string(REGEX REPLACE "^.*ZLIB_VERSION \"([0-9]+).*$" "\\1" ZLIB_VERSION_MAJOR "${ZLIB_H}")
string(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_MINOR "${ZLIB_H}")
string(REGEX REPLACE "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" ZLIB_VERSION_PATCH "${ZLIB_H}")
set(ZLIB_VERSION_STRING "${ZLIB_VERSION_MAJOR}.${ZLIB_VERSION_MINOR}.${ZLIB_VERSION_PATCH}")
# only append a TWEAK version if it exists:
set(ZLIB_VERSION_TWEAK "")
if ("${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$")
set(ZLIB_VERSION_TWEAK "${CMAKE_MATCH_1}")
set(ZLIB_VERSION_STRING "${ZLIB_VERSION_STRING}.${ZLIB_VERSION_TWEAK}")
endif ("${ZLIB_H}" MATCHES "^.*ZLIB_VERSION \"[0-9]+\\.[0-9]+\\.[0-9]+\\.([0-9]+).*$")
set(ZLIB_MAJOR_VERSION "${ZLIB_VERSION_MAJOR}")
set(ZLIB_MINOR_VERSION "${ZLIB_VERSION_MINOR}")
set(ZLIB_PATCH_VERSION "${ZLIB_VERSION_PATCH}")
endif (ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")
find_library(ZLIB_LIBRARY
NAMES
z
zdll
zlib
zlib1
PATHS
/usr/local/lib
/opt/local/lib
/sw/lib
/usr/sfw/lib/64
/usr/sfw/lib
${ZLIB_ROOT_DIR}/lib
)
mark_as_advanced(ZLIB_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZLIB DEFAULT_MSG ZLIB_INCLUDE_DIR ZLIB_LIBRARY)
#find_package_handle_standard_args(ZLIB REQUIRED_VARS ZLIB_INCLUDE_DIR ZLIB_LIBRARY
# VERSION_VAR ZLIB_VERSION_STRING)
if (ZLIB_FOUND)
set(ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR})
set(ZLIB_LIBRARIES ${ZLIB_LIBRARY})
endif (ZLIB_FOUND)
endif (ZLIB_LIBRARIES AND ZLIB_INCLUDE_DIRS)

View File

@@ -0,0 +1,36 @@
# - Try to find softhsm
# Once done this will define
#
# SOFTHSM_FOUND - system has softhsm
# SOFTHSM_LIBRARIES - Link these to use softhsm
#
#=============================================================================
# Copyright (c) 2019 Sahana Prasad <sahana@redhat.com>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
#
find_library(SOFTHSM2_LIBRARY
NAMES
softhsm2
)
if (SOFTHSM2_LIBRARY)
set(SOFTHSM_LIBRARIES
${SOFTHSM_LIBRARIES}
${SOFTHSM2_LIBRARY}
)
endif (SOFTHSM2_LIBRARY)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(softhsm DEFAULT_MSG SOFTHSM_LIBRARIES)
# show the SOFTHSM_INCLUDE_DIR and SOFTHSM_LIBRARIES variables only in the advanced view
mark_as_advanced(SOFTHSM_LIBRARIES)

View File

@@ -0,0 +1,118 @@
#
# Copyright (c) 2018 Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
#.rst:
# GenerateMap
# -----------
#
# This is a helper script for FindABImap.cmake.
#
# Generates a symbols version script using the abimap tool.
# This script is run in build time to use the correct command depending on the
# existence of the file provided ``CURRENT_MAP``.
#
# If the file exists, the ``abimap update`` subcommand is used to update the
# existing map. Otherwise, the ``abimap new`` subcommand is used to create a new
# map file.
#
# If the file provided in ``CURRENT_MAP`` exists, it is copied to the
# ``OUTPUT_PATH`` before updating.
# This is required because ``abimap`` do not generate output if no symbols were
# changed when updating an existing file.
#
# Expected defined variables
# --------------------------
#
# ``SYMBOLS``:
# Required file containing the symbols to be used as input. Usually this is
# the ``OUTPUT`` generated by ``extract_symbols()`` function provided in
# FindABImap.cmake
#
# ``RELEASE_NAME_VERSION``:
# Required, expects the library name and version information to be added to
# the symbols in the format ``library_name_1_2_3``
#
# ``CURRENT_MAP``:
# Required, expects the path to the current map file (or the path were it
# should be)
#
# ``OUTPUT_PATH``:
# Required, expects the output file path.
#
# ``ABIMAP_EXECUTABLE``:
# Required, expects the path to the ``abimap`` tool.
#
# Optionally defined variables
# ----------------------------
#
# ``FINAL``:
# If defined, will mark the modified set of symbols in the symbol version
# script as final, preventing later changes using ``abimap``.
#
# ``BREAK_ABI``:
# If defined, the build will not fail if symbols were removed.
# If defined and a symbol is removed, a new release is created containing
# all symbols from all released versions. This makes an incompatible release.
#
if (NOT DEFINED RELEASE_NAME_VERSION)
message(SEND_ERROR "RELEASE_NAME_VERSION not defined")
endif()
if (NOT DEFINED SYMBOLS)
message(SEND_ERROR "SYMBOLS not defined")
endif()
if (NOT DEFINED CURRENT_MAP)
message(SEND_ERROR "CURRENT_MAP not defined")
endif()
if (NOT DEFINED OUTPUT_PATH)
message(SEND_ERROR "OUTPUT_PATH not defined")
endif()
if (NOT ABIMAP_EXECUTABLE)
message(SEND_ERROR "ABIMAP_EXECUTABLE not defined")
endif()
set(ARGS_LIST)
if (FINAL)
list(APPEND ARGS_LIST "--final")
endif()
if (EXISTS ${CURRENT_MAP})
if (BREAK_ABI)
list(APPEND ARGS_LIST "--allow-abi-break")
endif()
execute_process(
COMMAND
${CMAKE_COMMAND} -E copy_if_different ${CURRENT_MAP} ${OUTPUT_PATH}
COMMAND
${ABIMAP_EXECUTABLE} update ${ARGS_LIST}
-r ${RELEASE_NAME_VERSION}
-i ${SYMBOLS}
-o ${OUTPUT_PATH}
${CURRENT_MAP}
RESULT_VARIABLE result
)
else ()
execute_process(
COMMAND
${ABIMAP_EXECUTABLE} new ${ARGS_LIST}
-r ${RELEASE_NAME_VERSION}
-i ${SYMBOLS}
-o ${OUTPUT_PATH}
RESULT_VARIABLE result
)
endif()
if (NOT "${result}" STREQUAL "0")
message(SEND_ERROR "Map generation failed")
endif()

View File

@@ -0,0 +1,59 @@
#
# Copyright (c) 2018 Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
#.rst:
# GetFilesList
# ------------
#
# This is a helper script for FindABImap.cmake.
#
# Search in the provided directories for files matching the provided pattern.
# The list of files is then written to the output file.
#
# Expected defined variables
# --------------------------
#
# ``DIRECTORIES``:
# Required, expects a list of directories paths.
#
# ``FILES_PATTERNS``:
# Required, expects a list of patterns to be used to search files
#
# ``OUTPUT_PATH``:
# Required, expects the output file path.
if (NOT DEFINED DIRECTORIES)
message(SEND_ERROR "DIRECTORIES not defined")
endif()
if (NOT DEFINED FILES_PATTERNS)
message(SEND_ERROR "FILES_PATTERNS not defined")
endif()
if (NOT DEFINED OUTPUT_PATH)
message(SEND_ERROR "OUTPUT_PATH not defined")
endif()
string(REPLACE " " ";" DIRECTORIES_LIST "${DIRECTORIES}")
string(REPLACE " " ";" FILES_PATTERNS_LIST "${FILES_PATTERNS}")
# Create the list of expressions for the files
set(glob_expressions)
foreach(dir ${DIRECTORIES_LIST})
foreach(exp ${FILES_PATTERNS_LIST})
list(APPEND glob_expressions
"${dir}/${exp}"
)
endforeach()
endforeach()
# Create the list of files
file(GLOB files ${glob_expressions})
# Write to the output
file(WRITE ${OUTPUT_PATH} "${files}")

View File

@@ -1,21 +0,0 @@
# - MACRO_ADD_COMPILE_FLAGS(target_name flag1 ... flagN)
# Copyright (c) 2006, Oswald Buddenhagen, <ossi@kde.org>
# Copyright (c) 2006, Andreas Schneider, <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
macro (MACRO_ADD_COMPILE_FLAGS _target)
get_target_property(_flags ${_target} COMPILE_FLAGS)
if (_flags)
set(_flags ${_flags} ${ARGN})
else (_flags)
set(_flags ${ARGN})
endif (_flags)
set_target_properties(${_target} PROPERTIES COMPILE_FLAGS ${_flags})
endmacro (MACRO_ADD_COMPILE_FLAGS)

View File

@@ -1,20 +0,0 @@
# - MACRO_ADD_LINK_FLAGS(target_name flag1 ... flagN)
# Copyright (c) 2006, Oswald Buddenhagen, <ossi@kde.org>
# Copyright (c) 2006, Andreas Schneider, <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
macro (MACRO_ADD_LINK_FLAGS _target)
get_target_property(_flags ${_target} LINK_FLAGS)
if (_flags)
set(_flags "${_flags} ${ARGN}")
else (_flags)
set(_flags "${ARGN}")
endif (_flags)
set_target_properties(${_target} PROPERTIES LINK_FLAGS "${_flags}")
endmacro (MACRO_ADD_LINK_FLAGS)

View File

@@ -1,30 +0,0 @@
# - MACRO_ADD_PLUGIN(name [WITH_PREFIX] file1 .. fileN)
#
# Create a plugin from the given source files.
# If WITH_PREFIX is given, the resulting plugin will have the
# prefix "lib", otherwise it won't.
#
# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
# Copyright (c) 2006, Laurent Montel, <montel@kde.org>
# Copyright (c) 2006, Andreas Schneider, <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
macro (MACRO_ADD_PLUGIN _target_NAME _with_PREFIX)
if (${_with_PREFIX} STREQUAL "WITH_PREFIX")
set(_first_SRC)
else (${_with_PREFIX} STREQUAL "WITH_PREFIX")
set(_first_SRC ${_with_PREFIX})
endif (${_with_PREFIX} STREQUAL "WITH_PREFIX")
add_library(${_target_NAME} MODULE ${_first_SRC} ${ARGN})
if (_first_SRC)
set_target_properties(${_target_NAME} PROPERTIES PREFIX "")
endif (_first_SRC)
endmacro (MACRO_ADD_PLUGIN _name _sources)

View File

@@ -1,33 +0,0 @@
# - macro_copy_file(_src _dst)
# Copies a file to ${_dst} only if ${_src} is different (newer) than ${_dst}
#
# Example:
# macro_copy_file(${CMAKE_CURRENT_SOURCE_DIR}/icon.png ${CMAKE_CURRENT_BINARY_DIR}/.)
# Copies file icon.png to ${CMAKE_CURRENT_BINARY_DIR} directory
#
# Copyright (c) 2006-2007 Wengo
# Copyright (c) 2006-2008 Andreas Schneider <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING file.
macro (macro_copy_file _src _dst)
# Removes all path containing .svn or CVS or CMakeLists.txt during the copy
if (NOT ${_src} MATCHES ".*\\.svn|CVS|CMakeLists\\.txt.*")
if (CMAKE_VERBOSE_MAKEFILE)
message(STATUS "Copy file from ${_src} to ${_dst}")
endif (CMAKE_VERBOSE_MAKEFILE)
# Creates directory if necessary
get_filename_component(_path ${_dst} PATH)
file(MAKE_DIRECTORY ${_path})
execute_process(
COMMAND
${CMAKE_COMMAND} -E copy_if_different ${_src} ${_dst}
OUTPUT_QUIET
)
endif (NOT ${_src} MATCHES ".*\\.svn|CVS|CMakeLists\\.txt.*")
endmacro (macro_copy_file)

View File

@@ -1,100 +0,0 @@
# - Run Doxygen
#
# Adds a doxygen target that runs doxygen to generate the html
# and optionally the LaTeX API documentation.
# The doxygen target is added to the doc target as dependency.
# i.e.: the API documentation is built with:
# make doc
#
# USAGE: INCLUDE IN PROJECT
#
# set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
# include(UseDoxygen)
# Add the Doxyfile.in and UseDoxygen.cmake files to the projects source directory.
#
#
# Variables you may define are:
# DOXYFILE_OUTPUT_DIR - Path where the Doxygen output is stored. Defaults to "doc".
#
# DOXYFILE_LATEX_DIR - Directory where the Doxygen LaTeX output is stored. Defaults to "latex".
#
# DOXYFILE_HTML_DIR - Directory where the Doxygen html output is stored. Defaults to "html".
#
#
# Copyright (c) 2009-2010 Tobias Rautenkranz <tobias@rautenkranz.ch>
# Copyright (c) 2010 Andreas Schneider <mail@cynapses.org>
#
# Redistribution and use is allowed according to the terms of the New
# BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
macro(usedoxygen_set_default name value)
if(NOT DEFINED "${name}")
set("${name}" "${value}")
endif()
endmacro()
find_package(Doxygen)
if(DOXYGEN_FOUND)
find_file(DOXYFILE_IN
NAMES
doxy.config.in
PATHS
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_ROOT}/Modules/
NO_DEFAULT_PATH)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(DOXYFILE_IN DEFAULT_MSG "DOXYFILE_IN")
endif()
if(DOXYGEN_FOUND AND DOXYFILE_IN_FOUND)
add_custom_target(doxygen ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxy.config)
usedoxygen_set_default(DOXYFILE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}")
usedoxygen_set_default(DOXYFILE_HTML_DIR "html")
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES "${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_HTML_DIR}")
set(DOXYFILE_LATEX FALSE)
set(DOXYFILE_PDFLATEX FALSE)
set(DOXYFILE_DOT FALSE)
find_package(LATEX)
if(LATEX_COMPILER AND MAKEINDEX_COMPILER)
set(DOXYFILE_LATEX TRUE)
usedoxygen_set_default(DOXYFILE_LATEX_DIR "latex")
set_property(DIRECTORY APPEND PROPERTY
ADDITIONAL_MAKE_CLEAN_FILES
"${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_LATEX_DIR}")
if(PDFLATEX_COMPILER)
set(DOXYFILE_PDFLATEX TRUE)
endif()
if(DOXYGEN_DOT_EXECUTABLE)
set(DOXYFILE_DOT TRUE)
endif()
add_custom_command(TARGET doxygen
POST_BUILD
COMMAND ${CMAKE_MAKE_PROGRAM}
WORKING_DIRECTORY "${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_LATEX_DIR}")
endif()
configure_file(${DOXYFILE_IN} ${CMAKE_CURRENT_BINARY_DIR}/doxy.config ESCAPE_QUOTES IMMEDIATE @ONLY)
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/doxy.trac.in)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/doxy.trac.in ${CMAKE_CURRENT_BINARY_DIR}/doxy.trac ESCAPE_QUOTES IMMEDIATE @ONLY)
add_custom_target(doxygen-trac ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/doxy.trac)
endif()
get_target_property(DOC_TARGET doc TYPE)
if(NOT DOC_TARGET)
add_custom_target(doc)
endif()
add_dependencies(doc doxygen)
endif()

View File

@@ -0,0 +1,23 @@
set(CMAKE_C_FLAGS "-m32" CACHE STRING "C compiler flags" FORCE)
set(CMAKE_CXX_FLAGS "-m32" CACHE STRING "C++ compiler flags" FORCE)
set(LIB32 /usr/lib) # Fedora
if(EXISTS /usr/lib32)
set(LIB32 /usr/lib32) # Arch, Solus
endif()
set(CMAKE_SYSTEM_LIBRARY_PATH ${LIB32} CACHE STRING "system library search path" FORCE)
set(CMAKE_LIBRARY_PATH ${LIB32} CACHE STRING "library search path" FORCE)
# this is probably unlikely to be needed, but just in case
set(CMAKE_EXE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "executable linker flags" FORCE)
set(CMAKE_SHARED_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "shared library linker flags" FORCE)
set(CMAKE_MODULE_LINKER_FLAGS "-m32 -L${LIB32}" CACHE STRING "module linker flags" FORCE)
# on Fedora and Arch and similar, point pkgconfig at 32 bit .pc files. We have
# to include the regular system .pc files as well (at the end), because some
# are not always present in the 32 bit directory
if(EXISTS ${LIB32}/pkgconfig)
set(ENV{PKG_CONFIG_LIBDIR} ${LIB32}/pkgconfig:/usr/share/pkgconfig:/usr/lib/pkgconfig:/usr/lib64/pkgconfig)
endiF()

View File

@@ -1,28 +1,63 @@
/* Name of package */
#cmakedefine PACKAGE "${APPLICATION_NAME}"
#cmakedefine PACKAGE "${PROJECT_NAME}"
/* Version number of package */
#cmakedefine VERSION "${APPLICATION_VERSION}"
#cmakedefine VERSION "${PROJECT_VERSION}"
#cmakedefine LOCALEDIR "${LOCALE_INSTALL_DIR}"
#cmakedefine DATADIR "${DATADIR}"
#cmakedefine LIBDIR "${LIBDIR}"
#cmakedefine PLUGINDIR "${PLUGINDIR}"
#cmakedefine SYSCONFDIR "${SYSCONFDIR}"
#cmakedefine BINARYDIR "${BINARYDIR}"
#cmakedefine SOURCEDIR "${SOURCEDIR}"
/* Global bind configuration file path */
#cmakedefine GLOBAL_BIND_CONFIG "${GLOBAL_BIND_CONFIG}"
/* Global client configuration file path */
#cmakedefine GLOBAL_CLIENT_CONFIG "${GLOBAL_CLIENT_CONFIG}"
/************************** HEADER FILES *************************/
/* Define to 1 if you have the <argp.h> header file. */
#cmakedefine HAVE_ARGP_H 1
/* Define to 1 if you have the <aprpa/inet.h> header file. */
#cmakedefine HAVE_ARPA_INET_H 1
/* Define to 1 if you have the <glob.h> header file. */
#cmakedefine HAVE_GLOB_H 1
/* Define to 1 if you have the <valgrind/valgrind.h> header file. */
#cmakedefine HAVE_VALGRIND_VALGRIND_H 1
/* Define to 1 if you have the <pty.h> header file. */
#cmakedefine HAVE_PTY_H 1
/* Define to 1 if you have the <utmp.h> header file. */
#cmakedefine HAVE_UTMP_H 1
/* Define to 1 if you have the <util.h> header file. */
#cmakedefine HAVE_UTIL_H 1
/* Define to 1 if you have the <libutil.h> header file. */
#cmakedefine HAVE_LIBUTIL_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#cmakedefine HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/utime.h> header file. */
#cmakedefine HAVE_SYS_UTIME_H 1
/* Define to 1 if you have the <io.h> header file. */
#cmakedefine HAVE_IO_H 1
/* Define to 1 if you have the <termios.h> header file. */
#cmakedefine HAVE_TERMIOS_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#cmakedefine HAVE_UNISTD_H 1
/* Define to 1 if you have the <stdint.h> header file. */
#cmakedefine HAVE_STDINT_H 1
/* Define to 1 if you have the <openssl/aes.h> header file. */
#cmakedefine HAVE_OPENSSL_AES_H 1
@@ -35,12 +70,65 @@
/* Define to 1 if you have the <openssl/des.h> header file. */
#cmakedefine HAVE_OPENSSL_DES_H 1
/* Define to 1 if you have the <openssl/ecdh.h> header file. */
#cmakedefine HAVE_OPENSSL_ECDH_H 1
/* Define to 1 if you have the <openssl/ec.h> header file. */
#cmakedefine HAVE_OPENSSL_EC_H 1
/* Define to 1 if you have the <openssl/ecdsa.h> header file. */
#cmakedefine HAVE_OPENSSL_ECDSA_H 1
/* Define to 1 if you have the <pthread.h> header file. */
#cmakedefine HAVE_PTHREAD_H 1
/* Define to 1 if you have eliptic curve cryptography in openssl */
#cmakedefine HAVE_OPENSSL_ECC 1
/* Define to 1 if you have eliptic curve cryptography in gcrypt */
#cmakedefine HAVE_GCRYPT_ECC 1
/* Define to 1 if you have eliptic curve cryptography */
#cmakedefine HAVE_ECC 1
/* Define to 1 if you have DSA */
#cmakedefine HAVE_DSA 1
/* Define to 1 if you have gl_flags as a glob_t sturct member */
#cmakedefine HAVE_GLOB_GL_FLAGS_MEMBER 1
/* Define to 1 if you have OpenSSL with Ed25519 support */
#cmakedefine HAVE_OPENSSL_ED25519 1
/* Define to 1 if you have OpenSSL with X25519 support */
#cmakedefine HAVE_OPENSSL_X25519 1
/* Define to 1 if you have OpenSSL with Poly1305 support */
#cmakedefine HAVE_OPENSSL_EVP_POLY1305 1
/* Define to 1 if you have gcrypt with ChaCha20/Poly1305 support */
#cmakedefine HAVE_GCRYPT_CHACHA_POLY 1
/*************************** FUNCTIONS ***************************/
/* Define to 1 if you have the `EVP_chacha20' function. */
#cmakedefine HAVE_OPENSSL_EVP_CHACHA20 1
/* Define to 1 if you have the `EVP_KDF_CTX_new_id' or `EVP_KDF_CTX_new` function. */
#cmakedefine HAVE_OPENSSL_EVP_KDF_CTX 1
/* Define to 1 if you have the `FIPS_mode' function. */
#cmakedefine HAVE_OPENSSL_FIPS_MODE 1
/* Define to 1 if you have the `EVP_DigestSign' function. */
#cmakedefine HAVE_OPENSSL_EVP_DIGESTSIGN 1
/* Define to 1 if you have the `EVP_DigestVerify' function. */
#cmakedefine HAVE_OPENSSL_EVP_DIGESTVERIFY 1
/* Define to 1 if you have the `OPENSSL_ia32cap_loc' function. */
#cmakedefine HAVE_OPENSSL_IA32CAP_LOC 1
/* Define to 1 if you have the `snprintf' function. */
#cmakedefine HAVE_SNPRINTF 1
@@ -59,9 +147,15 @@
/* Define to 1 if you have the `_vsnprintf_s' function. */
#cmakedefine HAVE__VSNPRINTF_S 1
/* Define to 1 if you have the `isblank' function. */
#cmakedefine HAVE_ISBLANK 1
/* Define to 1 if you have the `strncpy' function. */
#cmakedefine HAVE_STRNCPY 1
/* Define to 1 if you have the `strndup' function. */
#cmakedefine HAVE_STRNDUP 1
/* Define to 1 if you have the `cfmakeraw' function. */
#cmakedefine HAVE_CFMAKERAW 1
@@ -74,8 +168,38 @@
/* Define to 1 if you have the `select' function. */
#cmakedefine HAVE_SELECT 1
/* Define to 1 if you have the `regcomp' function. */
#cmakedefine HAVE_REGCOMP 1
/* Define to 1 if you have the `clock_gettime' function. */
#cmakedefine HAVE_CLOCK_GETTIME 1
/* Define to 1 if you have the `ntohll' function. */
#cmakedefine HAVE_NTOHLL 1
/* Define to 1 if you have the `htonll' function. */
#cmakedefine HAVE_HTONLL 1
/* Define to 1 if you have the `strtoull' function. */
#cmakedefine HAVE_STRTOULL 1
/* Define to 1 if you have the `__strtoull' function. */
#cmakedefine HAVE___STRTOULL 1
/* Define to 1 if you have the `_strtoui64' function. */
#cmakedefine HAVE__STRTOUI64 1
/* Define to 1 if you have the `glob' function. */
#cmakedefine HAVE_GLOB 1
/* Define to 1 if you have the `explicit_bzero' function. */
#cmakedefine HAVE_EXPLICIT_BZERO 1
/* Define to 1 if you have the `memset_s' function. */
#cmakedefine HAVE_MEMSET_S 1
/* Define to 1 if you have the `SecureZeroMemory' function. */
#cmakedefine HAVE_SECURE_ZERO_MEMORY 1
/* Define to 1 if you have the `cmocka_set_test_filter' function. */
#cmakedefine HAVE_CMOCKA_SET_TEST_FILTER 1
/*************************** LIBRARIES ***************************/
@@ -85,36 +209,73 @@
/* Define to 1 if you have the `gcrypt' library (-lgcrypt). */
#cmakedefine HAVE_LIBGCRYPT 1
/* Define to 1 if you have the `z' library (-lz). */
#cmakedefine HAVE_LIBZ 1
/* Define to 1 if you have the 'mbedTLS' library (-lmbedtls). */
#cmakedefine HAVE_LIBMBEDCRYPTO 1
/* Define to 1 if you have the `pthread' library (-lpthread). */
#cmakedefine HAVE_PTHREAD 1
/* Define to 1 if you have the `cmocka' library (-lcmocka). */
#cmakedefine HAVE_CMOCKA 1
/**************************** OPTIONS ****************************/
#cmakedefine HAVE_GCC_THREAD_LOCAL_STORAGE 1
#cmakedefine HAVE_MSC_THREAD_LOCAL_STORAGE 1
#cmakedefine HAVE_FALLTHROUGH_ATTRIBUTE 1
#cmakedefine HAVE_UNUSED_ATTRIBUTE 1
#cmakedefine HAVE_WEAK_ATTRIBUTE 1
#cmakedefine HAVE_CONSTRUCTOR_ATTRIBUTE 1
#cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
#cmakedefine HAVE_GCC_VOLATILE_MEMORY_PROTECTION 1
#cmakedefine HAVE_COMPILER__FUNC__ 1
#cmakedefine HAVE_COMPILER__FUNCTION__ 1
#cmakedefine HAVE_GCC_BOUNDED_ATTRIBUTE 1
/* Define to 1 if you want to enable GSSAPI */
#cmakedefine WITH_GSSAPI 1
/* Define to 1 if you want to enable ZLIB */
#cmakedefine WITH_LIBZ 1
#cmakedefine WITH_ZLIB 1
/* Define to 1 if you want to enable SFTP */
#cmakedefine WITH_SFTP 1
/* Define to 1 if you want to enable SSH1 */
#cmakedefine WITH_SSH1 1
/* Define to 1 if you want to enable server support */
#cmakedefine WITH_SERVER 1
/* Define to 1 if you want to enable DH group exchange algorithms */
#cmakedefine WITH_GEX 1
/* Define to 1 if you want to enable none cipher and MAC */
#cmakedefine WITH_INSECURE_NONE 1
/* Define to 1 if you want to enable blowfish cipher support */
#cmakedefine WITH_BLOWFISH_CIPHER 1
/* Define to 1 if you want to enable debug output for crypto functions */
#cmakedefine DEBUG_CRYPTO 1
/* Define to 1 if you want to enable debug output for packet functions */
#cmakedefine DEBUG_PACKET 1
/* Define to 1 if you want to enable pcap output support (experimental) */
#cmakedefine WITH_PCAP 1
/* Define to 1 if you want to enable calltrace debug output */
#cmakedefine DEBUG_CALLTRACE 1
/* Define to 1 if you want to enable NaCl support */
#cmakedefine WITH_NACL 1
/* Define to 1 if you want to enable PKCS #11 URI support */
#cmakedefine WITH_PKCS11_URI 1
/*************************** ENDIAN *****************************/
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most

View File

@@ -1,5 +1,49 @@
#
# Build the documentation
#
include(UseDoxygen OPTIONAL)
if (${CMAKE_VERSION} VERSION_GREATER "3.8.99")
find_package(Doxygen)
if (DOXYGEN_FOUND)
set(DOXYGEN_PROJECT_NAME ${PROJECT_NAME})
set(DOXYGEN_PROJECT_NUMBER ${PROJECT_VERSION})
set(DOXYGEN_PROJECT_BRIEF "The SSH library")
set(DOXYGEN_TAB_SIZE 4)
set(DOXYGEN_OPTIMIZE_OUTPUT_FOR_C YES)
set(DOXYGEN_MARKDOWN_SUPPORT YES)
set(DOXYGEN_FULL_PATH_NAMES NO)
set(DOXYGEN_PREDEFINED DOXYGEN
WITH_SERVER
WITH_SFTP
PRINTF_ATTRIBUTE(x,y))
set(DOXYGEN_EXCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/that_style)
set(DOXYGEN_HTML_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/that_style/header.html)
set(DOXYGEN_HTML_EXTRA_STYLESHEET ${CMAKE_CURRENT_SOURCE_DIR}/that_style/that_style.css)
set(DOXYGEN_HTML_EXTRA_FILES ${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/nav_edge_left.svg
${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/nav_edge_right.svg
${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/nav_edge_inter.svg
${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/sync_off.png
${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/sync_on.png
${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/splitbar_handle.svg
${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/doc.svg
${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/mag_glass.svg
${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/folderclosed.svg
${CMAKE_CURRENT_SOURCE_DIR}/that_style/img/folderopen.svg
${CMAKE_CURRENT_SOURCE_DIR}/that_style/js/striped_bg.js)
# This updates the Doxyfile if we do changes here
set(_doxyfile_template "${CMAKE_BINARY_DIR}/CMakeDoxyfile.in")
set(_target_doxyfile "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile.docs")
configure_file("${_doxyfile_template}" "${_target_doxyfile}")
doxygen_add_docs(docs
${CMAKE_SOURCE_DIR}/include/libssh
${CMAKE_SOURCE_DIR}/src
${CMAKE_CURRENT_SOURCE_DIR})
endif() # DOXYGEN_FOUND
endif() # CMAKE_VERSION

View File

@@ -0,0 +1,101 @@
# Install a FreeBSD CI instance
Install the following packages:
```
pkg install -y bash git gmake cmake cmocka openssl wget pkgconf ccache bash
```
Create gitlab-runner user:
```
pw group add -n gitlab-runner
pw user add -n gitlab-runner -g gitlab-runner -s /usr/local/bin/bash
mkdir /home/gitlab-runner
chown gitlab-runner:gitlab-runner /home/gitlab-runner
```
Get the gitlab-runner binary for freebsd:
```
wget -O /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-freebsd-amd64
chmod +x /usr/local/bin/gitlab-runner
```
Create a log file and allow access:
```
touch /var/log/gitlab_runner.log && chown gitlab-runner:gitlab-runner /var/log/gitlab_runner.log
```
We need a start script to run it on boot:
```
mkdir -p /usr/local/etc/rc.d
cat > /usr/local/etc/rc.d/gitlab_runner << EOF
#!/usr/local/bin/bash
# PROVIDE: gitlab_runner
# REQUIRE: DAEMON NETWORKING
# BEFORE:
# KEYWORD:
. /etc/rc.subr
name="gitlab_runner"
rcvar="gitlab_runner_enable"
load_rc_config $name
user="gitlab-runner"
user_home="/home/gitlab-runner"
command="/usr/local/bin/gitlab-runner run"
pidfile="/var/run/${name}.pid"
start_cmd="gitlab_runner_start"
stop_cmd="gitlab_runner_stop"
status_cmd="gitlab_runner_status"
gitlab_runner_start()
{
export USER=${user}
export HOME=${user_home}
if checkyesno ${rcvar}; then
cd ${user_home}
/usr/sbin/daemon -u ${user} -p ${pidfile} ${command} > /var/log/gitlab_runner.log 2>&1
fi
}
gitlab_runner_stop()
{
if [ -f ${pidfile} ]; then
kill `cat ${pidfile}`
fi
}
gitlab_runner_status()
{
if [ ! -f ${pidfile} ] || kill -0 `cat ${pidfile}`; then
echo "Service ${name} is not running."
else
echo "${name} appears to be running."
fi
}
run_rc_command $1
EOF
chmod +x /usr/local/etc/rc.d/gitlab_runner
```
Register your gitlab-runner with your gitlab project
```
su gitlab-runner -c 'gitlab-runner register'
```
Start the gitlab runner service:
```
sysrc -f /etc/rc.conf "gitlab_runner_enable=YES"
service gitlab_runner start
```

View File

@@ -1 +0,0 @@
<!-- Doxygen TracFooter -->

View File

@@ -1,4 +0,0 @@
<!-- Doxygen TracHeader -->
<style>@import url(/chrome/site/doxygen.css);</style>
<style>@import url(/chrome/site/tabs.css);</style>
<!-- /Doxygen TracHeader -->

View File

@@ -21,7 +21,7 @@ to read the abundant documentation on this topic to fully understand the
advantages and security risks linked to each method.
@subsection pubkeys Authenticating with public keys
@subsection pubkeys Authenticating with public keys
libssh is fully compatible with the openssh public and private keys. You
can either use the automatic public key authentication method provided by
@@ -33,6 +33,9 @@ The process of authenticating by public key to a server is the following:
used to authenticate the user).
- then, you retrieve the private key for this key and send a message
proving that you know that private key.
- when several identity files are specified, then the order of processing of
these files is from the last-mentioned to the first one
(if specified in the ~/.ssh/config, then starting from the bottom to the top).
The function ssh_userauth_autopubkey() does this using the available keys in
"~/.ssh/". The return values are the following:
@@ -40,22 +43,21 @@ The function ssh_userauth_autopubkey() does this using the available keys in
- SSH_AUTH_DENIED: no key matched
- SSH_AUTH_SUCCESS: you are now authenticated
- SSH_AUTH_PARTIAL: some key matched but you still have to provide an other
mean of authentication (like a password).
mean of authentication (like a password).
The ssh_userauth_autopubkey() function also tries to authenticate using the
The ssh_userauth_publickey_auto() function also tries to authenticate using the
SSH agent, if you have one running, or the "none" method otherwise.
If you wish to authenticate with public key by your own, follow these steps:
- Retrieve the public key in a ssh_string using publickey_from_file().
- Offer the public key to the SSH server using ssh_userauth_offer_pubkey().
- Retrieve the public key with ssh_pki_import_pubkey_file().
- Offer the public key to the SSH server using ssh_userauth_try_publickey().
If the return value is SSH_AUTH_SUCCESS, the SSH server accepts to
authenticate using the public key and you can go to the next step.
- Retrieve the private key, using the privatekey_from_file() function. If
a passphrase is needed, either the passphrase specified as argument or
a callback (see callbacks section) will be used.
- Authenticate using ssh_userauth_pubkey() with your public key string
and private key.
- Do not forget cleaning up memory using string_free() and privatekey_free().
- Retrieve the private key, using the ssh_pki_import_privkey_file() function.
If a passphrase is needed, either the passphrase specified as argument or
a callback will be used.
- Authenticate using ssh_userauth_publickey() with your private key.
- Do not forget cleaning up memory using ssh_key_free().
Here is a minimalistic example of public key authentication:
@@ -64,7 +66,7 @@ int authenticate_pubkey(ssh_session session)
{
int rc;
rc = ssh_userauth_autopubkey(session, NULL);
rc = ssh_userauth_publickey_auto(session, NULL, NULL);
if (rc == SSH_AUTH_ERROR)
{
@@ -77,14 +79,12 @@ int authenticate_pubkey(ssh_session session)
}
@endcode
@see ssh_userauth_autopubkey
@see ssh_userauth_offer_pubkey
@see ssh_userauth_pubkey
@see publickey_from_file
@see publickey_from_privatekey
@see string_free
@see privatekey_from_file
@see privatekey_free
@see ssh_userauth_publickey_auto()
@see ssh_userauth_try_publickey()
@see ssh_userauth_publickey()
@see ssh_pki_import_pubkey_file()
@see ssh_pki_import_privkey_file()
@see ssh_key_free()
@subsection password Authenticating with a password
@@ -130,7 +130,7 @@ The keyboard-interactive method is, as its name tells, interactive. The
server will issue one or more challenges that the user has to answer,
until the server takes an authentication decision.
ssh_userauth_kbdint() is the the main keyboard-interactive function.
ssh_userauth_kbdint() is the the main keyboard-interactive function.
It will return SSH_AUTH_SUCCESS,SSH_AUTH_DENIED, SSH_AUTH_PARTIAL,
SSH_AUTH_ERROR, or SSH_AUTH_INFO, depending on the result of the request.
@@ -157,9 +157,9 @@ Here are a few remarks:
- Even the first call can return SSH_AUTH_DENIED or SSH_AUTH_SUCCESS.
- The server can send an empty question set (this is the default behavior
on my system) after you have sent the answers to the first questions.
You must still parse the answer, it might contain some
You must still parse the answer, it might contain some
message from the server saying hello or such things. Just call
ssh_userauth_kbdint() until needed.
ssh_userauth_kbdint() until needed.
- The meaning of "name", "prompt", "instruction" may be a little
confusing. An explanation is given in the RFC section that follows.
@@ -167,13 +167,13 @@ Here is a little note about how to use the information from
keyboard-interactive authentication, coming from the RFC itself (rfc4256):
@verbatim
3.3 User Interface Upon receiving a request message, the client SHOULD
prompt the user as follows: A command line interface (CLI) client SHOULD
print the name and instruction (if non-empty), adding newlines. Then for
each prompt in turn, the client SHOULD display the prompt and read the
user input.
A graphical user interface (GUI) client has many choices on how to prompt
the user. One possibility is to use the name field (possibly prefixed
with the application's name) as the title of a dialog window in which
@@ -184,18 +184,18 @@ keyboard-interactive authentication, coming from the RFC itself (rfc4256):
titles; it SHOULD instead find another way to display this information. If
prompts are presented in a dialog window, then the client SHOULD NOT
present each prompt in a separate window.
All clients MUST properly handle an instruction field with embedded
newlines. They SHOULD also be able to display at least 30 characters for
the name and prompts. If the server presents names or prompts longer than 30
characters, the client MAY truncate these fields to the length it can
display. If the client does truncate any fields, there MUST be an obvious
indication that such truncation has occured.
indication that such truncation has occurred.
The instruction field SHOULD NOT be truncated. Clients SHOULD use control
character filtering as discussed in [SSH-ARCH] to avoid attacks by
including terminal control characters in the fields to be displayed.
For each prompt, the corresponding echo field indicates whether or not
the user input should be echoed as characters are typed. Clients SHOULD
correctly echo/mask user input for each prompt independently of other
@@ -265,10 +265,10 @@ int authenticate_kbdint(ssh_session session)
@endcode
@see ssh_userauth_kbdint()
@see ssh_userauth_kbdint_getnprompts
@see ssh_userauth_kbdint_getname
@see ssh_userauth_kbdint_getinstruction
@see ssh_userauth_kbdint_getprompt
@see ssh_userauth_kbdint_getnprompts()
@see ssh_userauth_kbdint_getname()
@see ssh_userauth_kbdint_getinstruction()
@see ssh_userauth_kbdint_getprompt()
@see ssh_userauth_kbdint_setanswer()
@@ -284,11 +284,11 @@ pass, ssh_userauth_none() might answer SSH_AUTH_SUCCESS.
The following example shows how to perform "none" authentication:
@code
int authenticate_kbdint(ssh_session session)
int authenticate_none(ssh_session session)
{
int rc;
rc = ssh_userauth_none(session, NULL, NULL);
rc = ssh_userauth_none(session, NULL);
return rc;
}
@endcode
@@ -307,6 +307,11 @@ int test_several_auth_methods(ssh_session session)
{
int method, rc;
rc = ssh_userauth_none(session, NULL);
if (rc == SSH_AUTH_SUCCESS || rc == SSH_AUTH_ERROR) {
return rc;
}
method = ssh_userauth_list(session, NULL);
if (method & SSH_AUTH_METHOD_NONE)

View File

@@ -56,7 +56,7 @@ If an error has been encountered, it returns a negative value:
@code
char buffer[256];
unsigned int nbytes;
int nbytes;
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
while (nbytes > 0)

View File

@@ -0,0 +1,119 @@
curve25519-sha256@libssh.org.txt Aris Adamantiadis <aris@badcode.be>
21/9/2013
1. Introduction
This document describes the key exchange methode curve25519-sha256@libssh.org
for SSH version 2 protocol. It is provided as an alternative to the existing
key exchange mechanisms based on either Diffie-Hellman or Elliptic Curve Diffie-
Hellman [RFC5656].
The reason is the following : During summer of 2013, revelations from ex-
consultant at NSA Edward Snowden gave proof that NSA willingly inserts backdoors
into softwares, hardware components and published standards. While it is still
believed that the mathematics behind ECC cryptography are still sound and solid,
some people (including Bruce Schneier [SCHNEIER]), showed their lack of confidence
in NIST-published curves such as nistp256, nistp384, nistp521, for which constant
parameters (including the generator point) are defined without explanation. It
is also believed that NSA had a word to say in their definition. These curves
are not the most secure or fastest possible for their key sizes [DJB], and
researchers think it is possible that NSA have ways of cracking NIST curves.
It is also interesting to note that SSH belongs to the list of protocols the NSA
claims to be able to eavesdrop. Having a secure replacement would make passive
attacks much harder if such a backdoor exists.
However an alternative exists in the form of Curve25519. This algorithm has been
proposed in 2006 by DJB [Curve25519]. Its main strengths are its speed, its
constant-time run time (and resistance against side-channel attacks), and its
lack of nebulous hard-coded constants.
The reference version being used in this document is the one described in
[Curve25519] as implemented in the library NaCl [NaCl].
This document does not attempt to provide alternatives to the ecdsa-sha1-*
authentication keys.
2. Key exchange
The key exchange procedure is very similar to the one described chapter 4 of
[RFC5656]. Public ephemeral keys are transmitted over SSH encapsulated into
standard SSH strings.
The following is an overview of the key exchange process:
Client Server
------ ------
Generate ephemeral key pair.
SSH_MSG_KEX_ECDH_INIT -------->
Verify that client public key
length is 32 bytes.
Generate ephemeral key pair.
Compute shared secret.
Generate and sign exchange hash.
<-------- SSH_MSG_KEX_ECDH_REPLY
Verify that server public key length is 32 bytes.
* Verify host keys belong to server.
Compute shared secret.
Generate exchange hash.
Verify server's signature.
* Optional but strongly recommanded as this protects against MITM attacks.
This is implemented using the same messages as described in RFC5656 chapter 4
3. Method Name
The name of this key exchange method is "curve25519-sha256@libssh.org".
4. Implementation considerations
The whole method is based on the curve25519 scalar multiplication. In this
method, a private key is a scalar of 256 bits, and a public key is a point
of 256 bits.
4.1. Private key generation
A 32 bytes private key should be generated for each new connection,
using a secure PRNG. The following actions must be done on the private key:
mysecret[0] &= 248;
mysecret[31] &= 127;
mysecret[31] |= 64;
In order to keep the key valid. However, many cryptographic libraries will do
this automatically.
It should be noted that, in opposition to NIST curves, no special validation
should be done to ensure the result is a valid and secure private key.
4.2 Public key generation
The 32 bytes public key of either a client or a server must be generated using
the 32 bytes private key and a common generator base. This base is defined as 9
followed by all zeroes:
const unsigned char basepoint[32] = {9};
The public key is calculated using the cryptographic scalar multiplication:
const unsigned char privkey[32];
unsigned char pubkey[32];
crypto_scalarmult (pubkey, privkey, basepoint);
However some cryptographic libraries may provide a combined function:
crypto_scalarmult_base (pubkey, privkey);
It should be noted that, in opposition to NIST curves, no special validation
should be done to ensure the received public keys are valid curves point. The
Curve25519 algorithm ensure that every possible public key maps to a valid
ECC Point.
4.3 Shared secret generation
The shared secret, k, is defined in SSH specifications to be a big integer.
This number is calculated using the following procedure:
X is the 32 bytes point obtained by the scalar multiplication of the other
side's public key and the local private key scalar.
The whole 32 bytes of the number X are then converted into a big integer k.
This conversion follows the network byte order. This step differs from
RFC5656.
[RFC5656] https://tools.ietf.org/html/rfc5656
[SCHNEIER] https://www.schneier.com/blog/archives/2013/09/the_nsa_is_brea.html#c1675929
[DJB] https://cr.yp.to/talks/2013.05.31/slides-dan+tanja-20130531-4x3.pdf
[Curve25519] "Curve25519: new Diffie-Hellman speed records."
https://cr.yp.to/ecdh/curve25519-20060209.pdf

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -4,7 +4,7 @@
Port forwarding comes in SSH protocol in two different flavours:
direct or reverse port forwarding. Direct port forwarding is also
named local port forwardind, and reverse port forwarding is also called
named local port forwarding, and reverse port forwarding is also called
remote port forwarding. SSH also allows X11 tunnels.
@@ -23,15 +23,15 @@ Mail client application Google Mail
5555 (arbitrary) |
| 143 (IMAP2)
V |
SSH client =====> SSH server
SSH client =====> SSH server
Legend:
--P-->: port connexion through port P
--P-->: port connections through port P
=====>: SSH tunnel
@endverbatim
A mail client connects to port 5555 of a client. An encrypted tunnel is
established to the server. The server connects to port 143 of Google Mail (the
end point). Now the local mail client can retreive mail.
end point). Now the local mail client can retrieve mail.
@subsection forwarding_reverse Reverse port forwarding
@@ -51,7 +51,7 @@ Example of use of reverse port forwarding:
SSH client <===== SSH server
Legend:
--P-->: port connexion through port P
--P-->: port connections through port P
=====>: SSH tunnel
@endverbatim
In this example, the SSH client establishes the tunnel,
@@ -85,7 +85,7 @@ this tutorial.
@subsection libssh_direct Doing direct port forwarding with libssh
To do direct port forwarding, call function channel_open_forward():
To do direct port forwarding, call function ssh_channel_open_forward():
- you need a separate channel for the tunnel as first parameter;
- second and third parameters are the remote endpoint;
- fourth and fifth parameters are sent to the remote server
@@ -101,16 +101,18 @@ used to retrieve google's home page from the remote SSH server.
int direct_forwarding(ssh_session session)
{
ssh_channel forwarding_channel;
int rc;
int rc = SSH_ERROR;
char *http_get = "GET / HTTP/1.1\nHost: www.google.com\n\n";
int nbytes, nwritten;
forwarding_channel = ssh_channel_new(session);
if (rc != SSH_OK) return rc;
if (forwarding_channel == NULL) {
return rc;
}
rc = channel_open_forward(forwarding_channel,
"www.google.com", 80,
"localhost", 5555);
rc = ssh_channel_open_forward(forwarding_channel,
"www.google.com", 80,
"localhost", 5555);
if (rc != SSH_OK)
{
ssh_channel_free(forwarding_channel);
@@ -118,7 +120,9 @@ int direct_forwarding(ssh_session session)
}
nbytes = strlen(http_get);
nwritten = channel_write(forwarding_channel, http_get, nbytes);
nwritten = ssh_channel_write(forwarding_channel,
http_get,
nbytes);
if (nbytes != nwritten)
{
ssh_channel_free(forwarding_channel);
@@ -140,13 +144,13 @@ or whatever use you have for it.
@subsection libssh_reverse Doing reverse port forwarding with libssh
To do reverse port forwarding, call ssh_channel_forward_listen(),
then ssh_channel_forward_accept().
To do reverse port forwarding, call ssh_channel_listen_forward(),
then ssh_channel_accept_forward().
When you call ssh_channel_forward_listen(), you can let the remote server
chose the non-priviledged port it should listen to. Otherwise, you can chose
your own priviledged or non-priviledged port. Beware that you should have
administrative priviledges on the remote server to open a priviledged port
When you call ssh_channel_listen_forward(), you can let the remote server
chose the non-privileged port it should listen to. Otherwise, you can chose
your own privileged or non-privileged port. Beware that you should have
administrative privileges on the remote server to open a privileged port
(port number < 1024).
Below is an example of a very rough web server waiting for connections on port
@@ -160,6 +164,9 @@ int web_server(ssh_session session)
ssh_channel channel;
char buffer[256];
int nbytes, nwritten;
int port = 0;
char *peer_address = NULL;
int peer_port = 0;
char *helloworld = ""
"HTTP/1.1 200 OK\n"
"Content-Type: text/html\n"
@@ -174,17 +181,20 @@ int web_server(ssh_session session)
" </body>\n"
"</html>\n";
rc = ssh_channel_forward_listen(session, NULL, 8080, NULL);
rc = ssh_channel_listen_forward(session, NULL, 8080, NULL);
if (rc != SSH_OK)
{
fprintf(stderr, "Error opening remote port: %s\n", ssh_get_error(session));
fprintf(stderr, "Error opening remote port: %s\n",
ssh_get_error(session));
return rc;
}
channel = ssh_channel_forward_accept(session, 60000);
channel = ssh_channel_open_forward_port(session, 60000, &port,
&peer_address, &peer_port);
if (channel == NULL)
{
fprintf(stderr, "Error waiting for incoming connection: %s\n", ssh_get_error(session));
fprintf(stderr, "Error waiting for incoming connection: %s\n",
ssh_get_error(session));
return SSH_ERROR;
}
@@ -193,9 +203,11 @@ int web_server(ssh_session session)
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
if (nbytes < 0)
{
fprintf(stderr, "Error reading incoming data: %s\n", ssh_get_error(session));
fprintf(stderr, "Error reading incoming data: %s\n",
ssh_get_error(session));
ssh_channel_send_eof(channel);
ssh_channel_free(channel);
ssh_string_free_char(peer_address);
return SSH_ERROR;
}
if (strncmp(buffer, "GET /", 5)) continue;
@@ -204,16 +216,19 @@ int web_server(ssh_session session)
nwritten = ssh_channel_write(channel, helloworld, nbytes);
if (nwritten != nbytes)
{
fprintf(stderr, "Error sending answer: %s\n", ssh_get_error(session));
fprintf(stderr, "Error sending answer: %s\n",
ssh_get_error(session));
ssh_channel_send_eof(channel);
ssh_channel_free(channel);
ssh_string_free_char(peer_address);
return SSH_ERROR;
}
printf("Sent answer\n");
printf("Sent answer to %s:%d\n", peer_address, peer_port);
}
ssh_channel_send_eof(channel);
ssh_channel_free(channel);
ssh_string_free_char(peer_address);
return SSH_OK;
}
@endcode

View File

@@ -31,20 +31,20 @@ A SSH session goes through the following steps:
- Invoke your own subsystem. This is outside the scope of this document,
but can be done.
- When everything is finished, just close the channels, and then the connection.
- When everything is finished, just close the channels, and then the connection.
The sftp and scp subsystems use channels, but libssh hides them to
the programmer. If you want to use those subsystems, instead of a channel,
you'll usually open a "sftp session" or a "scp session".
@subsection setup Creating the session and setting options
The most important object in a SSH connection is the SSH session. In order
to allocate a new SSH session, you use ssh_new(). Don't forget to
always verify that the allocation successed.
always verify that the allocation succeeded.
@code
#include <libssh/libssh.h>
#include <libssh/libssh.h>
#include <stdlib.h>
int main()
@@ -69,12 +69,12 @@ The ssh_options_set() function sets the options of the session. The most importa
The complete list of options can be found in the documentation of ssh_options_set().
The only mandatory option is SSH_OPTIONS_HOST. If you don't use SSH_OPTIONS_USER,
the local username of your account will be used.
the local username of your account will be used.
Here is a small example of how to use it:
@code
#include <libssh/libssh.h>
#include <libssh/libssh.h>
#include <stdlib.h>
int main()
@@ -122,7 +122,7 @@ Here's an example:
@code
#include <libssh/libssh.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
int main()
{
@@ -158,7 +158,7 @@ you just connected to is known and safe to use (remember, SSH is about security
authentication).
There are two ways of doing this:
- The first way (recommended) is to use the ssh_is_server_known()
- The first way (recommended) is to use the ssh_session_is_known_server()
function. This function will look into the known host file
(~/.ssh/known_hosts on UNIX), look for the server hostname's pattern,
and determine whether this host is present or not in the list.
@@ -185,74 +185,89 @@ examples/ directory:
int verify_knownhost(ssh_session session)
{
int state, hlen;
unsigned char *hash = NULL;
char *hexa;
char buf[10];
enum ssh_known_hosts_e state;
unsigned char *hash = NULL;
ssh_key srv_pubkey = NULL;
size_t hlen;
char buf[10];
char *hexa;
char *p;
int cmp;
int rc;
state = ssh_is_server_known(session);
hlen = ssh_get_pubkey_hash(session, &hash);
if (hlen < 0)
return -1;
switch (state)
{
case SSH_SERVER_KNOWN_OK:
break; /* ok */
case SSH_SERVER_KNOWN_CHANGED:
fprintf(stderr, "Host key for server changed: it is now:\n");
ssh_print_hexa("Public key hash", hash, hlen);
fprintf(stderr, "For security reasons, connection will be stopped\n");
free(hash);
return -1;
case SSH_SERVER_FOUND_OTHER:
fprintf(stderr, "The host key for this server was not found but an other"
"type of key exists.\n");
fprintf(stderr, "An attacker might change the default server key to"
"confuse your client into thinking the key does not exist\n");
free(hash);
return -1;
case SSH_SERVER_FILE_NOT_FOUND:
fprintf(stderr, "Could not find known host file.\n");
fprintf(stderr, "If you accept the host key here, the file will be"
"automatically created.\n");
/* fallback to SSH_SERVER_NOT_KNOWN behavior */
case SSH_SERVER_NOT_KNOWN:
hexa = ssh_get_hexa(hash, hlen);
fprintf(stderr,"The server is unknown. Do you trust the host key?\n");
fprintf(stderr, "Public key hash: %s\n", hexa);
free(hexa);
if (fgets(buf, sizeof(buf), stdin) == NULL)
{
free(hash);
rc = ssh_get_server_publickey(session, &srv_pubkey);
if (rc < 0) {
return -1;
}
if (strncasecmp(buf, "yes", 3) != 0)
{
free(hash);
return -1;
}
if (ssh_write_knownhost(session) < 0)
{
fprintf(stderr, "Error %s\n", strerror(errno));
free(hash);
return -1;
}
break;
}
case SSH_SERVER_ERROR:
fprintf(stderr, "Error %s", ssh_get_error(session));
free(hash);
return -1;
}
rc = ssh_get_publickey_hash(srv_pubkey,
SSH_PUBLICKEY_HASH_SHA1,
&hash,
&hlen);
ssh_key_free(srv_pubkey);
if (rc < 0) {
return -1;
}
free(hash);
return 0;
state = ssh_session_is_known_server(session);
switch (state) {
case SSH_KNOWN_HOSTS_OK:
/* OK */
break;
case SSH_KNOWN_HOSTS_CHANGED:
fprintf(stderr, "Host key for server changed: it is now:\n");
ssh_print_hexa("Public key hash", hash, hlen);
fprintf(stderr, "For security reasons, connection will be stopped\n");
ssh_clean_pubkey_hash(&hash);
return -1;
case SSH_KNOWN_HOSTS_OTHER:
fprintf(stderr, "The host key for this server was not found but an other"
"type of key exists.\n");
fprintf(stderr, "An attacker might change the default server key to"
"confuse your client into thinking the key does not exist\n");
ssh_clean_pubkey_hash(&hash);
return -1;
case SSH_KNOWN_HOSTS_NOT_FOUND:
fprintf(stderr, "Could not find known host file.\n");
fprintf(stderr, "If you accept the host key here, the file will be"
"automatically created.\n");
/* FALL THROUGH to SSH_SERVER_NOT_KNOWN behavior */
case SSH_KNOWN_HOSTS_UNKNOWN:
hexa = ssh_get_hexa(hash, hlen);
fprintf(stderr,"The server is unknown. Do you trust the host key?\n");
fprintf(stderr, "Public key hash: %s\n", hexa);
ssh_string_free_char(hexa);
ssh_clean_pubkey_hash(&hash);
p = fgets(buf, sizeof(buf), stdin);
if (p == NULL) {
return -1;
}
cmp = strncasecmp(buf, "yes", 3);
if (cmp != 0) {
return -1;
}
rc = ssh_session_update_known_hosts(session);
if (rc < 0) {
fprintf(stderr, "Error %s\n", strerror(errno));
return -1;
}
break;
case SSH_KNOWN_HOSTS_ERROR:
fprintf(stderr, "Error %s", ssh_get_error(session));
ssh_clean_pubkey_hash(&hash);
return -1;
}
ssh_clean_pubkey_hash(&hash);
return 0;
}
@endcode
@@ -260,18 +275,19 @@ int verify_knownhost(ssh_session session)
@see ssh_disconnect
@see ssh_get_error
@see ssh_get_error_code
@see ssh_get_pubkey_hash
@see ssh_is_server_known
@see ssh_write_knownhost
@see ssh_get_server_publickey
@see ssh_get_publickey_hash
@see ssh_session_is_known_server
@see ssh_session_update_known_hosts
@subsection auth Authenticating the user
The authentication process is the way a service provider can identify a
user and verify his/her identity. The authorization process is about enabling
the authenticated user the access to ressources. In SSH, the two concepts
the authenticated user the access to resources. In SSH, the two concepts
are linked. After authentication, the server can grant the user access to
several ressources such as port forwarding, shell, sftp subsystem, and so on.
several resources such as port forwarding, shell, sftp subsystem, and so on.
libssh supports several methods of authentication:
- "none" method. This method allows to get the available authentications
@@ -297,7 +313,7 @@ The example below shows an authentication with password:
@code
#include <libssh/libssh.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
int main()
{
@@ -322,7 +338,7 @@ int main()
}
// Verify the server's identity
// For the source code of verify_knowhost(), check previous example
// For the source code of verify_knownhost(), check previous example
if (verify_knownhost(my_ssh_session) < 0)
{
ssh_disconnect(my_ssh_session);
@@ -367,7 +383,7 @@ int show_remote_processes(ssh_session session)
ssh_channel channel;
int rc;
char buffer[256];
unsigned int nbytes;
int nbytes;
channel = ssh_channel_new(session);
if (channel == NULL)
@@ -391,7 +407,7 @@ int show_remote_processes(ssh_session session)
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
while (nbytes > 0)
{
if (write(1, buffer, nbytes) != nbytes)
if (write(1, buffer, nbytes) != (unsigned int) nbytes)
{
ssh_channel_close(channel);
ssh_channel_free(channel);
@@ -399,7 +415,7 @@ int show_remote_processes(ssh_session session)
}
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
}
if (nbytes < 0)
{
ssh_channel_close(channel);
@@ -415,6 +431,9 @@ int show_remote_processes(ssh_session session)
}
@endcode
Each ssh_channel_request_exec() needs to be run on freshly created
and connected (with ssh_channel_open_session()) channel.
@see @ref opening_shell
@see @ref remote_command
@see @ref sftp_subsystem
@@ -440,14 +459,13 @@ might be recoverable. SSH_FATAL means the connection has an important
problem and isn't probably recoverable.
Most of time, the error returned are SSH_FATAL, but some functions
(generaly the ssh_request_xxx ones) may fail because of server denying request.
(generally the ssh_request_xxx ones) may fail because of server denying request.
In these cases, SSH_REQUEST_DENIED is returned.
ssh_get_error() and ssh_get_error_code() take a ssh_session as a parameter.
That's for thread safety, error messages that can be attached to a session
aren't static anymore. Any error that happens during ssh_options_xxx()
or ssh_connect() (i.e., outside of any session) can be retrieved by
giving NULL as argument.
For thread safety, errors are bound to ssh_session objects.
As long as your ssh_session object is not NULL, you can retrieve the last error
message and error code from the ssh_session using ssh_get_error() and
ssh_get_error_code() respectively.
The SFTP subsystem has its own error codes, in addition to libssh ones.

View File

@@ -12,18 +12,17 @@ mean that you should not try to know about and understand these details.
libssh is a Free Software / Open Source project. The libssh library
is distributed under LGPL license. The libssh project has nothing to do with
"libssh2", which is a completly different and independant project.
"libssh2", which is a completely different and independent project.
libssh can run on top of either libgcrypt (http://directory.fsf.org/project/libgcrypt/)
or libcrypto (http://www.openssl.org/docs/crypto/crypto.html), two general-purpose
cryptographic libraries.
libssh can run on top of either libgcrypt or libcrypto,
two general-purpose cryptographic libraries.
This tutorial concentrates for its main part on the "client" side of libssh.
To learn how to accept incoming SSH connexions (how to write a SSH server),
To learn how to accept incoming SSH connections (how to write a SSH server),
you'll have to jump to the end of this document.
This tutorial describes libssh version 0.5.0. This version is the development
version and is *not* published yet. However, the examples should work with
This tutorial describes libssh version 0.5.0. This version is a little different
from the 0.4.X series. However, the examples should work with
little changes on versions like 0.4.2 and later.

View File

@@ -17,8 +17,17 @@ On UNIX systems linking against the static version of the library is the
same as linking against the shared library. Both have the same name. Some
build system require to use the full path to the static library.
On Windows you need to define LIBSSH_STATIC in the compiler command
line. This is required cause the dynamic library needs to specify the
dllimport attribute.
To be able to compile the application you're developing you need to either pass
LIBSSH_STATIC as a define in the compiler command line or define it before you
include libssh.h. This is required cause the dynamic library needs to specify
the dllimport attribute.
@code
#define LIBSSH_STATIC 1
#include <libssh/libssh.h>
@endcode
If you're are statically linking with OpenSSL, read the "Linking your
application" section in the NOTES.[OS] in the OpenSSL source tree!
*/

View File

@@ -19,41 +19,131 @@ the interesting functions as you go.
The libssh library provides:
- Full C library functions for manipulating a client-side SSH connection
- SSH2 and SSH1 protocol compliant
- Fully configurable sessions
- Server support
- SSH agent authentication support
- Support for AES-128, AES-192, AES-256, Blowfish, 3DES in CBC mode, and AES in CTR mode
- Supports OpenSSL and GCrypt
- Use multiple SSH connections in a same process, at same time
- Use multiple channels in the same connection
- Thread safety when using different sessions at same time
- POSIX-like SFTP (Secure File Transfer) implementation with openssh extension support
- SCP implementation
- Large file system support (files bigger than 4GB)
- RSA and DSS server public key supported
- Compression support (with zlib)
- Public key (RSA and DSS), password and keyboard-interactive authentication
- Full poll()/WSAPoll() support and a poll-emulation for Win32.
- Runs and tested under x86_64, x86, ARM, Sparc32, PPC under Linux, BSD, MacOSX, Solaris and Windows
- <strong>Key Exchange Methods</strong>: <i>curve25519-sha256, curve25519-sha256@libssh.org, ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521</i>, diffie-hellman-group1-sha1, diffie-hellman-group14-sha1
- <strong>Public Key Algorithms</strong>: ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, ssh-rsa, rsa-sha2-512, rsa-sha2-256,ssh-dss
- <strong>Ciphers</strong>: <i>aes256-ctr, aes192-ctr, aes128-ctr</i>, aes256-cbc (rijndael-cbc@lysator.liu.se), aes192-cbc, aes128-cbc, 3des-cbc, blowfish-cbc
- <strong>Compression Schemes</strong>: zlib, <i>zlib@openssh.com</i>, none
- <strong>MAC hashes</strong>: hmac-sha1, hmac-sha2-256, hmac-sha2-512, hmac-md5
- <strong>Authentication</strong>: none, password, public-key, keyboard-interactive, <i>gssapi-with-mic</i>
- <strong>Channels</strong>: shell, exec (incl. SCP wrapper), direct-tcpip, subsystem, <i>auth-agent-req@openssh.com</i>
- <strong>Global Requests</strong>: tcpip-forward, forwarded-tcpip
- <strong>Channel Requests</strong>: x11, pty, <i>exit-status, signal, exit-signal, keepalive@openssh.com, auth-agent-req@openssh.com</i>
- <strong>Subsystems</strong>: sftp(version 3), <i>OpenSSH Extensions</i>
- <strong>SFTP</strong>: <i>statvfs@openssh.com, fstatvfs@openssh.com</i>
- <strong>Thread-safe</strong>: Just don't share sessions
- <strong>Non-blocking</strong>: it can be used both blocking and non-blocking
- <strong>Your sockets</strong>: the app hands over the socket, or uses libssh sockets
- <b>OpenSSL</b> or <b>gcrypt</b>: builds with either
@section main-additional-features Additional Features
- Client <b>and</b> server support
- SSHv2 protocol support
- Supports <a href="https://test.libssh.org/" target="_blank">Linux, UNIX, BSD, Solaris, OS/2 and Windows</a>
- Automated test cases with nightly <a href="https://test.libssh.org/" target="_blank">tests</a>
- Event model based on poll(2), or a poll(2)-emulation.
@section main-copyright Copyright Policy
The developers of libssh have a policy of asking for contributions to be made
under the personal copyright of the contributor, instead of a corporate
copyright.
libssh is a project with distributed copyright ownership, which means we prefer
the copyright on parts of libssh to be held by individuals rather than
corporations if possible. There are historical legal reasons for this, but one
of the best ways to explain it is that its much easier to work with
individuals who have ownership than corporate legal departments if we ever need
to make reasonable compromises with people using and working with libssh.
There are some reasons for the establishment of this policy:
We track the ownership of every part of libssh via git, our source code control
system, so we know the provenance of every piece of code that is committed to
libssh.
@li Individual copyrights make copyright registration in the US a simpler
process.
@li If libssh is copyrighted by individuals rather than corporations,
decisions regarding enforcement and protection of copyright will, more
likely, be made in the interests of the project, and not in the interests
of any corporations shareholders.
@li If we ever need to relicense a portion of the code contacting individuals
for permission to do so is much easier than contacting a company.
So if possible, if youre doing libssh changes on behalf of a company who
normally owns all the work you do please get them to assign personal copyright
ownership of your changes to you as an individual, that makes things very easy
for us to work with and avoids bringing corporate legal departments into the
picture.
If you cant do this we can still accept patches from you owned by your
employer under a standard employment contract with corporate copyright
ownership. It just requires a simple set-up process first.
We use a process very similar to the way things are done in the Linux Kernel
community, so it should be very easy to get a sign off from your corporate
legal department. The only changes weve made are to accommodate the license we
use, which is LGPLv2 (or later) whereas the Linux kernel uses GPLv2.
The process is called signing.
How to sign your work
----------------------
Once you have permission to contribute to libssh from your employer, simply
email a copy of the following text from your corporate email address to:
contributing@libssh.org
@verbatim
libssh Developer's Certificate of Origin. Version 1.0
By making a contribution to this project, I certify that:
(a) The contribution was created in whole or in part by me and I
have the right to submit it under the appropriate
version of the GNU General Public License; or
(b) The contribution is based upon previous work that, to the best of
my knowledge, is covered under an appropriate open source license
and I have the right under that license to submit that work with
modifications, whether created in whole or in part by me, under
the GNU General Public License, in the appropriate version; or
(c) The contribution was provided directly to me by some other
person who certified (a) or (b) and I have not modified it.
(d) I understand and agree that this project and the contribution are
public and that a record of the contribution (including all
metadata and personal information I submit with it, including my
sign-off) is maintained indefinitely and may be redistributed
consistent with the libssh Team's policies and the requirements of
the GNU GPL where they are relevant.
(e) I am granting this work to this project under the terms of the
GNU Lesser General Public License as published by the
Free Software Foundation; either version 2.1 of
the License, or (at the option of the project) any later version.
https://www.gnu.org/licenses/lgpl-2.1.html
@endverbatim
We will maintain a copy of that email as a record that you have the rights to
contribute code to libssh under the required licenses whilst working for the
company where the email came from.
Then when sending in a patch via the normal mechanisms described above, add a
line that states:
@verbatim
Signed-off-by: Random J Developer <random@developer.example.org>
@endverbatim
using your real name and the email address you sent the original email you used
to send the libssh Developers Certificate of Origin to us (sorry, no
pseudonyms or anonymous contributions.)
Thats it! Such code can then quite happily contain changes that have copyright
messages such as:
@verbatim
(c) Example Corporation.
@endverbatim
and can be merged into the libssh codebase in the same way as patches from any
other individual. You dont need to send in a copy of the libssh Developers
Certificate of Origin for each patch, or inside each patch. Just the sign-off
message is all that is required once weve received the initial email.
Have fun and happy libssh hacking!
The libssh Team
@section main-rfc Internet standard
@@ -61,45 +151,81 @@ There are some reasons for the establishment of this policy:
The following RFC documents described SSH-2 protcol as an Internet standard.
- <a href="http://tools.ietf.org/html/rfc4250" target="_blank">RFC 4250</a>,
- <a href="https://tools.ietf.org/html/rfc4250" target="_blank">RFC 4250</a>,
The Secure Shell (SSH) Protocol Assigned Numbers
- <a href="http://tools.ietf.org/html/rfc4251" target="_blank">RFC 4251</a>,
- <a href="https://tools.ietf.org/html/rfc4251" target="_blank">RFC 4251</a>,
The Secure Shell (SSH) Protocol Architecture
- <a href="http://tools.ietf.org/html/rfc4252" target="_blank">RFC 4252</a>,
- <a href="https://tools.ietf.org/html/rfc4252" target="_blank">RFC 4252</a>,
The Secure Shell (SSH) Authentication Protocol
- <a href="http://tools.ietf.org/html/rfc4253" target="_blank">RFC 4253</a>,
- <a href="https://tools.ietf.org/html/rfc4253" target="_blank">RFC 4253</a>,
The Secure Shell (SSH) Transport Layer Protocol
- <a href="http://tools.ietf.org/html/rfc4254" target="_blank">RFC 4254</a>,
- <a href="https://tools.ietf.org/html/rfc4254" target="_blank">RFC 4254</a>,
The Secure Shell (SSH) Connection Protocol
- <a href="http://tools.ietf.org/html/rfc4255" target="_blank">RFC 4255</a>,
- <a href="https://tools.ietf.org/html/rfc4255" target="_blank">RFC 4255</a>,
Using DNS to Securely Publish Secure Shell (SSH) Key Fingerprints
- <a href="http://tools.ietf.org/html/rfc4256" target="_blank">RFC 4256</a>,
(not implemented in libssh)
- <a href="https://tools.ietf.org/html/rfc4256" target="_blank">RFC 4256</a>,
Generic Message Exchange Authentication for the Secure Shell Protocol (SSH)
- <a href="http://tools.ietf.org/html/rfc4335" target="_blank">RFC 4335</a>,
- <a href="https://tools.ietf.org/html/rfc4335" target="_blank">RFC 4335</a>,
The Secure Shell (SSH) Session Channel Break Extension
- <a href="http://tools.ietf.org/html/rfc4344" target="_blank">RFC 4344</a>,
- <a href="https://tools.ietf.org/html/rfc4344" target="_blank">RFC 4344</a>,
The Secure Shell (SSH) Transport Layer Encryption Modes
- <a href="http://tools.ietf.org/html/rfc4345" target="_blank">RFC 4345</a>,
- <a href="https://tools.ietf.org/html/rfc4345" target="_blank">RFC 4345</a>,
Improved Arcfour Modes for the Secure Shell (SSH) Transport Layer Protocol
It was later modified and expanded by the following RFCs.
- <a href="http://tools.ietf.org/html/rfc4419" target="_blank">RFC 4419</a>,
- <a href="https://tools.ietf.org/html/rfc4419" target="_blank">RFC 4419</a>,
Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer
Protocol
- <a href="http://tools.ietf.org/html/rfc4432" target="_blank">RFC 4432</a>,
- <a href="https://tools.ietf.org/html/rfc4432" target="_blank">RFC 4432</a>,
RSA Key Exchange for the Secure Shell (SSH) Transport Layer Protocol
- <a href="http://tools.ietf.org/html/rfc4462" target="_blank">RFC 4462</a>,
(not implemented in libssh)
- <a href="https://tools.ietf.org/html/rfc4462" target="_blank">RFC 4462</a>,
Generic Security Service Application Program Interface (GSS-API)
Authentication and Key Exchange for the Secure Shell (SSH) Protocol
- <a href="http://tools.ietf.org/html/rfc4716" target="_blank">RFC 4716</a>,
(only the authentication implemented in libssh)
- <a href="https://tools.ietf.org/html/rfc4716" target="_blank">RFC 4716</a>,
The Secure Shell (SSH) Public Key File Format
- <a href="http://tools.ietf.org/html/rfc5656" target="_blank">RFC 5656</a>,
(not implemented in libssh)
- <a href="https://tools.ietf.org/html/rfc5647" target="_blank">RFC 5647</a>,
AES Galois Counter Mode for the Secure Shell Transport Layer Protocol
(the algorithm negotiation implemented according to openssh.com)
- <a href="https://tools.ietf.org/html/rfc5656" target="_blank">RFC 5656</a>,
Elliptic Curve Algorithm Integration in the Secure Shell Transport Layer
- <a href="https://tools.ietf.org/html/rfc6594" target="_blank">RFC 6594</a>,
Use of the SHA-256 Algorithm with RSA, DSA, and ECDSA in SSHFP Resource Records
(not implemented in libssh)
- <a href="https://tools.ietf.org/html/rfc6668" target="_blank">RFC 6668</a>,
SHA-2 Data Integrity Verification for the Secure Shell (SSH) Transport Layer Protocol
- <a href="https://tools.ietf.org/html/rfc7479" target="_blank">RFC 7479</a>,
Using Ed25519 in SSHFP Resource Records
(not implemented in libssh)
- <a href="https://tools.ietf.org/html/rfc8160" target="_blank">RFC 8160</a>,
IUTF8 Terminal Mode in Secure Shell (SSH)
(not handled in libssh)
- <a href="https://tools.ietf.org/html/rfc8270" target="_blank">RFC 8270</a>,
Increase the Secure Shell Minimum Recommended Diffie-Hellman Modulus Size to 2048 Bits
- <a href="https://tools.ietf.org/html/rfc8308" target="_blank">RFC 8308</a>,
Extension Negotiation in the Secure Shell (SSH) Protocol
(only the "server-sig-algs" extension implemented)
- <a href="https://tools.ietf.org/html/rfc8332" target="_blank">RFC 8332</a>,
Use of RSA Keys with SHA-256 and SHA-512 in the Secure Shell (SSH) Protocol
- <a href="https://tools.ietf.org/html/rfc8709" target="_blank">RFC 8709</a>,
Ed25519 and Ed448 Public Key Algorithms for the Secure Shell (SSH) Protocol
There are also drafts that are being currently developed and followed.
- <a href="https://tools.ietf.org/html/draft-ietf-curdle-ssh-kex-sha2-10" target="_blank">draft-ietf-curdle-ssh-kex-sha2-10</a>
Key Exchange (KEX) Method Updates and Recommendations for Secure Shell (SSH)
- <a href="https://tools.ietf.org/html/draft-miller-ssh-agent-03" target="_blank">draft-miller-ssh-agent-03</a>
SSH Agent Protocol
- <a href="https://tools.ietf.org/html/draft-ietf-curdle-ssh-curves-12" target="_blank">draft-ietf-curdle-ssh-curves-12</a>
Secure Shell (SSH) Key Exchange Method using Curve25519 and Curve448
Interesting cryptography documents:
- <a href="http://www.cryptsoft.com/pkcs11doc/" target="_blank">PKCS #11</a>, PKCS #11 reference documents, describing interface with smartcards.
- <a href="https://www.cryptsoft.com/pkcs11doc/" target="_blank">PKCS #11</a>, PKCS #11 reference documents, describing interface with smartcards.
@subsection main-rfc-sftp Secure Shell File Transfer Protocol (SFTP)
@@ -107,7 +233,7 @@ The protocol is not an Internet standard but it is still widely implemented.
OpenSSH and most other implementation implement Version 3 of the protocol. We
do the same in libssh.
- <a href="http://tools.ietf.org/html/draft-ietf-secsh-filexfer-02" target="_blank">
- <a href="https://tools.ietf.org/html/draft-ietf-secsh-filexfer-02" target="_blank">
draft-ietf-secsh-filexfer-02.txt</a>,
SSH File Transfer Protocol
@@ -116,9 +242,13 @@ do the same in libssh.
The OpenSSH project has defined some extensions to the protocol. We support some of
them like the statvfs calls in SFTP or the ssh-agent.
- <a href="http://api.libssh.org/rfc/PROTOCOL" target="_blank">
- <a href="https://api.libssh.org/rfc/PROTOCOL" target="_blank">
OpenSSH's deviations and extensions</a>
- <a href="http://api.libssh.org/rfc/PROTOCOL.agent" target="_blank">
OpenSSH's ssh-agent</a>
- <a href="https://api.libssh.org/rfc/PROTOCOL.certkeys" target="_blank">
OpenSSH's pubkey certificate authentication</a>
- <a href="https://api.libssh.org/rfc/PROTOCOL.chacha20poly1305" target="_blank">
chacha20-poly1305@openssh.com authenticated encryption mode</a>
- <a href="https://api.libssh.org/rfc/PROTOCOL.key" target="_blank">
OpenSSH private key format (openssh-key-v1)</a>
*/

67
doc/pkcs11.dox Normal file
View File

@@ -0,0 +1,67 @@
/**
@page libssh_tutor_pkcs11 Chapter 9: Authentication using PKCS #11 URIs
@section how_to How to use PKCS #11 URIs in libssh?
PKCS #11 is a Cryptographic Token Interface Standard that provides an API
to devices like smart cards that store cryptographic private information.
Such cryptographic devices are referenced as tokens. A mechanism through which
objects stored on the tokens can be uniquely identified is called PKCS #11 URI
(Uniform Resource Identifier) and is defined in RFC 7512
(https://tools.ietf.org/html/rfc7512).
Pre-requisites:
OpenSSL defines an abstract layer called the "engine" to achieve cryptographic
acceleration. The engine_pkcs11 module acts like an interface between the PKCS #11
modules and the OpenSSL engine.
To build and use libssh with PKCS #11 support:
1. Enable the cmake option: $ cmake -DWITH_PKCS11_URI=ON
2. Build with OpenSSL.
3. Install and configure engine_pkcs11 (https://github.com/OpenSC/libp11).
4. Plug in a working smart card or configure softhsm (https://www.opendnssec.org/softhsm).
The functions ssh_pki_import_pubkey_file() and ssh_pki_import_privkey_file() that
import the public and private keys from files respectively are now modified to support
PKCS #11 URIs. These functions automatically detect if the provided filename is a file path
or a PKCS #11 URI (when it begins with "pkcs11:"). If a PKCS #11 URI is detected,
the engine is loaded and initialized. Through the engine, the private/public key
corresponding to the PKCS #11 URI are loaded from the PKCS #11 device.
If you wish to authenticate using public keys on your own, follow the steps mentioned under
"Authentication with public keys" in Chapter 2 - A deeper insight into authentication.
The function pki_uri_import() is used to populate the public/private ssh_key from the
engine with PKCS #11 URIs as the look up.
Here is a minimalistic example of public key authentication using PKCS #11 URIs:
@code
int authenticate_pkcs11_URI(ssh_session session)
{
int rc;
char priv_uri[1042] = "pkcs11:token=my-token;object=my-object;type=private?pin-value=1234";
rc = ssh_options_set(session, SSH_OPTIONS_IDENTITY, priv_uri);
assert_int_equal(rc, SSH_OK)
rc = ssh_userauth_publickey_auto(session, NULL, NULL);
if (rc == SSH_AUTH_ERROR)
{
fprintf(stderr, "Authentication with PKCS #11 URIs failed: %s\n",
ssh_get_error(session));
return SSH_AUTH_ERROR;
}
return rc;
}
@endcode
@subsection Caveats
We recommend the users to provide a specific PKCS #11 URI so that it matches only a single slot in the engine.
If the engine discovers multiple slots that could potentially contain the private keys referenced
by the provided PKCS #11 URI, the engine will not try to authenticate.
*/

View File

@@ -2,7 +2,7 @@
@page libssh_tutor_scp Chapter 6: The SCP subsystem
@section scp_subsystem The SCP subsystem
The SCP subsystem has far less functionnality than the SFTP subsystem.
The SCP subsystem has far less functionality than the SFTP subsystem.
However, if you only need to copy files from and to the remote system,
it does its job.
@@ -39,14 +39,16 @@ int scp_write(ssh_session session)
(session, SSH_SCP_WRITE | SSH_SCP_RECURSIVE, ".");
if (scp == NULL)
{
fprintf(stderr, "Error allocating scp session: %s\n", ssh_get_error(session));
fprintf(stderr, "Error allocating scp session: %s\n",
ssh_get_error(session));
return SSH_ERROR;
}
rc = ssh_scp_init(scp);
if (rc != SSH_OK)
{
fprintf(stderr, "Error initializing scp session: %s\n", ssh_get_error(session));
fprintf(stderr, "Error initializing scp session: %s\n",
ssh_get_error(session));
ssh_scp_free(scp);
return rc;
}
@@ -71,14 +73,16 @@ int scp_read(ssh_session session)
(session, SSH_SCP_READ, "helloworld/helloworld.txt");
if (scp == NULL)
{
fprintf(stderr, "Error allocating scp session: %s\n", ssh_get_error(session));
fprintf(stderr, "Error allocating scp session: %s\n",
ssh_get_error(session));
return SSH_ERROR;
}
rc = ssh_scp_init(scp);
if (rc != SSH_OK)
{
fprintf(stderr, "Error initializing scp session: %s\n", ssh_get_error(session));
fprintf(stderr, "Error initializing scp session: %s\n",
ssh_get_error(session));
ssh_scp_free(scp);
return rc;
}
@@ -119,7 +123,8 @@ int scp_helloworld(ssh_session session, ssh_scp scp)
rc = ssh_scp_push_directory(scp, "helloworld", S_IRWXU);
if (rc != SSH_OK)
{
fprintf(stderr, "Can't create remote directory: %s\n", ssh_get_error(session));
fprintf(stderr, "Can't create remote directory: %s\n",
ssh_get_error(session));
return rc;
}
@@ -127,14 +132,16 @@ int scp_helloworld(ssh_session session, ssh_scp scp)
(scp, "helloworld.txt", length, S_IRUSR | S_IWUSR);
if (rc != SSH_OK)
{
fprintf(stderr, "Can't open remote file: %s\n", ssh_get_error(session));
fprintf(stderr, "Can't open remote file: %s\n",
ssh_get_error(session));
return rc;
}
rc = ssh_scp_write(scp, helloworld, length);
if (rc != SSH_OK)
{
fprintf(stderr, "Can't write to remote file: %s\n", ssh_get_error(session));
fprintf(stderr, "Can't write to remote file: %s\n",
ssh_get_error(session));
return rc;
}
@@ -151,7 +158,7 @@ Let's say you want to copy the following tree of files to the remote site:
+-- file1
+-- B --+
| +-- file2
-- A --+
-- A --+
| +-- file3
+-- C --+
+-- file4
@@ -195,14 +202,16 @@ int scp_receive(ssh_session session, ssh_scp scp)
rc = ssh_scp_pull_request(scp);
if (rc != SSH_SCP_REQUEST_NEWFILE)
{
fprintf(stderr, "Error receiving information about file: %s\n", ssh_get_error(session));
fprintf(stderr, "Error receiving information about file: %s\n",
ssh_get_error(session));
return SSH_ERROR;
}
size = ssh_scp_request_get_size(scp);
filename = strdup(ssh_scp_request_get_filename(scp));
mode = ssh_scp_request_get_permissions(scp);
printf("Receiving file %s, size %d, permisssions 0%o\n", filename, size, mode);
printf("Receiving file %s, size %d, permissions 0%o\n",
filename, size, mode);
free(filename);
buffer = malloc(size);
@@ -216,7 +225,8 @@ int scp_receive(ssh_session session, ssh_scp scp)
rc = ssh_scp_read(scp, buffer, size);
if (rc == SSH_ERROR)
{
fprintf(stderr, "Error receiving file data: %s\n", ssh_get_error(session));
fprintf(stderr, "Error receiving file data: %s\n",
ssh_get_error(session));
free(buffer);
return rc;
}
@@ -228,7 +238,8 @@ int scp_receive(ssh_session session, ssh_scp scp)
rc = ssh_scp_pull_request(scp);
if (rc != SSH_SCP_REQUEST_EOF)
{
fprintf(stderr, "Unexpected request: %s\n", ssh_get_error(session));
fprintf(stderr, "Unexpected request: %s\n",
ssh_get_error(session));
return SSH_ERROR;
}

View File

@@ -53,14 +53,16 @@ int sftp_helloworld(ssh_session session)
sftp = sftp_new(session);
if (sftp == NULL)
{
fprintf(stderr, "Error allocating SFTP session: %s\n", ssh_get_error(session));
fprintf(stderr, "Error allocating SFTP session: %s\n",
ssh_get_error(session));
return SSH_ERROR;
}
rc = sftp_init(sftp);
if (rc != SSH_OK)
{
fprintf(stderr, "Error initializing SFTP session: %s.\n", sftp_get_error(sftp));
fprintf(stderr, "Error initializing SFTP session: code %d.\n",
sftp_get_error(sftp));
sftp_free(sftp);
return rc;
}
@@ -98,7 +100,7 @@ Possible errors are:
@subsection sftp_mkdir Creating a directory
The function sftp_mkdir() tahes the "SFTP session" we juste created as
The function sftp_mkdir() takes the "SFTP session" we just created as
its first argument. It also needs the name of the file to create, and the
desired permissions. The permissions are the same as for the usual mkdir()
function. To get a comprehensive list of the available permissions, use the
@@ -121,7 +123,8 @@ int sftp_helloworld(ssh_session session, sftp_session sftp)
{
if (sftp_get_error(sftp) != SSH_FX_FILE_ALREADY_EXISTS)
{
fprintf(stderr, "Can't create directory: %s\n", ssh_get_error(session));
fprintf(stderr, "Can't create directory: %s\n",
ssh_get_error(session));
return rc;
}
}
@@ -167,17 +170,20 @@ int sftp_helloworld(ssh_session session, sftp_session sftp)
...
file = sftp_open(sftp, "helloworld/helloworld.txt", access_type, S_IRWXU);
file = sftp_open(sftp, "helloworld/helloworld.txt",
access_type, S_IRWXU);
if (file == NULL)
{
fprintf(stderr, "Can't open file for writing: %s\n", ssh_get_error(session));
fprintf(stderr, "Can't open file for writing: %s\n",
ssh_get_error(session));
return SSH_ERROR;
}
nwritten = sftp_write(file, helloworld, length);
if (nwritten != length)
{
fprintf(stderr, "Can't write data to file: %s\n", ssh_get_error(session));
fprintf(stderr, "Can't write data to file: %s\n",
ssh_get_error(session));
sftp_close(file);
return SSH_ERROR;
}
@@ -185,7 +191,8 @@ int sftp_helloworld(ssh_session session, sftp_session sftp)
rc = sftp_close(file);
if (rc != SSH_OK)
{
fprintf(stderr, "Can't close the written file: %s\n", ssh_get_error(session));
fprintf(stderr, "Can't close the written file: %s\n",
ssh_get_error(session));
return rc;
}
@@ -203,48 +210,63 @@ results to come.
Synchronous read is done with sftp_read().
The following example prints the contents of remote file "/etc/profile". For
each 1024 bytes of information read, it waits until the end of the read operation:
Files are normally transferred in chunks. A good chunk size is 16 KB. The following
example transfers the remote file "/etc/profile" in 16 KB chunks. For each chunk we
request, sftp_read blocks till the data has been received:
@code
// Good chunk size
#define MAX_XFER_BUF_SIZE 16384
int sftp_read_sync(ssh_session session, sftp_session sftp)
{
int access_type;
sftp_file file;
char buffer[1024];
int nbytes, rc;
char buffer[MAX_XFER_BUF_SIZE];
int nbytes, nwritten, rc;
int fd;
access_type = O_RDONLY;
file = sftp_open(sftp, "/etc/profile", access_type, 0);
if (file == NULL)
{
fprintf(stderr, "Can't open file for reading: %s\n", ssh_get_error(session));
return SSH_ERROR;
}
nbytes = sftp_read(file, buffer, sizeof(buffer));
while (nbytes > 0)
{
if (write(1, buffer, nbytes) != nbytes)
{
sftp_close(file);
file = sftp_open(sftp, "/etc/profile",
access_type, 0);
if (file == NULL) {
fprintf(stderr, "Can't open file for reading: %s\n",
ssh_get_error(session));
return SSH_ERROR;
}
nbytes = sftp_read(file, buffer, sizeof(buffer));
}
if (nbytes < 0)
{
fprintf(stderr, "Error while reading file: %s\n", ssh_get_error(session));
sftp_close(file);
return SSH_ERROR;
fd = open("/path/to/profile", O_CREAT);
if (fd < 0) {
fprintf(stderr, "Can't open file for writing: %s\n",
strerror(errno));
return SSH_ERROR;
}
for (;;) {
nbytes = sftp_read(file, buffer, sizeof(buffer));
if (nbytes == 0) {
break; // EOF
} else if (nbytes < 0) {
fprintf(stderr, "Error while reading file: %s\n",
ssh_get_error(session));
sftp_close(file);
return SSH_ERROR;
}
nwritten = write(fd, buffer, nbytes);
if (nwritten != nbytes) {
fprintf(stderr, "Error writing: %s\n",
strerror(errno));
sftp_close(file);
return SSH_ERROR;
}
}
rc = sftp_close(file);
if (rc != SSH_OK)
{
fprintf(stderr, "Can't close the read file: %s\n", ssh_get_error(session));
return rc;
if (rc != SSH_OK) {
fprintf(stderr, "Can't close the read file: %s\n",
ssh_get_error(session));
return rc;
}
return SSH_OK;
@@ -260,24 +282,28 @@ sftp_async_read() waits for the data to come. To open a file in nonblocking mode
call sftp_file_set_nonblocking() right after you opened it. Default is blocking mode.
The example below reads a very big file in asynchronous, nonblocking, mode. Each
time the data are not ready yet, a counter is incrementer.
time the data is not ready yet, a counter is incremented.
@code
// Good chunk size
#define MAX_XFER_BUF_SIZE 16384
int sftp_read_async(ssh_session session, sftp_session sftp)
{
int access_type;
sftp_file file;
char buffer[1024];
char buffer[MAX_XFER_BUF_SIZE];
int async_request;
int nbytes;
long counter;
int rc;
access_type = O_RDONLY;
file = sftp_open(sftp, "some_very_big_file", access_type, 0);
if (file == NULL)
{
fprintf(stderr, "Can't open file for reading: %s\n", ssh_get_error(session));
file = sftp_open(sftp, "some_very_big_file",
access_type, 0);
if (file == NULL) {
fprintf(stderr, "Can't open file for reading: %s\n",
ssh_get_error(session));
return SSH_ERROR;
}
sftp_file_set_nonblocking(file);
@@ -285,26 +311,33 @@ int sftp_read_async(ssh_session session, sftp_session sftp)
async_request = sftp_async_read_begin(file, sizeof(buffer));
counter = 0L;
usleep(10000);
if (async_request >= 0)
nbytes = sftp_async_read(file, buffer, sizeof(buffer), async_request);
else nbytes = -1;
while (nbytes > 0 || nbytes == SSH_AGAIN)
{
if (nbytes > 0)
{
write(1, buffer, nbytes);
async_request = sftp_async_read_begin(file, sizeof(buffer));
}
else counter++;
usleep(10000);
if (async_request >= 0)
nbytes = sftp_async_read(file, buffer, sizeof(buffer), async_request);
else nbytes = -1;
if (async_request >= 0) {
nbytes = sftp_async_read(file, buffer, sizeof(buffer),
async_request);
} else {
nbytes = -1;
}
if (nbytes < 0)
{
fprintf(stderr, "Error while reading file: %s\n", ssh_get_error(session));
while (nbytes > 0 || nbytes == SSH_AGAIN) {
if (nbytes > 0) {
write(1, buffer, nbytes);
async_request = sftp_async_read_begin(file, sizeof(buffer));
} else {
counter++;
}
usleep(10000);
if (async_request >= 0) {
nbytes = sftp_async_read(file, buffer, sizeof(buffer),
async_request);
} else {
nbytes = -1;
}
}
if (nbytes < 0) {
fprintf(stderr, "Error while reading file: %s\n",
ssh_get_error(session));
sftp_close(file);
return SSH_ERROR;
}
@@ -312,9 +345,9 @@ int sftp_read_async(ssh_session session, sftp_session sftp)
printf("The counter has reached value: %ld\n", counter);
rc = sftp_close(file);
if (rc != SSH_OK)
{
fprintf(stderr, "Can't close the read file: %s\n", ssh_get_error(session));
if (rc != SSH_OK) {
fprintf(stderr, "Can't close the read file: %s\n",
ssh_get_error(session));
return rc;
}
@@ -325,19 +358,19 @@ int sftp_read_async(ssh_session session, sftp_session sftp)
@subsection sftp_ls Listing the contents of a directory
The functions sftp_opendir(), sftp_readdir(), sftp_dir_eof(),
and sftp_closedir() enable to list the contents of a directory.
and sftp_closedir() enable to list the contents of a directory.
They use a new handle_type, "sftp_dir", which gives access to the
directory being read.
In addition, sftp_readdir() returns a "sftp_attributes" which is a pointer
to a structure with informations about a directory entry:
to a structure with information about a directory entry:
- name: the name of the file or directory
- size: its size in bytes
- etc.
sftp_readdir() might return NULL under two conditions:
- when the end of the directory has been met
- when an error occured
- when an error occurred
To tell the difference, call sftp_dir_eof().
@@ -356,15 +389,16 @@ int sftp_list_dir(ssh_session session, sftp_session sftp)
dir = sftp_opendir(sftp, "/var/log");
if (!dir)
{
fprintf(stderr, "Directory not opened: %s\n", ssh_get_error(session));
fprintf(stderr, "Directory not opened: %s\n",
ssh_get_error(session));
return SSH_ERROR;
}
printf("Name Size Perms Owner\tGroup\n");
printf("Name Size Perms Owner\tGroup\n");
while ((attributes = sftp_readdir(sftp, dir)) != NULL)
{
printf("%-22s %10llu %.8o %s(%d)\t%s(%d)\n",
printf("%-20s %10llu %.8o %s(%d)\t%s(%d)\n",
attributes->name,
(long long unsigned int) attributes->size,
attributes->permissions,
@@ -378,7 +412,8 @@ int sftp_list_dir(ssh_session session, sftp_session sftp)
if (!sftp_dir_eof(dir))
{
fprintf(stderr, "Can't list directory: %s\n", ssh_get_error(session));
fprintf(stderr, "Can't list directory: %s\n",
ssh_get_error(session));
sftp_closedir(dir);
return SSH_ERROR;
}
@@ -386,7 +421,8 @@ int sftp_list_dir(ssh_session session, sftp_session sftp)
rc = sftp_closedir(dir);
if (rc != SSH_OK)
{
fprintf(stderr, "Can't close directory: %s\n", ssh_get_error(session));
fprintf(stderr, "Can't close directory: %s\n",
ssh_get_error(session));
return rc;
}
}

View File

@@ -209,7 +209,7 @@ int interactive_shell_session(ssh_channel channel)
Of course, this is a poor terminal emulator, since the echo from the keys
pressed should not be done locally, but should be done by the remote side.
Also, user's input should not be sent once "Enter" key is pressed, but
Also, user's input should not be sent once "Enter" key is pressed, but
immediately after each key is pressed. This can be accomplished
by setting the local terminal to "raw" mode with the cfmakeraw(3) function.
cfmakeraw() is a standard function under Linux, on other systems you can
@@ -245,13 +245,13 @@ provide a more elegant way to wait for data coming from many sources.
The functions ssh_select() and ssh_channel_select() remind of the standard
UNIX select(2) function. The idea is to wait for "something" to happen:
incoming data to be read, outcoming data to block, or an exception to
incoming data to be read, outgoing data to block, or an exception to
occur. Both these functions do a "passive wait", i.e. you can safely use
them repeatedly in a loop, it will not consume exaggerate processor time
and make your computer unresponsive. It is quite common to use these
functions in your application's main loop.
The difference between ssh_select() and ssh_channel_select() is that
The difference between ssh_select() and ssh_channel_select() is that
ssh_channel_select() is simpler, but allows you only to watch SSH channels.
ssh_select() is more complete and enables watching regular file descriptors
as well, in the same function call.
@@ -320,18 +320,36 @@ int interactive_shell_session(ssh_session session, ssh_channel channel)
If your remote application is graphical, you can forward the X11 protocol to
your local computer.
To do that, you first declare that you accept X11 connections with
ssh_channel_accept_x11(). Then you create the forwarding tunnel for
the X11 protocol with ssh_channel_request_x11().
To do that, you first declare a callback to manage channel_open_request_x11_function.
Then you create the forwarding tunnel for the X11 protocol with ssh_channel_request_x11().
The following code performs channel initialization and shell session
opening, and handles a parallel X11 connection:
@code
#include <libssh/callbacks.h>
ssh_channel x11channel = NULL;
ssh_channel x11_open_request_callback(ssh_session session, const char *shost, int sport, void *userdata)
{
x11channel = ssh_channel_new(session);
return x11channel;
}
int interactive_shell_session(ssh_channel channel)
{
int rc;
ssh_channel x11channel;
struct ssh_callbacks_struct cb =
{
.channel_open_request_x11_function = x11_open_request_callback,
.userdata = NULL
};
ssh_callbacks_init(&cb);
rc = ssh_set_callbacks(session, &cb);
if (rc != SSH_OK) return rc;
rc = ssh_channel_request_pty(channel);
if (rc != SSH_OK) return rc;
@@ -350,12 +368,15 @@ int interactive_shell_session(ssh_channel channel)
}
@endcode
Don't forget to set the $DISPLAY environment variable on the remote
Don't forget to check the $DISPLAY environment variable on the remote
side, or the remote applications won't try using the X11 tunnel:
@code
$ export DISPLAY=:0
$ echo $DISPLAY
localhost:10.0
$ xclock &
@endcode
See an implementation example at https://gitlab.com/libssh/libssh-mirror/-/tree/master/examples/ssh_X11_client.c for details.
*/

21
doc/that_style/LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Jan-Lukas Wynen
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

22
doc/that_style/README.md Normal file
View File

@@ -0,0 +1,22 @@
# that style
A plain, more modern HTML style for Doxygen
## Requirements
- Doxygen (tested with version 1.8.13)
- *optional*: a sass/scss compiler if you want to modify the style
## Simple usage
Tell Doxygen about the files for that style as shown in [doxyfile.conf](doxyfile.conf). You might need to adjust the
paths depending on where you installed that style.
When you run Doxygen, all files are copied into to generated HTML folder. So you don't need to keep the originals around
unless you want to re-generate the documentation.
## Advanced
that style uses a custom javascript to hack some nice stripes into some tables. It has to be loaded from HTML. Hence you need
to use the provided custom header. Since its default content may change when Doxygen is updated, there might be syntax error in
the generated HTML. If this is the case, you can remove the custom header (adjust your doxyfile.conf). This has no
disadvantages other than removing the stripes.
[that_style.css](that_style.css) was generated from the scss files in the folder [sass](sass). If you want to change the style,
use those files in order to have better control. For instance, you can easily change most colors by modifying the variables
in the beginning of [that_style.scss](sass/that_style.scss).

View File

@@ -0,0 +1,56 @@
<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen $doxygenversion"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<!--BEGIN PROJECT_NAME--><title>$projectname: $title</title><!--END PROJECT_NAME-->
<!--BEGIN !PROJECT_NAME--><title>$title</title><!--END !PROJECT_NAME-->
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="$relpath^jquery.js"></script>
<script type="text/javascript" src="$relpath^dynsections.js"></script>
$treeview
$search
$mathjax
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
<script src="$relpath^striped_bg.js"></script>
$extrastylesheet
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<!--BEGIN TITLEAREA-->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr style="height: 56px;">
<!--BEGIN PROJECT_LOGO-->
<td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo"/></td>
<!--END PROJECT_LOGO-->
<!--BEGIN PROJECT_NAME-->
<td id="projectalign" style="padding-left: 0.5em;">
<div id="projectname">$projectname
<!--BEGIN PROJECT_NUMBER-->&#160;<span id="projectnumber">$projectnumber</span><!--END PROJECT_NUMBER-->
</div>
<!--BEGIN PROJECT_BRIEF--><div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF-->
</td>
<!--END PROJECT_NAME-->
<!--BEGIN !PROJECT_NAME-->
<!--BEGIN PROJECT_BRIEF-->
<td style="padding-left: 0.5em;">
<div id="projectbrief">$projectbrief</div>
</td>
<!--END PROJECT_BRIEF-->
<!--END !PROJECT_NAME-->
<!--BEGIN DISABLE_INDEX-->
<!--BEGIN SEARCHENGINE-->
<td>$searchbox</td>
<!--END SEARCHENGINE-->
<!--END DISABLE_INDEX-->
</tr>
</tbody>
</table>
</div>
<!--END TITLEAREA-->
<!-- end header part -->

View File

@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="24"
height="22"
viewBox="0 0 6.3499999 5.8208335"
version="1.1"
id="svg8"
sodipodi:docname="doc.svg"
inkscape:version="0.92.1 r">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
inkscape:cx="11.139212"
inkscape:cy="14.811193"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:showpageshadow="false"
units="px"
inkscape:window-width="2560"
inkscape:window-height="1357"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-291.17915)">
<path
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#4d4d4d;stroke-width:0.26458329;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="M 3.315043,291.8406 H 1.4552083 v 4.49792 h 3.1749999 v -3.10055 z"
id="path5095"
inkscape:connector-curvature="0" />
<path
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#4d4d4d;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 3.1837239,291.84114 v 1.71186 h 1.4472656 v -0.31418 H 3.4473958 v -1.39768 z"
id="path5128"
inkscape:connector-curvature="0" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect5132"
width="2.1166668"
height="0.26458332"
x="1.8520833"
y="293.82498" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect5136"
width="1.0583334"
height="0.26458332"
x="1.8520832"
y="294.35416" />
<rect
y="294.88333"
x="1.8520832"
height="0.26458332"
width="1.8520833"
id="rect5138"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:normal;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4543"
width="1.5875"
height="0.26458332"
x="1.8520832"
y="295.41248" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 6.5 KiB

View File

@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="24"
height="22"
viewBox="0 0 6.3499998 5.8208335"
version="1.1"
id="svg8"
inkscape:version="0.92.1 r"
sodipodi:docname="folderclosed.svg"
inkscape:export-filename="/home/jl/Prog/doxygen_style/folderclosed.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="51.113139"
inkscape:cx="7.7057751"
inkscape:cy="12.584171"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:snap-global="false"
units="px"
inkscape:showpageshadow="false"
inkscape:window-width="2560"
inkscape:window-height="1357"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:measure-start="0,0"
inkscape:measure-end="0,0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-291.17915)">
<path
inkscape:connector-curvature="0"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.26458332;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;paint-order:stroke fill markers;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 0.52916667,292.2374 -0.26458334,0.52925 v 3.43958 H 4.7625001 v -3.43958 H 2.38125 L 2.1166667,292.2374 Z"
id="rect4498"
sodipodi:nodetypes="cccccccc" />
<path
inkscape:connector-curvature="0"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#cccccc;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.66145831;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="M 2.9104167,292.76665 2.38125,293.56034 H 0.26458333 v 0.26464 H 2.38125 l 0.5291667,-0.79375 h 1.8520834 v -0.26458 z"
id="rect4500"
sodipodi:nodetypes="ccccccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="24"
height="22"
viewBox="0 0 6.3499998 5.8208335"
version="1.1"
id="svg8"
inkscape:version="0.92.1 r"
sodipodi:docname="folderopen.svg"
inkscape:export-filename="/home/jl/Prog/doxygen_style/folderopen.png"
inkscape:export-xdpi="96"
inkscape:export-ydpi="96">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="43.725861"
inkscape:cx="8.2043861"
inkscape:cy="13.464183"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
inkscape:snap-global="false"
units="px"
inkscape:showpageshadow="false"
inkscape:window-width="2560"
inkscape:window-height="1357"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:measure-start="0,0"
inkscape:measure-end="0,0" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title />
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-291.17915)">
<path
inkscape:connector-curvature="0"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.66145831;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 0.52916667,292.23748 -0.26458334,0.52917 v 3.43958 H 4.762461 l 7.8e-5,-3.43958 H 2.38125 l -0.2645833,-0.52917 z"
id="path5228"
sodipodi:nodetypes="cccccccc" />
<path
inkscape:connector-curvature="0"
id="path5279"
d="M 1.0583333,293.5604 H 5.55625 L 4.7625,296.20603 H 0.26458333 Z"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ececec;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.66145831;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
sodipodi:nodetypes="ccccc" />
<path
sodipodi:nodetypes="ccccccc"
inkscape:connector-curvature="0"
id="path5234"
d="M 1.0583333,294.35415 H 3.175 l 0.5291667,-0.52917 H 5.55625 L 4.7625,296.20603 H 0.26458333 Z"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#4d4d4d;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.66145831;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="22"
height="22"
viewBox="0 0 5.8208332 5.8208335"
version="1.1"
id="svg8"
inkscape:version="0.92.1 r"
sodipodi:docname="mag_glass.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
inkscape:cx="8.961936"
inkscape:cy="10.205344"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:showpageshadow="false"
inkscape:snap-bbox="false"
inkscape:bbox-nodes="true"
inkscape:window-width="2560"
inkscape:window-height="1357"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1"
inkscape:snap-global="false" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-291.17915)">
<path
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#333333;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.99999988;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="M 6.9101562 2.4082031 C 3.1105656 2.4082031 -5.9211895e-16 5.5081643 0 9.3027344 C 0 13.097342 3.1105656 16.197266 6.9101562 16.197266 C 8.2869348 16.197266 9.5698699 15.787508 10.650391 15.087891 L 15.162109 19.587891 L 16.636719 18.115234 L 12.214844 13.707031 C 13.214837 12.510659 13.818359 10.974238 13.818359 9.3027344 C 13.818359 5.5081643 10.709747 2.4082031 6.9101562 2.4082031 z M 6.9101562 4.9101562 C 9.3624717 4.9101562 11.324219 6.8631249 11.324219 9.3027344 C 11.324219 11.742382 9.3624717 13.695312 6.9101562 13.695312 C 4.4578408 13.695312 2.5019531 11.742382 2.5019531 9.3027344 C 2.5019531 6.8631249 4.4578408 4.9101562 6.9101562 4.9101562 z "
transform="matrix(0.26458333,0,0,0.26458333,0,291.17915)"
id="rect4524" />
<path
transform="matrix(0.99422295,0,0,0.68955299,-0.83134947,91.755588)"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#333333;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.63466448;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
inkscape:transform-center-y="0.25905895"
d="m 5.6074138,294.49889 -1.0836583,-1.87695 2.1673165,0 z"
id="path4491" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="10.53333"
height="32"
viewBox="0 0 9.8749964 30"
id="svg2"
version="1.1"
inkscape:version="0.92.1 r"
sodipodi:docname="nav_edge_inter.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
inkscape:cx="8.6823304"
inkscape:cy="16.225639"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:snap-bbox="true"
inkscape:bbox-paths="false"
inkscape:bbox-nodes="true"
inkscape:snap-bbox-edge-midpoints="true"
inkscape:object-nodes="true"
inkscape:window-width="2560"
inkscape:window-height="1357"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1022.3622)">
<path
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 0,1022.3622 v 15 15 l 8,-15 z"
id="path4143"
inkscape:connector-curvature="0" />
<path
style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#333333;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.9375px;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 1.2910156,1022.3496 -0.82421872,0.4473 7.87890622,14.5527 -7.87890622,14.5527 0.82421872,0.4473 8.1210938,-15 z"
id="path5240"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.8 KiB

View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="8.5333338"
height="32"
viewBox="0 0 8.0000001 30"
id="svg2"
version="1.1"
inkscape:version="0.92.1 r"
sodipodi:docname="nav_edge_left.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
inkscape:cx="5.3721385"
inkscape:cy="14.16429"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:snap-bbox="true"
inkscape:bbox-paths="false"
inkscape:bbox-nodes="false"
inkscape:snap-bbox-edge-midpoints="false"
inkscape:object-nodes="true"
inkscape:window-width="2560"
inkscape:window-height="1357"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1022.3622)">
<path
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:6;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="M 0 0 L 0 32 L 8.5332031 16 L 0 0 z "
transform="matrix(0.93749998,0,0,0.93749998,0,1022.3622)"
id="rect4586" />
<path
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 0,1022.3622 v 15 15 l 8,-15 z"
id="path4143"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="8"
height="30"
viewBox="0 0 8.0000001 30"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="nav_edge.svg">
<defs
id="defs4" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
inkscape:cx="5.3721385"
inkscape:cy="14.16429"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:snap-bbox="true"
inkscape:bbox-paths="false"
inkscape:bbox-nodes="false"
inkscape:snap-bbox-edge-midpoints="false"
inkscape:object-nodes="true"
inkscape:window-width="2560"
inkscape:window-height="1357"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-1022.3622)">
<path
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:none;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 0,1022.3622 0,15 0,15 8,-15 -8,-15 z"
id="path4143"
inkscape:connector-curvature="0" />
<path
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
d="m 1e-8,1022.3622 7.99999999,15 0,-15 -8,0 z m 7.99999999,15 -8,15 8,0 0,-15 z"
id="rect4136"
inkscape:connector-curvature="0" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="6"
height="9"
viewBox="0 0 1.5875 2.3812501"
version="1.1"
id="svg8"
inkscape:version="0.92.1 r"
sodipodi:docname="splitbar_handle.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
inkscape:cx="8.7681488"
inkscape:cy="-2.7929517"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
showgrid="false"
units="px"
inkscape:showpageshadow="false"
showguides="false"
inkscape:window-width="2560"
inkscape:window-height="1357"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1">
<inkscape:grid
type="xygrid"
id="grid4487" />
</sodipodi:namedview>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-294.61873)">
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4485"
width="0.26458335"
height="0.26458332"
x="0.26458332"
y="294.8833" />
<rect
y="294.8833"
x="1.0583333"
height="0.26458332"
width="0.26458335"
id="rect4489"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<rect
y="295.41248"
x="0.26458329"
height="0.26458332"
width="0.26458335"
id="rect4491"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4493"
width="0.26458335"
height="0.26458332"
x="1.0583333"
y="295.41248" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4495"
width="0.26458335"
height="0.26458332"
x="0.26458332"
y="295.94165" />
<rect
y="295.94165"
x="1.0583333"
height="0.26458332"
width="0.26458335"
id="rect4497"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<rect
y="296.47079"
x="0.26458329"
height="0.26458332"
width="0.26458335"
id="rect4499"
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<rect
style="color:#000000;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.52916664;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate"
id="rect4501"
width="0.26458335"
height="0.26458332"
x="1.0583333"
y="296.47079" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 483 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 488 B

View File

@@ -0,0 +1,32 @@
// Adds extra CSS classes "even" and "odd" to .memberdecls to allow
// striped backgrounds.
function MemberDeclsStriper () {
var counter = 0;
this.stripe = function() {
$(".memberdecls tbody").children().each(function(i) {
// reset counter at every heading -> always start with even
if ($(this).is(".heading")) {
counter = 0;
}
// add extra classes
if (counter % 2 == 1) {
$(this).addClass("odd");
}
else {
$(this).addClass("even");
}
// advance counter at every separator
// this is the only way to reliably detect which table rows belong together
if ($(this).is('[class^="separator"]')) {
counter++;
}
});
}
}
// execute the function
$(document).ready(new MemberDeclsStriper().stripe);

File diff suppressed because it is too large Load Diff

View File

@@ -3,63 +3,50 @@
@section threads_with_libssh How to use libssh with threads
libssh may be used in multithreaded applications, but under several conditions :
- Threading must be initialized during the initialization of libssh. This
initialization must be done outside of any threading context.
- If pthreads is being used by your application (or your framework's backend),
you must link with libssh_threads_pthread dynamic library and initialize
threading with the ssh_threads_pthreads threading object.
- If an other threading library is being used by your application, you must
implement all the methods of the ssh_threads_callbacks_struct structure
and initialize libssh with it.
- Your system must support libpthread or, in Windows environment,
CriticalSection based mutex control.
- Since version 0.8.0, threads initialization is called automatically in the
library constructor if libssh is dynamically linked. This means it is no
longer necessary to call ssh_init()/ssh_finalize().
- If libssh is statically linked, threading must be initialized by calling
ssh_init() before using any of libssh provided functions. This initialization
must be done outside of any threading context. Don't forget to call
ssh_finalize() to avoid memory leak
- At all times, you may use different sessions inside threads, make parallel
connections, read/write on different sessions and so on. You can use a
single session in several channels at the same time. This will lead to
internal state corruption. This limitation is being worked out and will
maybe disappear later.
connections, read/write on different sessions and so on. You *cannot* use a
single session (or channels for a single session) in several threads at the same
time. This will most likely lead to internal state corruption. This limitation is
being worked out and will maybe disappear later.
@subsection threads_init Initialization of threads
To initialize threading, you must first select the threading model you want to
use, using ssh_threads_set_callbacks(), then call ssh_init().
Since version 0.8.0, it is no longer necessary to call ssh_init()/ssh_finalize()
if libssh is dynamically linked.
@code
#include <libssh/callbacks.h>
...
ssh_threads_set_callbacks(ssh_threads_noop);
ssh_init();
@endcode
ssh_threads_noop is the threading structure that does nothing. It's the
threading callbacks being used by default when you're not using threading.
If libssh is statically linked, call ssh_init() before using any of libssh
provided functions.
@subsection threads_pthread Using libpthread with libssh
If your application is using libpthread, you may simply use the libpthread
threading backend:
Since version 0.8.0, libpthread is the default threads library used by libssh.
@code
#include <libssh/callbacks.h>
...
ssh_threads_set_callbacks(ssh_threads_pthread);
ssh_init();
@endcode
However, you must be sure to link with the library ssh_threads_pthread. If
you're using gcc, you must use the commandline
@code
gcc -o output input.c -lssh -lssh_threads_pthread
@endcode
To use libpthread, simply link it to you application.
If you are using libssh statically linked, don't forget to call ssh_init()
before using any of libssh provided functions (and ssh_finalize() in the end).
@subsection threads_other Using another threading library
You must find your way in the ssh_threads_callbacks_struct structure. You must
implement the following methods :
- mutex_lock
- mutex_unlock
- mutex_init
- mutex_destroy
- thread_id
Since version 0.8.0, libssh does not support custom threading libraries.
The change makes sense since the newer versions for libcrypto (OpenSSL) and
libgcrypt don't support custom threading libraries.
The default used threading library is libpthread.
Alternatively, in Windows environment, CriticalSection based mutex control can
be used.
If your system does not support libpthread nor CriticalSection based mutex
control, unfortunately, you cannot use libssh in multithreaded scenarios.
Good luck !
*/

View File

@@ -6,43 +6,94 @@ set(examples_SRCS
connect_ssh.c
)
include_directories(
${LIBSSH_PUBLIC_INCLUDE_DIRS}
${CMAKE_BINARY_DIR}
)
include_directories(${libssh_BINARY_DIR}/include ${libssh_BINARY_DIR})
if (LINUX)
if (ARGP_INCLUDE_DIR)
include_directories(${ARGP_INCLUDE_DIR})
endif()
if (UNIX AND NOT WIN32)
add_executable(libssh_scp libssh_scp.c ${examples_SRCS})
target_link_libraries(libssh_scp ${LIBSSH_SHARED_LIBRARY})
target_compile_options(libssh_scp PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(libssh_scp ssh::ssh)
add_executable(scp_download scp_download.c ${examples_SRCS})
target_link_libraries(scp_download ${LIBSSH_SHARED_LIBRARY})
add_executable(samplessh sample.c ${examples_SRCS})
target_link_libraries(samplessh ${LIBSSH_SHARED_LIBRARY})
target_compile_options(scp_download PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(scp_download ssh::ssh)
add_executable(sshnetcat sshnetcat.c ${examples_SRCS})
target_link_libraries(sshnetcat ${LIBSSH_SHARED_LIBRARY})
target_compile_options(sshnetcat PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(sshnetcat ssh::ssh)
if (WITH_SFTP)
add_executable(samplesftp samplesftp.c ${examples_SRCS})
target_link_libraries(samplesftp ${LIBSSH_SHARED_LIBRARY})
target_compile_options(samplesftp PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(samplesftp ssh::ssh)
endif (WITH_SFTP)
if (WITH_SERVER)
add_executable(samplesshd samplesshd.c)
target_link_libraries(samplesshd ${LIBSSH_SHARED_LIBRARY})
endif (WITH_SERVER)
endif (LINUX)
add_executable(ssh-client ssh_client.c ${examples_SRCS})
target_compile_options(ssh-client PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(ssh-client ssh::ssh)
add_executable(ssh-X11-client ssh_X11_client.c ${examples_SRCS})
target_compile_options(ssh-X11-client PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(ssh-X11-client ssh::ssh)
if (WITH_SERVER AND (ARGP_LIBRARY OR HAVE_ARGP_H))
if (HAVE_LIBUTIL)
add_executable(ssh_server_fork ssh_server.c)
target_compile_options(ssh_server_fork PRIVATE ${DEFAULT_C_COMPILE_FLAGS} -DWITH_FORK)
target_link_libraries(ssh_server_fork ssh::ssh ${ARGP_LIBRARY} util)
add_executable(ssh_server_pthread ssh_server.c)
target_compile_options(ssh_server_pthread PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(ssh_server_pthread ssh::ssh ${ARGP_LIBRARY} pthread util)
endif (HAVE_LIBUTIL)
if (WITH_GSSAPI AND GSSAPI_FOUND)
add_executable(proxy proxy.c)
target_compile_options(proxy PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(proxy ssh::ssh ${ARGP_LIBRARY})
add_executable(sshd_direct-tcpip sshd_direct-tcpip.c)
target_compile_options(sshd_direct-tcpip PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(sshd_direct-tcpip ssh::ssh ${ARGP_LIBRARY})
endif (WITH_GSSAPI AND GSSAPI_FOUND)
add_executable(samplesshd-kbdint samplesshd-kbdint.c)
target_compile_options(samplesshd-kbdint PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(samplesshd-kbdint ssh::ssh ${ARGP_LIBRARY})
add_executable(keygen2 keygen2.c ${examples_SRCS})
target_compile_options(keygen2 PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(keygen2 ssh::ssh ${ARGP_LIBRARY})
endif()
endif (UNIX AND NOT WIN32)
if (WITH_SERVER)
add_executable(samplesshd-cb samplesshd-cb.c)
target_compile_options(samplesshd-cb PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(samplesshd-cb ssh::ssh)
if (ARGP_LIBRARY OR HAVE_ARGP_H)
target_link_libraries(samplesshd-cb ${ARGP_LIBRARY})
endif(ARGP_LIBRARY OR HAVE_ARGP_H)
endif()
add_executable(exec exec.c ${examples_SRCS})
target_link_libraries(exec ${LIBSSH_SHARED_LIBRARY})
target_compile_options(exec PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(exec ssh::ssh)
add_executable(senddata senddata.c ${examples_SRCS})
target_link_libraries(senddata ${LIBSSH_SHARED_LIBRARY})
target_compile_options(senddata PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(senddata ssh::ssh)
add_executable(keygen keygen.c)
target_compile_options(keygen PRIVATE ${DEFAULT_C_COMPILE_FLAGS})
target_link_libraries(keygen ssh::ssh)
add_executable(libsshpp libsshpp.cpp)
target_link_libraries(libsshpp ${LIBSSH_SHARED_LIBRARY})
target_link_libraries(libsshpp ssh::ssh)
add_executable(libsshpp_noexcept libsshpp_noexcept.cpp)
target_link_libraries(libsshpp_noexcept ${LIBSSH_SHARED_LIBRARY})
target_link_libraries(libsshpp_noexcept ssh::ssh)

View File

@@ -24,7 +24,8 @@ clients must be made or how a client should react.
#include <libssh/libssh.h>
#include "examples_common.h"
int authenticate_kbdint(ssh_session session, const char *password) {
int authenticate_kbdint(ssh_session session, const char *password)
{
int err;
err = ssh_userauth_kbdint(session, NULL, NULL);
@@ -86,7 +87,9 @@ int authenticate_kbdint(ssh_session session, const char *password) {
}
answer = buffer;
}
if (ssh_userauth_kbdint_setanswer(session, i, answer) < 0) {
err = ssh_userauth_kbdint_setanswer(session, i, answer);
memset(buffer, 0, sizeof(buffer));
if (err < 0) {
return SSH_AUTH_ERROR;
}
}
@@ -97,68 +100,142 @@ int authenticate_kbdint(ssh_session session, const char *password) {
return err;
}
static void error(ssh_session session){
fprintf(stderr,"Authentication failed: %s\n",ssh_get_error(session));
}
static int auth_keyfile(ssh_session session, char* keyfile)
{
ssh_key key = NULL;
char pubkey[132] = {0}; // +".pub"
int rc;
int authenticate_console(ssh_session session){
int rc;
int method;
char password[128] = {0};
char *banner;
snprintf(pubkey, sizeof(pubkey), "%s.pub", keyfile);
rc = ssh_pki_import_pubkey_file( pubkey, &key);
if (rc != SSH_OK)
return SSH_AUTH_DENIED;
rc = ssh_userauth_try_publickey(session, NULL, key);
ssh_key_free(key);
if (rc!=SSH_AUTH_SUCCESS)
return SSH_AUTH_DENIED;
rc = ssh_pki_import_privkey_file(keyfile, NULL, NULL, NULL, &key);
if (rc != SSH_OK)
return SSH_AUTH_DENIED;
rc = ssh_userauth_publickey(session, NULL, key);
ssh_key_free(key);
return rc;
}
static void error(ssh_session session)
{
fprintf(stderr,"Authentication failed: %s\n",ssh_get_error(session));
}
int authenticate_console(ssh_session session)
{
int rc;
int method;
char password[128] = {0};
char *banner;
// Try to authenticate
rc = ssh_userauth_none(session, NULL);
if (rc == SSH_AUTH_ERROR) {
error(session);
return rc;
}
method = ssh_userauth_list(session, NULL);
while (rc != SSH_AUTH_SUCCESS) {
if (method & SSH_AUTH_METHOD_GSSAPI_MIC){
rc = ssh_userauth_gssapi(session);
if(rc == SSH_AUTH_ERROR) {
error(session);
return rc;
} else if (rc == SSH_AUTH_SUCCESS) {
break;
}
}
// Try to authenticate with public key first
if (method & SSH_AUTH_METHOD_PUBLICKEY) {
rc = ssh_userauth_publickey_auto(session, NULL, NULL);
if (rc == SSH_AUTH_ERROR) {
error(session);
return rc;
} else if (rc == SSH_AUTH_SUCCESS) {
break;
}
}
{
char buffer[128] = {0};
char *p = NULL;
printf("Automatic pubkey failed. "
"Do you want to try a specific key? (y/n)\n");
if (fgets(buffer, sizeof(buffer), stdin) == NULL) {
break;
}
if ((buffer[0]=='Y') || (buffer[0]=='y')) {
printf("private key filename: ");
if (fgets(buffer, sizeof(buffer), stdin) == NULL) {
return SSH_AUTH_ERROR;
}
buffer[sizeof(buffer) - 1] = '\0';
if ((p = strchr(buffer, '\n'))) {
*p = '\0';
}
rc = auth_keyfile(session, buffer);
if(rc == SSH_AUTH_SUCCESS) {
break;
}
fprintf(stderr, "failed with key\n");
}
}
// Try to authenticate with keyboard interactive";
if (method & SSH_AUTH_METHOD_INTERACTIVE) {
rc = authenticate_kbdint(session, NULL);
if (rc == SSH_AUTH_ERROR) {
error(session);
return rc;
} else if (rc == SSH_AUTH_SUCCESS) {
break;
}
}
if (ssh_getpass("Password: ", password, sizeof(password), 0, 0) < 0) {
return SSH_AUTH_ERROR;
}
// Try to authenticate with password
if (method & SSH_AUTH_METHOD_PASSWORD) {
rc = ssh_userauth_password(session, NULL, password);
if (rc == SSH_AUTH_ERROR) {
error(session);
return rc;
} else if (rc == SSH_AUTH_SUCCESS) {
break;
}
}
memset(password, 0, sizeof(password));
}
banner = ssh_get_issue_banner(session);
if (banner) {
printf("%s\n",banner);
SSH_STRING_FREE_CHAR(banner);
}
// Try to authenticate
rc = ssh_userauth_none(session, NULL);
if (rc == SSH_AUTH_ERROR) {
error(session);
return rc;
}
method = ssh_auth_list(session);
while (rc != SSH_AUTH_SUCCESS) {
// Try to authenticate with public key first
if (method & SSH_AUTH_METHOD_PUBLICKEY) {
rc = ssh_userauth_autopubkey(session, NULL);
if (rc == SSH_AUTH_ERROR) {
error(session);
return rc;
} else if (rc == SSH_AUTH_SUCCESS) {
break;
}
}
// Try to authenticate with keyboard interactive";
if (method & SSH_AUTH_METHOD_INTERACTIVE) {
rc = authenticate_kbdint(session, NULL);
if (rc == SSH_AUTH_ERROR) {
error(session);
return rc;
} else if (rc == SSH_AUTH_SUCCESS) {
break;
}
}
if (ssh_getpass("Password: ", password, sizeof(password), 0, 0) < 0) {
return SSH_AUTH_ERROR;
}
// Try to authenticate with password
if (method & SSH_AUTH_METHOD_PASSWORD) {
rc = ssh_userauth_password(session, NULL, password);
if (rc == SSH_AUTH_ERROR) {
error(session);
return rc;
} else if (rc == SSH_AUTH_SUCCESS) {
break;
}
}
}
banner = ssh_get_issue_banner(session);
if (banner) {
printf("%s\n",banner);
free(banner);
}
return rc;
}

View File

@@ -32,22 +32,25 @@ ssh_session connect_ssh(const char *host, const char *user,int verbosity){
if(user != NULL){
if (ssh_options_set(session, SSH_OPTIONS_USER, user) < 0) {
ssh_disconnect(session);
ssh_free(session);
return NULL;
}
}
if (ssh_options_set(session, SSH_OPTIONS_HOST, host) < 0) {
ssh_free(session);
return NULL;
}
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
if(ssh_connect(session)){
fprintf(stderr,"Connection failed : %s\n",ssh_get_error(session));
ssh_disconnect(session);
ssh_free(session);
return NULL;
}
if(verify_knownhost(session)<0){
ssh_disconnect(session);
ssh_free(session);
return NULL;
}
auth=authenticate_console(session);
@@ -59,5 +62,6 @@ ssh_session connect_ssh(const char *host, const char *user,int verbosity){
fprintf(stderr,"Error while authenticating : %s\n",ssh_get_error(session));
}
ssh_disconnect(session);
ssh_free(session);
return NULL;
}

View File

@@ -14,6 +14,10 @@ clients must be made or how a client should react.
#define EXAMPLES_COMMON_H_
#include <libssh/libssh.h>
/** Zero a structure */
#define ZERO_STRUCT(x) memset((char *)&(x), 0, sizeof(x))
int authenticate_console(ssh_session session);
int authenticate_kbdint(ssh_session session, const char *password);
int verify_knownhost(ssh_session session);

View File

@@ -8,18 +8,20 @@ int main(void) {
ssh_session session;
ssh_channel channel;
char buffer[256];
int nbytes;
int rbytes, wbytes, total = 0;
int rc;
session = connect_ssh("localhost", NULL, 0);
if (session == NULL) {
ssh_finalize();
return 1;
}
channel = ssh_channel_new(session);;
channel = ssh_channel_new(session);
if (channel == NULL) {
ssh_disconnect(session);
ssh_free(session);
ssh_finalize();
return 1;
}
@@ -33,22 +35,39 @@ int main(void) {
goto failed;
}
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
while (nbytes > 0) {
if (fwrite(buffer, 1, nbytes, stdout) != (unsigned int) nbytes) {
goto failed;
}
nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
rbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
if (rbytes <= 0) {
goto failed;
}
if (nbytes < 0) {
do {
wbytes = fwrite(buffer + total, 1, rbytes, stdout);
if (wbytes <= 0) {
goto failed;
}
total += wbytes;
/* When it was not possible to write the whole buffer to stdout */
if (wbytes < rbytes) {
rbytes -= wbytes;
continue;
}
rbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
total = 0;
} while (rbytes > 0);
if (rbytes < 0) {
goto failed;
}
ssh_channel_send_eof(channel);
ssh_channel_close(channel);
ssh_channel_free(channel);
ssh_disconnect(session);
ssh_free(session);
ssh_finalize();
return 0;
failed:
@@ -56,6 +75,7 @@ failed:
ssh_channel_free(channel);
ssh_disconnect(session);
ssh_free(session);
ssh_finalize();
return 1;
}

41
examples/keygen.c Normal file
View File

@@ -0,0 +1,41 @@
/* keygen.c
* Sample implementation of ssh-keygen using libssh
*/
/*
Copyright 2019 Red Hat, Inc.
Author: Jakub Jelen <jjelen@redhat.com>
This file is part of the SSH Library
You are free to copy this file, modify it in any way, consider it being public
domain. This does not apply to the rest of the library though, but it is
allowed to cut-and-paste working code from this file to any license of
program.
*/
#include <libssh/libssh.h>
#include <stdio.h>
int main(void)
{
ssh_key key = NULL;
int rv;
/* Generate a new ED25519 private key file */
rv = ssh_pki_generate(SSH_KEYTYPE_ED25519, 0, &key);
if (rv != SSH_OK) {
fprintf(stderr, "Failed to generate private key");
return -1;
}
/* Write it to a file testkey in the current dirrectory */
rv = ssh_pki_export_privkey_file(key, NULL, NULL, NULL, "testkey");
if (rv != SSH_OK) {
fprintf(stderr, "Failed to write private key file");
return -1;
}
return 0;
}

505
examples/keygen2.c Normal file
View File

@@ -0,0 +1,505 @@
/*
* keygen2.c - Generate SSH keys using libssh
* Author: Anderson Toshiyuki Sasaki <ansasaki@redhat.com>
*/
/*
* Copyright (c) 2019 Red Hat, Inc.
*
* 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/
#include "config.h"
#include <libssh/libssh.h>
#include <stdio.h>
#include <stdlib.h>
#include <argp.h>
#include <errno.h>
#include <string.h>
#include <ctype.h>
#include <fcntl.h>
#include <sys/stat.h>
struct arguments_st {
enum ssh_keytypes_e type;
unsigned long bits;
char *file;
char *passphrase;
int action_list;
};
static struct argp_option options[] = {
{
.name = "bits",
.key = 'b',
.arg = "BITS",
.flags = 0,
.doc = "The size of the key to be generated. "
"If omitted, a default value is used depending on the TYPE. "
"Accepted values are: "
"1024, 2048, 3072 (default), 4096, and 8192 for TYPE=\"rsa\"; "
"256 (default), 384, and 521 for TYPE=\"ecdsa\"; "
"1024 (default) and 2048 for TYPE=\"dsa\"; "
"can be omitted for TYPE=\"ed25519\" "
"(it will be ignored if provided).\n",
.group = 0
},
{
.name = "file",
.key = 'f',
.arg = "FILE",
.flags = 0,
.doc = "The output file. "
"If not provided, the used file name will be generated "
"according to the key type as \"id_TYPE\" "
"(e.g. \"id_rsa\" for type \"rsa\"). "
"The public key file name is generated from the private key "
"file name by appending \".pub\".\n",
.group = 0
},
{
.name = "passphrase",
.key = 'p',
.arg = "PASSPHRASE",
.flags = 0,
.doc = "The passphrase used to encrypt the private key. "
"If omitted the file will not be encrypted.\n",
.group = 0
},
{
.name = "type",
.key = 't',
.arg = "TYPE",
.flags = 0,
.doc = "The type of the key to be generated. "
"Accepted values are: "
"\"rsa\", \"ecdsa\", \"ed25519\", and \"dsa\".\n",
.group = 0
},
{
.name = "list",
.key = 'l',
.arg = NULL,
.flags = 0,
.doc = "List the Fingerprint of the given key\n",
.group = 0
},
{
/* End of the options */
0
},
};
/* Parse a single option. */
static error_t parse_opt (int key, char *arg, struct argp_state *state)
{
/* Get the input argument from argp_parse, which we
* know is a pointer to our arguments structure.
*/
struct arguments_st *arguments = NULL;
error_t rc = 0;
if (state == NULL) {
return EINVAL;
}
arguments = state->input;
if (arguments == NULL) {
fprintf(stderr, "Error: NULL pointer to arguments structure "
"provided\n");
rc = EINVAL;
goto end;
}
switch (key) {
case 'b':
errno = 0;
arguments->bits = strtoul(arg, NULL, 10);
if (errno != 0) {
rc = errno;
goto end;
}
break;
case 'f':
arguments->file = strdup(arg);
if (arguments->file == NULL) {
fprintf(stderr, "Error: Out of memory\n");
rc = ENOMEM;
goto end;
}
break;
case 'p':
arguments->passphrase = strdup(arg);
if (arguments->passphrase == NULL) {
fprintf(stderr, "Error: Out of memory\n");
rc = ENOMEM;
goto end;
}
break;
case 't':
if (!strcmp(arg, "rsa")) {
arguments->type = SSH_KEYTYPE_RSA;
}
else if (!strcmp(arg, "dsa")) {
arguments->type = SSH_KEYTYPE_DSS;
}
else if (!strcmp(arg, "ecdsa")) {
arguments->type = SSH_KEYTYPE_ECDSA;
}
else if (!strcmp(arg, "ed25519")) {
arguments->type = SSH_KEYTYPE_ED25519;
}
else {
fprintf(stderr, "Error: Invalid key type\n");
argp_usage(state);
rc = EINVAL;
goto end;
}
break;
case 'l':
arguments->action_list = 1;
break;
case ARGP_KEY_ARG:
if (state->arg_num > 0) {
/* Too many arguments. */
printf("Error: Too many arguments\n");
argp_usage(state);
}
break;
case ARGP_KEY_END:
break;
default:
return ARGP_ERR_UNKNOWN;
}
end:
return rc;
}
static int validate_args(struct arguments_st *args)
{
int rc = 0;
if (args == NULL) {
return EINVAL;
}
/* no other arguments needed for listing key fingerprints */
if (args->action_list) {
return 0;
}
switch (args->type) {
case SSH_KEYTYPE_RSA:
switch (args->bits) {
case 0:
/* If not provided, use default value */
args->bits = 3072;
break;
case 1024:
case 2048:
case 3072:
case 4096:
case 8192:
break;
default:
fprintf(stderr, "Error: Invalid bits parameter provided\n");
rc = EINVAL;
break;
}
if (args->file == NULL) {
args->file = strdup("id_rsa");
if (args->file == NULL) {
rc = ENOMEM;
break;
}
}
break;
case SSH_KEYTYPE_ECDSA:
switch (args->bits) {
case 0:
/* If not provided, use default value */
args->bits = 256;
break;
case 256:
case 384:
case 521:
break;
default:
fprintf(stderr, "Error: Invalid bits parameter provided\n");
rc = EINVAL;
break;
}
if (args->file == NULL) {
args->file = strdup("id_ecdsa");
if (args->file == NULL) {
rc = ENOMEM;
break;
}
}
break;
case SSH_KEYTYPE_DSS:
switch (args->bits) {
case 0:
/* If not provided, use default value */
args->bits = 1024;
break;
case 1024:
case 2048:
break;
default:
fprintf(stderr, "Error: Invalid bits parameter provided\n");
rc = EINVAL;
break;
}
if (args->file == NULL) {
args->file = strdup("id_dsa");
if (args->file == NULL) {
rc = ENOMEM;
break;
}
}
break;
case SSH_KEYTYPE_ED25519:
/* Ignore value and overwrite with a zero */
args->bits = 0;
if (args->file == NULL) {
args->file = strdup("id_ed25519");
if (args->file == NULL) {
rc = ENOMEM;
break;
}
}
break;
default:
fprintf(stderr, "Error: unknown key type\n");
rc = EINVAL;
break;
}
return rc;
}
/* Program documentation. */
static char doc[] = "Generate an SSH key pair. "
"The \"--type\" (short: \"-t\") option is required.";
/* Our argp parser */
static struct argp argp = {options, parse_opt, NULL, doc, NULL, NULL, NULL};
static void
list_fingerprint(char *file)
{
ssh_key key = NULL;
unsigned char *hash = NULL;
size_t hlen = 0;
int rc;
rc = ssh_pki_import_privkey_file(file, NULL, NULL, NULL, &key);
if (rc != SSH_OK) {
fprintf(stderr, "Failed to import private key %s\n", file);
return;
}
rc = ssh_get_publickey_hash(key, SSH_PUBLICKEY_HASH_SHA256, &hash, &hlen);
if (rc != SSH_OK) {
fprintf(stderr, "Failed to get key fingerprint\n");
return;
}
ssh_print_hash(SSH_PUBLICKEY_HASH_SHA256, hash, hlen);
ssh_clean_pubkey_hash(&hash);
ssh_key_free(key);
}
int main(int argc, char *argv[])
{
ssh_key key = NULL;
int rc = 0;
char overwrite[1024] = "";
char *pubkey_file = NULL;
struct arguments_st arguments = {
.type = SSH_KEYTYPE_UNKNOWN,
.bits = 0,
.file = NULL,
.passphrase = NULL,
.action_list = 0,
};
if (argc < 2) {
argp_help(&argp, stdout, ARGP_HELP_DOC | ARGP_HELP_USAGE, argv[0]);
goto end;
}
rc = argp_parse(&argp, argc, argv, 0, 0, &arguments);
if (rc != 0) {
goto end;
}
rc = validate_args(&arguments);
if (rc != 0) {
goto end;
}
if (arguments.action_list && arguments.file) {
list_fingerprint(arguments.file);
goto end;
}
errno = 0;
rc = open(arguments.file, O_CREAT | O_EXCL | O_WRONLY, S_IRUSR | S_IWUSR);
if (rc < 0) {
if (errno == EEXIST) {
printf("File \"%s\" exists. Overwrite it? (y|n) ", arguments.file);
rc = scanf("%1023s", overwrite);
if (rc > 0 && tolower(overwrite[0]) == 'y') {
rc = open(arguments.file, O_WRONLY);
if (rc > 0) {
close(rc);
errno = 0;
rc = chmod(arguments.file, S_IRUSR | S_IWUSR);
if (rc != 0) {
fprintf(stderr,
"Error(%d): Could not set file permissions\n",
errno);
goto end;
}
} else {
fprintf(stderr,
"Error: Could not create private key file\n");
goto end;
}
} else {
goto end;
}
} else {
fprintf(stderr, "Error opening \"%s\" file\n", arguments.file);
goto end;
}
} else {
close(rc);
}
/* Generate a new private key */
rc = ssh_pki_generate(arguments.type, arguments.bits, &key);
if (rc != SSH_OK) {
fprintf(stderr, "Error: Failed to generate keys");
goto end;
}
/* Write the private key */
rc = ssh_pki_export_privkey_file(key, arguments.passphrase, NULL, NULL,
arguments.file);
if (rc != SSH_OK) {
fprintf(stderr, "Error: Failed to write private key file");
goto end;
}
/* If a passphrase was provided, overwrite and free it as it is not needed
* anymore */
if (arguments.passphrase != NULL) {
#ifdef HAVE_EXPLICIT_BZERO
explicit_bzero(arguments.passphrase, strlen(arguments.passphrase));
#else
bzero(arguments.passphrase, strlen(arguments.passphrase));
#endif
free(arguments.passphrase);
arguments.passphrase = NULL;
}
pubkey_file = (char *)malloc(strlen(arguments.file) + 5);
if (pubkey_file == NULL) {
rc = ENOMEM;
goto end;
}
sprintf(pubkey_file, "%s.pub", arguments.file);
errno = 0;
rc = open(pubkey_file,
O_CREAT | O_EXCL | O_WRONLY,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (rc < 0) {
if (errno == EEXIST) {
printf("File \"%s\" exists. Overwrite it? (y|n) ", pubkey_file);
rc = scanf("%1023s", overwrite);
if (rc > 0 && tolower(overwrite[0]) == 'y') {
rc = open(pubkey_file, O_WRONLY);
if (rc > 0) {
close(rc);
errno = 0;
rc = chmod(pubkey_file,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
if (rc != 0) {
fprintf(stderr,
"Error(%d): Could not set file permissions\n",
errno);
goto end;
}
} else {
fprintf(stderr,
"Error: Could not create public key file\n");
goto end;
}
} else {
goto end;
}
} else {
fprintf(stderr, "Error opening \"%s\" file\n", pubkey_file);
goto end;
}
} else {
close(rc);
}
/* Write the public key */
rc = ssh_pki_export_pubkey_file(key, pubkey_file);
if (rc != SSH_OK) {
fprintf(stderr, "Error: Failed to write public key file");
goto end;
}
end:
if (key != NULL) {
ssh_key_free(key);
}
if (arguments.file != NULL) {
free(arguments.file);
}
if (arguments.passphrase != NULL) {
#ifdef HAVE_EXPLICIT_BZERO
explicit_bzero(arguments.passphrase, strlen(arguments.passphrase));
#else
bzero(arguments.passphrase, strlen(arguments.passphrase));
#endif
free(arguments.passphrase);
}
if (pubkey_file != NULL) {
free(pubkey_file);
}
return rc;
}

View File

@@ -17,11 +17,14 @@ The goal is to show the API in action. It's not a reference on how terminal
clients must be made or how a client should react.
*/
#include "config.h"
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "libssh/priv.h"
#include <libssh/libssh.h>
#include "examples_common.h"
@@ -29,67 +32,86 @@ clients must be made or how a client should react.
#define strncasecmp _strnicmp
#endif
int verify_knownhost(ssh_session session){
char *hexa;
int state;
char buf[10];
unsigned char *hash = NULL;
int hlen;
int verify_knownhost(ssh_session session)
{
enum ssh_known_hosts_e state;
char buf[10];
unsigned char *hash = NULL;
size_t hlen;
ssh_key srv_pubkey;
int rc;
state=ssh_is_server_known(session);
rc = ssh_get_server_publickey(session, &srv_pubkey);
if (rc < 0) {
return -1;
}
hlen = ssh_get_pubkey_hash(session, &hash);
if (hlen < 0) {
return -1;
}
switch(state){
case SSH_SERVER_KNOWN_OK:
break; /* ok */
case SSH_SERVER_KNOWN_CHANGED:
fprintf(stderr,"Host key for server changed : server's one is now :\n");
ssh_print_hexa("Public key hash",hash, hlen);
free(hash);
fprintf(stderr,"For security reason, connection will be stopped\n");
return -1;
case SSH_SERVER_FOUND_OTHER:
fprintf(stderr,"The host key for this server was not found but an other type of key exists.\n");
fprintf(stderr,"An attacker might change the default server key to confuse your client"
"into thinking the key does not exist\n"
"We advise you to rerun the client with -d or -r for more safety.\n");
return -1;
case SSH_SERVER_FILE_NOT_FOUND:
fprintf(stderr,"Could not find known host file. If you accept the host key here,\n");
fprintf(stderr,"the file will be automatically created.\n");
/* fallback to SSH_SERVER_NOT_KNOWN behavior */
rc = ssh_get_publickey_hash(srv_pubkey,
SSH_PUBLICKEY_HASH_SHA256,
&hash,
&hlen);
ssh_key_free(srv_pubkey);
if (rc < 0) {
return -1;
}
state = ssh_session_is_known_server(session);
switch(state) {
case SSH_KNOWN_HOSTS_CHANGED:
fprintf(stderr,"Host key for server changed : server's one is now :\n");
ssh_print_hash(SSH_PUBLICKEY_HASH_SHA256, hash, hlen);
ssh_clean_pubkey_hash(&hash);
fprintf(stderr,"For security reason, connection will be stopped\n");
return -1;
case SSH_KNOWN_HOSTS_OTHER:
fprintf(stderr,"The host key for this server was not found but an other type of key exists.\n");
fprintf(stderr,"An attacker might change the default server key to confuse your client"
"into thinking the key does not exist\n"
"We advise you to rerun the client with -d or -r for more safety.\n");
return -1;
case SSH_KNOWN_HOSTS_NOT_FOUND:
fprintf(stderr,"Could not find known host file. If you accept the host key here,\n");
fprintf(stderr,"the file will be automatically created.\n");
/* fallback to SSH_SERVER_NOT_KNOWN behavior */
FALL_THROUGH;
case SSH_SERVER_NOT_KNOWN:
hexa = ssh_get_hexa(hash, hlen);
fprintf(stderr,"The server is unknown. Do you trust the host key ?\n");
fprintf(stderr, "Public key hash: %s\n", hexa);
free(hexa);
if (fgets(buf, sizeof(buf), stdin) == NULL) {
return -1;
}
if(strncasecmp(buf,"yes",3)!=0){
return -1;
}
fprintf(stderr,"This new key will be written on disk for further usage. do you agree ?\n");
if (fgets(buf, sizeof(buf), stdin) == NULL) {
return -1;
}
if(strncasecmp(buf,"yes",3)==0){
if (ssh_write_knownhost(session) < 0) {
free(hash);
fprintf(stderr, "error %s\n", strerror(errno));
return -1;
}
}
fprintf(stderr,
"The server is unknown. Do you trust the host key (yes/no)?\n");
ssh_print_hash(SSH_PUBLICKEY_HASH_SHA256, hash, hlen);
break;
case SSH_SERVER_ERROR:
free(hash);
fprintf(stderr,"%s",ssh_get_error(session));
return -1;
}
free(hash);
return 0;
if (fgets(buf, sizeof(buf), stdin) == NULL) {
ssh_clean_pubkey_hash(&hash);
return -1;
}
if(strncasecmp(buf,"yes",3)!=0){
ssh_clean_pubkey_hash(&hash);
return -1;
}
fprintf(stderr,"This new key will be written on disk for further usage. do you agree ?\n");
if (fgets(buf, sizeof(buf), stdin) == NULL) {
ssh_clean_pubkey_hash(&hash);
return -1;
}
if(strncasecmp(buf,"yes",3)==0){
rc = ssh_session_update_known_hosts(session);
if (rc != SSH_OK) {
ssh_clean_pubkey_hash(&hash);
fprintf(stderr, "error %s\n", strerror(errno));
return -1;
}
}
break;
case SSH_KNOWN_HOSTS_ERROR:
ssh_clean_pubkey_hash(&hash);
fprintf(stderr,"%s",ssh_get_error(session));
return -1;
case SSH_KNOWN_HOSTS_OK:
break; /* ok */
}
ssh_clean_pubkey_hash(&hash);
return 0;
}

View File

@@ -22,143 +22,233 @@ program.
#include <libssh/libssh.h>
#include "examples_common.h"
char **sources;
int nsources;
char *destination;
int verbosity=0;
#ifndef BUF_SIZE
#define BUF_SIZE 16384
#endif
static char **sources;
static int nsources;
static char *destination;
static int verbosity = 0;
struct location {
int is_ssh;
char *user;
char *host;
char *path;
ssh_session session;
ssh_scp scp;
FILE *file;
int is_ssh;
char *user;
char *host;
char *path;
ssh_session session;
ssh_scp scp;
FILE *file;
};
enum {
READ,
WRITE
READ,
WRITE
};
static void usage(const char *argv0){
fprintf(stderr,"Usage : %s [options] [[user@]host1:]file1 ... \n"
" [[user@]host2:]destination\n"
"sample scp client - libssh-%s\n",
// "Options :\n",
// " -r : use RSA to verify host public key\n",
argv0,
ssh_version(0));
exit(0);
static void usage(const char *argv0) {
fprintf(stderr, "Usage : %s [options] [[user@]host1:]file1 ... \n"
" [[user@]host2:]destination\n"
"sample scp client - libssh-%s\n",
// "Options :\n",
// " -r : use RSA to verify host public key\n",
argv0,
ssh_version(0));
exit(0);
}
static int opts(int argc, char **argv){
int i;
while((i=getopt(argc,argv,"v"))!=-1){
switch(i){
case 'v':
verbosity++;
break;
default:
fprintf(stderr,"unknown option %c\n",optopt);
static int opts(int argc, char **argv) {
int i;
while((i = getopt(argc, argv, "v")) != -1) {
switch(i) {
case 'v':
verbosity++;
break;
default:
fprintf(stderr, "unknown option %c\n", optopt);
usage(argv[0]);
return -1;
}
}
nsources = argc - optind - 1;
if (nsources < 1) {
usage(argv[0]);
return -1;
}
}
nsources=argc-optind-1;
if(nsources < 1){
usage(argv[0]);
return -1;
}
sources=malloc((nsources + 1) * sizeof(char *));
if(sources == NULL)
return -1;
for(i=0;i<nsources;++i){
sources[i] = argv[optind];
optind++;
}
sources[i]=NULL;
destination=argv[optind];
return 0;
sources = malloc((nsources + 1) * sizeof(char *));
if (sources == NULL) {
return -1;
}
for(i = 0; i < nsources; ++i) {
sources[i] = argv[optind];
optind++;
}
sources[i] = NULL;
destination = argv[optind];
return 0;
}
static struct location *parse_location(char *loc){
struct location *location=malloc(sizeof(struct location));
char *ptr;
static void location_free(struct location *loc)
{
if (loc) {
if (loc->path) {
free(loc->path);
}
loc->path = NULL;
if (loc->is_ssh) {
if (loc->host) {
free(loc->host);
}
loc->host = NULL;
if (loc->user) {
free(loc->user);
}
loc->user = NULL;
}
free(loc);
}
}
location->host=location->user=NULL;
ptr=strchr(loc,':');
if(ptr != NULL){
location->is_ssh=1;
location->path=strdup(ptr+1);
*ptr='\0';
ptr=strchr(loc,'@');
if(ptr != NULL){
location->host=strdup(ptr+1);
*ptr='\0';
location->user=strdup(loc);
static struct location *parse_location(char *loc) {
struct location *location;
char *ptr;
location = malloc(sizeof(struct location));
if (location == NULL) {
return NULL;
}
memset(location, 0, sizeof(struct location));
location->host = location->user = NULL;
ptr = strchr(loc, ':');
if (ptr != NULL) {
location->is_ssh = 1;
location->path = strdup(ptr+1);
*ptr = '\0';
ptr = strchr(loc, '@');
if (ptr != NULL) {
location->host = strdup(ptr+1);
*ptr = '\0';
location->user = strdup(loc);
} else {
location->host = strdup(loc);
}
} else {
location->host=strdup(loc);
location->is_ssh = 0;
location->path = strdup(loc);
}
} else {
location->is_ssh=0;
location->path=strdup(loc);
}
return location;
return location;
}
static int open_location(struct location *loc, int flag){
if(loc->is_ssh && flag==WRITE){
loc->session=connect_ssh(loc->host,loc->user,verbosity);
if(!loc->session){
fprintf(stderr,"Couldn't connect to %s\n",loc->host);
return -1;
static void close_location(struct location *loc) {
int rc;
if (loc) {
if (loc->is_ssh) {
if (loc->scp) {
rc = ssh_scp_close(loc->scp);
if (rc == SSH_ERROR) {
fprintf(stderr,
"Error closing scp: %s\n",
ssh_get_error(loc->session));
}
ssh_scp_free(loc->scp);
loc->scp = NULL;
}
if (loc->session) {
ssh_disconnect(loc->session);
ssh_free(loc->session);
loc->session = NULL;
}
} else {
if (loc->file) {
fclose(loc->file);
loc->file = NULL;
}
}
}
loc->scp=ssh_scp_new(loc->session,SSH_SCP_WRITE,loc->path);
if(!loc->scp){
fprintf(stderr,"error : %s\n",ssh_get_error(loc->session));
return -1;
}
static int open_location(struct location *loc, int flag) {
if (loc->is_ssh && flag == WRITE) {
loc->session = connect_ssh(loc->host, loc->user, verbosity);
if (!loc->session) {
fprintf(stderr, "Couldn't connect to %s\n", loc->host);
return -1;
}
loc->scp = ssh_scp_new(loc->session, SSH_SCP_WRITE, loc->path);
if (!loc->scp) {
fprintf(stderr, "error : %s\n", ssh_get_error(loc->session));
ssh_disconnect(loc->session);
ssh_free(loc->session);
loc->session = NULL;
return -1;
}
if (ssh_scp_init(loc->scp) == SSH_ERROR) {
fprintf(stderr, "error : %s\n", ssh_get_error(loc->session));
ssh_scp_free(loc->scp);
loc->scp = NULL;
ssh_disconnect(loc->session);
ssh_free(loc->session);
loc->session = NULL;
return -1;
}
return 0;
} else if (loc->is_ssh && flag == READ) {
loc->session = connect_ssh(loc->host, loc->user, verbosity);
if (!loc->session) {
fprintf(stderr, "Couldn't connect to %s\n", loc->host);
return -1;
}
loc->scp = ssh_scp_new(loc->session, SSH_SCP_READ, loc->path);
if (!loc->scp) {
fprintf(stderr, "error : %s\n", ssh_get_error(loc->session));
ssh_disconnect(loc->session);
ssh_free(loc->session);
loc->session = NULL;
return -1;
}
if (ssh_scp_init(loc->scp) == SSH_ERROR) {
fprintf(stderr, "error : %s\n", ssh_get_error(loc->session));
ssh_scp_free(loc->scp);
loc->scp = NULL;
ssh_disconnect(loc->session);
ssh_free(loc->session);
loc->session = NULL;
return -1;
}
return 0;
} else {
loc->file = fopen(loc->path, flag == READ ? "r":"w");
if (!loc->file) {
if (errno == EISDIR) {
if (loc->path != NULL && chdir(loc->path)) {
fprintf(stderr,
"Error changing directory to %s: %s\n",
loc->path, strerror(errno));
return -1;
}
return 0;
}
fprintf(stderr,
"Error opening %s: %s\n",
loc->path, strerror(errno));
return -1;
}
return 0;
}
if(ssh_scp_init(loc->scp)==SSH_ERROR){
fprintf(stderr,"error : %s\n",ssh_get_error(loc->session));
ssh_scp_free(loc->scp);
return -1;
}
return 0;
} else if(loc->is_ssh && flag==READ){
loc->session=connect_ssh(loc->host, loc->user,verbosity);
if(!loc->session){
fprintf(stderr,"Couldn't connect to %s\n",loc->host);
return -1;
}
loc->scp=ssh_scp_new(loc->session,SSH_SCP_READ,loc->path);
if(!loc->scp){
fprintf(stderr,"error : %s\n",ssh_get_error(loc->session));
return -1;
}
if(ssh_scp_init(loc->scp)==SSH_ERROR){
fprintf(stderr,"error : %s\n",ssh_get_error(loc->session));
ssh_scp_free(loc->scp);
return -1;
}
return 0;
} else {
loc->file=fopen(loc->path,flag==READ ? "r":"w");
if(!loc->file){
if(errno==EISDIR){
if(chdir(loc->path)){
fprintf(stderr,"Error changing directory to %s: %s\n",loc->path,strerror(errno));
return -1;
}
return 0;
}
fprintf(stderr,"Error opening %s: %s\n",loc->path,strerror(errno));
return -1;
}
return 0;
}
return -1;
return -1;
}
/** @brief copies files from source location to destination
@@ -166,139 +256,201 @@ static int open_location(struct location *loc, int flag){
* @param dest destination location
* @param recursive Copy also directories
*/
static int do_copy(struct location *src, struct location *dest, int recursive){
int size;
socket_t fd;
struct stat s;
int w,r;
char buffer[16384];
int total=0;
int mode;
char *filename;
/* recursive mode doesn't work yet */
(void)recursive;
/* Get the file name and size*/
if(!src->is_ssh){
fd=fileno(src->file);
fstat(fd,&s);
size=s.st_size;
mode = s.st_mode & S_IFMT;
filename=ssh_basename(src->path);
} else {
size=0;
static int do_copy(struct location *src, struct location *dest, int recursive) {
size_t size;
socket_t fd;
struct stat s;
int w, r;
char buffer[BUF_SIZE];
size_t total = 0;
mode_t mode;
char *filename = NULL;
/* recursive mode doesn't work yet */
(void)recursive;
/* Get the file name and size*/
if (!src->is_ssh) {
fd = fileno(src->file);
if (fd < 0) {
fprintf(stderr,
"Invalid file pointer, error: %s\n",
strerror(errno));
return -1;
}
r = fstat(fd, &s);
if (r < 0) {
return -1;
}
size = s.st_size;
mode = s.st_mode & ~S_IFMT;
filename = ssh_basename(src->path);
} else {
size = 0;
do {
r = ssh_scp_pull_request(src->scp);
if (r == SSH_SCP_REQUEST_NEWDIR) {
ssh_scp_deny_request(src->scp, "Not in recursive mode");
continue;
}
if (r == SSH_SCP_REQUEST_NEWFILE) {
size = ssh_scp_request_get_size(src->scp);
filename = strdup(ssh_scp_request_get_filename(src->scp));
mode = ssh_scp_request_get_permissions(src->scp);
//ssh_scp_accept_request(src->scp);
break;
}
if (r == SSH_ERROR) {
fprintf(stderr,
"Error: %s\n",
ssh_get_error(src->session));
SSH_STRING_FREE_CHAR(filename);
return -1;
}
} while(r != SSH_SCP_REQUEST_NEWFILE);
}
if (dest->is_ssh) {
r = ssh_scp_push_file(dest->scp, src->path, size, mode);
// snprintf(buffer, sizeof(buffer), "C0644 %d %s\n", size, src->path);
if (r == SSH_ERROR) {
fprintf(stderr,
"error: %s\n",
ssh_get_error(dest->session));
SSH_STRING_FREE_CHAR(filename);
ssh_scp_free(dest->scp);
dest->scp = NULL;
return -1;
}
} else {
if (!dest->file) {
dest->file = fopen(filename, "w");
if (!dest->file) {
fprintf(stderr,
"Cannot open %s for writing: %s\n",
filename, strerror(errno));
if (src->is_ssh) {
ssh_scp_deny_request(src->scp, "Cannot open local file");
}
SSH_STRING_FREE_CHAR(filename);
return -1;
}
}
if (src->is_ssh) {
ssh_scp_accept_request(src->scp);
}
}
do {
r=ssh_scp_pull_request(src->scp);
if(r==SSH_SCP_REQUEST_NEWDIR){
ssh_scp_deny_request(src->scp,"Not in recursive mode");
continue;
}
if(r==SSH_SCP_REQUEST_NEWFILE){
size=ssh_scp_request_get_size(src->scp);
filename=strdup(ssh_scp_request_get_filename(src->scp));
mode=ssh_scp_request_get_permissions(src->scp);
//ssh_scp_accept_request(src->scp);
break;
}
if(r==SSH_ERROR){
fprintf(stderr,"Error: %s\n",ssh_get_error(src->session));
return -1;
}
} while(r != SSH_SCP_REQUEST_NEWFILE);
}
if (src->is_ssh) {
r = ssh_scp_read(src->scp, buffer, sizeof(buffer));
if (r == SSH_ERROR) {
fprintf(stderr,
"Error reading scp: %s\n",
ssh_get_error(src->session));
SSH_STRING_FREE_CHAR(filename);
return -1;
}
if(dest->is_ssh){
r=ssh_scp_push_file(dest->scp,src->path, size, mode);
// snprintf(buffer,sizeof(buffer),"C0644 %d %s\n",size,src->path);
if(r==SSH_ERROR){
fprintf(stderr,"error: %s\n",ssh_get_error(dest->session));
ssh_scp_free(dest->scp);
return -1;
}
} else {
if(!dest->file){
dest->file=fopen(filename,"w");
if(!dest->file){
fprintf(stderr,"Cannot open %s for writing: %s\n",filename,strerror(errno));
if(src->is_ssh)
ssh_scp_deny_request(src->scp,"Cannot open local file");
return -1;
}
}
if(src->is_ssh){
ssh_scp_accept_request(src->scp);
}
}
do {
if(src->is_ssh){
r=ssh_scp_read(src->scp,buffer,sizeof(buffer));
if(r==SSH_ERROR){
fprintf(stderr,"Error reading scp: %s\n",ssh_get_error(src->session));
return -1;
}
if(r==0)
break;
} else {
r=fread(buffer,1,sizeof(buffer),src->file);
if(r==0)
break;
if(r<0){
fprintf(stderr,"Error reading file: %s\n",strerror(errno));
return -1;
}
}
if(dest->is_ssh){
w=ssh_scp_write(dest->scp,buffer,r);
if(w == SSH_ERROR){
fprintf(stderr,"Error writing in scp: %s\n",ssh_get_error(dest->session));
ssh_scp_free(dest->scp);
dest->scp=NULL;
return -1;
}
} else {
w=fwrite(buffer,r,1,dest->file);
if(w<=0){
fprintf(stderr,"Error writing in local file: %s\n",strerror(errno));
return -1;
}
}
total+=r;
if (r == 0) {
break;
}
} else {
r = fread(buffer, 1, sizeof(buffer), src->file);
if (r == 0) {
break;
}
} while(total < size);
printf("wrote %d bytes\n",total);
return 0;
if (r < 0) {
fprintf(stderr,
"Error reading file: %s\n",
strerror(errno));
SSH_STRING_FREE_CHAR(filename);
return -1;
}
}
if (dest->is_ssh) {
w = ssh_scp_write(dest->scp, buffer, r);
if (w == SSH_ERROR) {
fprintf(stderr,
"Error writing in scp: %s\n",
ssh_get_error(dest->session));
ssh_scp_free(dest->scp);
dest->scp = NULL;
SSH_STRING_FREE_CHAR(filename);
return -1;
}
} else {
w = fwrite(buffer, r, 1, dest->file);
if (w <= 0) {
fprintf(stderr,
"Error writing in local file: %s\n",
strerror(errno));
SSH_STRING_FREE_CHAR(filename);
return -1;
}
}
total += r;
} while(total < size);
SSH_STRING_FREE_CHAR(filename);
printf("wrote %zu bytes\n", total);
return 0;
}
int main(int argc, char **argv){
struct location *dest, *src;
int i;
int r;
if(opts(argc,argv)<0)
return EXIT_FAILURE;
dest=parse_location(destination);
if(open_location(dest,WRITE)<0)
return EXIT_FAILURE;
for(i=0;i<nsources;++i){
src=parse_location(sources[i]);
if(open_location(src,READ)<0){
return EXIT_FAILURE;
int main(int argc, char **argv) {
struct location *dest, *src;
int i;
int r;
if (opts(argc, argv) < 0) {
return EXIT_FAILURE;
}
if(do_copy(src,dest,0) < 0){
break;
ssh_init();
dest = parse_location(destination);
if (dest == NULL) {
r = EXIT_FAILURE;
goto end;
}
}
if(dest->is_ssh){
r=ssh_scp_close(dest->scp);
if(r == SSH_ERROR){
fprintf(stderr,"Error closing scp: %s\n",ssh_get_error(dest->session));
ssh_scp_free(dest->scp);
dest->scp=NULL;
return -1;
}
} else {
fclose(dest->file);
dest->file=NULL;
}
ssh_disconnect(dest->session);
ssh_finalize();
return 0;
if (open_location(dest, WRITE) < 0) {
location_free(dest);
r = EXIT_FAILURE;
goto end;
}
for (i = 0; i < nsources; ++i) {
src = parse_location(sources[i]);
if (src == NULL) {
r = EXIT_FAILURE;
goto close_dest;
}
if (open_location(src, READ) < 0) {
location_free(src);
r = EXIT_FAILURE;
goto close_dest;
}
if (do_copy(src, dest, 0) < 0) {
close_location(src);
location_free(src);
break;
}
close_location(src);
location_free(src);
}
r = 0;
close_dest:
close_location(dest);
location_free(dest);
end:
ssh_finalize();
free(sources);
return r;
}

View File

@@ -16,18 +16,18 @@ program.
#include <libssh/libsshpp.hpp>
int main(int argc, const char **argv){
ssh::Session session,s2;
ssh::Session session;
try {
if(argc>1)
session.setOption(SSH_OPTIONS_HOST,argv[1]);
else
session.setOption(SSH_OPTIONS_HOST,"localhost");
session.connect();
session.userauthAutopubkey();
session.userauthPublickeyAuto();
session.disconnect();
} catch (ssh::SshException e){
std::cout << "Error during connection : ";
std::cout << e.getError() << std::endl;
}
//s2=session;
return 0;
}

View File

@@ -29,7 +29,7 @@ int main(int argc, const char **argv){
err=session.connect();
if(err==SSH_ERROR)
goto error;
err=session.userauthAutopubkey();
err=session.userauthPublickeyAuto();
if(err==SSH_ERROR)
goto error;

351
examples/proxy.c Normal file
View File

@@ -0,0 +1,351 @@
/* This is a sample implementation of a libssh based SSH proxy */
/*
Copyright 2003-2013 Aris Adamantiadis
This file is part of the SSH Library
You are free to copy this file, modify it in any way, consider it being public
domain. This does not apply to the rest of the library though, but it is
allowed to cut-and-paste working code from this file to any license of
program.
The goal is to show the API in action. It's not a reference on how terminal
clients must be made or how a client should react.
*/
#include "config.h"
#include <libssh/libssh.h>
#include <libssh/server.h>
#include <libssh/callbacks.h>
#ifdef HAVE_ARGP_H
#include <argp.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#ifndef BUF_SIZE
#define BUF_SIZE 2048
#endif
#define USER "myuser"
#define PASSWORD "mypassword"
static int authenticated=0;
static int tries = 0;
static int error = 0;
static ssh_channel chan=NULL;
static char *username;
static ssh_gssapi_creds client_creds = NULL;
static int auth_password(ssh_session session, const char *user,
const char *password, void *userdata){
(void)userdata;
printf("Authenticating user %s pwd %s\n",user, password);
if(strcmp(user,USER) == 0 && strcmp(password, PASSWORD) == 0){
authenticated = 1;
printf("Authenticated\n");
return SSH_AUTH_SUCCESS;
}
if (tries >= 3){
printf("Too many authentication tries\n");
ssh_disconnect(session);
error = 1;
return SSH_AUTH_DENIED;
}
tries++;
return SSH_AUTH_DENIED;
}
static int auth_gssapi_mic(ssh_session session, const char *user, const char *principal, void *userdata){
(void)userdata;
client_creds = ssh_gssapi_get_creds(session);
printf("Authenticating user %s with gssapi principal %s\n",user, principal);
if (client_creds != NULL)
printf("Received some gssapi credentials\n");
else
printf("Not received any forwardable creds\n");
printf("authenticated\n");
authenticated = 1;
username = strdup(principal);
return SSH_AUTH_SUCCESS;
}
static int pty_request(ssh_session session, ssh_channel channel, const char *term,
int x,int y, int px, int py, void *userdata){
(void) session;
(void) channel;
(void) term;
(void) x;
(void) y;
(void) px;
(void) py;
(void) userdata;
printf("Allocated terminal\n");
return 0;
}
static int shell_request(ssh_session session, ssh_channel channel, void *userdata){
(void)session;
(void)channel;
(void)userdata;
printf("Allocated shell\n");
return 0;
}
struct ssh_channel_callbacks_struct channel_cb = {
.channel_pty_request_function = pty_request,
.channel_shell_request_function = shell_request
};
static ssh_channel new_session_channel(ssh_session session, void *userdata){
(void) session;
(void) userdata;
if(chan != NULL)
return NULL;
printf("Allocated session channel\n");
chan = ssh_channel_new(session);
ssh_callbacks_init(&channel_cb);
ssh_set_channel_callbacks(chan, &channel_cb);
return chan;
}
#ifdef HAVE_ARGP_H
const char *argp_program_version = "libssh proxy example "
SSH_STRINGIFY(LIBSSH_VERSION);
const char *argp_program_bug_address = "<libssh@libssh.org>";
/* Program documentation. */
static char doc[] = "libssh -- a Secure Shell protocol implementation";
/* A description of the arguments we accept. */
static char args_doc[] = "BINDADDR";
/* The options we understand. */
static struct argp_option options[] = {
{
.name = "port",
.key = 'p',
.arg = "PORT",
.flags = 0,
.doc = "Set the port to bind.",
.group = 0
},
{
.name = "hostkey",
.key = 'k',
.arg = "FILE",
.flags = 0,
.doc = "Set the host key.",
.group = 0
},
{
.name = "dsakey",
.key = 'd',
.arg = "FILE",
.flags = 0,
.doc = "Set the dsa key.",
.group = 0
},
{
.name = "rsakey",
.key = 'r',
.arg = "FILE",
.flags = 0,
.doc = "Set the rsa key.",
.group = 0
},
{
.name = "verbose",
.key = 'v',
.arg = NULL,
.flags = 0,
.doc = "Get verbose output.",
.group = 0
},
{NULL, 0, NULL, 0, NULL, 0}
};
/* Parse a single option. */
static error_t parse_opt (int key, char *arg, struct argp_state *state) {
/* Get the input argument from argp_parse, which we
* know is a pointer to our arguments structure.
*/
ssh_bind sshbind = state->input;
switch (key) {
case 'p':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDPORT_STR, arg);
break;
case 'd':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY, arg);
break;
case 'k':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_HOSTKEY, arg);
break;
case 'r':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, arg);
break;
case 'v':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_LOG_VERBOSITY_STR, "3");
break;
case ARGP_KEY_ARG:
if (state->arg_num >= 1) {
/* Too many arguments. */
argp_usage (state);
}
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDADDR, arg);
break;
case ARGP_KEY_END:
if (state->arg_num < 1) {
/* Not enough arguments. */
argp_usage (state);
}
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
/* Our argp parser. */
static struct argp argp = {options, parse_opt, args_doc, doc, NULL, NULL, NULL};
#endif /* HAVE_ARGP_H */
int main(int argc, char **argv){
ssh_session session;
ssh_bind sshbind;
ssh_event mainloop;
ssh_session client_session;
struct ssh_server_callbacks_struct cb = {
.userdata = NULL,
.auth_password_function = auth_password,
.auth_gssapi_mic_function = auth_gssapi_mic,
.channel_open_request_session_function = new_session_channel
};
char buf[BUF_SIZE];
char host[128]="";
char *ptr;
int i,r, rc;
sshbind=ssh_bind_new();
session=ssh_new();
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, "sshd_rsa");
#ifdef HAVE_ARGP_H
/*
* Parse our arguments; every option seen by parse_opt will
* be reflected in arguments.
*/
argp_parse (&argp, argc, argv, 0, 0, sshbind);
#else
(void) argc;
(void) argv;
#endif
if(ssh_bind_listen(sshbind)<0){
printf("Error listening to socket: %s\n",ssh_get_error(sshbind));
return 1;
}
r=ssh_bind_accept(sshbind,session);
if(r==SSH_ERROR){
printf("error accepting a connection : %s\n",ssh_get_error(sshbind));
return 1;
}
ssh_callbacks_init(&cb);
ssh_set_server_callbacks(session, &cb);
if (ssh_handle_key_exchange(session)) {
printf("ssh_handle_key_exchange: %s\n", ssh_get_error(session));
return 1;
}
ssh_set_auth_methods(session,SSH_AUTH_METHOD_PASSWORD | SSH_AUTH_METHOD_GSSAPI_MIC);
mainloop = ssh_event_new();
ssh_event_add_session(mainloop, session);
while (!(authenticated && chan != NULL)){
if(error)
break;
r = ssh_event_dopoll(mainloop, -1);
if (r == SSH_ERROR){
printf("Error : %s\n",ssh_get_error(session));
ssh_disconnect(session);
return 1;
}
}
if(error){
printf("Error, exiting loop\n");
return 1;
} else
printf("Authenticated and got a channel\n");
if (!client_creds){
snprintf(buf,sizeof(buf), "Sorry, but you do not have forwardable tickets. Try again with -K\r\n");
ssh_channel_write(chan,buf,strlen(buf));
printf("%s",buf);
ssh_disconnect(session);
return 1;
}
snprintf(buf,sizeof(buf), "Hello %s, welcome to the Sample SSH proxy.\r\nPlease select your destination: ", username);
ssh_channel_write(chan, buf, strlen(buf));
do{
i=ssh_channel_read(chan,buf, sizeof(buf), 0);
if(i>0) {
ssh_channel_write(chan, buf, i);
if(strlen(host) + i < sizeof(host)){
strncat(host, buf, i);
}
if (strchr(host, '\x0d')) {
*strchr(host, '\x0d')='\0';
ssh_channel_write(chan, "\n", 1);
break;
}
} else {
printf ("Error: %s\n", ssh_get_error(session) );
return 1;
}
} while (i>0);
snprintf(buf,sizeof(buf),"Trying to connect to \"%s\"\r\n", host);
ssh_channel_write(chan, buf, strlen(buf));
printf("%s",buf);
client_session = ssh_new();
/* ssh servers expect username without realm */
ptr = strchr(username,'@');
if(ptr)
*ptr= '\0';
ssh_options_set(client_session, SSH_OPTIONS_HOST, host);
ssh_options_set(client_session, SSH_OPTIONS_USER, username);
ssh_gssapi_set_creds(client_session, client_creds);
rc = ssh_connect(client_session);
if (rc != SSH_OK){
printf("Error connecting to %s: %s", host, ssh_get_error(client_session));
return 1;
}
rc = ssh_userauth_none(client_session, NULL);
if(rc == SSH_AUTH_SUCCESS){
printf("Authenticated using method none\n");
} else {
rc = ssh_userauth_gssapi(client_session);
if(rc != SSH_AUTH_SUCCESS){
printf("GSSAPI Authentication failed: %s\n",ssh_get_error(client_session));
return 1;
}
}
snprintf(buf,sizeof(buf), "Authentication success\r\n");
printf("%s",buf);
ssh_channel_write(chan,buf,strlen(buf));
ssh_disconnect(client_session);
ssh_disconnect(session);
ssh_bind_free(sshbind);
ssh_finalize();
return 0;
}

View File

@@ -1,535 +0,0 @@
/* client.c */
/*
Copyright 2003-2009 Aris Adamantiadis
This file is part of the SSH Library
You are free to copy this file, modify it in any way, consider it being public
domain. This does not apply to the rest of the library though, but it is
allowed to cut-and-paste working code from this file to any license of
program.
The goal is to show the API in action. It's not a reference on how terminal
clients must be made or how a client should react.
*/
#include "config.h"
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <sys/select.h>
#include <sys/time.h>
#ifdef HAVE_PTY_H
#include <pty.h>
#endif
#include <sys/ioctl.h>
#include <signal.h>
#include <errno.h>
#include <libssh/callbacks.h>
#include <libssh/libssh.h>
#include <libssh/sftp.h>
#include <fcntl.h>
#include "examples_common.h"
#define MAXCMD 10
char *host;
char *user;
char *cmds[MAXCMD];
struct termios terminal;
char *pcap_file=NULL;
char *proxycommand;
static int auth_callback(const char *prompt, char *buf, size_t len,
int echo, int verify, void *userdata) {
char *answer = NULL;
char *ptr;
(void) verify;
(void) userdata;
if (echo) {
while ((answer = fgets(buf, len, stdin)) == NULL);
if ((ptr = strchr(buf, '\n'))) {
*ptr = '\0';
}
} else {
if (ssh_getpass(prompt, buf, len, 0, 0) < 0) {
return -1;
}
return 0;
}
if (answer == NULL) {
return -1;
}
strncpy(buf, answer, len);
return 0;
}
struct ssh_callbacks_struct cb = {
.auth_function=auth_callback,
.userdata=NULL
};
static void add_cmd(char *cmd){
int n;
for(n=0;cmds[n] && (n<MAXCMD);n++);
if(n==MAXCMD)
return;
cmds[n]=strdup(cmd);
}
static void usage(){
fprintf(stderr,"Usage : ssh [options] [login@]hostname\n"
"sample client - libssh-%s\n"
"Options :\n"
" -l user : log in as user\n"
" -p port : connect to port\n"
" -d : use DSS to verify host public key\n"
" -r : use RSA to verify host public key\n"
#ifdef WITH_PCAP
" -P file : create a pcap debugging file\n"
#endif
#ifndef _WIN32
" -T proxycommand : command to execute as a socket proxy\n"
#endif
,
ssh_version(0));
exit(0);
}
static int opts(int argc, char **argv){
int i;
// for(i=0;i<argc;i++)
// printf("%d : %s\n",i,argv[i]);
/* insert your own arguments here */
while((i=getopt(argc,argv,"T:P:"))!=-1){
switch(i){
case 'P':
pcap_file=optarg;
break;
#ifndef _WIN32
case 'T':
proxycommand=optarg;
break;
#endif
default:
fprintf(stderr,"unknown option %c\n",optopt);
usage();
}
}
if(optind < argc)
host=argv[optind++];
while(optind < argc)
add_cmd(argv[optind++]);
if(host==NULL)
usage();
return 0;
}
#ifndef HAVE_CFMAKERAW
static void cfmakeraw(struct termios *termios_p){
termios_p->c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
termios_p->c_oflag &= ~OPOST;
termios_p->c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
termios_p->c_cflag &= ~(CSIZE|PARENB);
termios_p->c_cflag |= CS8;
}
#endif
static void do_cleanup(int i) {
/* unused variable */
(void) i;
tcsetattr(0,TCSANOW,&terminal);
}
static void do_exit(int i) {
/* unused variable */
(void) i;
do_cleanup(0);
exit(0);
}
ssh_channel chan;
int signal_delayed=0;
static void sigwindowchanged(int i){
(void) i;
signal_delayed=1;
}
static void setsignal(void){
signal(SIGWINCH, sigwindowchanged);
signal_delayed=0;
}
static void sizechanged(void){
struct winsize win = { 0, 0, 0, 0 };
ioctl(1, TIOCGWINSZ, &win);
ssh_channel_change_pty_size(chan,win.ws_col, win.ws_row);
// printf("Changed pty size\n");
setsignal();
}
/* There are two flavors of select loop: the one based on
* ssh_select and the one based on channel_select.
* The ssh_select one permits you to give your own file descriptors to
* follow. It is thus a complete select loop.
* The second one only selects on channels. It is simplier to use
* but doesn't permit you to fill in your own file descriptor. It is
* more adapted if you can't use ssh_select as a main loop (because
* you already have another main loop system).
*/
#ifdef USE_CHANNEL_SELECT
/* channel_select base main loop, with a standard select(2)
*/
static void select_loop(ssh_session session,ssh_channel channel){
fd_set fds;
struct timeval timeout;
char buffer[4096];
ssh_buffer readbuf=ssh_buffer_new();
ssh_channel channels[2];
int lus;
int eof=0;
int maxfd;
int ret;
while(channel){
/* when a signal is caught, ssh_select will return
* with SSH_EINTR, which means it should be started
* again. It lets you handle the signal the faster you
* can, like in this window changed example. Of course, if
* your signal handler doesn't call libssh at all, you're
* free to handle signals directly in sighandler.
*/
do{
FD_ZERO(&fds);
if(!eof)
FD_SET(0,&fds);
timeout.tv_sec=30;
timeout.tv_usec=0;
FD_SET(ssh_get_fd(session),&fds);
maxfd=ssh_get_fd(session)+1;
ret=select(maxfd,&fds,NULL,NULL,&timeout);
if(ret==EINTR)
continue;
if(FD_ISSET(0,&fds)){
lus=read(0,buffer,sizeof(buffer));
if(lus)
ssh_channel_write(channel,buffer,lus);
else {
eof=1;
ssh_channel_send_eof(channel);
}
}
if(FD_ISSET(ssh_get_fd(session),&fds)){
ssh_set_fd_toread(session);
}
channels[0]=channel; // set the first channel we want to read from
channels[1]=NULL;
ret=ssh_channel_select(channels,NULL,NULL,NULL); // no specific timeout - just poll
if(signal_delayed)
sizechanged();
} while (ret==EINTR || ret==SSH_EINTR);
// we already looked for input from stdin. Now, we are looking for input from the channel
if(channel && ssh_channel_is_closed(channel)){
ssh_log(session,SSH_LOG_RARE,"exit-status : %d\n",ssh_channel_get_exit_status(channel));
ssh_channel_free(channel);
channel=NULL;
channels[0]=NULL;
}
if(channels[0]){
while(channel && ssh_channel_is_open(channel) && ssh_channel_poll(channel,0)>0){
lus=channel_read_buffer(channel,readbuf,0,0);
if(lus==-1){
fprintf(stderr, "Error reading channel: %s\n",
ssh_get_error(session));
return;
}
if(lus==0){
ssh_log(session,SSH_LOG_RARE,"EOF received\n");
ssh_log(session,SSH_LOG_RARE,"exit-status : %d\n",ssh_channel_get_exit_status(channel));
ssh_channel_free(channel);
channel=channels[0]=NULL;
} else
if (write(1,ssh_buffer_get_begin(readbuf),lus) < 0) {
fprintf(stderr, "Error writing to buffer\n");
return;
}
}
while(channel && ssh_channel_is_open(channel) && ssh_channel_poll(channel,1)>0){ /* stderr */
lus=channel_read_buffer(channel,readbuf,0,1);
if(lus==-1){
fprintf(stderr, "Error reading channel: %s\n",
ssh_get_error(session));
return;
}
if(lus==0){
ssh_log(session,SSH_LOG_RARE,"EOF received\n");
ssh_log(session,SSH_LOG_RARE,"exit-status : %d\n",ssh_channel_get_exit_status(channel));
ssh_channel_free(channel);
channel=channels[0]=NULL;
} else
if (write(2,ssh_buffer_get_begin(readbuf),lus) < 0) {
fprintf(stderr, "Error writing to buffer\n");
return;
}
}
}
if(channel && ssh_channel_is_closed(channel)){
ssh_channel_free(channel);
channel=NULL;
}
}
ssh_buffer_free(readbuf);
}
#else /* CHANNEL_SELECT */
static void select_loop(ssh_session session,ssh_channel channel){
fd_set fds;
struct timeval timeout;
char buffer[4096];
/* channels will be set to the channels to poll.
* outchannels will contain the result of the poll
*/
ssh_channel channels[2], outchannels[2];
int lus;
int eof=0;
int maxfd;
int ret;
while(channel){
do{
FD_ZERO(&fds);
if(!eof)
FD_SET(0,&fds);
timeout.tv_sec=30;
timeout.tv_usec=0;
FD_SET(ssh_get_fd(session),&fds);
maxfd=ssh_get_fd(session)+1;
channels[0]=channel; // set the first channel we want to read from
channels[1]=NULL;
ret=ssh_select(channels,outchannels,maxfd,&fds,&timeout);
if(signal_delayed)
sizechanged();
if(ret==EINTR)
continue;
if(FD_ISSET(0,&fds)){
lus=read(0,buffer,sizeof(buffer));
if(lus)
ssh_channel_write(channel,buffer,lus);
else {
eof=1;
ssh_channel_send_eof(channel);
}
}
if(channel && ssh_channel_is_closed(channel)){
ssh_log(session,SSH_LOG_RARE,"exit-status : %d\n",ssh_channel_get_exit_status(channel));
ssh_channel_free(channel);
channel=NULL;
channels[0]=NULL;
}
if(outchannels[0]){
while(channel && ssh_channel_is_open(channel) && ssh_channel_poll(channel,0)!=0){
lus=ssh_channel_read(channel,buffer,sizeof(buffer),0);
if(lus==-1){
fprintf(stderr, "Error reading channel: %s\n",
ssh_get_error(session));
return;
}
if(lus==0){
ssh_log(session,SSH_LOG_RARE,"EOF received\n");
ssh_log(session,SSH_LOG_RARE,"exit-status : %d\n",ssh_channel_get_exit_status(channel));
ssh_channel_free(channel);
channel=channels[0]=NULL;
} else
if (write(1,buffer,lus) < 0) {
fprintf(stderr, "Error writing to buffer\n");
return;
}
}
while(channel && ssh_channel_is_open(channel) && ssh_channel_poll(channel,1)!=0){ /* stderr */
lus=ssh_channel_read(channel,buffer,sizeof(buffer),1);
if(lus==-1){
fprintf(stderr, "Error reading channel: %s\n",
ssh_get_error(session));
return;
}
if(lus==0){
ssh_log(session,SSH_LOG_RARE,"EOF received\n");
ssh_log(session,SSH_LOG_RARE,"exit-status : %d\n",ssh_channel_get_exit_status(channel));
ssh_channel_free(channel);
channel=channels[0]=NULL;
} else
if (write(2,buffer,lus) < 0) {
fprintf(stderr, "Error writing to buffer\n");
return;
}
}
}
if(channel && ssh_channel_is_closed(channel)){
ssh_channel_free(channel);
channel=NULL;
}
} while (ret==EINTR || ret==SSH_EINTR);
}
}
#endif
static void shell(ssh_session session){
ssh_channel channel;
struct termios terminal_local;
int interactive=isatty(0);
channel = ssh_channel_new(session);
if(interactive){
tcgetattr(0,&terminal_local);
memcpy(&terminal,&terminal_local,sizeof(struct termios));
}
if(ssh_channel_open_session(channel)){
printf("error opening channel : %s\n",ssh_get_error(session));
return;
}
chan=channel;
if(interactive){
ssh_channel_request_pty(channel);
sizechanged();
}
if(ssh_channel_request_shell(channel)){
printf("Requesting shell : %s\n",ssh_get_error(session));
return;
}
if(interactive){
cfmakeraw(&terminal_local);
tcsetattr(0,TCSANOW,&terminal_local);
setsignal();
}
signal(SIGTERM,do_cleanup);
select_loop(session,channel);
if(interactive)
do_cleanup(0);
}
static void batch_shell(ssh_session session){
ssh_channel channel;
char buffer[1024];
int i,s=0;
for(i=0;i<MAXCMD && cmds[i];++i)
s+=snprintf(buffer+s,sizeof(buffer)-s,"%s ",cmds[i]);
channel=ssh_channel_new(session);
ssh_channel_open_session(channel);
if(ssh_channel_request_exec(channel,buffer)){
printf("error executing \"%s\" : %s\n",buffer,ssh_get_error(session));
return;
}
select_loop(session,channel);
}
static int client(ssh_session session){
int auth=0;
char *banner;
int state;
if (user)
if (ssh_options_set(session, SSH_OPTIONS_USER, user) < 0)
return -1;
if (ssh_options_set(session, SSH_OPTIONS_HOST ,host) < 0)
return -1;
if (proxycommand != NULL){
if(ssh_options_set(session, SSH_OPTIONS_PROXYCOMMAND, proxycommand))
return -1;
}
ssh_options_parse_config(session, NULL);
if(ssh_connect(session)){
fprintf(stderr,"Connection failed : %s\n",ssh_get_error(session));
return -1;
}
state=verify_knownhost(session);
if (state != 0)
return -1;
ssh_userauth_none(session, NULL);
banner=ssh_get_issue_banner(session);
if(banner){
printf("%s\n",banner);
free(banner);
}
auth=authenticate_console(session);
if(auth != SSH_AUTH_SUCCESS){
return -1;
}
ssh_log(session, SSH_LOG_FUNCTIONS, "Authentication success");
if(!cmds[0])
shell(session);
else
batch_shell(session);
return 0;
}
ssh_pcap_file pcap;
void set_pcap(ssh_session session);
void set_pcap(ssh_session session){
if(!pcap_file)
return;
pcap=ssh_pcap_file_new();
if(!pcap)
return;
if(ssh_pcap_file_open(pcap,pcap_file) == SSH_ERROR){
printf("Error opening pcap file\n");
ssh_pcap_file_free(pcap);
pcap=NULL;
return;
}
ssh_set_pcap_file(session,pcap);
}
void cleanup_pcap(void);
void cleanup_pcap(){
if(pcap)
ssh_pcap_file_free(pcap);
pcap=NULL;
}
int main(int argc, char **argv){
ssh_session session;
session = ssh_new();
ssh_callbacks_init(&cb);
ssh_set_callbacks(session,&cb);
if(ssh_options_getopt(session, &argc, argv)) {
fprintf(stderr, "error parsing command line :%s\n",
ssh_get_error(session));
usage();
}
opts(argc,argv);
signal(SIGTERM, do_exit);
set_pcap(session);
client(session);
ssh_disconnect(session);
ssh_free(session);
cleanup_pcap();
ssh_finalize();
return 0;
}

View File

@@ -15,11 +15,13 @@ clients must be made or how a client should react.
#include <sys/statvfs.h>
#include <stdio.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <libssh/libssh.h>
#include <libssh/sftp.h>
@@ -27,239 +29,265 @@ clients must be made or how a client should react.
#include "examples_common.h"
#ifdef WITH_SFTP
int verbosity;
char *destination;
#define DATALEN 65536
static void do_sftp(ssh_session session){
sftp_session sftp=sftp_new(session);
#ifndef BUF_SIZE
#define BUF_SIZE 65536
#endif
static int verbosity;
static char *destination;
static void do_sftp(ssh_session session) {
sftp_session sftp = sftp_new(session);
sftp_dir dir;
sftp_attributes file;
sftp_statvfs_t sftpstatvfs;
struct statvfs sysstatvfs;
sftp_file fichier;
sftp_file to;
int len=1;
int len = 1;
unsigned int i;
char data[DATALEN]={0};
char data[BUF_SIZE] = {0};
char *lnk;
unsigned int count;
if(!sftp){
if (!sftp) {
fprintf(stderr, "sftp error initialising channel: %s\n",
ssh_get_error(session));
return;
ssh_get_error(session));
goto end;
}
if(sftp_init(sftp)){
if (sftp_init(sftp)) {
fprintf(stderr, "error initialising sftp: %s\n",
ssh_get_error(session));
return;
ssh_get_error(session));
goto end;
}
printf("Additional SFTP extensions provided by the server:\n");
count = sftp_extensions_get_count(sftp);
for (i = 0; i < count; i++) {
printf("\t%s, version: %s\n",
sftp_extensions_get_name(sftp, i),
sftp_extensions_get_data(sftp, i));
printf("\t%s, version: %s\n",
sftp_extensions_get_name(sftp, i),
sftp_extensions_get_data(sftp, i));
}
/* test symlink and readlink */
if (sftp_symlink(sftp, "/tmp/this_is_the_link",
"/tmp/sftp_symlink_test") < 0) {
fprintf(stderr, "Could not create link (%s)\n", ssh_get_error(session));
return;
"/tmp/sftp_symlink_test") < 0)
{
fprintf(stderr, "Could not create link (%s)\n",
ssh_get_error(session));
goto end;
}
lnk = sftp_readlink(sftp, "/tmp/sftp_symlink_test");
if (lnk == NULL) {
fprintf(stderr, "Could not read link (%s)\n", ssh_get_error(session));
return;
fprintf(stderr, "Could not read link (%s)\n", ssh_get_error(session));
goto end;
}
printf("readlink /tmp/sftp_symlink_test: %s\n", lnk);
sftp_unlink(sftp, "/tmp/sftp_symlink_test");
if (sftp_extension_supported(sftp, "statvfs@openssh.com", "2")) {
sftpstatvfs = sftp_statvfs(sftp, "/tmp");
if (sftpstatvfs == NULL) {
fprintf(stderr, "statvfs failed (%s)\n", ssh_get_error(session));
return;
}
sftpstatvfs = sftp_statvfs(sftp, "/tmp");
if (sftpstatvfs == NULL) {
fprintf(stderr, "statvfs failed (%s)\n", ssh_get_error(session));
goto end;
}
printf("sftp statvfs:\n"
"\tfile system block size: %llu\n"
"\tfundamental fs block size: %llu\n"
"\tnumber of blocks (unit f_frsize): %llu\n"
"\tfree blocks in file system: %llu\n"
"\tfree blocks for non-root: %llu\n"
"\ttotal file inodes: %llu\n"
"\tfree file inodes: %llu\n"
"\tfree file inodes for to non-root: %llu\n"
"\tfile system id: %llu\n"
"\tbit mask of f_flag values: %llu\n"
"\tmaximum filename length: %llu\n",
(unsigned long long) sftpstatvfs->f_bsize,
(unsigned long long) sftpstatvfs->f_frsize,
(unsigned long long) sftpstatvfs->f_blocks,
(unsigned long long) sftpstatvfs->f_bfree,
(unsigned long long) sftpstatvfs->f_bavail,
(unsigned long long) sftpstatvfs->f_files,
(unsigned long long) sftpstatvfs->f_ffree,
(unsigned long long) sftpstatvfs->f_favail,
(unsigned long long) sftpstatvfs->f_fsid,
(unsigned long long) sftpstatvfs->f_flag,
(unsigned long long) sftpstatvfs->f_namemax);
printf("sftp statvfs:\n"
"\tfile system block size: %llu\n"
"\tfundamental fs block size: %llu\n"
"\tnumber of blocks (unit f_frsize): %llu\n"
"\tfree blocks in file system: %llu\n"
"\tfree blocks for non-root: %llu\n"
"\ttotal file inodes: %llu\n"
"\tfree file inodes: %llu\n"
"\tfree file inodes for to non-root: %llu\n"
"\tfile system id: %llu\n"
"\tbit mask of f_flag values: %llu\n"
"\tmaximum filename length: %llu\n",
(unsigned long long) sftpstatvfs->f_bsize,
(unsigned long long) sftpstatvfs->f_frsize,
(unsigned long long) sftpstatvfs->f_blocks,
(unsigned long long) sftpstatvfs->f_bfree,
(unsigned long long) sftpstatvfs->f_bavail,
(unsigned long long) sftpstatvfs->f_files,
(unsigned long long) sftpstatvfs->f_ffree,
(unsigned long long) sftpstatvfs->f_favail,
(unsigned long long) sftpstatvfs->f_fsid,
(unsigned long long) sftpstatvfs->f_flag,
(unsigned long long) sftpstatvfs->f_namemax);
sftp_statvfs_free(sftpstatvfs);
sftp_statvfs_free(sftpstatvfs);
if (statvfs("/tmp", &sysstatvfs) < 0) {
fprintf(stderr, "statvfs failed (%s)\n", strerror(errno));
return;
}
if (statvfs("/tmp", &sysstatvfs) < 0) {
fprintf(stderr, "statvfs failed (%s)\n", strerror(errno));
goto end;
}
printf("sys statvfs:\n"
"\tfile system block size: %llu\n"
"\tfundamental fs block size: %llu\n"
"\tnumber of blocks (unit f_frsize): %llu\n"
"\tfree blocks in file system: %llu\n"
"\tfree blocks for non-root: %llu\n"
"\ttotal file inodes: %llu\n"
"\tfree file inodes: %llu\n"
"\tfree file inodes for to non-root: %llu\n"
"\tfile system id: %llu\n"
"\tbit mask of f_flag values: %llu\n"
"\tmaximum filename length: %llu\n",
(unsigned long long) sysstatvfs.f_bsize,
(unsigned long long) sysstatvfs.f_frsize,
(unsigned long long) sysstatvfs.f_blocks,
(unsigned long long) sysstatvfs.f_bfree,
(unsigned long long) sysstatvfs.f_bavail,
(unsigned long long) sysstatvfs.f_files,
(unsigned long long) sysstatvfs.f_ffree,
(unsigned long long) sysstatvfs.f_favail,
(unsigned long long) sysstatvfs.f_fsid,
(unsigned long long) sysstatvfs.f_flag,
(unsigned long long) sysstatvfs.f_namemax);
printf("sys statvfs:\n"
"\tfile system block size: %llu\n"
"\tfundamental fs block size: %llu\n"
"\tnumber of blocks (unit f_frsize): %llu\n"
"\tfree blocks in file system: %llu\n"
"\tfree blocks for non-root: %llu\n"
"\ttotal file inodes: %llu\n"
"\tfree file inodes: %llu\n"
"\tfree file inodes for to non-root: %llu\n"
"\tfile system id: %llu\n"
"\tbit mask of f_flag values: %llu\n"
"\tmaximum filename length: %llu\n",
(unsigned long long) sysstatvfs.f_bsize,
(unsigned long long) sysstatvfs.f_frsize,
(unsigned long long) sysstatvfs.f_blocks,
(unsigned long long) sysstatvfs.f_bfree,
(unsigned long long) sysstatvfs.f_bavail,
(unsigned long long) sysstatvfs.f_files,
(unsigned long long) sysstatvfs.f_ffree,
(unsigned long long) sysstatvfs.f_favail,
(unsigned long long) sysstatvfs.f_fsid,
(unsigned long long) sysstatvfs.f_flag,
(unsigned long long) sysstatvfs.f_namemax);
}
/* the connection is made */
/* opening a directory */
dir=sftp_opendir(sftp,"./");
if(!dir) {
dir = sftp_opendir(sftp, "./");
if (!dir) {
fprintf(stderr, "Directory not opened(%s)\n", ssh_get_error(session));
return ;
goto end;
}
/* reading the whole directory, file by file */
while((file=sftp_readdir(sftp,dir))){
while ((file = sftp_readdir(sftp, dir))) {
fprintf(stderr, "%30s(%.8o) : %s(%.5d) %s(%.5d) : %.10llu bytes\n",
file->name,
file->permissions,
file->owner,
file->uid,
file->group,
file->gid,
(long long unsigned int) file->size);
file->name,
file->permissions,
file->owner,
file->uid,
file->group,
file->gid,
(long long unsigned int) file->size);
sftp_attributes_free(file);
}
/* when file=NULL, an error has occured OR the directory listing is end of file */
if(!sftp_dir_eof(dir)){
/* when file = NULL, an error has occured OR the directory listing is end of
* file */
if (!sftp_dir_eof(dir)) {
fprintf(stderr, "Error: %s\n", ssh_get_error(session));
return;
goto end;
}
if(sftp_closedir(dir)){
if (sftp_closedir(dir)) {
fprintf(stderr, "Error: %s\n", ssh_get_error(session));
return;
goto end;
}
/* this will open a file and copy it into your /home directory */
/* the small buffer size was intended to stress the library. of course, you can use a buffer till 20kbytes without problem */
/* the small buffer size was intended to stress the library. of course, you
* can use a buffer till 20kbytes without problem */
fichier=sftp_open(sftp,"/usr/bin/ssh",O_RDONLY, 0);
if(!fichier){
fichier = sftp_open(sftp, "/usr/bin/ssh", O_RDONLY, 0);
if (!fichier) {
fprintf(stderr, "Error opening /usr/bin/ssh: %s\n",
ssh_get_error(session));
return;
ssh_get_error(session));
goto end;
}
/* open a file for writing... */
to=sftp_open(sftp,"ssh-copy",O_WRONLY | O_CREAT, 0700);
if(!to){
to = sftp_open(sftp, "ssh-copy", O_WRONLY | O_CREAT, 0700);
if (!to) {
fprintf(stderr, "Error opening ssh-copy for writing: %s\n",
ssh_get_error(session));
return;
ssh_get_error(session));
sftp_close(fichier);
goto end;
}
while((len=sftp_read(fichier,data,4096)) > 0){
if(sftp_write(to,data,len)!=len){
while ((len = sftp_read(fichier, data, 4096)) > 0) {
if (sftp_write(to, data, len) != len) {
fprintf(stderr, "Error writing %d bytes: %s\n",
len, ssh_get_error(session));
return;
len, ssh_get_error(session));
sftp_close(to);
sftp_close(fichier);
goto end;
}
}
printf("finished\n");
if(len<0)
if (len < 0) {
fprintf(stderr, "Error reading file: %s\n", ssh_get_error(session));
}
sftp_close(fichier);
sftp_close(to);
printf("fichiers ferm\n");
to=sftp_open(sftp,"/tmp/grosfichier",O_WRONLY|O_CREAT, 0644);
for(i=0;i<1000;++i){
len=sftp_write(to,data,DATALEN);
printf("wrote %d bytes\n",len);
if(len != DATALEN){
printf("chunk %d : %d (%s)\n",i,len,ssh_get_error(session));
to = sftp_open(sftp, "/tmp/grosfichier", O_WRONLY|O_CREAT, 0644);
for (i = 0; i < 1000; ++i) {
len = sftp_write(to, data, sizeof(data));
printf("wrote %d bytes\n", len);
if (len != sizeof(data)) {
printf("chunk %d : %d (%s)\n", i, len, ssh_get_error(session));
}
}
sftp_close(to);
sftp_close(to);
end:
/* close the sftp session */
sftp_free(sftp);
printf("sftp session terminated\n");
}
static void usage(const char *argv0){
fprintf(stderr,"Usage : %s [-v] remotehost\n"
"sample sftp test client - libssh-%s\n"
"Options :\n"
" -v : increase log verbosity\n",
argv0,
ssh_version(0));
exit(0);
static void usage(const char *argv0) {
fprintf(stderr, "Usage : %s [-v] remotehost\n"
"sample sftp test client - libssh-%s\n"
"Options :\n"
" -v : increase log verbosity\n",
argv0,
ssh_version(0));
exit(0);
}
static int opts(int argc, char **argv){
int i;
while((i=getopt(argc,argv,"v"))!=-1){
switch(i){
case 'v':
verbosity++;
break;
default:
fprintf(stderr,"unknown option %c\n",optopt);
static int opts(int argc, char **argv) {
int i;
while ((i = getopt(argc, argv, "v")) != -1) {
switch(i) {
case 'v':
verbosity++;
break;
default:
fprintf(stderr, "unknown option %c\n", optopt);
usage(argv[0]);
return -1;
}
}
destination = argv[optind];
if (destination == NULL) {
usage(argv[0]);
return -1;
}
}
destination=argv[optind];
if(destination == NULL){
usage(argv[0]);
return -1;
}
return 0;
return 0;
}
int main(int argc, char **argv){
ssh_session session;
if(opts(argc,argv)<0)
return EXIT_FAILURE;
session=connect_ssh(destination,NULL,verbosity);
if(session == NULL)
return EXIT_FAILURE;
do_sftp(session);
ssh_disconnect(session);
ssh_free(session);
return 0;
int main(int argc, char **argv) {
ssh_session session;
if (opts(argc, argv) < 0) {
return EXIT_FAILURE;
}
session = connect_ssh(destination, NULL, verbosity);
if (session == NULL) {
return EXIT_FAILURE;
}
do_sftp(session);
ssh_disconnect(session);
ssh_free(session);
return 0;
}
#endif

356
examples/samplesshd-cb.c Normal file
View File

@@ -0,0 +1,356 @@
/* This is a sample implementation of a libssh based SSH server */
/*
Copyright 2003-2009 Aris Adamantiadis
This file is part of the SSH Library
You are free to copy this file, modify it in any way, consider it being public
domain. This does not apply to the rest of the library though, but it is
allowed to cut-and-paste working code from this file to any license of
program.
The goal is to show the API in action. It's not a reference on how terminal
clients must be made or how a client should react.
*/
#include "config.h"
#include <libssh/libssh.h>
#include <libssh/server.h>
#include <libssh/callbacks.h>
#ifdef HAVE_ARGP_H
#include <argp.h>
#endif
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#ifdef _WIN32
#include <io.h>
#endif
#ifndef BUF_SIZE
#define BUF_SIZE 2049
#endif
#ifndef KEYS_FOLDER
#ifdef _WIN32
#define KEYS_FOLDER
#else
#define KEYS_FOLDER "/etc/ssh/"
#endif
#endif
#define USER "myuser"
#define PASSWORD "mypassword"
static int authenticated=0;
static int tries = 0;
static int error = 0;
static ssh_channel chan=NULL;
static int auth_none(ssh_session session,
const char *user,
void *userdata)
{
ssh_string banner = NULL;
(void)user; /* unused */
(void)userdata; /* unused */
ssh_set_auth_methods(session,
SSH_AUTH_METHOD_PASSWORD | SSH_AUTH_METHOD_GSSAPI_MIC);
banner = ssh_string_from_char("Banner Example\n");
if (banner != NULL) {
ssh_send_issue_banner(session, banner);
}
ssh_string_free(banner);
return SSH_AUTH_DENIED;
}
static int auth_password(ssh_session session, const char *user,
const char *password, void *userdata){
(void)userdata;
printf("Authenticating user %s pwd %s\n",user, password);
if(strcmp(user,USER) == 0 && strcmp(password, PASSWORD) == 0){
authenticated = 1;
printf("Authenticated\n");
return SSH_AUTH_SUCCESS;
}
if (tries >= 3){
printf("Too many authentication tries\n");
ssh_disconnect(session);
error = 1;
return SSH_AUTH_DENIED;
}
tries++;
return SSH_AUTH_DENIED;
}
#ifdef WITH_GSSAPI
static int auth_gssapi_mic(ssh_session session, const char *user, const char *principal, void *userdata){
ssh_gssapi_creds creds = ssh_gssapi_get_creds(session);
(void)userdata;
printf("Authenticating user %s with gssapi principal %s\n",user, principal);
if (creds != NULL)
printf("Received some gssapi credentials\n");
else
printf("Not received any forwardable creds\n");
printf("authenticated\n");
authenticated = 1;
return SSH_AUTH_SUCCESS;
}
#endif
static int pty_request(ssh_session session, ssh_channel channel, const char *term,
int x,int y, int px, int py, void *userdata){
(void) session;
(void) channel;
(void) term;
(void) x;
(void) y;
(void) px;
(void) py;
(void) userdata;
printf("Allocated terminal\n");
return 0;
}
static int shell_request(ssh_session session, ssh_channel channel, void *userdata){
(void)session;
(void)channel;
(void)userdata;
printf("Allocated shell\n");
return 0;
}
struct ssh_channel_callbacks_struct channel_cb = {
.channel_pty_request_function = pty_request,
.channel_shell_request_function = shell_request
};
static ssh_channel new_session_channel(ssh_session session, void *userdata){
(void) session;
(void) userdata;
if(chan != NULL)
return NULL;
printf("Allocated session channel\n");
chan = ssh_channel_new(session);
ssh_callbacks_init(&channel_cb);
ssh_set_channel_callbacks(chan, &channel_cb);
return chan;
}
#ifdef HAVE_ARGP_H
const char *argp_program_version = "libssh server example "
SSH_STRINGIFY(LIBSSH_VERSION);
const char *argp_program_bug_address = "<libssh@libssh.org>";
/* Program documentation. */
static char doc[] = "libssh -- a Secure Shell protocol implementation";
/* A description of the arguments we accept. */
static char args_doc[] = "BINDADDR";
/* The options we understand. */
static struct argp_option options[] = {
{
.name = "port",
.key = 'p',
.arg = "PORT",
.flags = 0,
.doc = "Set the port to bind.",
.group = 0
},
{
.name = "hostkey",
.key = 'k',
.arg = "FILE",
.flags = 0,
.doc = "Set the host key.",
.group = 0
},
{
.name = "dsakey",
.key = 'd',
.arg = "FILE",
.flags = 0,
.doc = "Set the dsa key.",
.group = 0
},
{
.name = "rsakey",
.key = 'r',
.arg = "FILE",
.flags = 0,
.doc = "Set the rsa key.",
.group = 0
},
{
.name = "verbose",
.key = 'v',
.arg = NULL,
.flags = 0,
.doc = "Get verbose output.",
.group = 0
},
{
.name = "config",
.key = 'f',
.arg = "FILE",
.flags = 0,
.doc = "Configuration file to use.",
.group = 0
},
{NULL, 0, NULL, 0, NULL, 0}
};
/* Parse a single option. */
static error_t parse_opt (int key, char *arg, struct argp_state *state) {
/* Get the input argument from argp_parse, which we
* know is a pointer to our arguments structure.
*/
ssh_bind sshbind = state->input;
switch (key) {
case 'p':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDPORT_STR, arg);
break;
case 'd':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY, arg);
break;
case 'k':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_HOSTKEY, arg);
break;
case 'r':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, arg);
break;
case 'v':
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_LOG_VERBOSITY_STR, "3");
break;
case 'f':
ssh_bind_options_parse_config(sshbind, arg);
break;
case ARGP_KEY_ARG:
if (state->arg_num >= 1) {
/* Too many arguments. */
argp_usage (state);
}
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_BINDADDR, arg);
break;
case ARGP_KEY_END:
if (state->arg_num < 1) {
/* Not enough arguments. */
argp_usage (state);
}
break;
default:
return ARGP_ERR_UNKNOWN;
}
return 0;
}
/* Our argp parser. */
static struct argp argp = {options, parse_opt, args_doc, doc, NULL, NULL, NULL};
#endif /* HAVE_ARGP_H */
int main(int argc, char **argv){
ssh_session session;
ssh_bind sshbind;
ssh_event mainloop;
struct ssh_server_callbacks_struct cb = {
.userdata = NULL,
.auth_none_function = auth_none,
.auth_password_function = auth_password,
#ifdef WITH_GSSAPI
.auth_gssapi_mic_function = auth_gssapi_mic,
#endif
.channel_open_request_session_function = new_session_channel
};
char buf[BUF_SIZE];
int i;
int r;
sshbind=ssh_bind_new();
session=ssh_new();
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_DSAKEY, KEYS_FOLDER "ssh_host_dsa_key");
ssh_bind_options_set(sshbind, SSH_BIND_OPTIONS_RSAKEY, KEYS_FOLDER "ssh_host_rsa_key");
#ifdef HAVE_ARGP_H
/*
* Parse our arguments; every option seen by parse_opt will
* be reflected in arguments.
*/
argp_parse (&argp, argc, argv, 0, 0, sshbind);
#else
(void) argc;
(void) argv;
#endif
if(ssh_bind_listen(sshbind)<0){
printf("Error listening to socket: %s\n",ssh_get_error(sshbind));
return 1;
}
r=ssh_bind_accept(sshbind,session);
if(r==SSH_ERROR){
printf("error accepting a connection : %s\n",ssh_get_error(sshbind));
return 1;
}
ssh_callbacks_init(&cb);
ssh_set_server_callbacks(session, &cb);
if (ssh_handle_key_exchange(session)) {
printf("ssh_handle_key_exchange: %s\n", ssh_get_error(session));
return 1;
}
ssh_set_auth_methods(session,SSH_AUTH_METHOD_PASSWORD | SSH_AUTH_METHOD_GSSAPI_MIC);
mainloop = ssh_event_new();
ssh_event_add_session(mainloop, session);
while (!(authenticated && chan != NULL)){
if(error)
break;
r = ssh_event_dopoll(mainloop, -1);
if (r == SSH_ERROR){
printf("Error : %s\n",ssh_get_error(session));
ssh_disconnect(session);
return 1;
}
}
if(error){
printf("Error, exiting loop\n");
} else
printf("Authenticated and got a channel\n");
do{
i=ssh_channel_read(chan, buf, sizeof(buf) - 1, 0);
if(i>0) {
if (ssh_channel_write(chan, buf, i) == SSH_ERROR) {
printf("error writing to channel\n");
return 1;
}
buf[i] = '\0';
printf("%s", buf);
fflush(stdout);
if (buf[0] == '\x0d') {
if (ssh_channel_write(chan, "\n", 1) == SSH_ERROR) {
printf("error writing to channel\n");
return 1;
}
printf("\n");
}
}
} while (i>0);
ssh_disconnect(session);
ssh_bind_free(sshbind);
ssh_finalize();
return 0;
}

Some files were not shown because too many files have changed in this diff Show More