From: Nikos Mavrogiannopoulos Date: Tue, 21 Feb 2012 18:00:15 +0000 (+0100) Subject: added error reporting X-Git-Tag: gnutls_3_0_14~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=864be199082e2eb7fd291d7d6443971081edf74c;p=thirdparty%2Fgnutls.git added error reporting --- diff --git a/tests/gc.c b/tests/gc.c index 5058592bdc..2cc06941d7 100644 --- a/tests/gc.c +++ b/tests/gc.c @@ -32,6 +32,12 @@ #include "../lib/x509/pbkdf2-sha1.h" #include "../lib/debug.h" +static void +tls_log_func (int level, const char *str) +{ + fprintf (stderr, "|<%d>| %s", level, str); +} + void doit (void) { @@ -40,6 +46,9 @@ doit (void) /* XXX: We need this to fix secure memory. */ gnutls_global_init (); + gnutls_global_set_log_function (tls_log_func); + if (debug) + gnutls_global_set_log_level (4711); err = _gnutls_hmac_fast (GNUTLS_MAC_MD5, "keykeykey", 9, "abcdefgh", 8, digest); diff --git a/tests/pskself.c b/tests/pskself.c index f4c058b70c..f6eed94c69 100644 --- a/tests/pskself.c +++ b/tests/pskself.c @@ -46,6 +46,14 @@ /* A very basic TLS client, with PSK authentication. */ +const char* side = ""; + +static void +tls_log_func (int level, const char *str) +{ + fprintf (stderr, "%s|<%d>| %s", side, level, str); +} + #define MAX_BUF 1024 #define MSG "Hello TLS" @@ -60,6 +68,11 @@ client (void) const gnutls_datum_t key = { (void *) "DEADBEEF", 8 }; gnutls_global_init (); + gnutls_global_set_log_function (tls_log_func); + if (debug) + gnutls_global_set_log_level (4711); + + side = "client"; gnutls_psk_allocate_client_credentials (&pskcred); gnutls_psk_set_client_credentials (pskcred, "test", &key, @@ -237,6 +250,11 @@ server (void) /* this must be called once in the program */ gnutls_global_init (); + gnutls_global_set_log_function (tls_log_func); + if (debug) + gnutls_global_set_log_level (4711); + + side = "server"; gnutls_psk_allocate_server_credentials (&server_pskcred); gnutls_psk_set_server_credentials_function (server_pskcred, pskfunc);