diff options
Diffstat (limited to 'tests/x509signself.c')
-rw-r--r-- | tests/x509signself.c | 53 |
1 files changed, 7 insertions, 46 deletions
diff --git a/tests/x509signself.c b/tests/x509signself.c index 7920cc6f00..7b1586a149 100644 --- a/tests/x509signself.c +++ b/tests/x509signself.c @@ -40,7 +40,7 @@ #include "ex-session-info.c" #include "ex-x509-info.c" -extern int print_info (gnutls_session_t session); +#include "tcp.c" #include "utils.h" @@ -58,45 +58,6 @@ tls_log_func (int level, const char *str) #define MAX_BUF 1024 #define MSG "Hello TLS" -/* Connects to the peer and returns a socket - * descriptor. - */ -int -tcp_connect (void) -{ - const char *PORT = "5556"; - const char *SERVER = "127.0.0.1"; - int err, sd; - struct sockaddr_in sa; - - /* connects to server - */ - sd = socket (AF_INET, SOCK_STREAM, 0); - - memset (&sa, '\0', sizeof (sa)); - sa.sin_family = AF_INET; - sa.sin_port = htons (atoi (PORT)); - inet_pton (AF_INET, SERVER, &sa.sin_addr); - - err = connect (sd, (struct sockaddr *) &sa, sizeof (sa)); - if (err < 0) - { - fprintf (stderr, "Connect error\n"); - exit (1); - } - - return sd; -} - -/* closes the given socket descriptor. - */ -void -tcp_close (int sd) -{ - shutdown (sd, SHUT_RDWR); /* no more receptions */ - close (sd); -} - static char ca_pem[] = "-----BEGIN CERTIFICATE-----\n" "MIIB5zCCAVKgAwIBAgIERiYdJzALBgkqhkiG9w0BAQUwGTEXMBUGA1UEAxMOR251\n" @@ -128,7 +89,7 @@ static char cert_pem[] = "dc8Siq5JojruiMizAf0pA7in\n" "-----END CERTIFICATE-----\n"; const gnutls_datum_t cert = { cert_pem, sizeof (cert_pem) }; -int +static int sign_func (gnutls_session_t session, void *userdata, gnutls_certificate_type_t cert_type, @@ -174,7 +135,7 @@ done: return ret; } -void +static void client (void) { int ret, sd, ii; @@ -282,7 +243,7 @@ end: /* These are global */ gnutls_certificate_credentials_t x509_cred; -gnutls_session_t +static gnutls_session_t initialize_tls_session (void) { gnutls_session_t session; @@ -310,7 +271,7 @@ static gnutls_dh_params_t dh_params; static int generate_dh_params (void) { - const gnutls_datum_t p3 = { pkcs3, strlen (pkcs3) }; + const gnutls_datum_t p3 = { (char*) pkcs3, strlen (pkcs3) }; /* Generate Diffie Hellman parameters - for use with DHE * kx algorithms. These should be discarded and regenerated * once a day, once a week or once a month. Depending on the @@ -371,7 +332,7 @@ const gnutls_datum_t server_key = { server_key_pem, sizeof (server_key_pem) }; -void +static void server_start (void) { /* Socket operations @@ -410,7 +371,7 @@ server_start (void) success ("server: ready. Listening to port '%d'.\n", PORT); } -void +static void server (void) { /* this must be called once in the program |