summaryrefslogtreecommitdiff
path: root/tests/openpgpself.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/openpgpself.c')
-rw-r--r--tests/openpgpself.c50
1 files changed, 6 insertions, 44 deletions
diff --git a/tests/openpgpself.c b/tests/openpgpself.c
index b399a111e8..fc802880cb 100644
--- a/tests/openpgpself.c
+++ b/tests/openpgpself.c
@@ -42,6 +42,7 @@
#include "ex-session-info.c"
#include "ex-x509-info.c"
+#include "tcp.c"
pid_t child;
@@ -57,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 unsigned char cert_txt[] =
"-----BEGIN PGP PUBLIC KEY BLOCK-----\n"
"Version: GnuPG v1.0.6 (GNU/Linux)\n"
@@ -139,7 +101,7 @@ static unsigned char key_txt[] =
"=4M0W\n" "-----END PGP PRIVATE KEY BLOCK-----\n";
const gnutls_datum_t key = { key_txt, sizeof (key_txt) };
-void
+static void
client (void)
{
int ret, sd, ii;
@@ -249,7 +211,7 @@ end:
/* These are global */
gnutls_certificate_credentials_t pgp_cred;
-gnutls_session_t
+static gnutls_session_t
initialize_tls_session (void)
{
gnutls_session_t session;
@@ -277,7 +239,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
@@ -372,7 +334,7 @@ static unsigned char server_key_txt[] =
"=mZnW\n" "-----END PGP PRIVATE KEY BLOCK-----\n";
const gnutls_datum_t server_key = { server_key_txt, sizeof (server_key_txt) };
-void
+static void
server_start (void)
{
/* Socket operations
@@ -411,7 +373,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