methods now tests all methods separately, and reports which one goes wrong

Corrected Makefile dependency
This commit is contained in:
Bert Vermeulen 2005-01-25 05:46:00 +00:00
parent 064c6cde3a
commit b25446d0a5
2 changed files with 62 additions and 71 deletions

View File

@ -9,11 +9,11 @@ libssh2-test: $(OBJS)
$(CC) -o libssh2-test $(OBJS) $(LIBS)
main.o: main.c libssh2.h
util.o: util.c libssh2.h
methods.o: methods.c libssh2.h
auth.o: auth.c libssh2.h
forward.o: forward.c libssh2.h
main.o: main.c libssh2-test.h
util.o: util.c libssh2-test.h
methods.o: methods.c libssh2-test.h
auth.o: auth.c libssh2-test.h
forward.o: forward.c libssh2-test.h
clean:
rm -f $(OBJS) libssh2-test

View File

@ -1,5 +1,6 @@
/*
* methods.c -- test all available key exchange, hostkey, encryption, mac and compression methods
* methods.c -- test all available key exchange, hostkey, encryption, mac
* and compression methods
*
* Copyright (C) 2005 Bert Vermeulen <bert@biot.com>
* All rights reserved.
@ -61,13 +62,13 @@ static char *hostkey_methods[] = {
};
static char *crypt_methods[] = {
"3des-cbc",
"aes256-cbc",
"aes192-cbc",
"aes128-cbc",
"blowfish-cbc",
"arcfour",
"cast128-cbc",
"3des-cbc",
NULL
};
@ -81,6 +82,7 @@ static char *mac_methods[] = {
};
static char *compression_methods[] = {
"none",
"zlib",
NULL
};
@ -119,11 +121,14 @@ static void dump_methods(LIBSSH2_SESSION *session)
static void cycle_methods(void)
{
LIBSSH2_SESSION *session;
int sock, size, methods_done, i, res;
struct methodlist *method;
char methodstring[256], *errmsg;
int sock, size, res, method_type, method, i;
char *errmsg;
while(1)
method_type = 0;
method = 0;
while(methods[method_type].description)
{
while(methods[method_type].list[method])
{
increase_progress();
sock = new_socket();
@ -135,19 +140,18 @@ static void cycle_methods(void)
session = libssh2_session_init();
i = 0;
methodstring[0] = '\0';
while(methods[i].description)
for(i = 0; methods[i].description; i++)
{
method = &methods[i];
strncat(methodstring, method->list[method->cursor], 256);
strncat(methodstring, " ", 256);
res = libssh2_session_method_pref(session, method->method_type, method->list[method->cursor]);
res = libssh2_session_method_pref(session, methods[i].method_type,
methods[i].list[ i == method_type ? method : 0 ]);
if(res != 0)
{
libssh2_session_last_error(session, &errmsg, &size, 0);
log_line(ERROR, "%s method set to '%s' failed: %s\n",
method->description, method->list[method->cursor], errmsg);
methods[i].description,
methods[i].list[ i == method_type ? method : 0 ], errmsg);
return;
}
@ -167,29 +171,18 @@ static void cycle_methods(void)
else
{
libssh2_session_last_error(session, &errmsg, &size, 0);
log_line(ERROR, "session startup with methods [ %s] failed: %s\n", methodstring, errmsg);
log_line(ERROR, "session startup for %s method %s failed: %s\n",
methods[method_type].description, methods[method_type].list[method], errmsg);
}
libssh2_session_disconnect(session, "All done.");
libssh2_session_free(session);
close(sock);
/* increment method cursors */
i = 0;
methods_done = 0;
while( (method = &methods[i++]) && method->description )
{
if(!method->list[++method->cursor])
{
method->done = 1;
method->cursor = 0;
method++;
}
methods_done += method->done;
}
if(--i == methods_done)
break;
method_type++;
method = 1;
}
printf("\n");
@ -198,20 +191,18 @@ static void cycle_methods(void)
void runtest_methods(void)
{
struct methodlist *method;
int i, j, max;
int i, j, num_steps;
max = 0;
num_steps = 0;
for(i = 0; methods[i].description; i++)
{
method = &methods[i];
for(j = 0; method->list[j]; j++)
for(j = 0; methods[i].list[j]; j++)
;
if(j > max)
max = j;
num_steps += j - 1;
}
num_steps++;
init_test("kex/hostkey/crypt/max/compression methods", max);
init_test("kex/hostkey/crypt/max/compression methods", num_steps);
cycle_methods();