1
1

3540 Коммитов

Автор SHA1 Сообщение Дата
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:
 * e66f370682927ca8bd7ae0e7544754c6f4ac4969

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

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

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

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

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

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

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

Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-18 09:30:19 +02:00
Jon Simons
2f42296edd wrapper: fix 4-space indentation in ssh_cipher_clear
Signed-off-by: Jon Simons <jon@jonsimons.org>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-18 09:29:56 +02:00
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 cf1e808e2ffa1f26644fb5d2cb82a919f323deba.

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

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

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

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

Found running the `pkd_hello` test with:

    valgrind ./pkd_hello -i1 -t torture_pkd_openssh_dsa_rsa_default

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

[1] 6e59a892db

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

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-06-28 12:29:53 +02:00
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