mirror of
https://git.libssh.org/projects/libssh.git
synced 2026-02-04 12:20:42 +09:00
reformat: gssapi key exchange
Signed-off-by: Gauravsingh Sisodia <xaerru@gmail.com> Reviewed-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
committed by
Jakub Jelen
parent
06b61f75fa
commit
a0707afc3e
@@ -2,17 +2,16 @@
|
||||
|
||||
#define LIBSSH_STATIC
|
||||
|
||||
#include "libssh/crypto.h"
|
||||
#include "torture.h"
|
||||
#include <libssh/libssh.h>
|
||||
#include "libssh/crypto.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <gssapi.h>
|
||||
#include <pwd.h>
|
||||
|
||||
static int
|
||||
sshd_setup(void **state)
|
||||
static int sshd_setup(void **state)
|
||||
{
|
||||
torture_setup_sshd_server(state, false);
|
||||
torture_update_sshd_config(state,
|
||||
@@ -22,8 +21,7 @@ sshd_setup(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sshd_teardown(void **state)
|
||||
static int sshd_teardown(void **state)
|
||||
{
|
||||
assert_non_null(state);
|
||||
|
||||
@@ -32,8 +30,7 @@ sshd_teardown(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
session_setup(void **state)
|
||||
static int session_setup(void **state)
|
||||
{
|
||||
struct torture_state *s = *state;
|
||||
int verbosity = torture_libssh_verbosity();
|
||||
@@ -62,8 +59,7 @@ session_setup(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
session_teardown(void **state)
|
||||
static int session_teardown(void **state)
|
||||
{
|
||||
struct torture_state *s = *state;
|
||||
|
||||
@@ -75,8 +71,7 @@ session_teardown(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
torture_gssapi_key_exchange(void **state)
|
||||
static void torture_gssapi_key_exchange(void **state)
|
||||
{
|
||||
struct torture_state *s = *state;
|
||||
ssh_session session = s->ssh.session;
|
||||
@@ -106,8 +101,7 @@ torture_gssapi_key_exchange(void **state)
|
||||
torture_teardown_kdc_server(state);
|
||||
}
|
||||
|
||||
static void
|
||||
torture_gssapi_key_exchange_no_tgt(void **state)
|
||||
static void torture_gssapi_key_exchange_no_tgt(void **state)
|
||||
{
|
||||
struct torture_state *s = *state;
|
||||
ssh_session session = s->ssh.session;
|
||||
@@ -136,14 +130,15 @@ torture_gssapi_key_exchange_no_tgt(void **state)
|
||||
rc = ssh_connect(session);
|
||||
assert_ssh_return_code(session, rc);
|
||||
|
||||
assert_int_not_equal(session->current_crypto->kex_type, SSH_GSS_KEX_DH_GROUP14_SHA256);
|
||||
assert_int_not_equal(session->current_crypto->kex_type, SSH_GSS_KEX_DH_GROUP16_SHA512);
|
||||
assert_int_not_equal(session->current_crypto->kex_type,
|
||||
SSH_GSS_KEX_DH_GROUP14_SHA256);
|
||||
assert_int_not_equal(session->current_crypto->kex_type,
|
||||
SSH_GSS_KEX_DH_GROUP16_SHA512);
|
||||
|
||||
torture_teardown_kdc_server(state);
|
||||
}
|
||||
|
||||
static void
|
||||
torture_gssapi_key_exchange_gss_group14_sha256(void **state)
|
||||
static void torture_gssapi_key_exchange_gss_group14_sha256(void **state)
|
||||
{
|
||||
struct torture_state *s = *state;
|
||||
ssh_session session = s->ssh.session;
|
||||
@@ -168,19 +163,21 @@ torture_gssapi_key_exchange_gss_group14_sha256(void **state)
|
||||
rc = ssh_options_set(s->ssh.session, SSH_OPTIONS_GSSAPI_KEY_EXCHANGE, &t);
|
||||
assert_ssh_return_code(s->ssh.session, rc);
|
||||
|
||||
rc = ssh_options_set(s->ssh.session, SSH_OPTIONS_GSSAPI_KEY_EXCHANGE_ALGS, "gss-group14-sha256-");
|
||||
rc = ssh_options_set(s->ssh.session,
|
||||
SSH_OPTIONS_GSSAPI_KEY_EXCHANGE_ALGS,
|
||||
"gss-group14-sha256-");
|
||||
assert_ssh_return_code(s->ssh.session, rc);
|
||||
|
||||
rc = ssh_connect(session);
|
||||
assert_ssh_return_code(session, rc);
|
||||
|
||||
assert_int_equal(session->current_crypto->kex_type, SSH_GSS_KEX_DH_GROUP14_SHA256);
|
||||
assert_int_equal(session->current_crypto->kex_type,
|
||||
SSH_GSS_KEX_DH_GROUP14_SHA256);
|
||||
|
||||
torture_teardown_kdc_server(state);
|
||||
}
|
||||
|
||||
static void
|
||||
torture_gssapi_key_exchange_gss_group16_sha512(void **state)
|
||||
static void torture_gssapi_key_exchange_gss_group16_sha512(void **state)
|
||||
{
|
||||
struct torture_state *s = *state;
|
||||
ssh_session session = s->ssh.session;
|
||||
@@ -205,19 +202,21 @@ torture_gssapi_key_exchange_gss_group16_sha512(void **state)
|
||||
rc = ssh_options_set(s->ssh.session, SSH_OPTIONS_GSSAPI_KEY_EXCHANGE, &t);
|
||||
assert_ssh_return_code(s->ssh.session, rc);
|
||||
|
||||
rc = ssh_options_set(s->ssh.session, SSH_OPTIONS_GSSAPI_KEY_EXCHANGE_ALGS, "gss-group16-sha512-");
|
||||
rc = ssh_options_set(s->ssh.session,
|
||||
SSH_OPTIONS_GSSAPI_KEY_EXCHANGE_ALGS,
|
||||
"gss-group16-sha512-");
|
||||
assert_ssh_return_code(s->ssh.session, rc);
|
||||
|
||||
rc = ssh_connect(session);
|
||||
assert_ssh_return_code(session, rc);
|
||||
|
||||
assert_true(session->current_crypto->kex_type == SSH_GSS_KEX_DH_GROUP16_SHA512);
|
||||
assert_true(session->current_crypto->kex_type ==
|
||||
SSH_GSS_KEX_DH_GROUP16_SHA512);
|
||||
|
||||
torture_teardown_kdc_server(state);
|
||||
}
|
||||
|
||||
static void
|
||||
torture_gssapi_key_exchange_auth(void **state)
|
||||
static void torture_gssapi_key_exchange_auth(void **state)
|
||||
{
|
||||
struct torture_state *s = *state;
|
||||
ssh_session session = s->ssh.session;
|
||||
@@ -251,8 +250,7 @@ torture_gssapi_key_exchange_auth(void **state)
|
||||
torture_teardown_kdc_server(state);
|
||||
}
|
||||
|
||||
static void
|
||||
torture_gssapi_key_exchange_no_auth(void **state)
|
||||
static void torture_gssapi_key_exchange_no_auth(void **state)
|
||||
{
|
||||
struct torture_state *s = *state;
|
||||
ssh_session session = s->ssh.session;
|
||||
@@ -288,8 +286,7 @@ torture_gssapi_key_exchange_no_auth(void **state)
|
||||
torture_teardown_kdc_server(state);
|
||||
}
|
||||
|
||||
int
|
||||
torture_run_tests(void)
|
||||
int torture_run_tests(void)
|
||||
{
|
||||
int rc;
|
||||
struct CMUnitTest tests[] = {
|
||||
@@ -299,12 +296,14 @@ torture_run_tests(void)
|
||||
cmocka_unit_test_setup_teardown(torture_gssapi_key_exchange_no_tgt,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_gssapi_key_exchange_gss_group14_sha256,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_gssapi_key_exchange_gss_group16_sha512,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(
|
||||
torture_gssapi_key_exchange_gss_group14_sha256,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(
|
||||
torture_gssapi_key_exchange_gss_group16_sha512,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_gssapi_key_exchange_auth,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
#include <gssapi.h>
|
||||
#include <pwd.h>
|
||||
|
||||
static int
|
||||
sshd_setup(void **state)
|
||||
static int sshd_setup(void **state)
|
||||
{
|
||||
struct torture_state *s = NULL;
|
||||
torture_setup_sshd_server(state, false);
|
||||
@@ -31,16 +30,15 @@ sshd_setup(void **state)
|
||||
"echo bar | kinit alice");
|
||||
|
||||
torture_update_sshd_config(state,
|
||||
"GSSAPIAuthentication yes\n"
|
||||
"GSSAPIKeyExchange yes\n");
|
||||
"GSSAPIAuthentication yes\n"
|
||||
"GSSAPIKeyExchange yes\n");
|
||||
|
||||
torture_teardown_kdc_server(state);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
sshd_teardown(void **state)
|
||||
static int sshd_teardown(void **state)
|
||||
{
|
||||
assert_non_null(state);
|
||||
|
||||
@@ -49,8 +47,7 @@ sshd_teardown(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
session_setup(void **state)
|
||||
static int session_setup(void **state)
|
||||
{
|
||||
struct torture_state *s = *state;
|
||||
int verbosity = torture_libssh_verbosity();
|
||||
@@ -79,8 +76,7 @@ session_setup(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
session_teardown(void **state)
|
||||
static int session_teardown(void **state)
|
||||
{
|
||||
struct torture_state *s = *state;
|
||||
|
||||
@@ -92,8 +88,7 @@ session_teardown(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
torture_gssapi_key_exchange_null(void **state)
|
||||
static void torture_gssapi_key_exchange_null(void **state)
|
||||
{
|
||||
struct torture_state *s = *state;
|
||||
ssh_session session = s->ssh.session;
|
||||
@@ -121,13 +116,13 @@ torture_gssapi_key_exchange_null(void **state)
|
||||
rc = ssh_connect(session);
|
||||
assert_ssh_return_code(s->ssh.session, rc);
|
||||
|
||||
assert_string_equal(session->current_crypto->kex_methods[SSH_HOSTKEYS], "null");
|
||||
assert_string_equal(session->current_crypto->kex_methods[SSH_HOSTKEYS],
|
||||
"null");
|
||||
|
||||
torture_teardown_kdc_server(state);
|
||||
}
|
||||
|
||||
int
|
||||
torture_run_tests(void)
|
||||
int torture_run_tests(void)
|
||||
{
|
||||
int rc;
|
||||
struct CMUnitTest tests[] = {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <dlfcn.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <sys/syscall.h>
|
||||
#include <unistd.h>
|
||||
|
||||
/*******************************************************************************
|
||||
* Structs
|
||||
@@ -224,31 +224,32 @@ static int is_file_blocked(const char *pathname)
|
||||
/* Block for torture_gssapi_server_key_exchange_null */
|
||||
"/etc/ssh/ssh_host_ecdsa_key",
|
||||
"/etc/ssh/ssh_host_rsa_key",
|
||||
"/etc/ssh/ssh_host_ed25519_key"
|
||||
"/etc/ssh/ssh_host_ed25519_key",
|
||||
};
|
||||
|
||||
for (size_t i = 0; i < sizeof(blocked_files) / sizeof(blocked_files[0]); i++) {
|
||||
for (size_t i = 0; i < sizeof(blocked_files) / sizeof(blocked_files[0]);
|
||||
i++) {
|
||||
if (strcmp(pathname, blocked_files[i]) == 0) {
|
||||
errno = ENOENT; /* No such file or directory */
|
||||
errno = ENOENT; /* No such file or directory */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define WRAP_FOPEN(func_name) \
|
||||
FILE *func_name(const char *pathname, const char *mode) \
|
||||
{ \
|
||||
typedef FILE *(*orig_func_t)(const char *pathname, const char *mode); \
|
||||
static orig_func_t orig_func = NULL; \
|
||||
if (orig_func == NULL) { \
|
||||
orig_func = (orig_func_t)dlsym(RTLD_NEXT, #func_name); \
|
||||
} \
|
||||
if (is_file_blocked(pathname)) { \
|
||||
return NULL; \
|
||||
} \
|
||||
return orig_func(pathname, mode); \
|
||||
}
|
||||
#define WRAP_FOPEN(func_name) \
|
||||
FILE *func_name(const char *pathname, const char *mode) \
|
||||
{ \
|
||||
typedef FILE *(*orig_func_t)(const char *pathname, const char *mode); \
|
||||
static orig_func_t orig_func = NULL; \
|
||||
if (orig_func == NULL) { \
|
||||
orig_func = (orig_func_t)dlsym(RTLD_NEXT, #func_name); \
|
||||
} \
|
||||
if (is_file_blocked(pathname)) { \
|
||||
return NULL; \
|
||||
} \
|
||||
return orig_func(pathname, mode); \
|
||||
}
|
||||
|
||||
WRAP_FOPEN(fopen)
|
||||
WRAP_FOPEN(fopen64)
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "libssh/libssh.h"
|
||||
#include "libssh/crypto.h"
|
||||
#include "libssh/libssh.h"
|
||||
#include "torture.h"
|
||||
#include "torture_key.h"
|
||||
|
||||
@@ -21,8 +21,7 @@ struct test_server_st {
|
||||
char *cwd;
|
||||
};
|
||||
|
||||
static void
|
||||
free_test_server_state(void **state)
|
||||
static void free_test_server_state(void **state)
|
||||
{
|
||||
struct test_server_st *tss = *state;
|
||||
|
||||
@@ -30,8 +29,7 @@ free_test_server_state(void **state)
|
||||
SAFE_FREE(tss);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_config(void **state)
|
||||
static void setup_config(void **state)
|
||||
{
|
||||
struct torture_state *s = NULL;
|
||||
struct server_state_st *ss = NULL;
|
||||
@@ -147,8 +145,7 @@ setup_config(void **state)
|
||||
*state = tss;
|
||||
}
|
||||
|
||||
static int
|
||||
setup_default_server(void **state)
|
||||
static int setup_default_server(void **state)
|
||||
{
|
||||
struct torture_state *s = NULL;
|
||||
struct server_state_st *ss = NULL;
|
||||
@@ -186,8 +183,7 @@ setup_default_server(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
teardown_default_server(void **state)
|
||||
static int teardown_default_server(void **state)
|
||||
{
|
||||
struct torture_state *s = NULL;
|
||||
struct server_state_st *ss = NULL;
|
||||
@@ -212,8 +208,7 @@ teardown_default_server(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
session_setup(void **state)
|
||||
static int session_setup(void **state)
|
||||
{
|
||||
struct test_server_st *tss = *state;
|
||||
struct torture_state *s = NULL;
|
||||
@@ -253,8 +248,7 @@ session_setup(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
session_teardown(void **state)
|
||||
static int session_teardown(void **state)
|
||||
{
|
||||
struct test_server_st *tss = *state;
|
||||
struct torture_state *s = NULL;
|
||||
@@ -276,9 +270,7 @@ session_teardown(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
torture_gssapi_server_key_exchange(void **state)
|
||||
static void torture_gssapi_server_key_exchange(void **state)
|
||||
{
|
||||
struct test_server_st *tss = *state;
|
||||
struct torture_state *s = NULL;
|
||||
@@ -303,7 +295,8 @@ torture_gssapi_server_key_exchange(void **state)
|
||||
torture_setup_kdc_server(
|
||||
(void **)&s,
|
||||
"kadmin.local addprinc -randkey host/server.libssh.site\n"
|
||||
"kadmin.local ktadd -k $(dirname $0)/d/ssh.keytab host/server.libssh.site\n"
|
||||
"kadmin.local ktadd -k $(dirname $0)/d/ssh.keytab "
|
||||
"host/server.libssh.site\n"
|
||||
"kadmin.local addprinc -pw bar alice\n"
|
||||
"kadmin.local list_principals",
|
||||
|
||||
@@ -318,8 +311,7 @@ torture_gssapi_server_key_exchange(void **state)
|
||||
torture_teardown_kdc_server((void **)&s);
|
||||
}
|
||||
|
||||
static void
|
||||
torture_gssapi_server_key_exchange_no_tgt(void **state)
|
||||
static void torture_gssapi_server_key_exchange_no_tgt(void **state)
|
||||
{
|
||||
struct test_server_st *tss = *state;
|
||||
struct torture_state *s = NULL;
|
||||
@@ -344,7 +336,8 @@ torture_gssapi_server_key_exchange_no_tgt(void **state)
|
||||
torture_setup_kdc_server(
|
||||
(void **)&s,
|
||||
"kadmin.local addprinc -randkey host/server.libssh.site \n"
|
||||
"kadmin.local ktadd -k $(dirname $0)/d/ssh.keytab host/server.libssh.site \n"
|
||||
"kadmin.local ktadd -k $(dirname $0)/d/ssh.keytab "
|
||||
"host/server.libssh.site \n"
|
||||
"kadmin.local addprinc -pw bar alice \n"
|
||||
"kadmin.local list_principals",
|
||||
|
||||
@@ -357,14 +350,15 @@ torture_gssapi_server_key_exchange_no_tgt(void **state)
|
||||
rc = ssh_connect(session);
|
||||
assert_ssh_return_code(session, rc);
|
||||
|
||||
assert_int_not_equal(session->current_crypto->kex_type, SSH_GSS_KEX_DH_GROUP14_SHA256);
|
||||
assert_int_not_equal(session->current_crypto->kex_type, SSH_GSS_KEX_DH_GROUP16_SHA512);
|
||||
assert_int_not_equal(session->current_crypto->kex_type,
|
||||
SSH_GSS_KEX_DH_GROUP14_SHA256);
|
||||
assert_int_not_equal(session->current_crypto->kex_type,
|
||||
SSH_GSS_KEX_DH_GROUP16_SHA512);
|
||||
|
||||
torture_teardown_kdc_server((void **)&s);
|
||||
}
|
||||
|
||||
static void
|
||||
torture_gssapi_server_key_exchange_gss_group14_sha256(void **state)
|
||||
static void torture_gssapi_server_key_exchange_gss_group14_sha256(void **state)
|
||||
{
|
||||
struct test_server_st *tss = *state;
|
||||
struct torture_state *s = NULL;
|
||||
@@ -389,7 +383,8 @@ torture_gssapi_server_key_exchange_gss_group14_sha256(void **state)
|
||||
torture_setup_kdc_server(
|
||||
(void **)&s,
|
||||
"kadmin.local addprinc -randkey host/server.libssh.site \n"
|
||||
"kadmin.local ktadd -k $(dirname $0)/d/ssh.keytab host/server.libssh.site \n"
|
||||
"kadmin.local ktadd -k $(dirname $0)/d/ssh.keytab "
|
||||
"host/server.libssh.site \n"
|
||||
"kadmin.local addprinc -pw bar alice \n"
|
||||
"kadmin.local list_principals",
|
||||
|
||||
@@ -398,19 +393,21 @@ torture_gssapi_server_key_exchange_gss_group14_sha256(void **state)
|
||||
rc = ssh_options_set(s->ssh.session, SSH_OPTIONS_GSSAPI_KEY_EXCHANGE, &t);
|
||||
assert_ssh_return_code(s->ssh.session, rc);
|
||||
|
||||
rc = ssh_options_set(s->ssh.session, SSH_OPTIONS_GSSAPI_KEY_EXCHANGE_ALGS, "gss-group14-sha256-");
|
||||
rc = ssh_options_set(s->ssh.session,
|
||||
SSH_OPTIONS_GSSAPI_KEY_EXCHANGE_ALGS,
|
||||
"gss-group14-sha256-");
|
||||
assert_ssh_return_code(s->ssh.session, rc);
|
||||
|
||||
rc = ssh_connect(session);
|
||||
assert_ssh_return_code(session, rc);
|
||||
|
||||
assert_int_equal(session->current_crypto->kex_type, SSH_GSS_KEX_DH_GROUP14_SHA256);
|
||||
assert_int_equal(session->current_crypto->kex_type,
|
||||
SSH_GSS_KEX_DH_GROUP14_SHA256);
|
||||
|
||||
torture_teardown_kdc_server((void **)&s);
|
||||
}
|
||||
|
||||
static void
|
||||
torture_gssapi_server_key_exchange_gss_group16_sha512(void **state)
|
||||
static void torture_gssapi_server_key_exchange_gss_group16_sha512(void **state)
|
||||
{
|
||||
struct test_server_st *tss = *state;
|
||||
struct torture_state *s = NULL;
|
||||
@@ -435,7 +432,8 @@ torture_gssapi_server_key_exchange_gss_group16_sha512(void **state)
|
||||
torture_setup_kdc_server(
|
||||
(void **)&s,
|
||||
"kadmin.local addprinc -randkey host/server.libssh.site \n"
|
||||
"kadmin.local ktadd -k $(dirname $0)/d/ssh.keytab host/server.libssh.site \n"
|
||||
"kadmin.local ktadd -k $(dirname $0)/d/ssh.keytab "
|
||||
"host/server.libssh.site \n"
|
||||
"kadmin.local addprinc -pw bar alice \n"
|
||||
"kadmin.local list_principals",
|
||||
|
||||
@@ -444,19 +442,21 @@ torture_gssapi_server_key_exchange_gss_group16_sha512(void **state)
|
||||
rc = ssh_options_set(s->ssh.session, SSH_OPTIONS_GSSAPI_KEY_EXCHANGE, &t);
|
||||
assert_ssh_return_code(s->ssh.session, rc);
|
||||
|
||||
rc = ssh_options_set(s->ssh.session, SSH_OPTIONS_GSSAPI_KEY_EXCHANGE_ALGS, "gss-group16-sha512-");
|
||||
rc = ssh_options_set(s->ssh.session,
|
||||
SSH_OPTIONS_GSSAPI_KEY_EXCHANGE_ALGS,
|
||||
"gss-group16-sha512-");
|
||||
assert_ssh_return_code(s->ssh.session, rc);
|
||||
|
||||
rc = ssh_connect(session);
|
||||
assert_ssh_return_code(session, rc);
|
||||
|
||||
assert_int_equal(session->current_crypto->kex_type, SSH_GSS_KEX_DH_GROUP16_SHA512);
|
||||
assert_int_equal(session->current_crypto->kex_type,
|
||||
SSH_GSS_KEX_DH_GROUP16_SHA512);
|
||||
|
||||
torture_teardown_kdc_server((void **)&s);
|
||||
}
|
||||
|
||||
static void
|
||||
torture_gssapi_server_key_exchange_auth(void **state)
|
||||
static void torture_gssapi_server_key_exchange_auth(void **state)
|
||||
{
|
||||
struct test_server_st *tss = *state;
|
||||
struct torture_state *s = NULL;
|
||||
@@ -499,8 +499,7 @@ torture_gssapi_server_key_exchange_auth(void **state)
|
||||
torture_teardown_kdc_server((void **)&s);
|
||||
}
|
||||
|
||||
static void
|
||||
torture_gssapi_server_key_exchange_no_auth(void **state)
|
||||
static void torture_gssapi_server_key_exchange_no_auth(void **state)
|
||||
{
|
||||
struct test_server_st *tss = *state;
|
||||
struct torture_state *s = NULL;
|
||||
@@ -545,29 +544,32 @@ torture_gssapi_server_key_exchange_no_auth(void **state)
|
||||
torture_teardown_kdc_server((void **)&s);
|
||||
}
|
||||
|
||||
int
|
||||
torture_run_tests(void)
|
||||
int torture_run_tests(void)
|
||||
{
|
||||
int rc;
|
||||
struct CMUnitTest tests[] = {
|
||||
cmocka_unit_test_setup_teardown(torture_gssapi_server_key_exchange,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_gssapi_server_key_exchange_no_tgt,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_gssapi_server_key_exchange_gss_group14_sha256,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_gssapi_server_key_exchange_gss_group16_sha512,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(
|
||||
torture_gssapi_server_key_exchange_no_tgt,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(
|
||||
torture_gssapi_server_key_exchange_gss_group14_sha256,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(
|
||||
torture_gssapi_server_key_exchange_gss_group16_sha512,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_gssapi_server_key_exchange_auth,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(torture_gssapi_server_key_exchange_no_auth,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
cmocka_unit_test_setup_teardown(
|
||||
torture_gssapi_server_key_exchange_no_auth,
|
||||
session_setup,
|
||||
session_teardown),
|
||||
};
|
||||
|
||||
ssh_init();
|
||||
|
||||
@@ -19,8 +19,7 @@ struct test_server_st {
|
||||
char *cwd;
|
||||
};
|
||||
|
||||
static void
|
||||
free_test_server_state(void **state)
|
||||
static void free_test_server_state(void **state)
|
||||
{
|
||||
struct test_server_st *tss = *state;
|
||||
|
||||
@@ -28,8 +27,7 @@ free_test_server_state(void **state)
|
||||
SAFE_FREE(tss);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_config(void **state)
|
||||
static void setup_config(void **state)
|
||||
{
|
||||
struct torture_state *s = NULL;
|
||||
struct server_state_st *ss = NULL;
|
||||
@@ -105,8 +103,7 @@ setup_config(void **state)
|
||||
*state = tss;
|
||||
}
|
||||
|
||||
static int
|
||||
setup_default_server(void **state)
|
||||
static int setup_default_server(void **state)
|
||||
{
|
||||
struct torture_state *s = NULL;
|
||||
struct server_state_st *ss = NULL;
|
||||
@@ -144,8 +141,7 @@ setup_default_server(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
teardown_default_server(void **state)
|
||||
static int teardown_default_server(void **state)
|
||||
{
|
||||
struct torture_state *s = NULL;
|
||||
struct server_state_st *ss = NULL;
|
||||
@@ -170,8 +166,7 @@ teardown_default_server(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
session_setup(void **state)
|
||||
static int session_setup(void **state)
|
||||
{
|
||||
struct test_server_st *tss = *state;
|
||||
struct torture_state *s = NULL;
|
||||
@@ -211,8 +206,7 @@ session_setup(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
session_teardown(void **state)
|
||||
static int session_teardown(void **state)
|
||||
{
|
||||
struct test_server_st *tss = *state;
|
||||
struct torture_state *s = NULL;
|
||||
@@ -234,9 +228,7 @@ session_teardown(void **state)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
torture_gssapi_server_key_exchange_null(void **state)
|
||||
static void torture_gssapi_server_key_exchange_null(void **state)
|
||||
{
|
||||
struct test_server_st *tss = *state;
|
||||
struct torture_state *s = NULL;
|
||||
@@ -261,7 +253,8 @@ torture_gssapi_server_key_exchange_null(void **state)
|
||||
torture_setup_kdc_server(
|
||||
(void **)&s,
|
||||
"kadmin.local addprinc -randkey host/server.libssh.site\n"
|
||||
"kadmin.local ktadd -k $(dirname $0)/d/ssh.keytab host/server.libssh.site\n"
|
||||
"kadmin.local ktadd -k $(dirname $0)/d/ssh.keytab "
|
||||
"host/server.libssh.site\n"
|
||||
"kadmin.local addprinc -pw bar alice\n"
|
||||
"kadmin.local list_principals",
|
||||
|
||||
@@ -273,13 +266,13 @@ torture_gssapi_server_key_exchange_null(void **state)
|
||||
rc = ssh_connect(session);
|
||||
assert_ssh_return_code(s->ssh.session, rc);
|
||||
|
||||
assert_string_equal(session->current_crypto->kex_methods[SSH_HOSTKEYS], "null");
|
||||
assert_string_equal(session->current_crypto->kex_methods[SSH_HOSTKEYS],
|
||||
"null");
|
||||
|
||||
torture_teardown_kdc_server((void **)&s);
|
||||
}
|
||||
|
||||
int
|
||||
torture_run_tests(void)
|
||||
int torture_run_tests(void)
|
||||
{
|
||||
int rc;
|
||||
struct CMUnitTest tests[] = {
|
||||
|
||||
@@ -999,8 +999,10 @@ torture_setup_create_sshd_config(void **state, bool pam, bool second_sshd)
|
||||
fips_config_string,
|
||||
second_sshd ? TORTURE_SSHD_SRV1_IPV4 : TORTURE_SSHD_SRV_IPV4,
|
||||
second_sshd ? TORTURE_SSHD_SRV1_IPV6 : TORTURE_SSHD_SRV_IPV6,
|
||||
"HostKey", rsa_hostkey,
|
||||
"HostKey", ecdsa_hostkey,
|
||||
"HostKey",
|
||||
rsa_hostkey,
|
||||
"HostKey",
|
||||
ecdsa_hostkey,
|
||||
trusted_ca_pubkey,
|
||||
sftp_server,
|
||||
usepam,
|
||||
@@ -1012,9 +1014,12 @@ torture_setup_create_sshd_config(void **state, bool pam, bool second_sshd)
|
||||
config_string,
|
||||
second_sshd ? TORTURE_SSHD_SRV1_IPV4 : TORTURE_SSHD_SRV_IPV4,
|
||||
second_sshd ? TORTURE_SSHD_SRV1_IPV6 : TORTURE_SSHD_SRV_IPV6,
|
||||
"", "",
|
||||
"", "",
|
||||
"", "",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
trusted_ca_pubkey,
|
||||
sftp_server,
|
||||
usepam,
|
||||
@@ -1026,9 +1031,12 @@ torture_setup_create_sshd_config(void **state, bool pam, bool second_sshd)
|
||||
config_string,
|
||||
second_sshd ? TORTURE_SSHD_SRV1_IPV4 : TORTURE_SSHD_SRV_IPV4,
|
||||
second_sshd ? TORTURE_SSHD_SRV1_IPV6 : TORTURE_SSHD_SRV_IPV6,
|
||||
"HostKey", ed25519_hostkey,
|
||||
"HostKey", rsa_hostkey,
|
||||
"HostKey", ecdsa_hostkey,
|
||||
"HostKey",
|
||||
ed25519_hostkey,
|
||||
"HostKey",
|
||||
rsa_hostkey,
|
||||
"HostKey",
|
||||
ecdsa_hostkey,
|
||||
trusted_ca_pubkey,
|
||||
sftp_server,
|
||||
usepam,
|
||||
|
||||
@@ -650,7 +650,8 @@ static void torture_config_new(void ** state,
|
||||
assert_string_equal(session->opts.gss_server_identity, "example.com");
|
||||
assert_string_equal(session->opts.gss_client_identity, "home.sweet");
|
||||
#ifdef WITH_GSSAPI
|
||||
assert_string_equal(session->opts.gssapi_key_exchange_algs, "gss-group14-sha256-");
|
||||
assert_string_equal(session->opts.gssapi_key_exchange_algs,
|
||||
"gss-group14-sha256-");
|
||||
#endif /* WITH_GSSAPI */
|
||||
|
||||
assert_int_equal(ssh_get_log_level(), SSH_LOG_TRACE);
|
||||
|
||||
Reference in New Issue
Block a user