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_12_1-32-gf0426


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU gnutls branch, gnutls_2_12_x, updated. gnutls_2_12_1-32-gf04269f
Date: Thu, 07 Apr 2011 22:27:30 +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=f04269f1f34ff89905ac15f671c164f6388b1d3b

The branch, gnutls_2_12_x has been updated
       via  f04269f1f34ff89905ac15f671c164f6388b1d3b (commit)
       via  5e9e7567b740cc9ac76a88e090442d6dfde3cf5c (commit)
       via  566d08dcb44b7d3e7ad248c2738794afe329703f (commit)
       via  187ce77498f8538fa2d42e28f1690c18210a084a (commit)
       via  149bdc49651968f9d3f2bbbfec67ed16e43e2019 (commit)
       via  25c578c6fa50a83e20fc14d7659405a525a7ce9e (commit)
       via  bdeb1f5fb5741a4c287cdf3f23bb120fef6553ad (commit)
       via  902e043dcacee88c0e849881139942ac917bd165 (commit)
       via  2b8396dd6938cb9c388fcb4e7fdff0f598a83533 (commit)
       via  c05602e88ee155860e62583fd61ca5fc334e3bb7 (commit)
       via  b766508a2e8f452b195b08738990c2b10aa1fbae (commit)
       via  72659e44b9590220fd05e26aea19267a2e5c354f (commit)
       via  2d0ecff74d6904c4794b58ab00cb23645dbb8fcf (commit)
       via  d6f07e7e1bd0f736d67b1278c1d7ad9673633655 (commit)
       via  08e91517e197c58430a6400c0b73d08e843ba296 (commit)
       via  377a7b28fb9d18b35791a4b1210deb402bce23db (commit)
       via  4118c57609d180acbcc771517b55aea9059fb90c (commit)
       via  28e8d88d8a8a2df0ad445115d023a96921bd17a4 (commit)
       via  e72ea8750cb2655a3d78807c1e3e0aa721218d31 (commit)
       via  9a04bffd5986ed2fc7764cbe657ba6f8c70193df (commit)
       via  674c0c2eadebe2eed7ec64b66a9c180a451a4e83 (commit)
       via  58162c90c3cbbd466f498faf316903e244586af9 (commit)
       via  936597830e666f9e6c7c9808e0e724b5bf675e78 (commit)
       via  8321122e8e03be456471e6c3779fcc6e34d22d73 (commit)
       via  69b94b537e36d1236538d20144205be9226897c1 (commit)
      from  0afa0ff850bce075d15c27fda121f2b801fb5f49 (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 f04269f1f34ff89905ac15f671c164f6388b1d3b
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Fri Apr 8 00:27:22 2011 +0200

    updated

commit 5e9e7567b740cc9ac76a88e090442d6dfde3cf5c
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Fri Apr 8 00:06:03 2011 +0200

    removed unneeded variable.

commit 566d08dcb44b7d3e7ad248c2738794afe329703f
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Fri Apr 8 00:05:26 2011 +0200

    Corrected check for an unknown sign algorithm. Patch by LRN.

commit 187ce77498f8538fa2d42e28f1690c18210a084a
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Fri Apr 8 00:02:59 2011 +0200

    Do not use %e in strftime. Use %d instead which is identically available in 
windows as well.
    Based on patch by LRN.

commit 149bdc49651968f9d3f2bbbfec67ed16e43e2019
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Fri Apr 8 00:00:45 2011 +0200

    Fixed mismatch in size_t size. Patch by LRN.

commit 25c578c6fa50a83e20fc14d7659405a525a7ce9e
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Fri Apr 8 00:24:38 2011 +0200

    win32 fixes for set_global_errno(). Based on patch by LRN.

commit bdeb1f5fb5741a4c287cdf3f23bb120fef6553ad
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Fri Apr 8 00:23:05 2011 +0200

    Win32 changes for benchmark. Patch by LRN.

commit 902e043dcacee88c0e849881139942ac917bd165
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Thu Apr 7 23:18:01 2011 +0200

    win32 fixes. Patch by LRN.

commit 2b8396dd6938cb9c388fcb4e7fdff0f598a83533
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Thu Apr 7 01:14:25 2011 +0200

    simplified cdk_trim_string() to make it safer to use.

commit c05602e88ee155860e62583fd61ca5fc334e3bb7
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Thu Apr 7 00:58:42 2011 +0200

    correctly reset params.

commit b766508a2e8f452b195b08738990c2b10aa1fbae
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Thu Apr 7 00:54:34 2011 +0200

    correctly compare sign algorithm_st.

commit 72659e44b9590220fd05e26aea19267a2e5c354f
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Thu Apr 7 00:48:46 2011 +0200

    removed unused code

commit 2d0ecff74d6904c4794b58ab00cb23645dbb8fcf
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Thu Apr 7 00:37:20 2011 +0200

    null terminate the armored string

commit d6f07e7e1bd0f736d67b1278c1d7ad9673633655
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Thu Apr 7 00:31:01 2011 +0200

    properly null terminate string.

commit 08e91517e197c58430a6400c0b73d08e843ba296
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Thu Apr 7 00:18:01 2011 +0200

    check PIN size.

commit 377a7b28fb9d18b35791a4b1210deb402bce23db
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Thu Apr 7 00:16:21 2011 +0200

    check salt size.

commit 4118c57609d180acbcc771517b55aea9059fb90c
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Thu Apr 7 00:11:44 2011 +0200

    more clear bounds checking

commit 28e8d88d8a8a2df0ad445115d023a96921bd17a4
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Wed Apr 6 00:18:16 2011 +0200

    initialize e and d.

commit e72ea8750cb2655a3d78807c1e3e0aa721218d31
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Wed Apr 6 00:16:50 2011 +0200

    deinitialize pks variable only when needed.

commit 9a04bffd5986ed2fc7764cbe657ba6f8c70193df
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Wed Apr 6 00:12:45 2011 +0200

    Initialize verify.

commit 674c0c2eadebe2eed7ec64b66a9c180a451a4e83
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Wed Apr 6 00:10:37 2011 +0200

    initialize session_id_size.

commit 58162c90c3cbbd466f498faf316903e244586af9
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Wed Apr 6 00:08:30 2011 +0200

    removed unneeded function.

commit 936597830e666f9e6c7c9808e0e724b5bf675e78
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Wed Apr 6 00:03:49 2011 +0200

    correctly traverse slots

commit 8321122e8e03be456471e6c3779fcc6e34d22d73
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Tue Apr 5 23:53:40 2011 +0200

    Initialize tinfo using the initially available information.

commit 69b94b537e36d1236538d20144205be9226897c1
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Mon Apr 4 22:02:27 2011 +0200

    The mini-* programs were combined. (backported from master branch)

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

Summary of changes:
 NEWS                      |    4 +
 lib/auth_cert.c           |    2 +-
 lib/gnutls_algorithms.c   |    2 +-
 lib/gnutls_buffers.c      |   20 +++
 lib/opencdk/Makefile.am   |    2 +-
 lib/opencdk/armor.c       |   12 +-
 lib/opencdk/context.h     |    4 -
 lib/opencdk/literal.c     |    8 +-
 lib/opencdk/main.c        |   16 ---
 lib/opencdk/main.h        |    6 +-
 lib/opencdk/misc.c        |   39 +-----
 lib/opencdk/opencdk.h     |   48 -------
 lib/opencdk/read-packet.c |    2 +-
 lib/opencdk/verify.c      |  319 ---------------------------------------------
 lib/openpgp/output.c      |    4 +-
 lib/openpgp/pgpverify.c   |    2 +
 lib/pakchois/pakchois.c   |    1 +
 lib/pkcs11.c              |    2 +
 lib/pkcs11_write.c        |    5 +-
 lib/system.c              |    1 -
 lib/x509/output.c         |    2 +-
 lib/x509/privkey.c        |    5 +-
 lib/x509/privkey_pkcs8.c  |    6 +-
 src/benchmark.c           |   66 +++++++++-
 src/cli.c                 |    3 +-
 src/common.c              |    6 +
 src/crypt.c               |    6 +
 src/pkcs11.c              |   17 ++-
 tests/anonself.c          |    2 +
 tests/certuniqueid.c      |    2 +-
 tests/dhepskself.c        |    2 +
 tests/eagain-common.h     |  228 ++++++++++++++++++++++++++++++++
 tests/mini-eagain.c       |  212 ++----------------------------
 tests/mini.c              |  175 ++-----------------------
 tests/openpgpself.c       |    2 +
 tests/pskself.c           |    2 +
 tests/resume.c            |    2 +
 tests/rng-fork.c          |   10 ++
 tests/x509dn.c            |    2 +
 tests/x509self.c          |    2 +
 40 files changed, 433 insertions(+), 818 deletions(-)
 delete mode 100644 lib/opencdk/verify.c
 create mode 100644 tests/eagain-common.h

diff --git a/NEWS b/NEWS
index 315e81e..23c6a01 100644
--- a/NEWS
+++ b/NEWS
@@ -5,6 +5,10 @@ See the end for copying conditions.
 
 * Version 2.12.2 (unreleased)
 
+** libgnutls: Several updates and fixes for win32. Patches by LRN.
+
+** libgnutls: Several bug fixes.
+
 ** srptool: Accepts the -d option to enable debugging.
 
 ** libgnutls: Corrected bug in gnutls_srp_verifier() that prevented
diff --git a/lib/auth_cert.c b/lib/auth_cert.c
index 033d3d7..2ddbf46 100644
--- a/lib/auth_cert.c
+++ b/lib/auth_cert.c
@@ -1643,7 +1643,7 @@ _gnutls_proc_cert_client_cert_vrfy (gnutls_session_t 
session,
       aid.sign_algorithm = pdata[1];
 
       sign_algo = _gnutls_tls_aid_to_sign (&aid);
-      if (sign_algo == GNUTLS_PK_UNKNOWN)
+      if (sign_algo == GNUTLS_SIGN_UNKNOWN)
         {
           gnutls_assert ();
           return GNUTLS_E_UNSUPPORTED_SIGNATURE_ALGORITHM;
diff --git a/lib/gnutls_algorithms.c b/lib/gnutls_algorithms.c
index cdd7feb..9ce73ce 100644
--- a/lib/gnutls_algorithms.c
+++ b/lib/gnutls_algorithms.c
@@ -2129,7 +2129,7 @@ _gnutls_tls_aid_to_sign (const sign_algorithm_st * aid)
 {
   gnutls_sign_algorithm_t ret = GNUTLS_SIGN_UNKNOWN;
 
-  if (memcmp(aid, &unknown_tls_aid, sizeof(aid))==0)
+  if (memcmp(aid, &unknown_tls_aid, sizeof(*aid))==0)
     return ret;
 
   GNUTLS_SIGN_LOOP (if (p->aid.hash_algorithm == aid->hash_algorithm
diff --git a/lib/gnutls_buffers.c b/lib/gnutls_buffers.c
index 5f14815..1fb90a5 100644
--- a/lib/gnutls_buffers.c
+++ b/lib/gnutls_buffers.c
@@ -57,6 +57,9 @@
 #include <system.h>
 
 #include <errno.h>
+#ifdef _WIN32
+# include <windows.h>
+#endif
 
 #ifndef EAGAIN
 #define EAGAIN EWOULDBLOCK
@@ -115,7 +118,24 @@ gnutls_transport_set_errno (gnutls_session_t session, int 
err)
 void
 gnutls_transport_set_global_errno (int err)
 {
+#ifdef _WIN32
+  /* Keep this in sync with system_errno */
+  switch (err)
+    {
+    case EAGAIN:
+      SetLastError (WSAEWOULDBLOCK);
+      break;
+    case EINTR:
+      SetLastError (WSAEINTR);
+      break;
+    default:
+      /* We don't care about anything else */
+      SetLastError (NO_ERROR);
+      break;
+    }
+#else
   errno = err;
+#endif
 }
 
 /* Buffers received packets of type APPLICATION DATA and
diff --git a/lib/opencdk/Makefile.am b/lib/opencdk/Makefile.am
index 16c7707..5728d8b 100644
--- a/lib/opencdk/Makefile.am
+++ b/lib/opencdk/Makefile.am
@@ -35,7 +35,7 @@ endif
 noinst_LTLIBRARIES = libminiopencdk.la
 
 libminiopencdk_la_SOURCES = armor.c filters.h keydb.h main.c types.h   \
-       kbnode.c main.h packet.h dummy.c sig-check.c verify.c hash.c \
+       kbnode.c main.h packet.h dummy.c sig-check.c hash.c \
        keydb.c pubkey.c stream.c write-packet.c misc.c seskey.c \
        context.h literal.c new-packet.c read-packet.c stream.h opencdk.h
 
diff --git a/lib/opencdk/armor.c b/lib/opencdk/armor.c
index b731226..2928182 100644
--- a/lib/opencdk/armor.c
+++ b/lib/opencdk/armor.c
@@ -746,7 +746,9 @@ _cdk_filter_armor (void *data, int ctl, FILE * in, FILE * 
out)
  * @nwritten: actual length of the base64 data
  * @type: the base64 file type.
  * 
- * Encode the given buffer into base64 format.
+ * Encode the given buffer into base64 format. The base64
+ * string will be null terminated but the null will
+ * not be contained in the size.
  **/
 cdk_error_t
 cdk_armor_encode_buffer (const byte * inbuf, size_t inlen,
@@ -772,13 +774,14 @@ cdk_armor_encode_buffer (const byte * inbuf, size_t inlen,
   head = armor_begin[type];
   tail = armor_end[type];
   le = _cdk_armor_get_lineend ();
-  pos = strlen (head) + 10 + 2 + 2 + strlen (tail) + 10 + 2 + 5 + 2;
+  pos = strlen (head) + 10 + 2 + 2 + strlen (tail) + 10 + 2 + 5 + 2 + 1;
   /* The output data is 4/3 times larger, plus a line end for each line. */
-  pos += (4 * inlen / 3) + 2 * (4 * inlen / 3 / 64);
+  pos += (4 * inlen / 3) + 2 * (4 * inlen / 3 / 64) + 1;
 
   if (outbuf && outlen < pos)
     {
       gnutls_assert ();
+      *nwritten = pos;
       return CDK_Too_Short;
     }
 
@@ -832,6 +835,7 @@ cdk_armor_encode_buffer (const byte * inbuf, size_t inlen,
   pos += 5;
   memcpy (outbuf + pos, le, strlen (le));
   pos += strlen (le);
-  *nwritten = pos;
+  outbuf[pos] = 0;
+  *nwritten = pos - 1;
   return 0;
 }
diff --git a/lib/opencdk/context.h b/lib/opencdk/context.h
index 7c32ea7..35ffc97 100644
--- a/lib/opencdk/context.h
+++ b/lib/opencdk/context.h
@@ -77,10 +77,6 @@ struct cdk_ctx_s
   } opt;
   struct
   {
-    cdk_verify_result_t verify;
-  } result;
-  struct
-  {
     cdk_pkt_seckey_t sk;
     unsigned on:1;
   } cache;
diff --git a/lib/opencdk/literal.c b/lib/opencdk/literal.c
index 4c8f966..a36921c 100644
--- a/lib/opencdk/literal.c
+++ b/lib/opencdk/literal.c
@@ -262,10 +262,12 @@ text_encode (void *data, FILE * in, FILE * out)
   /* FIXME: This code does not work for very long lines. */
   while (!feof (in))
     {
-      s = fgets (buf, DIM (buf) - 1, in);
+      /* give space for trim_string \r\n */
+      s = fgets (buf, DIM (buf) - 3, in);
       if (!s)
         break;
-      _cdk_trim_string (buf, 1);
+      _cdk_trim_string (buf);
+      strcat (buf, "\r\n");
       fwrite (buf, 1, strlen (buf), out);
     }
 
@@ -288,7 +290,7 @@ text_decode (void *data, FILE * in, FILE * out)
       s = fgets (buf, DIM (buf) - 1, in);
       if (!s)
         break;
-      _cdk_trim_string (buf, 0);
+      _cdk_trim_string (buf);
       fwrite (buf, 1, strlen (buf), out);
       fwrite (tfx->lf, 1, strlen (tfx->lf), out);
     }
diff --git a/lib/opencdk/main.c b/lib/opencdk/main.c
index 1dd0ea2..5478a8b 100644
--- a/lib/opencdk/main.c
+++ b/lib/opencdk/main.c
@@ -318,21 +318,6 @@ cdk_handle_set_passphrase_cb (cdk_ctx_t hd,
   hd->passphrase_cb_value = cb_value;
 }
 
-
-/**
- * cdk_handle_verify_get_result:
- * @hd: the session handle
- * 
- * Return the verify result for the current session.
- * Do not free the pointer.
- **/
-cdk_verify_result_t
-cdk_handle_verify_get_result (cdk_ctx_t hd)
-{
-  return hd->result.verify;
-}
-
-
 /**
  * cdk_handle_free:
  * @hd: the handle
@@ -344,7 +329,6 @@ cdk_handle_free (cdk_ctx_t hd)
 {
   if (!hd)
     return;
-  _cdk_result_verify_free (hd->result.verify);
 
   /* If cdk_handle_set_keyring() were used, we need to free the key db
      handles here because the handles are not controlled by the user. */
diff --git a/lib/opencdk/main.h b/lib/opencdk/main.h
index bc7d523..5a69bf2 100644
--- a/lib/opencdk/main.h
+++ b/lib/opencdk/main.h
@@ -158,7 +158,7 @@ cdk_error_t _cdk_keydb_check_userid (cdk_keydb_hd_t hd, u32 
* keyid,
 
 /*-- sign.c --*/
 int _cdk_sig_hash_for (cdk_pkt_pubkey_t pk);
-void _cdk_trim_string (char *s, int canon);
+void _cdk_trim_string (char *s);
 cdk_error_t _cdk_sig_create (cdk_pkt_pubkey_t pk, cdk_pkt_signature_t sig);
 cdk_error_t _cdk_sig_complete (cdk_pkt_signature_t sig, cdk_pkt_seckey_t sk,
                                digest_hd_st * hd);
@@ -179,10 +179,6 @@ int _cdk_stream_puts (cdk_stream_t s, const char *buf);
 cdk_error_t _cdk_stream_fpopen (FILE * fp, unsigned write_mode,
                                 cdk_stream_t * ret_out);
 
-/*-- verify.c --*/
-void _cdk_result_verify_free (cdk_verify_result_t res);
-cdk_verify_result_t _cdk_result_verify_new (void);
-
 
 /*-- read-packet.c --*/
 size_t _cdk_pkt_read_len (FILE * inp, size_t * ret_partial);
diff --git a/lib/opencdk/misc.c b/lib/opencdk/misc.c
index a2608ad..d6a89ae 100644
--- a/lib/opencdk/misc.c
+++ b/lib/opencdk/misc.c
@@ -105,32 +105,6 @@ cdk_strlist_add (cdk_strlist_t * list, const char *string)
   return sl;
 }
 
-
-/**
- * cdk_strlist_next:
- * @root: the opaque string list.
- * @r_str: optional argument to store the string data.
- *
- * Return the next string list node from @root. The optional
- * argument @r_str return the data of the current (!) node.
- **/
-cdk_strlist_t
-cdk_strlist_next (cdk_strlist_t root, const char **r_str)
-{
-  cdk_strlist_t node;
-
-  if (!root)
-    return NULL;
-
-  if (r_str)
-    *r_str = root->d;
-  for (node = root->next; node; node = node->next)
-    return node;
-
-  return NULL;
-}
-
-
 const char *
 _cdk_memistr (const char *buf, size_t buflen, const char *sub)
 {
@@ -172,15 +146,14 @@ _cdk_map_gnutls_error (int err)
 
 /* Remove all trailing white spaces from the string. */
 void
-_cdk_trim_string (char *s, int canon)
+_cdk_trim_string (char *s)
 {
+int len = strlen(s);
   while (s && *s &&
-         (s[strlen (s) - 1] == '\t' ||
-          s[strlen (s) - 1] == '\r' ||
-          s[strlen (s) - 1] == '\n' || s[strlen (s) - 1] == ' '))
-    s[strlen (s) - 1] = '\0';
-  if (canon)
-    strcat (s, "\r\n");
+         (s[len - 1] == '\t' ||
+          s[len - 1] == '\r' ||
+          s[len - 1] == '\n' || s[len - 1] == ' '))
+    s[len - 1] = '\0';
 }
 
 
diff --git a/lib/opencdk/opencdk.h b/lib/opencdk/opencdk.h
index 6516824..859920a 100644
--- a/lib/opencdk/opencdk.h
+++ b/lib/opencdk/opencdk.h
@@ -625,29 +625,6 @@ extern "C"
 /* Set the mode and the digest for the S2K operation. */
 #define cdk_handle_set_s2k(a, val1, val2) \
   cdk_handle_control ((a), CDK_CTLF_SET, CDK_CTL_S2K, (val1), (val2))
-
-
-/* This context holds all information of the verification process. */
-  struct cdk_verify_result_s
-  {
-    int sig_ver;                /* Version of the signature. */
-    int sig_status;             /* The status (GOOD, BAD) of the signature */
-    int sig_flags;              /* May contain expired or revoked flags */
-    unsigned int keyid[2];      /* The issuer key ID */
-    unsigned int created;       /* Timestamp when the sig was created. */
-    unsigned int expires;
-    int pubkey_algo;
-    int digest_algo;
-    char *user_id;              /* NULL or user ID which issued the signature. 
*/
-    char *policy_url;           /* If set, the policy the sig was created 
under. */
-    size_t sig_len;             /* Size of the signature data inbits. */
-    unsigned char *sig_data;    /* Raw signature data. */
-  };
-  typedef struct cdk_verify_result_s *cdk_verify_result_t;
-
-/* Return the verify result. Do not free the data. */
-  cdk_verify_result_t cdk_handle_verify_get_result (cdk_ctx_t hd);
-
 /* Raw packet routines. */
 
 /* Allocate a new packet or a new packet with the given packet type. */
@@ -1032,30 +1009,6 @@ extern "C"
                                   unsigned char **outbuf, size_t * outsize,
                                   int modval);
 
-/* Sign the stream @INP. Optionally, the output will be encrypted
-   if @REMUSR is not NULL and the @ENCRYPTFLAG is set.
-   The output will be written to @OUT.
-   @LOCUSR contains one ore more pattern for the secret key(s) to use. */
-  cdk_error_t cdk_stream_sign (cdk_ctx_t hd, cdk_stream_t inp,
-                               cdk_stream_t out, cdk_strlist_t locusr,
-                               cdk_strlist_t remusr, int encryptflag,
-                               int sigmode);
-
-/* Same as the function above but it works on files. */
-  cdk_error_t cdk_file_sign (cdk_ctx_t hd, cdk_strlist_t locusr,
-                             cdk_strlist_t remusr,
-                             const char *file, const char *output,
-                             int sigmode, int encryptflag);
-
-  cdk_error_t cdk_stream_verify (cdk_ctx_t hd, cdk_stream_t inp,
-                                 cdk_stream_t data, cdk_stream_t out);
-
-/* Verify the given file @FILE. For a detached signature, @DATA_FILE
-   contains the actual file data and @FILE is only the signature.
-   If the @OUTPUT is not NULL, the plaintext will be written to this file. */
-  cdk_error_t cdk_file_verify (cdk_ctx_t hd, const char *file,
-                               const char *data_file, const char *output);
-
   int cdk_trustdb_get_validity (cdk_stream_t inp, cdk_pkt_userid_t id,
                                 int *r_val);
   int cdk_trustdb_get_ownertrust (cdk_stream_t inp, cdk_pubkey_t pk,
@@ -1063,7 +1016,6 @@ extern "C"
 
   void cdk_strlist_free (cdk_strlist_t sl);
   cdk_strlist_t cdk_strlist_add (cdk_strlist_t * list, const char *string);
-  cdk_strlist_t cdk_strlist_next (cdk_strlist_t root, const char **r_str);
   const char *cdk_check_version (const char *req_version);
 /* UTF8 */
   char *cdk_utf8_encode (const char *string);
diff --git a/lib/opencdk/read-packet.c b/lib/opencdk/read-packet.c
index 313e779..03395b3 100644
--- a/lib/opencdk/read-packet.c
+++ b/lib/opencdk/read-packet.c
@@ -527,7 +527,7 @@ read_attribute (cdk_stream_t inp, size_t pktlen, 
cdk_pkt_userid_t attr)
   p++;
   len--;
 
-  if (pktlen - (len + 1) > 0)
+  if (len >= pktlen)
     return CDK_Inv_Packet;
   attr->attrib_img = cdk_calloc (1, len);
   if (!attr->attrib_img)
diff --git a/lib/opencdk/verify.c b/lib/opencdk/verify.c
deleted file mode 100644
index 397b3ed..0000000
--- a/lib/opencdk/verify.c
+++ /dev/null
@@ -1,319 +0,0 @@
-/* verify.c - Verify signatures
- * Copyright (C) 2001, 2002, 2003, 2007, 2008, 2010 Free Software
- * Foundation, Inc.
- *
- * Author: Timo Schulz
- *
- * This file is part of OpenCDK.
- *
- * The OpenCDK library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- * USA
- *
- */
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-#include <stdio.h>
-#include <string.h>
-#include <sys/stat.h>
-
-#include "opencdk.h"
-#include "main.h"
-#include "filters.h"
-#include "packet.h"
-
-
-/* Table of all supported digest algorithms and their names. */
-struct
-{
-  const char *name;
-  int algo;
-} digest_table[] =
-{
-  {
-  "MD5", GNUTLS_DIG_MD5},
-  {
-  "SHA1", GNUTLS_DIG_SHA1},
-  {
-  "RIPEMD160", GNUTLS_DIG_RMD160},
-  {
-  "SHA256", GNUTLS_DIG_SHA256},
-  {
-  "SHA384", GNUTLS_DIG_SHA384},
-  {
-  "SHA512", GNUTLS_DIG_SHA512},
-  {
-  NULL, 0}
-};
-
-
-static cdk_error_t file_verify_clearsign (cdk_ctx_t, const char *,
-                                          const char *);
-
-
-/**
- * cdk_stream_verify:
- * @hd: session handle
- * @inp: the input stream
- * @data: for detached signatures, this is the data stream @inp is the sig
- * @out: where the output shall be written.
- *
- * Verify a signature in stream.
- */
-cdk_error_t
-cdk_stream_verify (cdk_ctx_t hd, cdk_stream_t inp, cdk_stream_t data,
-                   cdk_stream_t out)
-{
-  /* FIXME: out is not currently used. */
-  if (cdk_armor_filter_use (inp))
-    cdk_stream_set_armor_flag (inp, 0);
-  return _cdk_proc_packets (hd, inp, data, NULL, NULL, NULL);
-}
-
-/**
- * cdk_file_verify:
- * @hd: the session handle
- * @file: the input file
- * @data_file: for detached signature this is the data file and @file is the 
sig.
- * @output: the output file
- *
- * Verify a signature.
- **/
-cdk_error_t
-cdk_file_verify (cdk_ctx_t hd, const char *file, const char *data_file,
-                 const char *output)
-{
-  struct stat stbuf;
-  cdk_stream_t inp, data;
-  char buf[4096];
-  int n;
-  cdk_error_t rc;
-
-  if (!hd || !file)
-    return CDK_Inv_Value;
-  if (output && !hd->opt.overwrite && !stat (output, &stbuf))
-    return CDK_Inv_Mode;
-
-  rc = cdk_stream_open (file, &inp);
-  if (rc)
-    return rc;
-  if (cdk_armor_filter_use (inp))
-    {
-      n = cdk_stream_peek (inp, (byte *) buf, DIM (buf) - 1);
-      if (!n || n == -1)
-        return CDK_EOF;
-      buf[n] = '\0';
-      if (strstr (buf, "BEGIN PGP SIGNED MESSAGE"))
-        {
-          cdk_stream_close (inp);
-          return file_verify_clearsign (hd, file, output);
-        }
-      cdk_stream_set_armor_flag (inp, 0);
-    }
-
-  if (data_file)
-    {
-      rc = cdk_stream_open (data_file, &data);
-      if (rc)
-        {
-          cdk_stream_close (inp);
-          return rc;
-        }
-    }
-  else
-    data = NULL;
-
-  rc = _cdk_proc_packets (hd, inp, data, NULL, NULL, NULL);
-
-  if (data != NULL)
-    cdk_stream_close (data);
-  cdk_stream_close (inp);
-  return rc;
-}
-
-
-void
-_cdk_result_verify_free (cdk_verify_result_t res)
-{
-  if (!res)
-    return;
-  cdk_free (res->policy_url);
-  cdk_free (res->sig_data);
-  cdk_free (res);
-}
-
-
-cdk_verify_result_t
-_cdk_result_verify_new (void)
-{
-  cdk_verify_result_t res;
-
-  res = cdk_calloc (1, sizeof *res);
-  if (!res)
-    return NULL;
-  return res;
-}
-
-
-static cdk_error_t
-file_verify_clearsign (cdk_ctx_t hd, const char *file, const char *output)
-{
-  cdk_stream_t inp = NULL, out = NULL, tmp = NULL;
-  digest_hd_st md;
-  char buf[512], chk[512];
-  const char *s;
-  int i, is_signed = 0, nbytes;
-  int digest_algo = 0;
-  int err;
-  cdk_error_t rc;
-
-  memset(&md, 0, sizeof(md));
-
-  if (output)
-    {
-      rc = cdk_stream_create (output, &out);
-      if (rc)
-        return rc;
-    }
-
-  rc = cdk_stream_open (file, &inp);
-  if (rc)
-    {
-      if (output)
-        cdk_stream_close (out);
-      return rc;
-    }
-
-  s = "-----BEGIN PGP SIGNED MESSAGE-----";
-  while (!cdk_stream_eof (inp))
-    {
-      nbytes = _cdk_stream_gets (inp, buf, DIM (buf) - 1);
-      if (!nbytes || nbytes == -1)
-        break;
-      if (!strncmp (buf, s, strlen (s)))
-        {
-          is_signed = 1;
-          break;
-        }
-    }
-
-  if (cdk_stream_eof (inp) && !is_signed)
-    {
-      rc = CDK_Armor_Error;
-      goto leave;
-    }
-
-  while (!cdk_stream_eof (inp))
-    {
-      nbytes = _cdk_stream_gets (inp, buf, DIM (buf) - 1);
-      if (!nbytes || nbytes == -1)
-        break;
-      if (nbytes == 1)          /* Empty line */
-        break;
-      else if (!strncmp (buf, "Hash: ", 6))
-        {
-          for (i = 0; digest_table[i].name; i++)
-            {
-              if (!strcmp (buf + 6, digest_table[i].name))
-                {
-                  digest_algo = digest_table[i].algo;
-                  break;
-                }
-            }
-        }
-    }
-
-  if (digest_algo && _gnutls_hash_get_algo_len (digest_algo) <= 0)
-    {
-      rc = CDK_Inv_Algo;
-      goto leave;
-    }
-
-  if (!digest_algo)
-    digest_algo = GNUTLS_DIG_MD5;
-
-  err = _gnutls_hash_init (&md, digest_algo);
-  if (err < 0)
-    {
-      gnutls_assert ();
-      rc = map_gnutls_error (err);
-      goto leave;
-    }
-
-  s = "-----BEGIN PGP SIGNATURE-----";
-  while (!cdk_stream_eof (inp))
-    {
-      nbytes = _cdk_stream_gets (inp, buf, DIM (buf) - 1);
-      if (!nbytes || nbytes == -1)
-        break;
-      if (!strncmp (buf, s, strlen (s)))
-        break;
-      else
-        {
-          cdk_stream_peek (inp, (byte *) chk, DIM (chk) - 1);
-          i = strncmp (chk, s, strlen (s));
-          if (strlen (buf) == 0 && i == 0)
-            continue;           /* skip last '\n' */
-          _cdk_trim_string (buf, i == 0 ? 0 : 1);
-          _gnutls_hash (&md, buf, strlen (buf));
-        }
-      if (!strncmp (buf, "- ", 2))      /* FIXME: handle it recursive. */
-        memmove (buf, buf + 2, nbytes - 2);
-      if (out)
-        {
-          if (strstr (buf, "\r\n"))
-            buf[strlen (buf) - 2] = '\0';
-          cdk_stream_write (out, buf, strlen (buf));
-          _cdk_stream_puts (out, _cdk_armor_get_lineend ());
-        }
-    }
-
-  /* We create a temporary stream object to store the
-     signature data in there. */
-  rc = cdk_stream_tmp_new (&tmp);
-  if (rc)
-    goto leave;
-
-  s = "-----BEGIN PGP SIGNATURE-----\n";
-  _cdk_stream_puts (tmp, s);
-  while (!cdk_stream_eof (inp))
-    {
-      nbytes = _cdk_stream_gets (inp, buf, DIM (buf) - 1);
-      if (!nbytes || nbytes == -1)
-        break;
-      if (nbytes < (int) (DIM (buf) - 3))
-        {
-          buf[nbytes - 1] = '\n';
-          buf[nbytes] = '\0';
-        }
-      cdk_stream_write (tmp, buf, nbytes);
-    }
-
-  /* FIXME: This code is not very elegant. */
-  cdk_stream_tmp_set_mode (tmp, STREAMCTL_READ);
-  cdk_stream_seek (tmp, 0);
-  cdk_stream_set_armor_flag (tmp, 0);
-  cdk_stream_read (tmp, NULL, 0);
-
-  /* the digest handle will be closed there. */
-  rc = _cdk_proc_packets (hd, tmp, NULL, NULL, NULL, &md);
-
-leave:
-  _gnutls_hash_deinit (&md, NULL);
-  cdk_stream_close (out);
-  cdk_stream_close (tmp);
-  cdk_stream_close (inp);
-  return rc;
-}
diff --git a/lib/openpgp/output.c b/lib/openpgp/output.c
index b832253..ab146e5 100644
--- a/lib/openpgp/output.c
+++ b/lib/openpgp/output.c
@@ -187,7 +187,7 @@ print_key_times (gnutls_buffer_st * str, 
gnutls_openpgp_crt_t cert, int idx)
 
     if (gmtime_r (&tim, &t) == NULL)
       addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
-    else if (strftime (s, max, "%a %b %e %H:%M:%S UTC %Y", &t) == 0)
+    else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
       addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
     else
       addf (str, _("\t\tCreation: %s\n"), s);
@@ -210,7 +210,7 @@ print_key_times (gnutls_buffer_st * str, 
gnutls_openpgp_crt_t cert, int idx)
       {
         if (gmtime_r (&tim, &t) == NULL)
           addf (str, "error: gmtime_r (%ld)\n", (unsigned long) tim);
-        else if (strftime (s, max, "%a %b %e %H:%M:%S UTC %Y", &t) == 0)
+        else if (strftime (s, max, "%a %b %d %H:%M:%S UTC %Y", &t) == 0)
           addf (str, "error: strftime (%ld)\n", (unsigned long) tim);
         else
           addf (str, _("\t\tExpiration: %s\n"), s);
diff --git a/lib/openpgp/pgpverify.c b/lib/openpgp/pgpverify.c
index 3a5771b..bdb2ea3 100644
--- a/lib/openpgp/pgpverify.c
+++ b/lib/openpgp/pgpverify.c
@@ -137,6 +137,8 @@ gnutls_openpgp_crt_verify_self (gnutls_openpgp_crt_t key,
   int status;
   cdk_error_t rc;
 
+  *verify = 0;
+
   rc = cdk_pk_check_self_sig (key->knode, &status);
   if (rc || status != CDK_KEY_VALID)
     *verify |= GNUTLS_CERT_INVALID;
diff --git a/lib/pakchois/pakchois.c b/lib/pakchois/pakchois.c
index 0c2a86a..e2ffe0f 100644
--- a/lib/pakchois/pakchois.c
+++ b/lib/pakchois/pakchois.c
@@ -812,6 +812,7 @@ pakchois_close_all_sessions (pakchois_module_t * mod, 
ck_slot_id_t slot_id)
         {
           frv = rv;
         }
+      slot = slot->next;
     }
 
   return frv;
diff --git a/lib/pkcs11.c b/lib/pkcs11.c
index 3b7bdee..2285ce8 100644
--- a/lib/pkcs11.c
+++ b/lib/pkcs11.c
@@ -2093,6 +2093,8 @@ pkcs11_login (pakchois_session_t * pks, const struct 
token_info *info, int so)
       char pin[GNUTLS_PKCS11_MAX_PIN_LEN];
       unsigned int flags;
 
+      memcpy(&tinfo, &info->tinfo, sizeof(tinfo));
+
       /* If login has been attempted once already, check the token
        * status again, the flags might change. */
       if (attempt)
diff --git a/lib/pkcs11_write.c b/lib/pkcs11_write.c
index de319f6..8ab3aa3 100644
--- a/lib/pkcs11_write.c
+++ b/lib/pkcs11_write.c
@@ -186,7 +186,7 @@ gnutls_pkcs11_copy_x509_privkey (const char *token_url,
                                  unsigned int key_usage, unsigned int flags)
 {
   int ret;
-  pakchois_session_t *pks;
+  pakchois_session_t *pks = NULL;
   struct pkcs11_url_info info;
   ck_rv_t rv;
   size_t id_size;
@@ -406,7 +406,8 @@ gnutls_pkcs11_copy_x509_privkey (const char *token_url,
   ret = 0;
 
 cleanup:
-  pakchois_close_session (pks);
+  if (pks != NULL)
+    pakchois_close_session (pks);
 
   return ret;
 
diff --git a/lib/system.c b/lib/system.c
index b795fca..81fe97b 100644
--- a/lib/system.c
+++ b/lib/system.c
@@ -115,7 +115,6 @@ static int
 gnutls_system_mutex_init (void **priv)
 {
   CRITICAL_SECTION *lock = malloc (sizeof (CRITICAL_SECTION));
-  int ret;
 
   if (lock == NULL)
     return GNUTLS_E_MEMORY_ERROR;
diff --git a/lib/x509/output.c b/lib/x509/output.c
index a3e62f2..a49ae95 100644
--- a/lib/x509/output.c
+++ b/lib/x509/output.c
@@ -742,7 +742,7 @@ print_unique_ids (gnutls_buffer_st * str, const 
gnutls_x509_crt_t cert)
 {
   int result;
   char buf[256];                /* if its longer, we won't bother to print it 
*/
-  ssize_t buf_size = 256;
+  size_t buf_size = 256;
 
   result = gnutls_x509_crt_get_issuer_unique_id (cert, buf, &buf_size);
   if (result >= 0)
diff --git a/lib/x509/privkey.c b/lib/x509/privkey.c
index 8443e3f..66f3290 100644
--- a/lib/x509/privkey.c
+++ b/lib/x509/privkey.c
@@ -1141,11 +1141,12 @@ _gnutls_asn1_encode_rsa (ASN1_TYPE * c2, bigint_t * 
params)
   memset (&pk_params, 0, sizeof (pk_params));
 
   memset (&m, 0, sizeof (m));
-  memset (&p, 0, sizeof (e));
-  memset (&q, 0, sizeof (d));
   memset (&p, 0, sizeof (p));
   memset (&q, 0, sizeof (q));
+  memset (&p, 0, sizeof (p));
   memset (&u, 0, sizeof (u));
+  memset (&e, 0, sizeof (e));
+  memset (&d, 0, sizeof (d));
   memset (&exp1, 0, sizeof (exp1));
   memset (&exp2, 0, sizeof (exp2));
 
diff --git a/lib/x509/privkey_pkcs8.c b/lib/x509/privkey_pkcs8.c
index a065205..09c01cd 100644
--- a/lib/x509/privkey_pkcs8.c
+++ b/lib/x509/privkey_pkcs8.c
@@ -1256,7 +1256,7 @@ read_pbkdf2_params (ASN1_TYPE pbes2_asn,
   ASN1_TYPE pbkdf2_asn = ASN1_TYPE_EMPTY;
   char oid[64];
 
-  memset (params, 0, sizeof (params));
+  memset (params, 0, sizeof (*params));
 
   /* Check the key derivation algorithm
    */
@@ -1364,7 +1364,7 @@ read_pkcs12_kdf_params (ASN1_TYPE pbes2_asn, struct 
pbkdf2_params *params)
 {
   int result;
 
-  memset (params, 0, sizeof (params));
+  memset (params, 0, sizeof (*params));
 
   /* read the salt */
   params->salt_size = sizeof (params->salt);
@@ -1490,7 +1490,7 @@ read_pbe_enc_params (ASN1_TYPE pbes2_asn,
   char oid[64];
   const char *eparams;
 
-  memset (params, 0, sizeof (params));
+  memset (params, 0, sizeof (*params));
 
   /* Check the encryption algorithm
    */
diff --git a/src/benchmark.c b/src/benchmark.c
index df96f53..105d4bc 100644
--- a/src/benchmark.c
+++ b/src/benchmark.c
@@ -35,11 +35,52 @@ static unsigned char data[64 * 1024];
 
 static int must_finish = 0;
 
+#if !defined(_WIN32)
 static void
 alarm_handler (int signo)
 {
   must_finish = 1;
 }
+#else
+#include <windows.h>
+DWORD WINAPI alarm_handler (LPVOID lpParameter);
+DWORD WINAPI
+alarm_handler (LPVOID lpParameter)
+{
+  HANDLE wtimer = *((HANDLE *) lpParameter);
+  WaitForSingleObject (wtimer, INFINITE);
+  must_finish = 1;
+  return 0;
+}
+
+#define W32_ALARM_VARIABLES HANDLE wtimer = NULL, wthread = NULL; \
+  LARGE_INTEGER alarm_timeout
+#define W32_ALARM_TRIGGER(timeout, leave) { \
+  wtimer = CreateWaitableTimer (NULL, TRUE, NULL); \
+  if (wtimer == NULL) \
+    { \
+      fprintf (stderr, "error: CreateWaitableTimer %u\n", GetLastError ()); \
+      leave; \
+    } \
+  wthread = CreateThread (NULL, 0, alarm_handler, &wtimer, 0, NULL); \
+  if (wthread == NULL) \
+    { \
+      fprintf (stderr, "error: CreateThread %u\n", GetLastError ()); \
+      leave; \
+    } \
+  alarm_timeout.QuadPart = timeout * 10000000; \
+  if (SetWaitableTimer (wtimer, &alarm_timeout, 0, NULL, NULL, FALSE) == 0) \
+    { \
+      fprintf (stderr, "error: SetWaitableTimer %u\n", GetLastError ()); \
+      leave; \
+    } \
+  }
+#define W32_ALARM_CLEANUP { \
+  if (wtimer != NULL) \
+    CloseHandle (wtimer); \
+  if (wthread != NULL) \
+    CloseHandle (wthread);}
+#endif
 
 static void
 tls_log_func (int level, const char *str)
@@ -95,6 +136,9 @@ cipher_bench (int algo, int size)
   int blocksize = gnutls_cipher_get_block_size (algo);
   int keysize = gnutls_cipher_get_key_size (algo);
   char metric[16];
+#if defined(_WIN32)
+  W32_ALARM_VARIABLES;
+#endif
 
   _key = malloc (keysize);
   if (_key == NULL)
@@ -117,7 +161,11 @@ cipher_bench (int algo, int size)
   fflush (stdout);
 
   must_finish = 0;
+#if !defined(_WIN32)
   alarm (5);
+#else
+  W32_ALARM_TRIGGER(5, goto leave);
+#endif
 
   gettime (&start);
 
@@ -150,7 +198,9 @@ cipher_bench (int algo, int size)
 leave:
   free (_key);
   free (_iv);
-
+#if defined(_WIN32)
+  W32_ALARM_CLEANUP;
+#endif
 }
 
 static void
@@ -163,6 +213,9 @@ mac_bench (int algo, int size)
   double ddata, dspeed;
   int blocksize = gnutls_hmac_get_len (algo);
   char metric[16];
+#if defined(_WIN32)
+  W32_ALARM_VARIABLES;
+#endif
 
   _key = malloc (blocksize);
   if (_key == NULL)
@@ -173,7 +226,11 @@ mac_bench (int algo, int size)
   fflush (stdout);
 
   must_finish = 0;
+#if !defined(_WIN32)
   alarm (5);
+#else
+  W32_ALARM_TRIGGER(5, goto leave);
+#endif
 
   gettime (&start);
 
@@ -195,7 +252,10 @@ mac_bench (int algo, int size)
 
   printf ("Hashed %.2f %s in %.2f secs: ", ddata, metric, secs);
   printf ("%.2f %s/sec\n", dspeed, metric);
-
+#if defined(_WIN32)
+leave:
+  W32_ALARM_CLEANUP;
+#endif
   free (_key);
 }
 
@@ -207,7 +267,9 @@ main (int argc, char **argv)
   if (argc > 1)
     debug_level = 2;
 
+#if !defined(_WIN32)
   signal (SIGALRM, alarm_handler);
+#endif
 
   gnutls_global_set_log_function (tls_log_func);
   gnutls_global_set_log_level (debug_level);
diff --git a/src/cli.c b/src/cli.c
index c3aa050..963f7fc 100644
--- a/src/cli.c
+++ b/src/cli.c
@@ -681,7 +681,7 @@ main (int argc, char **argv)
   char *session_data = NULL;
   char *session_id = NULL;
   size_t session_data_size;
-  size_t session_id_size;
+  size_t session_id_size = 0;
   fd_set rset;
   int maxfd;
   struct timeval tv;
@@ -915,6 +915,7 @@ after_handshake:
               continue;
             }
 
+          buffer[bytes] = 0;
           if (crlf != 0)
             {
               char *b = strchr (buffer, '\n');
diff --git a/src/common.c b/src/common.c
index 81bb153..11368ec 100644
--- a/src/common.c
+++ b/src/common.c
@@ -748,6 +748,12 @@ pin_callback (void *user, int attempt, const char 
*token_url,
     {
       if (strcmp (cached_url, token_url) == 0)
         {
+          if (strlen(pin) >= sizeof(cached_pin))
+            {
+              fprintf (stderr, "Too long PIN given\n");
+              exit (1);
+            }
+
           strcpy (pin, cached_pin);
           return 0;
         }
diff --git a/src/crypt.c b/src/crypt.c
index 1878424..fd9f0f8 100644
--- a/src/crypt.c
+++ b/src/crypt.c
@@ -161,6 +161,12 @@ _verify_passwd_int (const char *username, const char 
*passwd,
   if (salt == NULL || verifier == NULL)
     return -1;
 
+  if (strlen(salt) >= sizeof(_salt))
+    {
+      fprintf (stderr, "Too long salt.\n");
+      return -1;
+    }
+
   /* copy salt, and null terminate after the ':' */
   strcpy (_salt, salt);
   pos = strchr (_salt, ':');
diff --git a/src/pkcs11.c b/src/pkcs11.c
index c6aceb5..47a2d43 100644
--- a/src/pkcs11.c
+++ b/src/pkcs11.c
@@ -60,10 +60,10 @@ pin_callback (void *user, int attempt, const char 
*token_url,
         }
     }
 
-  password = getpass ("Enter pin: ");
+  password = getpass ("Enter PIN: ");
   if (password == NULL || password[0] == 0)
     {
-      fprintf (stderr, "No password given\n");
+      fprintf (stderr, "No PIN given\n");
       exit (1);
     }
 
@@ -72,6 +72,12 @@ pin_callback (void *user, int attempt, const char *token_url,
   pin[len] = 0;
 
   /* cache */
+  if (strlen(pin) >= sizeof(cached_pin))
+    {
+      fprintf (stderr, "Too long PIN given\n");
+      exit (1);
+    }
+
   strcpy (cached_pin, pin);
   free (cached_url);
   cached_url = strdup (token_url);
@@ -609,13 +615,16 @@ pkcs11_init (FILE * outfile, const char *url, const char 
*label,
 
   pin = getpass ("Enter Security Officer's PIN: ");
   if (pin == NULL)
-    exit (0);
+    exit (1);
+
+  if (strlen(pin) >= sizeof(so_pin))
+    exit (1);
 
   strcpy (so_pin, pin);
 
   pin = getpass ("Enter new User's PIN: ");
   if (pin == NULL)
-    exit (0);
+    exit (1);
 
   ret = gnutls_pkcs11_token_init (url, so_pin, label);
   if (ret < 0)
diff --git a/tests/anonself.c b/tests/anonself.c
index 134b88b..2e30f57 100644
--- a/tests/anonself.c
+++ b/tests/anonself.c
@@ -33,8 +33,10 @@
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <sys/socket.h>
+#if !defined(_WIN32)
 #include <sys/wait.h>
 #include <arpa/inet.h>
+#endif
 #include <unistd.h>
 #include <gnutls/gnutls.h>
 
diff --git a/tests/certuniqueid.c b/tests/certuniqueid.c
index 96a363e..cf41751 100644
--- a/tests/certuniqueid.c
+++ b/tests/certuniqueid.c
@@ -145,7 +145,7 @@ doit (void)
   };
 
   char buf[17];
-  ssize_t buf_size;
+  size_t buf_size;
 
   ret = gnutls_global_init ();
   if (ret < 0)
diff --git a/tests/dhepskself.c b/tests/dhepskself.c
index 9319624..9f0540e 100644
--- a/tests/dhepskself.c
+++ b/tests/dhepskself.c
@@ -32,9 +32,11 @@
 #include <string.h>
 #include <sys/types.h>
 #include <sys/socket.h>
+#if !defined(_WIN32)
 #include <sys/wait.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#endif
 #include <unistd.h>
 #include <gnutls/gnutls.h>
 
diff --git a/tests/eagain-common.h b/tests/eagain-common.h
new file mode 100644
index 0000000..473e236
--- /dev/null
+++ b/tests/eagain-common.h
@@ -0,0 +1,228 @@
+#define min(x,y) ((x)<(y)?(x):(y))
+//#define EAGAIN_DEBUG
+
+#define HANDSHAKE(c, s) \
+  sret = cret = GNUTLS_E_AGAIN; \
+  do \
+    { \
+      if (cret == GNUTLS_E_AGAIN) \
+        { \
+          cret = gnutls_handshake (c); \
+        } \
+      if (sret == GNUTLS_E_AGAIN) \
+        { \
+          sret = gnutls_handshake (s); \
+        } \
+    } \
+  while (cret == GNUTLS_E_AGAIN || sret == GNUTLS_E_AGAIN); \
+  if (cret < 0 || sret < 0) \
+    { \
+      fprintf(stderr, "client: %s\n", gnutls_strerror(cret)); \
+      fprintf(stderr, "server: %s\n", gnutls_strerror(sret)); \
+      fail("Handshake failed\n"); \
+      exit(1); \
+    }
+
+#define TRANSFER(c, s, msg, msglen, buf, buflen) \
+  do \
+    { \
+      ret = gnutls_record_send (c, msg, msglen); \
+    } \
+  while(ret == GNUTLS_E_AGAIN); \
+  do \
+    { \
+      do \
+        { \
+          ret = gnutls_record_recv (s, buf, buflen); \
+        } \
+      while(ret == GNUTLS_E_AGAIN); \
+      if (ret == 0) \
+        fail ("server: didn't receive any data\n"); \
+      else if (ret < 0) \
+        { \
+          fail ("server: error: %s\n", gnutls_strerror (ret)); \
+        } \
+      else \
+        { \
+          transferred += ret; \
+        } \
+      do \
+        { \
+          ns = gnutls_record_send (server, msg, msglen); \
+        } \
+      while (ns == GNUTLS_E_AGAIN); \
+      do \
+        { \
+          ret = gnutls_record_recv (client, buf, buflen); \
+        } \
+      while(ret == GNUTLS_E_AGAIN); \
+      if (ret == 0) \
+        { \
+          fail ("client: Peer has closed the TLS connection\n"); \
+        } \
+      else if (ret < 0) \
+        { \
+          if (debug) \
+            fputs ("!", stdout); \
+          fail ("client: Error: %s\n", gnutls_strerror (ret)); \
+        } \
+      else \
+        { \
+          if (msglen != ret || memcmp (buf, msg, msglen) != 0) \
+            { \
+              fail ("client: Transmitted data do not match\n"); \
+            } \
+          /* echo back */ \
+          do \
+            { \
+              ns = gnutls_record_send (client, buf, msglen); \
+            } \
+          while (ns == GNUTLS_E_AGAIN); \
+          transferred += ret; \
+          if (debug) \
+            fputs (".", stdout); \
+        } \
+    } \
+  while (transferred < 70000)
+
+
+static char to_server[64*1024];
+static size_t to_server_len = 0;
+
+static char to_client[64*1024];
+static size_t to_client_len = 0;
+
+#ifdef RANDOMIZE
+#define RETURN_RND_EAGAIN(session) \
+  static unsigned char rnd = 0; \
+  if (rnd++ % 2 == 0) \
+    { \
+      gnutls_transport_set_errno (session, EAGAIN); \
+      return -1; \
+    }
+#else
+#define RETURN_RND_EAGAIN(session)
+#endif
+
+static ssize_t
+client_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
+{
+  size_t newlen;
+  RETURN_RND_EAGAIN(tr);
+
+  len = min(len, sizeof(to_server)-to_server_len);
+
+  newlen = to_server_len + len;
+  memcpy (to_server + to_server_len, data, len);
+  to_server_len = newlen;
+#ifdef EAGAIN_DEBUG
+  fprintf(stderr, "eagain: pushed %d bytes to server (avail: %d)\n", (int)len, 
(int)to_server_len);
+#endif
+  return len;
+}
+
+static ssize_t
+client_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
+{
+  RETURN_RND_EAGAIN(tr);
+
+  if (to_client_len == 0)
+    {
+#ifdef EAGAIN_DEBUG
+      fprintf(stderr, "eagain: Not enough data by server (asked for: %d, have: 
%d)\n", (int)len, (int)to_client_len);
+#endif
+      gnutls_transport_set_global_errno (EAGAIN);
+      return -1;
+    }
+
+  len = min(len, to_client_len);
+
+  memcpy (data, to_client, len);
+
+  memmove (to_client, to_client + len, to_client_len - len);
+  to_client_len -= len;
+#ifdef EAGAIN_DEBUG
+  fprintf(stderr, "eagain: pulled %d bytes by client (avail: %d)\n", (int)len, 
(int)to_client_len);
+#endif
+  return len;
+}
+
+static ssize_t
+server_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
+{
+  //success ("server_pull len %d has %d\n", len, to_server_len);
+  RETURN_RND_EAGAIN(tr);
+
+  if (to_server_len == 0)
+    {
+#ifdef EAGAIN_DEBUG
+      fprintf(stderr, "eagain: Not enough data by client (asked for: %d, have: 
%d)\n", (int)len, (int)to_server_len);
+#endif
+      gnutls_transport_set_global_errno (EAGAIN);
+      return -1;
+    }
+
+  len = min(len, to_server_len);
+#ifdef EAGAIN_DEBUG
+  fprintf(stderr, "eagain: pulled %d bytes by server (avail: %d)\n", (int)len, 
(int)to_server_len);
+#endif
+  memcpy (data, to_server, len);
+
+  memmove (to_server, to_server + len, to_server_len - len);
+  to_server_len -= len;
+
+  return len;
+}
+
+static ssize_t
+server_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
+{
+  size_t newlen;
+  RETURN_RND_EAGAIN(tr);
+
+//  hexprint (data, len);
+
+  len = min(len, sizeof(to_client)-to_client_len);
+
+  newlen = to_client_len + len;
+  memcpy (to_client + to_client_len, data, len);
+  to_client_len = newlen;
+#ifdef EAGAIN_DEBUG
+  fprintf(stderr, "eagain: pushed %d bytes to client (avail: %d)\n", (int)len, 
(int)to_client_len);
+#endif
+
+  return len;
+}
+
+/* inline is used to avoid a gcc warning if used in mini-eagain */
+inline static int server_pull_timeout_func(gnutls_transport_ptr_t ptr, 
unsigned int ms)
+{
+int ret;
+
+  if (to_server_len > 0)
+    ret = 1; /* available data */
+  else
+    ret = 0; /* timeout */
+
+#ifdef EAGAIN_DEBUG
+  fprintf(stderr, "eagain: server_pull_timeout: %d\n", ret);
+#endif
+
+  return ret;
+}
+
+inline static int client_pull_timeout_func(gnutls_transport_ptr_t ptr, 
unsigned int ms)
+{
+int ret;
+
+  if (to_client_len > 0)
+    ret = 1;
+  else
+    ret = 0;
+
+#ifdef EAGAIN_DEBUG
+  fprintf(stderr, "eagain: client_pull_timeout: %d\n", ret);
+#endif
+
+  return ret;
+}
diff --git a/tests/mini-eagain.c b/tests/mini-eagain.c
index 9bb7e2c..274e158 100644
--- a/tests/mini-eagain.c
+++ b/tests/mini-eagain.c
@@ -32,6 +32,8 @@
 #include <gnutls/crypto.h>
 
 #include "utils.h"
+#define RANDOMIZE
+#include "eagain-common.h"
 
 static void
 tls_log_func (int level, const char *str)
@@ -41,109 +43,6 @@ tls_log_func (int level, const char *str)
 
 static int handshake = 0;
 
-char *to_server;
-size_t to_server_len;
-
-char *to_client;
-size_t to_client_len;
-
-
-static ssize_t
-client_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
-{
-//  success ("client_pull len %d has %d\n", len, to_client_len);
-  static unsigned char rnd = 0;
-
-  if (rnd++ % 2 == 0 || to_client_len < len)
-    {
-      gnutls_transport_set_global_errno (EAGAIN);
-      return -1;
-    }
-
-  memcpy (data, to_client, len);
-
-  memmove (to_client, to_client + len, to_client_len - len);
-  to_client_len -= len;
-
-  return len;
-}
-
-static ssize_t
-client_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
-{
-  char *tmp;
-  size_t newlen = to_server_len + len;
-  static unsigned char rnd = 0;
-
-  if (rnd++ % 2 == 0)
-    {
-      gnutls_transport_set_global_errno (EAGAIN);
-      return -1;
-    }
-
-  tmp = realloc (to_server, newlen);
-  if (!tmp)
-    {
-      fail ("Memory allocation failure...\n");
-      exit (1);
-    }
-  to_server = tmp;
-
-  memcpy (to_server + to_server_len, data, len);
-  to_server_len = newlen;
-
-  return len;
-}
-
-static ssize_t
-server_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
-{
-  //success ("server_pull len %d has %d\n", len, to_server_len);
-  static unsigned char rnd = 0;
-
-  if (rnd++ % 2 == 0 || to_server_len < len)
-    {
-      gnutls_transport_set_global_errno (EAGAIN);
-      return -1;
-    }
-
-  memcpy (data, to_server, len);
-
-  memmove (to_server, to_server + len, to_server_len - len);
-  to_server_len -= len;
-
-  return len;
-}
-
-static ssize_t
-server_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
-{
-  char *tmp;
-  size_t newlen = to_client_len + len;
-  static unsigned char rnd = 0;
-
-  if (rnd++ % 2 == 0)
-    {
-      gnutls_transport_set_global_errno (EAGAIN);
-      return -1;
-    }
-
-//  hexprint (data, len);
-
-  tmp = realloc (to_client, newlen);
-  if (!tmp)
-    {
-      fail ("Memory allocation failure...\n");
-      exit (1);
-    }
-  to_client = tmp;
-
-  memcpy (to_client + to_client_len, data, len);
-  to_client_len = newlen;
-
-  return len;
-}
-
 #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..."
 
@@ -155,11 +54,10 @@ doit (void)
   const gnutls_datum_t p3 = { (char *) pkcs3, strlen (pkcs3) };
   static gnutls_dh_params_t dh_params;
   gnutls_session_t server;
-  int sret = GNUTLS_E_AGAIN;
+  int sret, cret;
   /* Client stuff. */
   gnutls_anon_client_credentials_t c_anoncred;
   gnutls_session_t client;
-  int cret = GNUTLS_E_AGAIN;
   /* Need to enable anonymous KX specifically. */
   char buffer[MAX_BUF + 1];
   ssize_t ns;
@@ -169,7 +67,7 @@ doit (void)
   gnutls_global_init ();
   gnutls_global_set_log_function (tls_log_func);
   if (debug)
-    gnutls_global_set_log_level (99);
+    gnutls_global_set_log_level (2);
 
   /* Init server */
   gnutls_anon_allocate_server_credentials (&s_anoncred);
@@ -177,112 +75,35 @@ doit (void)
   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);
-  gnutls_priority_set_direct (server, 
"NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
+  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_dh_set_prime_bits (server, 1024);
   gnutls_transport_set_push_function (server, server_push);
   gnutls_transport_set_pull_function (server, server_pull);
+  gnutls_transport_set_ptr (server, (gnutls_transport_ptr_t)server);
 
   /* Init client */
   gnutls_anon_allocate_client_credentials (&c_anoncred);
   gnutls_init (&client, GNUTLS_CLIENT);
-  gnutls_priority_set_direct (client, 
"NONE:+VERS-TLS-ALL:+CIPHER-ALL:+MAC-ALL:+SIGN-ALL:+COMP-ALL:+ANON-DH", NULL);
+  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, (gnutls_transport_ptr_t)client);
 
   handshake = 1;
-  do
-    {
-      if (cret == GNUTLS_E_AGAIN)
-        {
-          //success ("loop invoking client:\n");
-          cret = gnutls_handshake (client);
-          //success ("client %d: %s\n", cret, gnutls_strerror (cret));
-        }
-
-      if (sret == GNUTLS_E_AGAIN)
-        {
-          //success ("loop invoking server:\n");
-          sret = gnutls_handshake (server);
-          //success ("server %d: %s\n", sret, gnutls_strerror (sret));
-        }
-    }
-  while (cret == GNUTLS_E_AGAIN || sret == GNUTLS_E_AGAIN);
+  HANDSHAKE(client, server);
 
   handshake = 0;
   if (debug)
     success ("Handshake established\n");
 
-  ns = gnutls_record_send (client, MSG, strlen (MSG));
-  //success ("client: sent %d\n", ns);
-
-  do
-    {
-      //success("transferred: %d\n", transferred);
-
-      ret = gnutls_record_recv (server, buffer, MAX_BUF);
-      if (ret == 0)
-        fail ("server: didn't receive any data\n");
-      else if (ret < 0)
-        {
-//      if (debug)
-//          fputs ("#", stdout);
-          if (ret != GNUTLS_E_AGAIN)
-            {
-              fail ("server: error: %s\n", gnutls_strerror (ret));
-              break;
-            }
-        }
-      else
-        {
-          transferred += ret;
-//        if (debug)
-//          fputs ("*", stdout);
-        }
-
-      msglen = strlen (MSG);
-      do
-        {
-          ns = gnutls_record_send (server, MSG, msglen);
-        }
-      while (ns == GNUTLS_E_AGAIN);
-
-      ret = gnutls_record_recv (client, buffer, MAX_BUF);
-      if (ret == 0)
-        {
-          fail ("client: Peer has closed the TLS connection\n");
-        }
-      else if (ret < 0)
-        {
-          if (debug)
-            fputs ("!", stdout);
-          if (ret != GNUTLS_E_AGAIN)
-            {
-              fail ("client: Error: %s\n", gnutls_strerror (ret));
-              break;
-            }
-        }
-      else
-        {
-          if (msglen != ret || memcmp (buffer, MSG, msglen) != 0)
-            {
-              fail ("client: Transmitted data do not match\n");
-            }
-
-          /* echo back */
-          do
-            {
-              ns = gnutls_record_send (client, buffer, msglen);
-            }
-          while (ns == GNUTLS_E_AGAIN);
-
-          transferred += ret;
-          if (debug)
-            fputs (".", stdout);
-        }
-    }
-  while (transferred < 70000);
+  msglen = strlen(MSG);
+  TRANSFER(client, server, MSG, msglen, buffer, MAX_BUF);
   if (debug)
     fputs ("\n", stdout);
 
@@ -292,9 +113,6 @@ doit (void)
   gnutls_deinit (client);
   gnutls_deinit (server);
 
-  free (to_server);
-  free (to_client);
-
   gnutls_anon_free_client_credentials (c_anoncred);
   gnutls_anon_free_server_credentials (s_anoncred);
 
diff --git a/tests/mini.c b/tests/mini.c
index 21f7687..2955461 100644
--- a/tests/mini.c
+++ b/tests/mini.c
@@ -29,6 +29,7 @@
 #include <string.h>
 #include <errno.h>
 #include <gnutls/gnutls.h>
+#include "eagain-common.h"
 
 #include "utils.h"
 
@@ -38,104 +39,6 @@ tls_log_func (int level, const char *str)
   fprintf (stderr, "|<%d>| %s", level, str);
 }
 
-char *to_server;
-size_t to_server_len;
-
-char *to_client;
-size_t to_client_len;
-
-static ssize_t
-client_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
-{
-  if (debug)
-    success ("client_pull len %d has %d\n", (int) len, (int) to_client_len);
-
-  if (to_client_len < len)
-    {
-      gnutls_transport_set_global_errno (EAGAIN);
-      return -1;
-    }
-
-  memcpy (data, to_client, len);
-
-  memmove (to_client, to_client + len, to_client_len - len);
-  to_client_len -= len;
-
-  return len;
-}
-
-static ssize_t
-client_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
-{
-  size_t newlen = to_server_len + len;
-  char *tmp;
-
-  if (debug)
-    {
-      success ("client_push len %d has %d\n", (int) len, (int) to_server_len);
-      hexprint (data, len);
-    }
-
-  tmp = realloc (to_server, newlen);
-  if (!tmp)
-    {
-      fail ("Memory allocation failure...\n");
-      exit (1);
-    }
-  to_server = tmp;
-
-  memcpy (to_server + to_server_len, data, len);
-  to_server_len = newlen;
-
-  return len;
-}
-
-static ssize_t
-server_pull (gnutls_transport_ptr_t tr, void *data, size_t len)
-{
-  if (debug)
-    success ("server_pull len %d has %d\n", (int) len, (int) to_server_len);
-
-  if (to_server_len < len)
-    {
-      gnutls_transport_set_global_errno (EAGAIN);
-      return -1;
-    }
-
-  memcpy (data, to_server, len);
-
-  memmove (to_server, to_server + len, to_server_len - len);
-  to_server_len -= len;
-
-  return len;
-}
-
-static ssize_t
-server_push (gnutls_transport_ptr_t tr, const void *data, size_t len)
-{
-  size_t newlen = to_client_len + len;
-  char *tmp;
-
-  if (debug)
-    {
-      success ("server_push len %d has %d\n", (int) len, (int) to_client_len);
-      hexprint (data, len);
-    }
-
-  tmp = realloc (to_client, newlen);
-  if (!tmp)
-    {
-      fail ("Memory allocation failure...\n");
-      exit (1);
-    }
-  to_client = tmp;
-
-  memcpy (to_client + to_client_len, data, len);
-  to_client_len = newlen;
-
-  return len;
-}
-
 #define MAX_BUF 1024
 #define MSG "Hello TLS"
 
@@ -151,11 +54,11 @@ doit (void)
   /* Client stuff. */
   gnutls_anon_client_credentials_t c_anoncred;
   gnutls_session_t client;
-  int n, cret = GNUTLS_E_AGAIN;
+  int cret = GNUTLS_E_AGAIN;
   /* Need to enable anonymous KX specifically. */
   char buffer[MAX_BUF + 1];
   ssize_t ns;
-  int ret;
+  int ret, transferred = 0, msglen;
 
   /* General init. */
   gnutls_global_init ();
@@ -174,6 +77,7 @@ doit (void)
   gnutls_dh_set_prime_bits (server, 1024);
   gnutls_transport_set_push_function (server, server_push);
   gnutls_transport_set_pull_function (server, server_pull);
+  gnutls_transport_set_ptr (server, (gnutls_transport_ptr_t)server);
 
   /* Init client */
   gnutls_anon_allocate_client_credentials (&c_anoncred);
@@ -182,75 +86,17 @@ doit (void)
   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, (gnutls_transport_ptr_t)client);
 
-  do
-    {
-      if (cret == GNUTLS_E_AGAIN)
-        {
-          if (debug)
-            success ("loop invoking client:\n");
-          cret = gnutls_handshake (client);
-          if (debug)
-            success ("client %d: %s\n", cret, gnutls_strerror (cret));
-        }
-
-      if (sret == GNUTLS_E_AGAIN)
-        {
-          if (debug)
-            success ("loop invoking server:\n");
-          sret = gnutls_handshake (server);
-          if (debug)
-            success ("server %d: %s\n", sret, gnutls_strerror (sret));
-        }
-    }
-  while (cret == GNUTLS_E_AGAIN || sret == GNUTLS_E_AGAIN);
+  HANDSHAKE(client, server);
 
   if (debug)
     success ("Handshake established\n");
 
-  ns = gnutls_record_send (client, MSG, strlen (MSG));
+  msglen = strlen(MSG);
+  TRANSFER(client, server, MSG, msglen, buffer, MAX_BUF);
   if (debug)
-    success ("client: sent %d\n", (int) ns);
-
-  ret = gnutls_record_recv (server, buffer, MAX_BUF);
-  if (ret == 0)
-    fail ("server: didn't receive any data\n");
-  else if (ret < 0)
-    fail ("server: error: %s\n", gnutls_strerror (ret));
-  else
-    {
-      if (debug)
-        {
-          printf ("server: received %d: ", ret);
-          for (n = 0; n < ret; n++)
-            fputc (buffer[n], stdout);
-          fputs ("\n", stdout);
-        }
-    }
-
-  ns = gnutls_record_send (server, MSG, strlen (MSG));
-  if (debug)
-    success ("server: sent %d\n", (int) ns);
-
-  ret = gnutls_record_recv (client, buffer, MAX_BUF);
-  if (ret == 0)
-    {
-      fail ("client: Peer has closed the TLS connection\n");
-    }
-  else if (ret < 0)
-    {
-      fail ("client: Error: %s\n", gnutls_strerror (ret));
-    }
-  else
-    {
-      if (debug)
-        {
-          printf ("client: received %d: ", ret);
-          for (n = 0; n < ret; n++)
-            fputc (buffer[n], stdout);
-          fputs ("\n", stdout);
-        }
-    }
+    fputs ("\n", stdout);
 
   gnutls_bye (client, GNUTLS_SHUT_RDWR);
   gnutls_bye (server, GNUTLS_SHUT_RDWR);
@@ -258,9 +104,6 @@ doit (void)
   gnutls_deinit (client);
   gnutls_deinit (server);
 
-  free (to_server);
-  free (to_client);
-
   gnutls_anon_free_client_credentials (c_anoncred);
   gnutls_anon_free_server_credentials (s_anoncred);
 
diff --git a/tests/openpgpself.c b/tests/openpgpself.c
index 8d2a48f..388385c 100644
--- a/tests/openpgpself.c
+++ b/tests/openpgpself.c
@@ -31,10 +31,12 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
+#if !defined(_WIN32)
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
 #include <arpa/inet.h>
+#endif
 #include <unistd.h>
 #include <gnutls/gnutls.h>
 #include <gnutls/openpgp.h>
diff --git a/tests/pskself.c b/tests/pskself.c
index 09001ff..b04bd19 100644
--- a/tests/pskself.c
+++ b/tests/pskself.c
@@ -30,10 +30,12 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
+#if !defined(_WIN32)
 #include <sys/socket.h>
 #include <sys/wait.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#endif
 #include <unistd.h>
 #include <gnutls/gnutls.h>
 
diff --git a/tests/resume.c b/tests/resume.c
index f016c9a..6037989 100644
--- a/tests/resume.c
+++ b/tests/resume.c
@@ -31,10 +31,12 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
+#if !defined(_WIN32)
 #include <sys/socket.h>
 #include <sys/wait.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
+#endif
 #include <unistd.h>
 #include <gnutls/gnutls.h>
 
diff --git a/tests/rng-fork.c b/tests/rng-fork.c
index 1e4b5e5..c7fc189 100644
--- a/tests/rng-fork.c
+++ b/tests/rng-fork.c
@@ -27,13 +27,16 @@
 #include <stdio.h>
 #include <unistd.h>
 #include <sys/types.h>
+#if !defined(_WIN32)
 #include <sys/wait.h>
+#endif
 
 #include "utils.h"
 #include <gnutls/gnutls.h>
 #include <gnutls/crypto.h>
 #include "../lib/random.h"
 
+#if !defined(_WIN32)
 static void dump(const char* name, unsigned char* buf, int buf_size)
 {
 int i;
@@ -98,3 +101,10 @@ doit (void)
       success("success");
     }
 }
+#else
+void
+doit (void)
+{
+  exit (77);
+}
+#endif
diff --git a/tests/x509dn.c b/tests/x509dn.c
index f151895..cf6cc2b 100644
--- a/tests/x509dn.c
+++ b/tests/x509dn.c
@@ -31,10 +31,12 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
+#if !defined(_WIN32)
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
 #include <arpa/inet.h>
+#endif
 #include <unistd.h>
 #include <gnutls/gnutls.h>
 
diff --git a/tests/x509self.c b/tests/x509self.c
index a25b31f..5cc9157 100644
--- a/tests/x509self.c
+++ b/tests/x509self.c
@@ -31,10 +31,12 @@
 #include <stdlib.h>
 #include <string.h>
 #include <sys/types.h>
+#if !defined(_WIN32)
 #include <netinet/in.h>
 #include <sys/socket.h>
 #include <sys/wait.h>
 #include <arpa/inet.h>
+#endif
 #include <unistd.h>
 #include <gnutls/gnutls.h>
 


hooks/post-receive
-- 
GNU gnutls



reply via email to

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