diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2003-12-09 11:42:03 +0000 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2003-12-09 11:42:03 +0000 |
commit | 538facc73cbae5d9d23295db0a8142f0cae8d91f (patch) | |
tree | 808b3a333bf548a0fc77969d573cfc98c9de7bff /src | |
parent | 810c70b90bb0ee6c6fcad952c56f8361b3a599a9 (diff) | |
download | gnutls-538facc73cbae5d9d23295db0a8142f0cae8d91f.tar.gz |
Fixed the SRP detection test in gnutls-cli-debug.
Diffstat (limited to 'src')
-rw-r--r-- | src/tests.c | 29 | ||||
-rw-r--r-- | src/tests.h | 2 | ||||
-rw-r--r-- | src/tls_test.c | 2 |
3 files changed, 19 insertions, 14 deletions
diff --git a/src/tests.c b/src/tests.c index 982db31730..8c80e4f322 100644 --- a/src/tests.c +++ b/src/tests.c @@ -41,7 +41,6 @@ extern gnutls_anon_client_credentials anon_cred; extern gnutls_certificate_credentials xcred; extern int more_info; -static int srp = 0; static int dh_bits; extern int tls1_ok; @@ -76,16 +75,6 @@ int ret, alert; GERR(ret); } - if (srp) { - if ((ret == GNUTLS_E_WARNING_ALERT_RECEIVED || ret == - GNUTLS_E_FATAL_ALERT_RECEIVED) && - gnutls_alert_get(session) == GNUTLS_A_MISSING_SRP_USERNAME) - return SUCCEED; - - if (ret == GNUTLS_E_DECRYPTION_FAILED) - return SUCCEED; /* SRP was detected */ - } - if (ret < 0) return GFAILED; gnutls_session_get_data(session, NULL, &session_data_size); @@ -182,6 +171,18 @@ static void ADD_PROTOCOL(gnutls_session session, int protocol) { } #ifdef ENABLE_SRP +static int srp_detected; + +int _test_srp_username_callback( gnutls_session session, unsigned int times, + char** username, char** password) +{ + if (times == 1) { + srp_detected = 1; + } + + return -1; +} + int test_srp( gnutls_session session) { int ret; @@ -192,14 +193,14 @@ int ret; ADD_ALL_MACS(session); ADD_KX(session, GNUTLS_KX_SRP); - srp = 1; + srp_detected = 0; gnutls_credentials_set(session, GNUTLS_CRD_SRP, srp_cred); ret = do_handshake( session); - srp = 0; - return ret; + if (srp_detected != 0) return SUCCEED; + else return GFAILED; } #endif diff --git a/src/tests.h b/src/tests.h index 40820aa58a..3c97d891b9 100644 --- a/src/tests.h +++ b/src/tests.h @@ -28,6 +28,8 @@ int test_session_resume2( gnutls_session state); int test_rsa_pms_version_check( gnutls_session session); int test_version_oob( gnutls_session session); int test_zlib( gnutls_session session); +int _test_srp_username_callback( gnutls_session session, unsigned int times, + char** username, char** password); #define GERR(ret) fprintf(stderr, "*** Error: %s\n", gnutls_strerror(ret)) diff --git a/src/tls_test.c b/src/tls_test.c index 2e7ec07971..66fb8417b0 100644 --- a/src/tls_test.c +++ b/src/tls_test.c @@ -190,6 +190,8 @@ int main(int argc, char **argv) fprintf(stderr, "memory error\n"); exit(1); } + gnutls_srp_set_client_credentials_function(srp_cred, + _test_srp_username_callback); #endif #ifdef ENABLE_ANON |