mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-07-31 00:03:07 +03:00
tests: Migrate torture_algorithms to a cwrap test
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
@ -2,7 +2,6 @@ project(clienttests C)
|
|||||||
|
|
||||||
find_package(socket_wrapper)
|
find_package(socket_wrapper)
|
||||||
|
|
||||||
add_cmocka_test(torture_algorithms torture_algorithms.c ${TORTURE_LIBRARY})
|
|
||||||
add_cmocka_test(torture_knownhosts torture_knownhosts.c ${TORTURE_LIBRARY})
|
add_cmocka_test(torture_knownhosts torture_knownhosts.c ${TORTURE_LIBRARY})
|
||||||
add_cmocka_test(torture_proxycommand torture_proxycommand.c ${TORTURE_LIBRARY})
|
add_cmocka_test(torture_proxycommand torture_proxycommand.c ${TORTURE_LIBRARY})
|
||||||
add_cmocka_test(torture_session torture_session.c ${TORTURE_LIBRARY})
|
add_cmocka_test(torture_session torture_session.c ${TORTURE_LIBRARY})
|
||||||
@ -15,6 +14,7 @@ if (WITH_SFTP)
|
|||||||
endif (WITH_SFTP)
|
endif (WITH_SFTP)
|
||||||
|
|
||||||
set(LIBSSH_CLIENT_TESTS
|
set(LIBSSH_CLIENT_TESTS
|
||||||
|
torture_algorithms
|
||||||
torture_connect
|
torture_connect
|
||||||
torture_auth)
|
torture_auth)
|
||||||
|
|
||||||
|
@ -25,18 +25,42 @@
|
|||||||
#include "libssh/libssh.h"
|
#include "libssh/libssh.h"
|
||||||
#include "libssh/priv.h"
|
#include "libssh/priv.h"
|
||||||
|
|
||||||
|
static int sshd_setup(void **state)
|
||||||
static int setup(void **state) {
|
{
|
||||||
int verbosity=torture_libssh_verbosity();
|
torture_setup_sshd_server(state);
|
||||||
ssh_session session = ssh_new();
|
|
||||||
ssh_options_set(session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
|
|
||||||
*state = session;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int teardown(void **state) {
|
static int sshd_teardown(void **state) {
|
||||||
ssh_free(*state);
|
torture_teardown_sshd_server(state);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int session_setup(void **state) {
|
||||||
|
struct torture_state *s = *state;
|
||||||
|
int verbosity = torture_libssh_verbosity();
|
||||||
|
|
||||||
|
ssh_init();
|
||||||
|
|
||||||
|
s->ssh.session = ssh_new();
|
||||||
|
assert_non_null(s->ssh.session);
|
||||||
|
|
||||||
|
ssh_options_set(s->ssh.session, SSH_OPTIONS_LOG_VERBOSITY, &verbosity);
|
||||||
|
ssh_options_set(s->ssh.session, SSH_OPTIONS_HOST, TORTURE_SSH_SERVER);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int session_teardown(void **state)
|
||||||
|
{
|
||||||
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
ssh_disconnect(s->ssh.session);
|
||||||
|
ssh_free(s->ssh.session);
|
||||||
|
|
||||||
|
ssh_finalize();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -44,148 +68,191 @@ static int teardown(void **state) {
|
|||||||
static void test_algorithm(ssh_session session, const char *algo, const char *hmac) {
|
static void test_algorithm(ssh_session session, const char *algo, const char *hmac) {
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_HOST, "localhost");
|
|
||||||
assert_true(rc == SSH_OK);
|
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_CIPHERS_C_S, algo);
|
rc = ssh_options_set(session, SSH_OPTIONS_CIPHERS_C_S, algo);
|
||||||
assert_true(rc == SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_CIPHERS_S_C, algo);
|
rc = ssh_options_set(session, SSH_OPTIONS_CIPHERS_S_C, algo);
|
||||||
assert_true(rc == SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_HMAC_C_S, hmac);
|
rc = ssh_options_set(session, SSH_OPTIONS_HMAC_C_S, hmac);
|
||||||
assert_true(rc == SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_HMAC_S_C, hmac);
|
rc = ssh_options_set(session, SSH_OPTIONS_HMAC_S_C, hmac);
|
||||||
assert_true(rc == SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
|
|
||||||
rc = ssh_connect(session);
|
rc = ssh_connect(session);
|
||||||
assert_true(rc == SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
|
|
||||||
rc = ssh_userauth_none(session, NULL);
|
rc = ssh_userauth_none(session, NULL);
|
||||||
if (rc != SSH_OK) {
|
if (rc != SSH_OK) {
|
||||||
rc = ssh_get_error_code(session);
|
rc = ssh_get_error_code(session);
|
||||||
assert_true(rc == SSH_REQUEST_DENIED);
|
assert_int_equal(rc, SSH_REQUEST_DENIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_disconnect(session);
|
ssh_disconnect(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes128_cbc_hmac_sha1(void **state) {
|
static void torture_algorithms_aes128_cbc_hmac_sha1(void **state) {
|
||||||
test_algorithm(*state, "aes128-cbc", "hmac-sha1");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes128-cbc", "hmac-sha1");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes128_cbc_hmac_sha2_256(void **state) {
|
static void torture_algorithms_aes128_cbc_hmac_sha2_256(void **state) {
|
||||||
test_algorithm(*state, "aes128-cbc", "hmac-sha2-256");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes128-cbc", "hmac-sha2-256");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes128_cbc_hmac_sha2_512(void **state) {
|
static void torture_algorithms_aes128_cbc_hmac_sha2_512(void **state) {
|
||||||
test_algorithm(*state, "aes128-cbc", "hmac-sha2-512");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes128-cbc", "hmac-sha2-512");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes192_cbc_hmac_sha1(void **state) {
|
static void torture_algorithms_aes192_cbc_hmac_sha1(void **state) {
|
||||||
test_algorithm(*state, "aes192-cbc", "hmac-sha1");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes192-cbc", "hmac-sha1");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes192_cbc_hmac_sha2_256(void **state) {
|
static void torture_algorithms_aes192_cbc_hmac_sha2_256(void **state) {
|
||||||
test_algorithm(*state, "aes192-cbc", "hmac-sha2-256");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes192-cbc", "hmac-sha2-256");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes192_cbc_hmac_sha2_512(void **state) {
|
static void torture_algorithms_aes192_cbc_hmac_sha2_512(void **state) {
|
||||||
test_algorithm(*state, "aes192-cbc", "hmac-sha2-512");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes192-cbc", "hmac-sha2-512");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes256_cbc_hmac_sha1(void **state) {
|
static void torture_algorithms_aes256_cbc_hmac_sha1(void **state) {
|
||||||
test_algorithm(*state, "aes256-cbc", "hmac-sha1");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes256-cbc", "hmac-sha1");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes256_cbc_hmac_sha2_256(void **state) {
|
static void torture_algorithms_aes256_cbc_hmac_sha2_256(void **state) {
|
||||||
test_algorithm(*state, "aes256-cbc", "hmac-sha2-256");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes256-cbc", "hmac-sha2-256");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes256_cbc_hmac_sha2_512(void **state) {
|
static void torture_algorithms_aes256_cbc_hmac_sha2_512(void **state) {
|
||||||
test_algorithm(*state, "aes256-cbc", "hmac-sha2-512");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes256-cbc", "hmac-sha2-512");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes128_ctr_hmac_sha1(void **state) {
|
static void torture_algorithms_aes128_ctr_hmac_sha1(void **state) {
|
||||||
test_algorithm(*state, "aes128-ctr", "hmac-sha1");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes128-ctr", "hmac-sha1");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes128_ctr_hmac_sha2_256(void **state) {
|
static void torture_algorithms_aes128_ctr_hmac_sha2_256(void **state) {
|
||||||
test_algorithm(*state, "aes128-ctr", "hmac-sha2-256");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes128-ctr", "hmac-sha2-256");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes128_ctr_hmac_sha2_512(void **state) {
|
static void torture_algorithms_aes128_ctr_hmac_sha2_512(void **state) {
|
||||||
test_algorithm(*state, "aes128-ctr", "hmac-sha2-512");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes128-ctr", "hmac-sha2-512");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes192_ctr_hmac_sha1(void **state) {
|
static void torture_algorithms_aes192_ctr_hmac_sha1(void **state) {
|
||||||
test_algorithm(*state, "aes192-ctr", "hmac-sha1");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes192-ctr", "hmac-sha1");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes192_ctr_hmac_sha2_256(void **state) {
|
static void torture_algorithms_aes192_ctr_hmac_sha2_256(void **state) {
|
||||||
test_algorithm(*state, "aes192-ctr", "hmac-sha2-256");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes192-ctr", "hmac-sha2-256");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes192_ctr_hmac_sha2_512(void **state) {
|
static void torture_algorithms_aes192_ctr_hmac_sha2_512(void **state) {
|
||||||
test_algorithm(*state, "aes192-ctr", "hmac-sha2-512");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes192-ctr", "hmac-sha2-512");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes256_ctr_hmac_sha1(void **state) {
|
static void torture_algorithms_aes256_ctr_hmac_sha1(void **state) {
|
||||||
test_algorithm(*state, "aes256-ctr", "hmac-sha1");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes256-ctr", "hmac-sha1");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes256_ctr_hmac_sha2_256(void **state) {
|
static void torture_algorithms_aes256_ctr_hmac_sha2_256(void **state) {
|
||||||
test_algorithm(*state, "aes256-ctr", "hmac-sha2-256");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes256-ctr", "hmac-sha2-256");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_aes256_ctr_hmac_sha2_512(void **state) {
|
static void torture_algorithms_aes256_ctr_hmac_sha2_512(void **state) {
|
||||||
test_algorithm(*state, "aes256-ctr", "hmac-sha2-512");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "aes256-ctr", "hmac-sha2-512");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_3des_cbc_hmac_sha1(void **state) {
|
static void torture_algorithms_3des_cbc_hmac_sha1(void **state) {
|
||||||
test_algorithm(*state, "3des-cbc", "hmac-sha1");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "3des-cbc", "hmac-sha1");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_3des_cbc_hmac_sha2_256(void **state) {
|
static void torture_algorithms_3des_cbc_hmac_sha2_256(void **state) {
|
||||||
test_algorithm(*state, "3des-cbc", "hmac-sha2-256");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "3des-cbc", "hmac-sha2-256");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_3des_cbc_hmac_sha2_512(void **state) {
|
static void torture_algorithms_3des_cbc_hmac_sha2_512(void **state) {
|
||||||
test_algorithm(*state, "3des-cbc", "hmac-sha2-512");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "3des-cbc", "hmac-sha2-512");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_blowfish_cbc_hmac_sha1(void **state) {
|
static void torture_algorithms_blowfish_cbc_hmac_sha1(void **state) {
|
||||||
test_algorithm(*state, "blowfish-cbc", "hmac-sha1");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "blowfish-cbc", "hmac-sha1");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_blowfish_cbc_hmac_sha2_256(void **state) {
|
static void torture_algorithms_blowfish_cbc_hmac_sha2_256(void **state) {
|
||||||
test_algorithm(*state, "blowfish-cbc", "hmac-sha2-256");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "blowfish-cbc", "hmac-sha2-256");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_blowfish_cbc_hmac_sha2_512(void **state) {
|
static void torture_algorithms_blowfish_cbc_hmac_sha2_512(void **state) {
|
||||||
test_algorithm(*state, "blowfish-cbc", "hmac-sha2-512");
|
struct torture_state *s = *state;
|
||||||
|
|
||||||
|
test_algorithm(s->ssh.session, "blowfish-cbc", "hmac-sha2-512");
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_zlib(void **state) {
|
static void torture_algorithms_zlib(void **state) {
|
||||||
ssh_session session = *state;
|
struct torture_state *s = *state;
|
||||||
|
ssh_session session = s->ssh.session;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ssh_options_set(session,SSH_OPTIONS_HOST,"localhost");
|
|
||||||
assert_true(rc == SSH_OK);
|
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "zlib");
|
rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "zlib");
|
||||||
#ifdef WITH_ZLIB
|
#ifdef WITH_ZLIB
|
||||||
assert_true(rc == SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
#else
|
#else
|
||||||
assert_true(rc == SSH_ERROR);
|
assert_int_equal(rc, SSH_ERROR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "zlib");
|
rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "zlib");
|
||||||
#ifdef WITH_ZLIB
|
#ifdef WITH_ZLIB
|
||||||
assert_true(rc == SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
#else
|
#else
|
||||||
assert_true(rc == SSH_ERROR);
|
assert_int_equal(rc, SSH_ERROR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rc = ssh_connect(session);
|
rc = ssh_connect(session);
|
||||||
@ -196,36 +263,34 @@ static void torture_algorithms_zlib(void **state) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
assert_true(rc == SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
|
|
||||||
rc = ssh_userauth_none(session, NULL);
|
rc = ssh_userauth_none(session, NULL);
|
||||||
if (rc != SSH_OK) {
|
if (rc != SSH_OK) {
|
||||||
rc = ssh_get_error_code(session);
|
rc = ssh_get_error_code(session);
|
||||||
assert_true(rc == SSH_REQUEST_DENIED);
|
assert_int_equal(rc, SSH_REQUEST_DENIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_disconnect(session);
|
ssh_disconnect(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void torture_algorithms_zlib_openssh(void **state) {
|
static void torture_algorithms_zlib_openssh(void **state) {
|
||||||
ssh_session session = *state;
|
struct torture_state *s = *state;
|
||||||
|
ssh_session session = s->ssh.session;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ssh_options_set(session,SSH_OPTIONS_HOST,"localhost");
|
|
||||||
assert_true(rc == SSH_OK);
|
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "zlib@openssh.com");
|
rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_C_S, "zlib@openssh.com");
|
||||||
#ifdef WITH_ZLIB
|
#ifdef WITH_ZLIB
|
||||||
assert_true(rc == SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
#else
|
#else
|
||||||
assert_true(rc == SSH_ERROR);
|
assert_int_equal(rc, SSH_ERROR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "zlib@openssh.com");
|
rc = ssh_options_set(session, SSH_OPTIONS_COMPRESSION_S_C, "zlib@openssh.com");
|
||||||
#ifdef WITH_ZLIB
|
#ifdef WITH_ZLIB
|
||||||
assert_true(rc == SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
#else
|
#else
|
||||||
assert_true(rc == SSH_ERROR);
|
assert_int_equal(rc, SSH_ERROR);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rc = ssh_connect(session);
|
rc = ssh_connect(session);
|
||||||
@ -235,14 +300,14 @@ static void torture_algorithms_zlib_openssh(void **state) {
|
|||||||
rc = ssh_userauth_none(session, NULL);
|
rc = ssh_userauth_none(session, NULL);
|
||||||
if (rc != SSH_OK) {
|
if (rc != SSH_OK) {
|
||||||
rc = ssh_get_error_code(session);
|
rc = ssh_get_error_code(session);
|
||||||
assert_true(rc == SSH_REQUEST_DENIED);
|
assert_int_equal(rc, SSH_REQUEST_DENIED);
|
||||||
}
|
}
|
||||||
ssh_disconnect(session);
|
ssh_disconnect(session);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
assert_false(rc == SSH_OK);
|
assert_false(rc == SSH_OK);
|
||||||
#else
|
#else
|
||||||
assert_true(rc == SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ssh_disconnect(session);
|
ssh_disconnect(session);
|
||||||
@ -250,21 +315,19 @@ static void torture_algorithms_zlib_openssh(void **state) {
|
|||||||
|
|
||||||
#if defined(HAVE_LIBCRYPTO) && defined(HAVE_ECC)
|
#if defined(HAVE_LIBCRYPTO) && defined(HAVE_ECC)
|
||||||
static void torture_algorithms_ecdh_sha2_nistp256(void **state) {
|
static void torture_algorithms_ecdh_sha2_nistp256(void **state) {
|
||||||
ssh_session session = *state;
|
struct torture_state *s = *state;
|
||||||
|
ssh_session session = s->ssh.session;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ssh_options_set(session,SSH_OPTIONS_HOST,"localhost");
|
|
||||||
assert_true(rc == SSH_OK);
|
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_KEY_EXCHANGE, "ecdh-sha2-nistp256");
|
rc = ssh_options_set(session, SSH_OPTIONS_KEY_EXCHANGE, "ecdh-sha2-nistp256");
|
||||||
assert_true(rc == SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
|
|
||||||
rc = ssh_connect(session);
|
rc = ssh_connect(session);
|
||||||
assert_true(rc == SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
rc = ssh_userauth_none(session, NULL);
|
rc = ssh_userauth_none(session, NULL);
|
||||||
if (rc != SSH_OK) {
|
if (rc != SSH_OK) {
|
||||||
rc = ssh_get_error_code(session);
|
rc = ssh_get_error_code(session);
|
||||||
assert_true(rc == SSH_REQUEST_DENIED);
|
assert_int_equal(rc, SSH_REQUEST_DENIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_disconnect(session);
|
ssh_disconnect(session);
|
||||||
@ -272,21 +335,19 @@ static void torture_algorithms_ecdh_sha2_nistp256(void **state) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void torture_algorithms_dh_group1(void **state) {
|
static void torture_algorithms_dh_group1(void **state) {
|
||||||
ssh_session session = *state;
|
struct torture_state *s = *state;
|
||||||
|
ssh_session session = s->ssh.session;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
rc = ssh_options_set(session,SSH_OPTIONS_HOST,"localhost");
|
|
||||||
assert_true(rc == SSH_OK);
|
|
||||||
|
|
||||||
rc = ssh_options_set(session, SSH_OPTIONS_KEY_EXCHANGE, "diffie-hellman-group1-sha1");
|
rc = ssh_options_set(session, SSH_OPTIONS_KEY_EXCHANGE, "diffie-hellman-group1-sha1");
|
||||||
assert_true(rc == SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
|
|
||||||
rc = ssh_connect(session);
|
rc = ssh_connect(session);
|
||||||
assert_true(rc == SSH_OK);
|
assert_int_equal(rc, SSH_OK);
|
||||||
rc = ssh_userauth_none(session, NULL);
|
rc = ssh_userauth_none(session, NULL);
|
||||||
if (rc != SSH_OK) {
|
if (rc != SSH_OK) {
|
||||||
rc = ssh_get_error_code(session);
|
rc = ssh_get_error_code(session);
|
||||||
assert_true(rc == SSH_REQUEST_DENIED);
|
assert_int_equal(rc, SSH_REQUEST_DENIED);
|
||||||
}
|
}
|
||||||
|
|
||||||
ssh_disconnect(session);
|
ssh_disconnect(session);
|
||||||
@ -294,42 +355,96 @@ static void torture_algorithms_dh_group1(void **state) {
|
|||||||
int torture_run_tests(void) {
|
int torture_run_tests(void) {
|
||||||
int rc;
|
int rc;
|
||||||
struct CMUnitTest tests[] = {
|
struct CMUnitTest tests[] = {
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha1,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha2_256, setup, teardown),
|
session_setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha2_512, setup, teardown),
|
session_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha2_256,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha2_256, setup, teardown),
|
session_setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha2_512, setup, teardown),
|
session_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_cbc_hmac_sha2_512,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha2_256, setup, teardown),
|
session_setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha2_512, setup, teardown),
|
session_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha1,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha2_256, setup, teardown),
|
session_setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha2_512, setup, teardown),
|
session_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha2_256,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha2_256, setup, teardown),
|
session_setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha2_512, setup, teardown),
|
session_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_cbc_hmac_sha2_512,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha2_256, setup, teardown),
|
session_setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha2_512, setup, teardown),
|
session_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha1,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha2_256, setup, teardown),
|
session_setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha2_512, setup, teardown),
|
session_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha1, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha2_256,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha2_256, setup, teardown),
|
session_setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha2_512, setup, teardown),
|
session_teardown),
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_zlib, setup, teardown),
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_cbc_hmac_sha2_512,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_zlib_openssh, setup, teardown),
|
session_setup,
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_dh_group1,setup,teardown),
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha1,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha2_256,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes128_ctr_hmac_sha2_512,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha1,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha2_256,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes192_ctr_hmac_sha2_512,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha1,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha2_256,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_aes256_ctr_hmac_sha2_512,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha1,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha2_256,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_3des_cbc_hmac_sha2_512,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha1,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha2_256,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_blowfish_cbc_hmac_sha2_512,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_zlib,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_zlib_openssh,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
|
cmocka_unit_test_setup_teardown(torture_algorithms_dh_group1,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
#if defined(HAVE_LIBCRYPTO) && defined(HAVE_ECC)
|
#if defined(HAVE_LIBCRYPTO) && defined(HAVE_ECC)
|
||||||
cmocka_unit_test_setup_teardown(torture_algorithms_ecdh_sha2_nistp256,setup,teardown)
|
cmocka_unit_test_setup_teardown(torture_algorithms_ecdh_sha2_nistp256,
|
||||||
|
session_setup,
|
||||||
|
session_teardown),
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
ssh_init();
|
|
||||||
torture_filter_tests(tests);
|
torture_filter_tests(tests);
|
||||||
rc = cmocka_run_group_tests(tests, NULL, NULL);
|
rc = cmocka_run_group_tests(tests, sshd_setup, sshd_teardown);
|
||||||
ssh_finalize();
|
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user