gnutls-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU gnutls branch, gnutls_2_12_x, updated. gnutls_2_11_6-77-g1d918


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU gnutls branch, gnutls_2_12_x, updated. gnutls_2_11_6-77-g1d91821
Date: Sun, 06 Feb 2011 22:44:34 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU gnutls".

http://git.savannah.gnu.org/cgit/gnutls.git/commit/?id=1d91821a83ff5a80b2fbd77ecc6cc0af9e24c7ee

The branch, gnutls_2_12_x has been updated
       via  1d91821a83ff5a80b2fbd77ecc6cc0af9e24c7ee (commit)
       via  0e68bd876279923810dfa96d3722a085ed3d5e27 (commit)
      from  ffc721921bbd5903977d603802e34ec0d1678c47 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 1d91821a83ff5a80b2fbd77ecc6cc0af9e24c7ee
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Sun Feb 6 23:35:31 2011 +0100

    check the error of hash set_key.

commit 0e68bd876279923810dfa96d3722a085ed3d5e27
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Sun Feb 6 23:44:12 2011 +0100

    Removed documentation and tests related to TLS/IA.

-----------------------------------------------------------------------

Summary of changes:
 doc/Makefile.am                  |    2 +-
 doc/cha-gtls-app.texi            |    9 -
 doc/examples/Makefile.am         |    1 -
 doc/examples/ex-client-tlsia.c   |  161 -----------
 lib/gnutls_hash_int.c            |    9 +-
 libextra/includes/gnutls/extra.h |   12 +-
 tests/Makefile.am                |    3 +-
 tests/tlsia.c                    |  586 --------------------------------------
 8 files changed, 13 insertions(+), 770 deletions(-)
 delete mode 100644 doc/examples/ex-client-tlsia.c
 delete mode 100644 tests/tlsia.c

diff --git a/doc/Makefile.am b/doc/Makefile.am
index ec1a5db..4aa38b6 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -40,7 +40,7 @@ gnutls_TEXINFOS = gnutls.texi fdl-1.3.texi lgpl-2.1.texi 
gpl-3.0.texi \
 gnutls_TEXINFOS += examples/ex-client1.c examples/ex-client2.c         \
        examples/ex-session-info.c examples/ex-verify.c                 \
        examples/ex-cert-select.c examples/ex-client-resume.c           \
-       examples/ex-client-srp.c examples/ex-client-tlsia.c             \
+       examples/ex-client-srp.c        \
        examples/ex-rfc2818.c examples/ex-serv1.c                       \
        examples/ex-serv-anon.c         \
        examples/ex-serv-pgp.c examples/ex-serv-srp.c                   \
diff --git a/doc/cha-gtls-app.texi b/doc/cha-gtls-app.texi
index 2dfa871..fe12f61 100644
--- a/doc/cha-gtls-app.texi
+++ b/doc/cha-gtls-app.texi
@@ -181,7 +181,6 @@ implemented by another example.
 * Client using a PKCS #11 token with TLS::
 * Client with Resume capability example::
 * Simple client example with SRP authentication::
-* Simple client example with TLS/IA support::
 * Simple client example in C++::
 * Helper function for TCP connections::
 @end menu
@@ -282,14 +281,6 @@ itself using a certificate, and in that case it has to be 
verified.
 
 @verbatiminclude examples/ex-client-srp.c
 
address@hidden Simple client example with TLS/IA support
address@hidden Simple Client Example with @acronym{TLS/IA} Support
-
-The following client is a simple client which uses the
address@hidden/IA} extension to authenticate with the server.
-
address@hidden examples/ex-client-tlsia.c
-
 @node Simple client example in C++
 @subsection Simple Client Example using the C++ API
 
diff --git a/doc/examples/Makefile.am b/doc/examples/Makefile.am
index 9a19409..ef9d1d6 100644
--- a/doc/examples/Makefile.am
+++ b/doc/examples/Makefile.am
@@ -56,7 +56,6 @@ endif
 
 if ENABLE_ANON
 noinst_PROGRAMS += ex-client1 ex-serv-anon
-noinst_PROGRAMS += ex-client-tlsia 
 endif
 
 if ENABLE_OPENPGP
