summaryrefslogtreecommitdiff
path: root/tests/mini-eagain.c
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2013-11-08 22:14:07 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2013-11-08 22:17:10 +0100
commit76c93d23c073ef8b885503b7d28a31ffe2add6d8 (patch)
tree1dd2d22a197bc40c5330e516969a7cb1ae9bc96f /tests/mini-eagain.c
parent559a144f6bbcbb611453f82e655dd7438c14d1a7 (diff)
downloadgnutls-76c93d23c073ef8b885503b7d28a31ffe2add6d8.tar.gz
reindented code
Diffstat (limited to 'tests/mini-eagain.c')
-rw-r--r--tests/mini-eagain.c155
1 files changed, 80 insertions, 75 deletions
diff --git a/tests/mini-eagain.c b/tests/mini-eagain.c
index d95c644c74..8f913e66b2 100644
--- a/tests/mini-eagain.c
+++ b/tests/mini-eagain.c
@@ -35,12 +35,11 @@
#define RANDOMIZE
#include "eagain-common.h"
-const char* side = "";
+const char *side = "";
-static void
-tls_log_func (int level, const char *str)
+static void tls_log_func(int level, const char *str)
{
- fprintf (stderr, "%s|<%d>| %s", side, level, str);
+ fprintf(stderr, "%s|<%d>| %s", side, level, str);
}
static int handshake = 0;
@@ -48,76 +47,82 @@ static int handshake = 0;
#define MAX_BUF 1024
#define MSG "Hello TLS, and hi and how are you and more data here... and more... and even more and even more more data..."
-void
-doit (void)
+void doit(void)
{
- /* Server stuff. */
- gnutls_anon_server_credentials_t s_anoncred;
- const gnutls_datum_t p3 = { (unsigned char *) pkcs3, strlen (pkcs3) };
- static gnutls_dh_params_t dh_params;
- gnutls_session_t server;
- int sret, cret;
- /* Client stuff. */
- gnutls_anon_client_credentials_t c_anoncred;
- gnutls_session_t client;
- /* Need to enable anonymous KX specifically. */
- char buffer[MAX_BUF + 1];
- ssize_t ns;
- int ret, transferred = 0, msglen;
-
- /* General init. */
- global_init ();
- gnutls_global_set_log_function (tls_log_func);
- if (debug)
- gnutls_global_set_log_level (2);
-
- /* Init server */
- gnutls_anon_allocate_server_credentials (&s_anoncred);
- gnutls_dh_params_init (&dh_params);
- gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
- gnutls_anon_set_server_dh_params (s_anoncred, dh_params);
- gnutls_init (&server, GNUTLS_SERVER);
- ret = gnutls_priority_set_direct (server, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
- if (ret < 0)
- exit(1);
- gnutls_credentials_set (server, GNUTLS_CRD_ANON, s_anoncred);
- gnutls_transport_set_push_function (server, server_push);
- gnutls_transport_set_pull_function (server, server_pull);
- gnutls_transport_set_ptr (server, server);
-
- /* Init client */
- gnutls_anon_allocate_client_credentials (&c_anoncred);
- gnutls_init (&client, GNUTLS_CLIENT);
- ret = gnutls_priority_set_direct (client, "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
- if (ret < 0)
- exit(1);
- gnutls_credentials_set (client, GNUTLS_CRD_ANON, c_anoncred);
- gnutls_transport_set_push_function (client, client_push);
- gnutls_transport_set_pull_function (client, client_pull);
- gnutls_transport_set_ptr (client, client);
-
- handshake = 1;
- HANDSHAKE(client, server);
-
- handshake = 0;
- if (debug)
- success ("Handshake established\n");
-
- msglen = strlen(MSG);
- TRANSFER(client, server, MSG, msglen, buffer, MAX_BUF);
- if (debug)
- fputs ("\n", stdout);
-
- gnutls_bye (client, GNUTLS_SHUT_WR);
- gnutls_bye (server, GNUTLS_SHUT_WR);
-
- gnutls_deinit (client);
- gnutls_deinit (server);
-
- gnutls_anon_free_client_credentials (c_anoncred);
- gnutls_anon_free_server_credentials (s_anoncred);
-
- gnutls_dh_params_deinit (dh_params);
-
- gnutls_global_deinit ();
+ /* Server stuff. */
+ gnutls_anon_server_credentials_t s_anoncred;
+ const gnutls_datum_t p3 =
+ { (unsigned char *) pkcs3, strlen(pkcs3) };
+ static gnutls_dh_params_t dh_params;
+ gnutls_session_t server;
+ int sret, cret;
+ /* Client stuff. */
+ gnutls_anon_client_credentials_t c_anoncred;
+ gnutls_session_t client;
+ /* Need to enable anonymous KX specifically. */
+ char buffer[MAX_BUF + 1];
+ ssize_t ns;
+ int ret, transferred = 0, msglen;
+
+ /* General init. */
+ global_init();
+ gnutls_global_set_log_function(tls_log_func);
+ if (debug)
+ gnutls_global_set_log_level(2);
+
+ /* Init server */
+ gnutls_anon_allocate_server_credentials(&s_anoncred);
+ gnutls_dh_params_init(&dh_params);
+ gnutls_dh_params_import_pkcs3(dh_params, &p3, GNUTLS_X509_FMT_PEM);
+ gnutls_anon_set_server_dh_params(s_anoncred, dh_params);
+ gnutls_init(&server, GNUTLS_SERVER);
+ ret =
+ gnutls_priority_set_direct(server,
+ "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH",
+ NULL);
+ if (ret < 0)
+ exit(1);
+ gnutls_credentials_set(server, GNUTLS_CRD_ANON, s_anoncred);
+ gnutls_transport_set_push_function(server, server_push);
+ gnutls_transport_set_pull_function(server, server_pull);
+ gnutls_transport_set_ptr(server, server);
+
+ /* Init client */
+ gnutls_anon_allocate_client_credentials(&c_anoncred);
+ gnutls_init(&client, GNUTLS_CLIENT);
+ ret =
+ gnutls_priority_set_direct(client,
+ "NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH",
+ NULL);
+ if (ret < 0)
+ exit(1);
+ gnutls_credentials_set(client, GNUTLS_CRD_ANON, c_anoncred);
+ gnutls_transport_set_push_function(client, client_push);
+ gnutls_transport_set_pull_function(client, client_pull);
+ gnutls_transport_set_ptr(client, client);
+
+ handshake = 1;
+ HANDSHAKE(client, server);
+
+ handshake = 0;
+ if (debug)
+ success("Handshake established\n");
+
+ msglen = strlen(MSG);
+ TRANSFER(client, server, MSG, msglen, buffer, MAX_BUF);
+ if (debug)
+ fputs("\n", stdout);
+
+ gnutls_bye(client, GNUTLS_SHUT_WR);
+ gnutls_bye(server, GNUTLS_SHUT_WR);
+
+ gnutls_deinit(client);
+ gnutls_deinit(server);
+
+ gnutls_anon_free_client_credentials(c_anoncred);
+ gnutls_anon_free_server_credentials(s_anoncred);
+
+ gnutls_dh_params_deinit(dh_params);
+
+ gnutls_global_deinit();
}