aboutsummaryrefslogtreecommitdiff
path: root/tests/unittests
AgeCommit message (Collapse)AuthorFilesLines
2018-02-12tests: Fix segfault with mbedTLS built without threading supportjvijtiuk2-2/+10
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-01-10torture_pki_ed25519: Add tests for private key with passphraseAndreas Schneider1-0/+43
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10torture_pki_ecdsa: Add tests for private key with passphraseAndreas Schneider1-0/+42
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10torture_pki_dsa: Add tests for private key with passphraseAndreas Schneider1-0/+42
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10torture_pki_rsa: Add tests for private key with passphraseAndreas Schneider1-0/+42
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10pki_crypto: Fix private key generation with passwordAndreas Schneider3-3/+3
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-10tests: Move torture keys to own fileAndreas Schneider6-0/+6
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10cmake: Move ed25519 tests into unix partAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10tests: Move rsa tests to own test fileAndreas Schneider3-523/+549
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10tests: Remove obsolete setup_both_keys()Andreas Schneider1-10/+0
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10tests: Move ed25519 functions to the right fileAndreas Schneider2-289/+308
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10tests: Move ecdsa tests to own test fileAndreas Schneider3-487/+497
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10tests: Move dsa tests to own test fileAndreas Schneider3-387/+439
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-10tests: Move helper functions to a common fileAndreas Schneider1-69/+6
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2018-01-04tests: Fix torture_pki with libcryptoAndreas Schneider1-1/+3
This stops asking for a passphrase on commandline. Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-28add mbedtls crypto supportJuraj Vijtiuk3-5/+68
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-21tests/config: Verify LogLevel from config is appliedJakub Jelen1-0/+10
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-21tests/config: Newly parsed optionsJakub Jelen1-3/+10
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-21tests/config: Enable and disable authentication methodsJakub Jelen1-0/+80
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-21tests/config: Verify known_hosts files are appliedJakub Jelen1-0/+26
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-21tests: HostkeyAlgorithms passed from config to optionsJakub Jelen2-0/+32
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-21config: Add CMake check for glob()Jakub Jelen1-1/+5
2017-12-21config: glob support for include with testNoName1151-0/+40
Signed-off-by: NoName115 <robert.kolcun@gmail.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-15config: support for MACsJakub Jelen2-1/+14
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-15tests/config: Text KexAlgorithms parsing in ssh_configJakub Jelen1-1/+5
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-15tests/options: Verify key exchange algorithms are set properlyJakub Jelen1-0/+29
Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-12-15Add new optionsAris Adamantiadis1-0/+29
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-10-28Fix config.h includesAndreas Schneider14-0/+27
We need stdlib.h and string.h in priv.h for free() and memset(). Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-09-11config: fix memory leak with repeated opcodesJon Simons1-1/+20
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-08-24torture_options: test the setting of ciphers and MACsNikos Mavrogiannopoulos1-0/+40
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
2017-08-24tests: added unit test on including config filesNikos Mavrogiannopoulos2-0/+96
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-08-17tests: plug leak in torture_bind_options_import_keyJon Simons1-1/+2
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-07-18misc: relax fatal errors in ssh_analyze_bannerJon Simons1-21/+19
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-14tests: Fix endifAndreas Schneider1-1/+1
Ups. Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-14tests: Only run ssh_bind test if we build with server supportAndreas Schneider1-0/+6
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-13misc: fix error-checking in ssh_analyze_bannerJon Simons1-2/+0
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-13tests: torture-misc: add torture_ssh_analyze_bannerJon Simons1-0/+146
Signed-off-by: Jon Simons <jon@jonsimons.org> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-07-13tests: torture-misc: fix 4-space indentationJon Simons1-4/+4
Signed-off-by: Jon Simons <jon@jonsimons.org> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2017-04-11server: Add option SSH_BIND_OPTIONS_IMPORT_KEY to serverAlfredo Mazzinghi1-0/+52
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>
2016-11-07tests: Fix typo in torture_cryptoAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-05callbacks: Add support for MSVCAndreas Schneider1-2/+2
__typeof__ is GCC specific Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-04tests: Fix memory leak in torture_callbacksAndreas Schneider1-0/+2
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-04tests: Reset output buffer in torture_cryptoAndreas Schneider1-0/+1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-04tests: Some cleanup for torture_pkiAndreas Schneider1-2/+5
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-11-03tests: Disable x11 test which fails too oftenAndreas Schneider1-3/+4
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-09tests: Try to fix the x11 testAndreas Schneider1-0/+1
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-09tests: Fix buffer test without NARG macro supportAndreas Schneider1-0/+3
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02tests: Add test for ssh_callbacks_iterate()Aris Adamantiadis1-1/+52
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-05-02tests: Add unit test for ssh_callbacks_execute_listAris Adamantiadis1-0/+86
Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
2016-03-21torture: Fix guardJustus Winter1-1/+1
* 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>