diff --git a/doc/examples/ex-client-tlsia.c b/doc/examples/ex-client-tlsia.c
deleted file mode 100644
index 99d3640..0000000
--- a/doc/examples/ex-client-tlsia.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/* This example code is placed in the public domain. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <gnutls/gnutls.h>
-#include <gnutls/extra.h>
-
-/* A basic TLS client, with anonymous authentication and TLS/IA handshake.
- */
-
-#define MAX_BUF 1024
-#define MSG "GET / HTTP/1.0\r\n\r\n"
-
-extern int tcp_connect (void);
-extern void tcp_close (int sd);
-
-static int
-client_avp (gnutls_session_t session, void *ptr,
-            const char *last, size_t lastlen, char **new, size_t * newlen)
-{
-
-  if (last)
-    printf ("- received %d bytes AVP: `%.*s'\n",
-            (int) lastlen, (int) lastlen, last);
-  else
-    printf ("- new application phase\n");
-
-  *new = gnutls_strdup ("client avp");
-  if (!*new)
-    return -1;
-  *newlen = strlen (*new);
-
-  printf ("- sending %d bytes AVP: `%s'\n", (int) *newlen, *new);
-
-  gnutls_ia_permute_inner_secret (session, 3, "foo");
-
-  return 0;
-
-}
-
-int
-main (void)
-{
-  int ret, sd, ii;
-  gnutls_session_t session;
-  char buffer[MAX_BUF + 1];
-  gnutls_anon_client_credentials_t anoncred;
-  gnutls_ia_client_credentials_t iacred;
-  /* Need to enable anonymous KX specifically. */
-
-  gnutls_global_init ();
-
-  gnutls_anon_allocate_client_credentials (&anoncred);
-  gnutls_ia_allocate_client_credentials (&iacred);
-
-  /* Set TLS/IA stuff
-   */
-  gnutls_ia_set_client_avp_function (iacred, client_avp);
-
-  /* Initialize TLS session 
-   */
-  gnutls_init (&session, GNUTLS_CLIENT);
-
-  /* Use default priorities */
-  gnutls_priority_set_direct (session, "NORMAL:+ANON-DH", NULL);
-
-  /* put the anonymous and TLS/IA credentials to the current session
-   */
-  gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-  gnutls_credentials_set (session, GNUTLS_CRD_IA, iacred);
-
-  /* connect to the peer
-   */
-  sd = tcp_connect ();
-
-  gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd);
-
-  /* Perform the TLS handshake
-   */
-  ret = gnutls_handshake (session);
-
-  if (ret < 0)
-    {
-      fprintf (stderr, "*** Handshake failed\n");
-      gnutls_perror (ret);
-      goto end;
-    }
-  else
-    {
-      printf ("- Handshake was completed\n");
-    }
-
-  if (!gnutls_ia_handshake_p (session))
-    {
-      fprintf (stderr, "*** TLS/IA not negotiated...\n");
-      goto end;
-    }
-  else
-    {
-      printf ("- Starting TLS/IA handshake...\n");
-
-      ret = gnutls_ia_handshake (session);
-
-      if (ret < 0)
-        {
-          fprintf (stderr, "*** TLS/IA handshake failed\n");
-          gnutls_perror (ret);
-          goto end;
-        }
-      else
-        {
-          printf ("- TLS/IA Handshake was completed\n");
-        }
-    }
-
-
-  gnutls_record_send (session, MSG, strlen (MSG));
-
-  ret = gnutls_record_recv (session, buffer, MAX_BUF);
-  if (ret == 0)
-    {
-      printf ("- Peer has closed the TLS connection\n");
-      goto end;
-    }
-  else if (ret < 0)
-    {
-      fprintf (stderr, "*** Error: %s\n", gnutls_strerror (ret));
-      goto end;
-    }
-
-  printf ("- Received %d bytes: ", ret);
-  for (ii = 0; ii < ret; ii++)
-    {
-      fputc (buffer[ii], stdout);
-    }
-  fputs ("\n", stdout);
-
-  gnutls_bye (session, GNUTLS_SHUT_RDWR);
-
-end:
-
-  tcp_close (sd);
-
-  gnutls_deinit (session);
-
-  gnutls_ia_free_client_credentials (iacred);
-  gnutls_anon_free_client_credentials (anoncred);
-
-  gnutls_global_deinit ();
-
-  return 0;
-}
diff --git a/lib/gnutls_hash_int.c b/lib/gnutls_hash_int.c
index 5990d98..9d902f4 100644
--- a/lib/gnutls_hash_int.c
+++ b/lib/gnutls_hash_int.c
@@ -267,12 +267,17 @@ _gnutls_hmac_init (digest_hd_st * dig, 
gnutls_mac_algorithm_t algorithm,
       return result;
     }
 
-  _gnutls_mac_ops.setkey (dig->handle, key, keylen);
-
   dig->hash = _gnutls_mac_ops.hash;
   dig->output = _gnutls_mac_ops.output;
   dig->deinit = _gnutls_mac_ops.deinit;
 
+  if (_gnutls_mac_ops.setkey (dig->handle, key, keylen) < 0)
+    {
+      gnutls_assert();
+      dig->deinit(dig->handle);
+      return GNUTLS_E_HASH_FAILED;
+    }
+
   return 0;
 }
 
diff --git a/libextra/includes/gnutls/extra.h b/libextra/includes/gnutls/extra.h
index 88945dd..ee3ce6c 100644
--- a/libextra/includes/gnutls/extra.h
+++ b/libextra/includes/gnutls/extra.h
@@ -125,19 +125,15 @@ extern "C"
                                     size_t session_keys_size,
                                     const char *session_keys)
                                     _GNUTLS_GCC_ATTR_DEPRECATED;
-  extern int gnutls_ia_endphase_send (gnutls_session_t session, int final_p)
-  _GNUTLS_GCC_ATTR_DEPRECATED;
+  extern int gnutls_ia_endphase_send (gnutls_session_t session, int final_p);
 
   extern int gnutls_ia_verify_endphase (gnutls_session_t session,
-                                        const char *checksum)
-                                        _GNUTLS_GCC_ATTR_DEPRECATED;
+                                        const char *checksum);
 
   extern ssize_t gnutls_ia_send (gnutls_session_t session,
-                                 const char *data, size_t sizeofdata)
-                                 _GNUTLS_GCC_ATTR_DEPRECATED;
+                                 const char *data, size_t sizeofdata);
   extern ssize_t gnutls_ia_recv (gnutls_session_t session,
-                                 char *data, size_t sizeofdata)
-                                 _GNUTLS_GCC_ATTR_DEPRECATED;
+                                 char *data, size_t sizeofdata);
 
   /* Utility stuff. */
   extern int gnutls_ia_generate_challenge (gnutls_session_t session,
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1f10d23..b8adcfd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -74,13 +74,12 @@ endif
 
 if HAVE_FORK
 ctests += x509self x509dn anonself pskself dhepskself  \
-       tlsia resume setcredcrash
+       resume setcredcrash
 
 if ENABLE_OPENPGP
 ctests += openpgpself 
 endif
 
-tlsia_LDADD = ../libextra/libgnutls-extra.la $(LDADD) $(LTLIBREADLINE)
 endif
 
 check_PROGRAMS = $(ctests)
diff --git a/tests/tlsia.c b/tests/tlsia.c
deleted file mode 100644
index b63bc29..0000000
--- a/tests/tlsia.c
+++ /dev/null
@@ -1,586 +0,0 @@
-/*
- * Copyright (C) 2004, 2005, 2007, 2008, 2009, 2010 Free Software
- * Foundation, Inc.
- *
- * Author: Simon Josefsson
- *
- * This file is part of GnuTLS.
- *
- * GnuTLS is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * GnuTLS is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with GnuTLS; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
- */
-
-/* Parts copied from GnuTLS example programs. */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/wait.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <unistd.h>
-#include <gnutls/gnutls.h>
-#include <gnutls/extra.h>
-
-#include "utils.h"
-
-#include "tcp.c"
-
-#include <readline.h>
-
-/* A very basic TLS client, with anonymous authentication.
- */
-
-#define MAX_BUF 1024
-#define MSG "Hello TLS"
-
-static void
-tls_log_func (int level, const char *str)
-{
-  fprintf (stderr, "<%d>| %s", level, str);
-}
-
-static int
-client_avp (gnutls_session_t session, void *ptr,
-            const char *last, size_t lastlen, char **new, size_t * newlen)
-{
-  static int iter = 0;
-  const char *p;
-
-  if (debug)
-    {
-      if (last)
-        printf ("client: received %d bytes AVP: `%.*s'\n",
-                (int) lastlen, (int) lastlen, last);
-      else
-        printf ("client: new application phase\n");
-    }
-
-  switch (iter)
-    {
-    case 0:
-      p = "client's first AVP, next will be empty";
-      break;
-
-    case 1:
-      p = "";
-      break;
-
-    case 2:
-      p = "client avp";
-      break;
-
-    default:
-      p = "final client AVP, we'll restart next";
-      iter = -1;
-      break;
-    }
-
-  iter++;
-
-  if (debug)
-    p = readline ("Client TLS/IA AVP: ");
-
-  *new = gnutls_strdup (p);
-  if (!*new)
-    return -1;
-  *newlen = strlen (*new);
-
-  if (debug)
-    printf ("client: sending %d bytes AVP: `%s'\n", (int) *newlen, *new);
-
-  gnutls_ia_permute_inner_secret (session, 3, "foo");
-
-  return 0;
-}
-
-static void
-client (void)
-{
-  int ret, sd, ii;
-  gnutls_session_t session;
-  char buffer[MAX_BUF + 1];
-  gnutls_anon_client_credentials_t anoncred;
-  gnutls_ia_client_credentials_t iacred;
-  /* Need to enable anonymous KX specifically. */
-  const int kx_prio[] = { GNUTLS_KX_ANON_DH, 0 };
-
-  ret = gnutls_global_init ();
-  gnutls_global_set_log_function (tls_log_func);
-  if (debug)
-    gnutls_global_set_log_level (2);
-
-  if (ret)
-    fail ("global_init: %d\n", ret);
-  ret = gnutls_global_init_extra ();
-  if (ret)
-    fail ("global_init_extra: %d\n", ret);
-
-  gnutls_anon_allocate_client_credentials (&anoncred);
-  gnutls_ia_allocate_client_credentials (&iacred);
-
-  /* Initialize TLS session
-   */
-  gnutls_init (&session, GNUTLS_CLIENT);
-
-  /* Use default priorities */
-  gnutls_set_default_priority (session);
-  gnutls_kx_set_priority (session, kx_prio);
-
-  /* put the anonymous credentials to the current session
-   */
-  gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-  gnutls_credentials_set (session, GNUTLS_CRD_IA, iacred);
-
-  /* connect to the peer
-   */
-  sd = tcp_connect ();
-
-  gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd);
-
-  /* Enable TLS/IA. */
-  gnutls_ia_set_client_avp_function (iacred, client_avp);
-
-  /* Perform the TLS handshake
-   */
-  ret = gnutls_handshake (session);
-
-  if (ret < 0)
-    {
-      fail ("client: Handshake failed\n");
-      gnutls_perror (ret);
-      goto end;
-    }
-  else
-    {
-      if (debug)
-        success ("client: Handshake was completed\n");
-    }
-
-  /*
-     To test TLS/IA alert's (the server will print that a fatal alert
-     was received):
-     gnutls_alert_send(session, GNUTLS_AL_FATAL,
-     GNUTLS_A_INNER_APPLICATION_FAILURE);
-   */
-
-  if (!gnutls_ia_handshake_p (session))
-    fail ("client: No TLS/IA negotiation\n");
-  else
-    {
-      if (debug)
-        success ("client: TLS/IA handshake\n");
-
-      ret = gnutls_ia_handshake (session);
-
-      if (ret < 0)
-        {
-          fail ("client: TLS/IA handshake failed\n");
-          gnutls_perror (ret);
-          goto end;
-        }
-      else
-        {
-          if (debug)
-            success ("client: TLS/IA Handshake was completed\n");
-        }
-    }
-
-  gnutls_record_send (session, MSG, strlen (MSG));
-
-  ret = gnutls_record_recv (session, buffer, MAX_BUF);
-  if (ret == 0)
-    {
-      if (debug)
-        success ("client: Peer has closed the TLS connection\n");
-      goto end;
-    }
-  else if (ret < 0)
-    {
-      fail ("client: Error: %s\n", gnutls_strerror (ret));
-      goto end;
-    }
-
-  if (debug)
-    {
-      printf ("- Received %d bytes: ", ret);
-      for (ii = 0; ii < ret; ii++)
-        {
-          fputc (buffer[ii], stdout);
-        }
-      fputs ("\n", stdout);
-    }
-
-  gnutls_bye (session, GNUTLS_SHUT_RDWR);
-
-end:
-
-  tcp_close (sd);
-
-  gnutls_deinit (session);
-
-  gnutls_ia_free_client_credentials (iacred);
-
-  gnutls_anon_free_client_credentials (anoncred);
-
-  gnutls_global_deinit ();
-}
-
-/* This is a sample TLS 1.0 echo server, for anonymous authentication only.
- */
-
-#define SA struct sockaddr
-#define MAX_BUF 1024
-#define PORT 5556               /* listen to 5556 port */
-#define DH_BITS 1024
-
-/* These are global */
-gnutls_anon_server_credentials_t anoncred;
-gnutls_ia_server_credentials_t iacred;
-
-static gnutls_session_t
-initialize_tls_session (void)
-{
-  gnutls_session_t session;
-  const int kx_prio[] = { GNUTLS_KX_ANON_DH, 0 };
-
-  gnutls_init (&session, GNUTLS_SERVER);
-
-  /* avoid calling all the priority functions, since the defaults
-   * are adequate.
-   */
-  gnutls_set_default_priority (session);
-  gnutls_kx_set_priority (session, kx_prio);
-
-  gnutls_credentials_set (session, GNUTLS_CRD_ANON, anoncred);
-
-  gnutls_dh_set_prime_bits (session, DH_BITS);
-
-  return session;
-}
-
-static gnutls_dh_params_t dh_params;
-
-static int
-generate_dh_params (void)
-{
-  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
-   * security requirements.
-   */
-  gnutls_dh_params_init (&dh_params);
-  return gnutls_dh_params_import_pkcs3 (dh_params, &p3, GNUTLS_X509_FMT_PEM);
-}
-
-int err, listen_sd, i;
-int sd, ret;
-struct sockaddr_in sa_serv;
-struct sockaddr_in sa_cli;
-socklen_t client_len;
-char topbuf[512];
-gnutls_session_t session;
-char buffer[MAX_BUF + 1];
-int optval = 1;
-
-static int
-server_avp (gnutls_session_t session, void *ptr,
-            const char *last, size_t lastlen, char **new, size_t * newlen)
-{
-  static int iter = 0;
-  const char *p;
-
-  if (last && debug)
-    printf ("server: received %d bytes AVP: `%.*s'\n",
-            (int) lastlen, (int) lastlen, last);
-
-  gnutls_ia_permute_inner_secret (session, 3, "foo");
-
-  switch (iter)
-    {
-    case 0:
-      p = "first server AVP";
-      break;
-
-    case 1:
-      p = "second server AVP, next will be empty, then a intermediate finish";
-      break;
-
-    case 2:
-      p = "";
-      break;
-
-    case 3:
-      p = "1";
-      break;
-
-    case 4:
-      p = "server avp, after intermediate finish, next another intermediate";
-      break;
-
-    case 5:
-      p = "1";
-      break;
-
-    case 6:
-      p = "server avp, next will be the finish phase";
-      break;
-
-    default:
-      p = "2";
-      break;
-    }
-
-  iter++;
-
-  if (debug)
-    p = readline ("Server TLS/IA AVP (type '1' to sync, '2' to finish): ");
-
-  if (!p)
-    return -1;
-
-  if (strcmp (p, "1") == 0)
-    {
-      if (debug)
-        success ("server: Sending IntermediatePhaseFinished...\n");
-      return 1;
-    }
-
-  if (strcmp (p, "2") == 0)
-    {
-      if (debug)
-        success ("server: Sending FinalPhaseFinished...\n");
-      return 2;
-    }
-
-  *new = gnutls_strdup (p);
-  if (!*new)
-    return -1;
-  *newlen = strlen (*new);
-
-  if (debug)
-    printf ("server: sending %d bytes AVP: `%s'\n", (int) *newlen, *new);
-
-  return 0;
-}
-
-static void
-server_start (void)
-{
-  /* Socket operations
-   */
-  listen_sd = socket (AF_INET, SOCK_STREAM, 0);
-  if (err == -1)
-    {
-      perror ("socket");
-      fail ("server: socket failed\n");
-      return;
-    }
-
-  memset (&sa_serv, '\0', sizeof (sa_serv));
-  sa_serv.sin_family = AF_INET;
-  sa_serv.sin_addr.s_addr = INADDR_ANY;
-  sa_serv.sin_port = htons (PORT);      /* Server Port number */
-
-  setsockopt (listen_sd, SOL_SOCKET, SO_REUSEADDR, (void *) &optval,
-              sizeof (int));
-
-  err = bind (listen_sd, (SA *) & sa_serv, sizeof (sa_serv));
-  if (err == -1)
-    {
-      perror ("bind");
-      fail ("server: bind failed\n");
-      return;
-    }
-
-  err = listen (listen_sd, 1024);
-  if (err == -1)
-    {
-      perror ("listen");
-      fail ("server: listen failed\n");
-      return;
-    }
-
-  if (debug)
-    success ("server: ready. Listening to port '%d'\n", PORT);
-}
-
-static void
-server (void)
-{
-  /* this must be called once in the program
-   */
-  ret = gnutls_global_init ();
-  if (ret)
-    fail ("global_init: %d\n", ret);
-  ret = gnutls_global_init_extra ();
-  if (ret)
-    fail ("global_init_extra: %d\n", ret);
-
-  gnutls_global_set_log_function (tls_log_func);
-  if (debug)
-    gnutls_global_set_log_level (2);
-
-  gnutls_anon_allocate_server_credentials (&anoncred);
-  gnutls_ia_allocate_server_credentials (&iacred);
-
-  if (debug)
-    success ("Launched, generating DH parameters...\n");
-
-  generate_dh_params ();
-
-  gnutls_anon_set_server_dh_params (anoncred, dh_params);
-
-  client_len = sizeof (sa_cli);
-
-  session = initialize_tls_session ();
-
-  sd = accept (listen_sd, (SA *) & sa_cli, &client_len);
-
-  if (debug)
-    success ("server: connection from %s, port %d\n",
-             inet_ntop (AF_INET, &sa_cli.sin_addr, topbuf,
-                        sizeof (topbuf)), ntohs (sa_cli.sin_port));
-
-  gnutls_transport_set_ptr (session, (gnutls_transport_ptr_t) sd);
-
-  /* Enable TLS/IA. */
-  gnutls_credentials_set (session, GNUTLS_CRD_IA, iacred);
-  gnutls_ia_set_server_avp_function (iacred, server_avp);
-
-  ret = gnutls_handshake (session);
-  if (ret < 0)
-    {
-      close (sd);
-      gnutls_deinit (session);
-      fail ("server: Handshake has failed (%s)\n\n", gnutls_strerror (ret));
-      return;
-    }
-  if (debug)
-    success ("server: Handshake was completed\n");
-
-  if (!gnutls_ia_handshake_p (session))
-    fail ("server: No TLS/IA negotiation\n");
-  else
-    {
-      if (debug)
-        success ("server: TLS/IA handshake\n");
-
-      ret = gnutls_ia_handshake (session);
-
-      if (ret < 0)
-        {
-          fail ("server: TLS/IA handshake failed\n");
-          gnutls_perror (ret);
-          return;
-        }
-      else
-        {
-          if (debug)
-            success ("server: TLS/IA Handshake was completed\n");
-        }
-    }
-
-  /* see the Getting peer's information example */
-  /* print_info(session); */
-
-  i = 0;
-  for (;;)
-    {
-      memset (buffer, 0, MAX_BUF + 1);
-      ret = gnutls_record_recv (session, buffer, MAX_BUF);
-
-      if (ret == 0)
-        {
-          if (debug)
-            success ("server: Peer has closed the GnuTLS connection\n");
-          break;
-        }
-      else if (ret < 0)
-        {
-          if (ret == GNUTLS_E_FATAL_ALERT_RECEIVED)
-            {
-              gnutls_alert_description_t alert;
-              const char *err;
-              alert = gnutls_alert_get (session);
-              err = gnutls_alert_get_name (alert);
-              if (err)
-                printf ("Fatal alert: %s\n", err);
-            }
-
-          fail ("server: Received corrupted data(%d). Closing...\n", ret);
-          break;
-        }
-      else if (ret > 0)
-        {
-          /* echo data back to the client
-           */
-          gnutls_record_send (session, buffer, strlen (buffer));
-        }
-    }
-  /* do not wait for the peer to close the connection.
-   */
-  gnutls_bye (session, GNUTLS_SHUT_WR);
-
-  close (sd);
-  gnutls_deinit (session);
-
-  close (listen_sd);
-
-  gnutls_ia_free_server_credentials (iacred);
-
-  gnutls_anon_free_server_credentials (anoncred);
-
-  gnutls_dh_params_deinit (dh_params);
-
-  gnutls_global_deinit ();
-
-  if (debug)
-    success ("server: finished\n");
-}
-
-void
-doit (void)
-{
-  pid_t child;
-
-  server_start ();
-  if (error_count)
-    return;
-
-  child = fork ();
-  if (child < 0)
-    {
-      perror ("fork");
-      fail ("fork");
-      return;
-    }
-
-  if (child)
-    {
-      int status;
-      /* parent */
-      server ();
-      wait (&status);
-    }
-  else
-    client ();
-}


hooks/post-receive
-- 
GNU gnutls



reply via email to

[Prev in Thread] Current Thread [Next in Thread]