gnutls-commit
[Top][All Lists]
Advanced

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

[SCM] GNU gnutls branch, master, updated. gnutls_2_9_10-288-g671f509


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU gnutls branch, master, updated. gnutls_2_9_10-288-g671f509
Date: Sat, 03 Jul 2010 16:59:41 +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=671f50958c0cdeebb528df0e8c54a281eaddf9dd

The branch, master has been updated
       via  671f50958c0cdeebb528df0e8c54a281eaddf9dd (commit)
       via  539776d5e5e6725024e5ba619c48980b089f3415 (commit)
      from  6ce3391704b2d971266386b8b0c7143bf33e747d (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 671f50958c0cdeebb528df0e8c54a281eaddf9dd
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Sat Jul 3 18:37:19 2010 +0200

    Locks were converted to be in align with posix locks to easier wrap around 
them.

commit 539776d5e5e6725024e5ba619c48980b089f3415
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Sat Jul 3 18:21:44 2010 +0200

    The included pakchois will use gnutls locks and will use a portable
    dlopen() to allow compilation in win32 (untested).

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

Summary of changes:
 lib/Makefile.am                     |    4 +-
 lib/gcrypt/init.c                   |   22 +-
 lib/includes/gnutls/gnutls.h.in     |    6 +-
 lib/locks.c                         |   55 ++-
 lib/locks.h                         |    2 +
 lib/{random.h => pakchois/dlopen.c} |   30 +-
 lib/pakchois/dlopen.h               |   18 +
 lib/pakchois/pakchois.c             | 1164 ++++++++++++++++++-----------------
 8 files changed, 680 insertions(+), 621 deletions(-)
 copy lib/{random.h => pakchois/dlopen.c} (69%)
 create mode 100644 lib/pakchois/dlopen.h

diff --git a/lib/Makefile.am b/lib/Makefile.am
index a879629..3bafc5c 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -107,8 +107,8 @@ HFILES = debug.h gnutls_compress.h gnutls_cipher.h 
gnutls_buffers.h \
        ext_safe_renegotiation.h locks.h gnutls_mbuffers.h pkcs11_int.h
 
 if ENABLE_LOCAL_PAKCHOIS
-COBJECTS+=pakchois/pakchois.c pakchois/errors.c
-HFILES+=pakchois/pakchois.h pakchois/pakchois11.h
+COBJECTS+=pakchois/pakchois.c pakchois/errors.c pakchois/dlopen.c
+HFILES+=pakchois/pakchois.h pakchois/pakchois11.h pakchois/dlopen.h
 endif
 
 # Separate so we can create the documentation
diff --git a/lib/gcrypt/init.c b/lib/gcrypt/init.c
index 4e2a065..175cbd0 100644
--- a/lib/gcrypt/init.c
+++ b/lib/gcrypt/init.c
@@ -43,22 +43,6 @@ static struct gcry_thread_cbs gct = {
   .recvmsg = NULL,
 };
 
-static int wrap_gcry_mutex_lock(void** m)
-{
-  return gnutls_mutex_lock(*m);
-}
-
-static int wrap_gcry_mutex_unlock(void** m)
-{
-  return gnutls_mutex_unlock(*m);
-}
-
-static int wrap_gcry_mutex_deinit(void** m)
-{
-  gnutls_mutex_deinit(*m);
-  return 0;
-}
-
 int gnutls_crypto_init(void)
 {
   /* Initialize libgcrypt if it hasn't already been initialized. */
@@ -69,9 +53,9 @@ int gnutls_crypto_init(void)
       if (gnutls_mutex_init != NULL) 
         {
          gct.mutex_init = gnutls_mutex_init;
-         gct.mutex_destroy = wrap_gcry_mutex_deinit;
-         gct.mutex_lock = wrap_gcry_mutex_lock;
-         gct.mutex_unlock = wrap_gcry_mutex_unlock;
+         gct.mutex_destroy = gnutls_mutex_deinit;
+         gct.mutex_lock = gnutls_mutex_lock;
+         gct.mutex_unlock = gnutls_mutex_unlock;
 
          gcry_control (GCRYCTL_SET_THREAD_CBS, &gct);
         }
diff --git a/lib/includes/gnutls/gnutls.h.in b/lib/includes/gnutls/gnutls.h.in
index 6ff039b..9555432 100644
--- a/lib/includes/gnutls/gnutls.h.in
+++ b/lib/includes/gnutls/gnutls.h.in
@@ -1123,9 +1123,9 @@ extern "C"
   void gnutls_global_deinit (void);
 
   typedef int (*mutex_init_func)(void** mutex);
-  typedef int (*mutex_lock_func)(void* mutex);
-  typedef int (*mutex_unlock_func)(void* mutex);
-  typedef void (*mutex_deinit_func)(void* mutex);
+  typedef int (*mutex_lock_func)(void** mutex);
+  typedef int (*mutex_unlock_func)(void** mutex);
+  typedef int (*mutex_deinit_func)(void** mutex);
   
   void gnutls_global_set_mutex(mutex_init_func init, mutex_deinit_func, 
     mutex_lock_func, mutex_unlock_func);
diff --git a/lib/locks.c b/lib/locks.c
index c758d80..30ffd53 100644
--- a/lib/locks.c
+++ b/lib/locks.c
@@ -51,24 +51,32 @@ static int gnutls_system_mutex_init (void **priv)
   return 0;
 }
 
-static void gnutls_system_mutex_deinit (void *priv)
+static int gnutls_system_mutex_deinit (void **priv)
 {
-  DeleteCriticalSection(priv);
-  free(priv);
+  DeleteCriticalSection((CRITICAL_SECTION*)*priv);
+  free(*priv);
+  
+  return 0;
+}
+
+static int gnutls_system_mutex_lock (void **priv)
+{
+  EnterCriticalSection((CRITICAL_SECTION*)*priv);
+  return 0;
 }
 
-static int gnutls_system_mutex_lock (void *priv)
+static int gnutls_system_mutex_unlock (void **priv)
 {
-  EnterCriticalSection(priv);
+  LeaveCriticalSection((CRITICAL_SECTION*)*priv);
   return 0;
 }
 
-static int gnutls_system_mutex_unlock (void *priv)
+int _gnutls_atfork(void (*prepare)(void), void (*parent)(void), void 
(*child)(void))
 {
-  LeaveCriticalSection(priv);
   return 0;
 }
 
+
 #endif /* WIN32_LOCKS */
 
 #ifdef HAVE_PTHREAD_LOCKS
@@ -95,15 +103,16 @@ static int gnutls_system_mutex_init (void **priv)
   return 0;
 }
 
-static void gnutls_system_mutex_deinit (void *priv)
+static int gnutls_system_mutex_deinit (void **priv)
 {
-  pthread_mutex_destroy(priv);
-  free(priv);
+  pthread_mutex_destroy((pthread_mutex_t*)*priv);
+  free(*priv);
+  return 0;
 }
 
-static int gnutls_system_mutex_lock (void *priv)
+static int gnutls_system_mutex_lock (void **priv)
 {
-  if (pthread_mutex_lock(priv))
+  if (pthread_mutex_lock((pthread_mutex_t*)*priv))
     {
         gnutls_assert();
         return GNUTLS_E_LOCKING_ERROR;
@@ -112,9 +121,9 @@ static int gnutls_system_mutex_lock (void *priv)
   return 0;
 }
 
-static int gnutls_system_mutex_unlock (void *priv)
+static int gnutls_system_mutex_unlock (void **priv)
 {
-  if (pthread_mutex_unlock(priv))
+  if (pthread_mutex_unlock((pthread_mutex_t*)*priv))
     {
         gnutls_assert();
         return GNUTLS_E_LOCKING_ERROR;
@@ -123,6 +132,11 @@ static int gnutls_system_mutex_unlock (void *priv)
   return 0;
 }
 
+int _gnutls_atfork(void (*prepare)(void), void (*parent)(void), void 
(*child)(void))
+{
+  return pthread_atfork(prepare, parent, child);
+}
+
 #endif /* PTHREAD_LOCKS */
 
 #ifdef HAVE_NO_LOCKS
@@ -132,17 +146,22 @@ static int gnutls_system_mutex_init (void **priv)
   return 0;
 }
 
-static void gnutls_system_mutex_deinit (void *priv)
+static int gnutls_system_mutex_deinit (void **priv)
+{
+  return 0;
+}
+
+static int gnutls_system_mutex_lock (void **priv)
 {
-  return;
+  return 0;
 }
 
-static int gnutls_system_mutex_lock (void *priv)
+static int gnutls_system_mutex_unlock (void **priv)
 {
   return 0;
 }
 
-static int gnutls_system_mutex_unlock (void *priv)
+int _gnutls_atfork(void (*prepare)(void), void (*parent)(void), void 
(*child)(void))
 {
   return 0;
 }
diff --git a/lib/locks.h b/lib/locks.h
index f76b962..7fc31c0 100644
--- a/lib/locks.h
+++ b/lib/locks.h
@@ -19,4 +19,6 @@ extern mutex_deinit_func gnutls_mutex_deinit;
 extern mutex_lock_func gnutls_mutex_lock;
 extern mutex_unlock_func gnutls_mutex_unlock;
 
+int _gnutls_atfork(void (*prepare)(void), void (*parent)(void), void 
(*child)(void));
+
 #endif
diff --git a/lib/random.h b/lib/pakchois/dlopen.c
similarity index 69%
copy from lib/random.h
copy to lib/pakchois/dlopen.c
index 8859f8a..c7fab3a 100644
--- a/lib/random.h
+++ b/lib/pakchois/dlopen.c
@@ -1,5 +1,6 @@
 /*
- * Copyright (C) 2008, 2010 Free Software Foundation, Inc.
+ * Copyright (C) 2010
+ * Free Software Foundation, Inc.
  *
  * Author: Nikos Mavrogiannopoulos
  *
@@ -22,17 +23,26 @@
  *
  */
 
-#ifndef RANDOM_H
-# define RANDOM_H
+#include "dlopen.h"
 
-#include <gnutls/crypto.h>
+#ifdef _WIN32
 
-extern int crypto_rnd_prio;
-extern gnutls_crypto_rnd_st _gnutls_rnd_ops;
+# include <windows.h>
 
-int _gnutls_rnd (gnutls_rnd_level_t level, void *data, size_t len);
-#define _gnutls_rnd gnutls_rnd
-void _gnutls_rnd_deinit (void);
-int _gnutls_rnd_init (void);
+void *dlopen(const char *filename, int flag)
+{
+       return LoadLibrary(filename); 
+}
+
+
+void *dlsym(void *handle, const char *symbol)
+{
+       return GetProcAddress((HINSTANCE)handle, symbol);
+}
+
+int dlclose(void *handle)
+{
+       FreeLibrary((HINSTANCE)handle);
+}
 
 #endif
diff --git a/lib/pakchois/dlopen.h b/lib/pakchois/dlopen.h
new file mode 100644
index 0000000..b1385fd
--- /dev/null
+++ b/lib/pakchois/dlopen.h
@@ -0,0 +1,18 @@
+#ifndef DLOPEN_H
+# define DLOPEN_H
+
+#include "config.h"
+
+#ifdef _WIN32
+
+void *dlopen(const char *filename, int flag);
+void *dlsym(void *handle, const char *symbol);
+int dlclose(void *handle);
+
+#else
+
+# include <dlfcn.h>
+
+#endif
+
+#endif
diff --git a/lib/pakchois/pakchois.c b/lib/pakchois/pakchois.c
index 5ecbe36..45cd130 100644
--- a/lib/pakchois/pakchois.c
+++ b/lib/pakchois/pakchois.c
@@ -37,16 +37,16 @@
 
 #include "config.h"
 
-#include <dlfcn.h>
 #include <limits.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
-#include <pthread.h>
 #include <assert.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include "../locks.h"
+#include "dlopen.h"
 
 #ifdef HAVE_WORDEXP
 # include <wordexp.h>
@@ -54,99 +54,99 @@
 #include "pakchois.h"
 
 struct provider {
-    dev_t dev;
-    ino_t ino;
-    char *name;
-    void *handle;
-    pthread_mutex_t mutex;
-    const struct ck_function_list *fns;
-    unsigned int refcount;
-    struct provider *next, **prevref;
-    void* reserved;
+       dev_t dev;
+       ino_t ino;
+       char *name;
+       void *handle;
+       void *mutex;
+       const struct ck_function_list *fns;
+       unsigned int refcount;
+       struct provider *next, **prevref;
+       void *reserved;
 };
 
 struct pakchois_module_s {
-    struct slot *slots;
-    struct provider *provider;
+       struct slot *slots;
+       struct provider *provider;
 };
 
-static pthread_mutex_t provider_mutex = PTHREAD_MUTEX_INITIALIZER;
+static void *provider_mutex = NULL;
 
 /* List of loaded providers; any modification to the list or any
  * individual module must performed whilst holding this mutex. */
 static struct provider *provider_list;
 
 struct pakchois_session_s {
-    pakchois_module_t *module;
-    ck_session_handle_t id;
-    pakchois_notify_t notify;
-    void *notify_data;
-    /* Doubly-linked list.  Either prevref = &previous->next or else
-     * prevref = &slot->sessions for the list head. */
-    pakchois_session_t **prevref;
-    pakchois_session_t *next;
+       pakchois_module_t *module;
+       ck_session_handle_t id;
+       pakchois_notify_t notify;
+       void *notify_data;
+       /* Doubly-linked list.  Either prevref = &previous->next or else
+        * prevref = &slot->sessions for the list head. */
+       pakchois_session_t **prevref;
+       pakchois_session_t *next;
 };
 
 struct slot {
-    ck_slot_id_t id;
-    pakchois_session_t *sessions;
-    struct slot *next;
+       ck_slot_id_t id;
+       pakchois_session_t *sessions;
+       struct slot *next;
 };
 
 #define DIR_DELIMITER '/'
 
-static char* pkcs11ize(const char* name)
-{
-    int len;
-    char* oname;
-    char *base;
-    char *suffix;
-
-    oname = strdup(name);
-    if (oname == NULL) {
-           return NULL;
-    }
-
-    /* basename has too many ifs to use */
-    base = strrchr(oname, DIR_DELIMITER);
-    if (base == NULL) {
-        base = oname;
-    } else {
-        base++;
-    }
-
-    suffix = strchr(base, '.');
-    if (suffix != NULL) {
-               if (strncmp(suffix, ".so", 3)==0) {
-                       suffix[0] = 0; /* null terminate before . */
+static char *pkcs11ize(const char *name)
+{
+       int len;
+       char *oname;
+       char *base;
+       char *suffix;
+
+       oname = strdup(name);
+       if (oname == NULL) {
+               return NULL;
+       }
+
+       /* basename has too many ifs to use */
+       base = strrchr(oname, DIR_DELIMITER);
+       if (base == NULL) {
+               base = oname;
+       } else {
+               base++;
+       }
+
+       suffix = strchr(base, '.');
+       if (suffix != NULL) {
+               if (strncmp(suffix, ".so", 3) == 0) {
+                       suffix[0] = 0;  /* null terminate before . */
                }
-    }
+       }
 
-    /* check and remove for -p11 or -pkcs11 */
+       /* check and remove for -p11 or -pkcs11 */
        suffix = base;
-    while((suffix=strchr(suffix, '-')) != NULL) {
-       if (strncasecmp(suffix, "-p11", 4)==0 || 
-               strncasecmp(suffix, "-pkcs11", 7)==0) {
-               suffix[0] = 0;
-               break;
+       while ((suffix = strchr(suffix, '-')) != NULL) {
+               if (strncasecmp(suffix, "-p11", 4) == 0 ||
+                   strncasecmp(suffix, "-pkcs11", 7) == 0) {
+                       suffix[0] = 0;
+                       break;
+               }
+               suffix++;
        }
-       suffix++;
-    }
-    
-    len = strlen(base);
 
-    memmove(oname, base, len);
-    oname[len] = 0;
+       len = strlen(base);
 
-    return oname;
+       memmove(oname, base, len);
+       oname[len] = 0;
+
+       return oname;
 }
 
 static const char *suffix_prefixes[][2] = {
-    { "lib", "pk11.so" },
-    { "", "-pkcs11.so" },
-    { "", ".so" },
-    { "lib", ".so" },
-    { NULL, NULL }
+       {"lib", "pk11.so"},
+       {"", "-pkcs11.so"},
+       {"", ".so"},
+       {"lib", ".so"},
+       {NULL, NULL}
 };
 
 #define CALL(name, args) (mod->provider->fns->C_ ## name) args
@@ -165,57 +165,60 @@ static const char *suffix_prefixes[][2] = {
 /* Returns an allocated name of the real module as well
  * as it's inode and device numbers.
  */
-static char *find_pkcs11_module_name(const char *hint, dev_t* dev, ino_t* ino)
-{
-    char module_path[] = PAKCHOIS_MODPATH;
-    char *next = module_path;
-    struct stat st;
-
-    while (next) {
-        char *dir = next, *sep = strchr(next, ':');
-        unsigned i;
-
-        if (sep) { 
-            *sep++ = '\0';
-            next = sep;
-        }
-        else {
-            next = NULL;
-        }
-        
-        for (i = 0; suffix_prefixes[i][0]; i++) {
-            char path[PATH_MAX];
-            
-            snprintf(path, sizeof path, "%s/%s%s%s", dir,
-                     suffix_prefixes[i][0], hint, suffix_prefixes[i][1]);
-
-                       if (stat(path, &st) < 0) continue;
+static char *find_pkcs11_module_name(const char *hint, dev_t * dev,
+                                    ino_t * ino)
+{
+       char module_path[] = PAKCHOIS_MODPATH;
+       char *next = module_path;
+       struct stat st;
+
+       while (next) {
+               char *dir = next, *sep = strchr(next, ':');
+               unsigned i;
+
+               if (sep) {
+                       *sep++ = '\0';
+                       next = sep;
+               } else {
+                       next = NULL;
+               }
+
+               for (i = 0; suffix_prefixes[i][0]; i++) {
+                       char path[PATH_MAX];
+
+                       snprintf(path, sizeof path, "%s/%s%s%s", dir,
+                                suffix_prefixes[i][0], hint,
+                                suffix_prefixes[i][1]);
+
+                       if (stat(path, &st) < 0)
+                               continue;
 
                        *dev = st.st_dev;
                        *ino = st.st_ino;
 
                        return strdup(path);
-        }
-    }
+               }
+       }
 
-    return NULL;
-}            
+       return NULL;
+}
 
 /* Expands the given filename and returns an allocated
  * string, if the expanded file exists. In that case
  * dev and ino are filled in as well.
  */
-static char* find_real_module_name(const char* name, dev_t *dev, ino_t* ino)
+static char *find_real_module_name(const char *name, dev_t * dev,
+                                  ino_t * ino)
 {
-char* exname = NULL;
-struct stat st;
+       char *exname = NULL;
+       struct stat st;
 #ifdef HAVE_WORDEXP
-int len;
-wordexp_t we;
+       int len;
+       wordexp_t we;
 
        len = wordexp(name, &we, 0);
-       if (len == 0) { /* success */
-               if (we.we_wordc > 0) { /* we care about the 1st */
+       if (len == 0) {         /* success */
+               if (we.we_wordc > 0) {  /* we care about the 1st */
                        exname = strdup(we.we_wordv[0]);
                }
                wordfree(&we);
@@ -241,108 +244,109 @@ wordexp_t we;
 
 static struct provider *find_provider(dev_t dev, ino_t ino)
 {
-    struct provider *p;
+       struct provider *p;
 
-    for (p = provider_list; p; p = p->next) {
-        if (dev == p->dev && ino == p->ino) {
-            return p;
-        }
-    }
+       for (p = provider_list; p; p = p->next) {
+               if (dev == p->dev && ino == p->ino) {
+                       return p;
+               }
+       }
 
-    return NULL;    
+       return NULL;
 }
 
 /* The provider list must be locked when calling it
  */
-static ck_rv_t load_pkcs11_module( struct provider **provider, 
-    const char* name, dev_t dev, ino_t ino, void* reserved)
-{
-struct provider * prov;
-CK_C_GetFunctionList gfl;
-struct ck_c_initialize_args args;
-struct ck_function_list *fns;
-void *h;
-ck_rv_t rv;
-
-    /* try the plain name first */
-    h = dlopen(name, RTLD_LOCAL|RTLD_NOW);
-    if (h == NULL) {
-       return CKR_GENERAL_ERROR;
-    }
-
-    gfl = dlsym(h, "C_GetFunctionList");
-    if (!gfl) {
-        rv = CKR_GENERAL_ERROR;
-       goto fail_dso;    
-    }
-
-    prov = malloc(sizeof *prov);
-    if (prov == NULL) {
-        rv = CKR_HOST_MEMORY;
-       goto fail_dso;
-    }
-
-    if (pthread_mutex_init(&prov->mutex, NULL)) {
-        rv = CKR_CANT_LOCK;
-        goto fail_ctx;
-    }
-
-    rv = gfl(&fns);
-    if (rv != CKR_OK) {
-       goto fail_ctx;
-    }
-
-    prov->dev = dev;
-    prov->ino = ino;
-    prov->name = pkcs11ize(name);
-    prov->handle = h;
-    prov->fns = fns;
-    prov->refcount = 1;
-    prov->reserved = reserved;
-
-    /* Require OS locking, the only sane option. */
-    memset(&args, 0, sizeof args);
-    args.flags = CKF_OS_LOCKING_OK;          
-    args.reserved = reserved;
-
-    rv = fns->C_Initialize(&args);
-    if (rv != CKR_OK) {
-        goto fail_ctx;
-    }
-
-    prov->next = provider_list;
-    prov->prevref = &provider_list;
-    if (prov->next) {
-        prov->next->prevref = &prov->next;
-    }
-    provider_list = prov;
-
-    *provider = prov;
-    return CKR_OK;
-       
-fail_ctx:
-    free(prov);
-fail_dso:
-    dlclose(h);
-
-    return rv;
+static ck_rv_t load_pkcs11_module(struct provider **provider,
+                                 const char *name, dev_t dev, ino_t ino,
+                                 void *reserved)
+{
+       struct provider *prov;
+       CK_C_GetFunctionList gfl;
+       struct ck_c_initialize_args args;
+       struct ck_function_list *fns;
+       void *h;
+       ck_rv_t rv;
+
+       /* try the plain name first */
+       h = dlopen(name, RTLD_LOCAL | RTLD_NOW);
+       if (h == NULL) {
+               return CKR_GENERAL_ERROR;
+       }
+
+       gfl = dlsym(h, "C_GetFunctionList");
+       if (!gfl) {
+               rv = CKR_GENERAL_ERROR;
+               goto fail_dso;
+       }
+
+       prov = malloc(sizeof *prov);
+       if (prov == NULL) {
+               rv = CKR_HOST_MEMORY;
+               goto fail_dso;
+       }
+
+       if (gnutls_mutex_init(&prov->mutex)) {
+               rv = CKR_CANT_LOCK;
+               goto fail_ctx;
+       }
+
+       rv = gfl(&fns);
+       if (rv != CKR_OK) {
+               goto fail_ctx;
+       }
+
+       prov->dev = dev;
+       prov->ino = ino;
+       prov->name = pkcs11ize(name);
+       prov->handle = h;
+       prov->fns = fns;
+       prov->refcount = 1;
+       prov->reserved = reserved;
+
+       /* Require OS locking, the only sane option. */
+       memset(&args, 0, sizeof args);
+       args.flags = CKF_OS_LOCKING_OK;
+       args.reserved = reserved;
+
+       rv = fns->C_Initialize(&args);
+       if (rv != CKR_OK) {
+               goto fail_ctx;
+       }
+
+       prov->next = provider_list;
+       prov->prevref = &provider_list;
+       if (prov->next) {
+               prov->next->prevref = &prov->next;
+       }
+       provider_list = prov;
+
+       *provider = prov;
+       return CKR_OK;
+
+      fail_ctx:
+       free(prov);
+      fail_dso:
+       dlclose(h);
+
+       return rv;
 }
 
 /* Will load a provider using the given name. If real_name is zero
  * name is used as a hint to find library otherwise it is used as
  * absolute name.
  */
-static ck_rv_t load_provider(struct provider **provider, const char *name, 
-                             void *reserved, int real_name)
+static ck_rv_t load_provider(struct provider **provider, const char *name,
+                            void *reserved, int real_name)
 {
-    ck_rv_t rv;
-    char* cname = NULL;
-    dev_t dev;
-    ino_t ino;
+       ck_rv_t rv;
+       char *cname = NULL;
+       dev_t dev;
+       ino_t ino;
 
-    if (pthread_mutex_lock(&provider_mutex) != 0) {
-        return CKR_CANT_LOCK;
-    }
+       if (gnutls_mutex_lock(&provider_mutex) != 0) {
+               return CKR_CANT_LOCK;
+       }
 
        if (real_name) {
                cname = find_real_module_name(name, &dev, &ino);
@@ -355,757 +359,779 @@ static ck_rv_t load_provider(struct provider 
**provider, const char *name,
                goto fail_locked;
        }
 
-    *provider = find_provider(dev, ino);
-    if (*provider) {
-        (*provider)->refcount++;
-        free(cname);
-        pthread_mutex_unlock(&provider_mutex);
-        return CKR_OK;
-    }
+       *provider = find_provider(dev, ino);
+       if (*provider) {
+               (*provider)->refcount++;
+               free(cname);
+               gnutls_mutex_unlock(&provider_mutex);
+               return CKR_OK;
+       }
 
-    rv = load_pkcs11_module(provider, cname, dev, ino, reserved);
-    if (rv != CKR_OK) {
-       goto fail_ndup;
-    }
+       rv = load_pkcs11_module(provider, cname, dev, ino, reserved);
+       if (rv != CKR_OK) {
+               goto fail_ndup;
+       }
 
-    rv = CKR_OK;
+       rv = CKR_OK;
 
-fail_ndup:
-    free(cname);
-fail_locked:
-    pthread_mutex_unlock(&provider_mutex);
-    return rv;
-}    
+      fail_ndup:
+       free(cname);
+      fail_locked:
+       gnutls_mutex_unlock(&provider_mutex);
+       return rv;
+}
 
 static void providers_reinit(void)
 {
-    struct ck_c_initialize_args args;
-    ck_rv_t rv;
-    struct provider * p;
+       struct ck_c_initialize_args args;
+       ck_rv_t rv;
+       struct provider *p;
 
-    assert(pthread_mutex_lock(&provider_mutex) == 0);
+       assert(gnutls_mutex_lock(&provider_mutex) == 0);
 
-    memset(&args, 0, sizeof args);
-    args.flags = CKF_OS_LOCKING_OK;
+       memset(&args, 0, sizeof args);
+       args.flags = CKF_OS_LOCKING_OK;
 
-    for (p = provider_list; p; p = p->next) {
-        args.reserved = p->reserved;
-        rv = p->fns->C_Initialize(&args);
-        assert(rv == CKR_OK); /* what can we do? */
-    }
+       for (p = provider_list; p; p = p->next) {
+               args.reserved = p->reserved;
+               rv = p->fns->C_Initialize(&args);
+               assert(rv == CKR_OK);   /* what can we do? */
+       }
 
-    pthread_mutex_unlock(&provider_mutex);
+       gnutls_mutex_unlock(&provider_mutex);
 }
 
-static ck_rv_t load_module(pakchois_module_t **module, const char *name, 
-                           void *reserved, unsigned int real_name)
+static ck_rv_t load_module(pakchois_module_t ** module, const char *name,
+                          void *reserved, unsigned int real_name)
 {
-    ck_rv_t rv;
-    pakchois_module_t *pm = malloc(sizeof *pm);
-    static int forkinit = 0;
+       ck_rv_t rv;
+       pakchois_module_t *pm = malloc(sizeof *pm);
+       static int forkinit = 0;
+
+       if (!pm) {
+               return CKR_HOST_MEMORY;
+       }
 
-    if (!pm) {
-        return CKR_HOST_MEMORY;
-    }
-    
-    assert(pthread_mutex_lock(&provider_mutex) == 0);
+       if (provider_mutex == NULL) {
+               gnutls_mutex_init(&provider_mutex);
+       }
 
-    if (forkinit == 0) {
-       pthread_atfork(NULL, NULL, providers_reinit);
-       forkinit++;
-    }
+       assert(gnutls_mutex_lock(&provider_mutex) == 0);
 
-    pthread_mutex_unlock(&provider_mutex);
+       if (forkinit == 0) {
+               _gnutls_atfork(NULL, NULL, providers_reinit);
+               forkinit++;
+       }
 
-    rv = load_provider(&pm->provider, name, reserved, real_name);
-    if (rv) {
-        return rv;
-    }
-    
-    *module = pm;    
-    pm->slots = NULL;
+       gnutls_mutex_unlock(&provider_mutex);
+
+       rv = load_provider(&pm->provider, name, reserved, real_name);
+       if (rv) {
+               return rv;
+       }
 
-    return CKR_OK;
-}    
+       *module = pm;
+       pm->slots = NULL;
 
-ck_rv_t pakchois_module_load(pakchois_module_t **module, const char *name)
+       return CKR_OK;
+}
+
+ck_rv_t pakchois_module_load(pakchois_module_t ** module, const char *name)
 {
-    return load_module(module, name, NULL, 0);
+       return load_module(module, name, NULL, 0);
 }
 
-ck_rv_t pakchois_module_load_abs(pakchois_module_t **module, const char *name)
+ck_rv_t pakchois_module_load_abs(pakchois_module_t ** module,
+                                const char *name)
 {
-    return load_module(module, name, NULL, 1);
+       return load_module(module, name, NULL, 1);
 }
 
-ck_rv_t pakchois_module_nssload(pakchois_module_t **module, 
-                                const char *name,
-                                const char *directory,
-                                const char *cert_prefix,
-                                const char *key_prefix,
-                                const char *secmod_db)
+ck_rv_t pakchois_module_nssload(pakchois_module_t ** module,
+                               const char *name,
+                               const char *directory,
+                               const char *cert_prefix,
+                               const char *key_prefix,
+                               const char *secmod_db)
 {
-    char buf[256];
+       char buf[256];
 
-    snprintf(buf, sizeof buf, 
-             "configdir='%s' certPrefix='%s' keyPrefix='%s' secmod='%s'",
-             directory, cert_prefix ? cert_prefix : "",
-             key_prefix ? key_prefix : "", 
-             secmod_db ? secmod_db : "secmod.db");
+       snprintf(buf, sizeof buf,
+                "configdir='%s' certPrefix='%s' keyPrefix='%s' secmod='%s'",
+                directory, cert_prefix ? cert_prefix : "",
+                key_prefix ? key_prefix : "",
+                secmod_db ? secmod_db : "secmod.db");
 
-    return load_module(module, name, buf, 0);
+       return load_module(module, name, buf, 0);
 }
 
-ck_rv_t pakchois_module_nssload_abs(pakchois_module_t **module, 
-                                const char *name,
-                                const char *directory,
-                                const char *cert_prefix,
-                                const char *key_prefix,
-                                const char *secmod_db)
+ck_rv_t pakchois_module_nssload_abs(pakchois_module_t ** module,
+                                   const char *name,
+                                   const char *directory,
+                                   const char *cert_prefix,
+                                   const char *key_prefix,
+                                   const char *secmod_db)
 {
-    char buf[256];
+       char buf[256];
 
-    snprintf(buf, sizeof buf, 
-             "configdir='%s' certPrefix='%s' keyPrefix='%s' secmod='%s'",
-             directory, cert_prefix ? cert_prefix : "",
-             key_prefix ? key_prefix : "", 
-             secmod_db ? secmod_db : "secmod.db");
+       snprintf(buf, sizeof buf,
+                "configdir='%s' certPrefix='%s' keyPrefix='%s' secmod='%s'",
+                directory, cert_prefix ? cert_prefix : "",
+                key_prefix ? key_prefix : "",
+                secmod_db ? secmod_db : "secmod.db");
 
-    return load_module(module, name, buf, 1);
+       return load_module(module, name, buf, 1);
 }
 
 /* Unreference a provider structure and destoy if, if necessary.  Must
  * be called WIHTOUT the provider mutex held.  */
 static void provider_unref(struct provider *prov)
 {
-    assert(pthread_mutex_lock(&provider_mutex) == 0);
+       assert(gnutls_mutex_lock(&provider_mutex) == 0);
 
-    if (--prov->refcount == 0) {
-        prov->fns->C_Finalize(NULL);
-        dlclose(prov->handle);
-        *prov->prevref = prov->next;
-        if (prov->next) {
-            prov->next->prevref = prov->prevref;
-        }
-        free(prov->name);
-        free(prov);
-    }
-    pthread_mutex_unlock(&provider_mutex);
+       if (--prov->refcount == 0) {
+               prov->fns->C_Finalize(NULL);
+               dlclose(prov->handle);
+               *prov->prevref = prov->next;
+               if (prov->next) {
+                       prov->next->prevref = prov->prevref;
+               }
+               free(prov->name);
+               free(prov);
+       }
+       gnutls_mutex_unlock(&provider_mutex);
 }
 
-void pakchois_module_destroy(pakchois_module_t *mod)
+void pakchois_module_destroy(pakchois_module_t * mod)
 {
-    provider_unref(mod->provider);
+       provider_unref(mod->provider);
 
-    while (mod->slots) {
-        struct slot *slot = mod->slots;
-        pakchois_close_all_sessions(mod, slot->id);
-        mod->slots = slot->next;
-        free(slot);
-    }
+       while (mod->slots) {
+               struct slot *slot = mod->slots;
+               pakchois_close_all_sessions(mod, slot->id);
+               mod->slots = slot->next;
+               free(slot);
+       }
 
-    free(mod);
+       free(mod);
 }
 
 #ifdef __GNUC__
 static void pakchois_destructor(void)
-    __attribute__((destructor));
+    __attribute__ ((destructor));
 
 static void pakchois_destructor(void)
 {
-    pthread_mutex_destroy(&provider_mutex);
+       if (provider_mutex != NULL)
+               gnutls_mutex_deinit(&provider_mutex);
 }
 #else
 #warning need destructor support
 #endif
 
-ck_rv_t pakchois_get_info(pakchois_module_t *mod, struct ck_info *info)
+ck_rv_t pakchois_get_info(pakchois_module_t * mod, struct ck_info *info)
 {
-    return CALL(GetInfo, (info));
+       return CALL(GetInfo, (info));
 }
 
-ck_rv_t pakchois_get_slot_list(pakchois_module_t *mod,
+ck_rv_t pakchois_get_slot_list(pakchois_module_t * mod,
                               unsigned char token_present,
-                              ck_slot_id_t *slot_list,
+                              ck_slot_id_t * slot_list,
                               unsigned long *count)
 {
-    return CALL(GetSlotList, (token_present, slot_list, count));
+       return CALL(GetSlotList, (token_present, slot_list, count));
 }
 
-ck_rv_t pakchois_get_slot_info(pakchois_module_t *mod,
+ck_rv_t pakchois_get_slot_info(pakchois_module_t * mod,
                               ck_slot_id_t slot_id,
-                              struct ck_slot_info *info)
+                              struct ck_slot_info * info)
 {
-    return CALL(GetSlotInfo, (slot_id, info));
+       return CALL(GetSlotInfo, (slot_id, info));
 }
 
-ck_rv_t pakchois_get_token_info(pakchois_module_t *mod,
+ck_rv_t pakchois_get_token_info(pakchois_module_t * mod,
                                ck_slot_id_t slot_id,
-                               struct ck_token_info *info)
+                               struct ck_token_info * info)
 {
-    return CALL(GetTokenInfo, (slot_id, info));
+       return CALL(GetTokenInfo, (slot_id, info));
 }
 
-ck_rv_t pakchois_wait_for_slot_event(pakchois_module_t *mod,
-                                    ck_flags_t flags, ck_slot_id_t *slot,
+ck_rv_t pakchois_wait_for_slot_event(pakchois_module_t * mod,
+                                    ck_flags_t flags, ck_slot_id_t * slot,
                                     void *reserved)
 {
-    ck_rv_t rv;
+       ck_rv_t rv;
+
+       if (gnutls_mutex_lock(&mod->provider->mutex)) {
+               return CKR_CANT_LOCK;
+       }
 
-    if (pthread_mutex_lock(&mod->provider->mutex)) {
-        return CKR_CANT_LOCK;
-    }
-        
-    rv = CALL(WaitForSlotEvent, (flags, slot, reserved));
-    pthread_mutex_unlock(&mod->provider->mutex);
-    return rv;
+       rv = CALL(WaitForSlotEvent, (flags, slot, reserved));
+       gnutls_mutex_unlock(&mod->provider->mutex);
+       return rv;
 }
 
-ck_rv_t pakchois_get_mechanism_list(pakchois_module_t *mod,
+ck_rv_t pakchois_get_mechanism_list(pakchois_module_t * mod,
                                    ck_slot_id_t slot_id,
-                                   ck_mechanism_type_t *mechanism_list,
+                                   ck_mechanism_type_t * mechanism_list,
                                    unsigned long *count)
 {
-    return CALL(GetMechanismList, (slot_id, mechanism_list, count));
+       return CALL(GetMechanismList, (slot_id, mechanism_list, count));
 }
 
-ck_rv_t pakchois_get_mechanism_info(pakchois_module_t *mod,
+ck_rv_t pakchois_get_mechanism_info(pakchois_module_t * mod,
                                    ck_slot_id_t slot_id,
                                    ck_mechanism_type_t type,
-                                   struct ck_mechanism_info *info)
+                                   struct ck_mechanism_info * info)
 {
-    return CALL(GetMechanismInfo, (slot_id, type, info));
+       return CALL(GetMechanismInfo, (slot_id, type, info));
 }
 
-ck_rv_t pakchois_init_token(pakchois_module_t *mod,
+ck_rv_t pakchois_init_token(pakchois_module_t * mod,
                            ck_slot_id_t slot_id, unsigned char *pin,
                            unsigned long pin_len, unsigned char *label)
 {
-    return CALL(InitToken, (slot_id, pin, pin_len, label));
+       return CALL(InitToken, (slot_id, pin, pin_len, label));
 }
 
-ck_rv_t pakchois_init_pin(pakchois_session_t *sess, unsigned char *pin,
+ck_rv_t pakchois_init_pin(pakchois_session_t * sess, unsigned char *pin,
                          unsigned long pin_len)
 {
-    return CALLS2(InitPIN, pin, pin_len);
+       return CALLS2(InitPIN, pin, pin_len);
 }
 
-ck_rv_t pakchois_set_pin(pakchois_session_t *sess, unsigned char *old_pin,
+ck_rv_t pakchois_set_pin(pakchois_session_t * sess, unsigned char *old_pin,
                         unsigned long old_len, unsigned char *new_pin,
                         unsigned long new_len)
 {
-    return CALLS4(SetPIN, old_pin, old_len, new_pin, new_len);
+       return CALLS4(SetPIN, old_pin, old_len, new_pin, new_len);
 }
 
 static ck_rv_t notify_thunk(ck_session_handle_t session,
-                            ck_notification_t event, void *application)
+                           ck_notification_t event, void *application)
 {
-    pakchois_session_t *sess = application;
+       pakchois_session_t *sess = application;
 
-    return sess->notify(sess, event, sess->notify_data);
+       return sess->notify(sess, event, sess->notify_data);
 }
 
-static struct slot *find_slot(pakchois_module_t *mod, ck_slot_id_t id)
+static struct slot *find_slot(pakchois_module_t * mod, ck_slot_id_t id)
 {
-    struct slot *slot;
+       struct slot *slot;
 
-    for (slot = mod->slots; slot; slot = slot->next)
-        if (slot->id == id)
-            return slot;
+       for (slot = mod->slots; slot; slot = slot->next)
+               if (slot->id == id)
+                       return slot;
 
-    return NULL;
+       return NULL;
 }
 
-static struct slot *find_or_create_slot(pakchois_module_t *mod,
-                                        ck_slot_id_t id)
+static struct slot *find_or_create_slot(pakchois_module_t * mod,
+                                       ck_slot_id_t id)
 {
-    struct slot *slot = find_slot(mod, id);
+       struct slot *slot = find_slot(mod, id);
 
-    if (slot) {
-        return slot;
-    }
+       if (slot) {
+               return slot;
+       }
 
-    slot = malloc(sizeof *slot);
-    if (!slot) {
-        return NULL;
-    }
-    
-    slot->id = id;
-    slot->sessions = NULL;
-    slot->next = mod->slots;
-    mod->slots = slot;
+       slot = malloc(sizeof *slot);
+       if (!slot) {
+               return NULL;
+       }
 
-    return slot;
+       slot->id = id;
+       slot->sessions = NULL;
+       slot->next = mod->slots;
+       mod->slots = slot;
+
+       return slot;
 }
 
-static ck_rv_t insert_session(pakchois_module_t *mod,
-                              pakchois_session_t *session,
-                              ck_slot_id_t id)
+static ck_rv_t insert_session(pakchois_module_t * mod,
+                             pakchois_session_t * session,
+                             ck_slot_id_t id)
 {
-    struct slot *slot = find_or_create_slot(mod, id);
-    
-    if (!slot) {
-        return CKR_HOST_MEMORY;
-    }
+       struct slot *slot = find_or_create_slot(mod, id);
+
+       if (!slot) {
+               return CKR_HOST_MEMORY;
+       }
 
-    session->prevref = &slot->sessions;
-    session->next = slot->sessions;
-    if (session->next) {
-        session->next->prevref = session->prevref;
-    }
-    slot->sessions = session;
+       session->prevref = &slot->sessions;
+       session->next = slot->sessions;
+       if (session->next) {
+               session->next->prevref = session->prevref;
+       }
+       slot->sessions = session;
 
-    return CKR_OK;
+       return CKR_OK;
 }
 
-ck_rv_t pakchois_open_session(pakchois_module_t *mod,
+ck_rv_t pakchois_open_session(pakchois_module_t * mod,
                              ck_slot_id_t slot_id, ck_flags_t flags,
                              void *application, pakchois_notify_t notify,
-                             pakchois_session_t **session)
+                             pakchois_session_t ** session)
 {
-    ck_session_handle_t sh;
-    pakchois_session_t *sess;
-    ck_rv_t rv;
+       ck_session_handle_t sh;
+       pakchois_session_t *sess;
+       ck_rv_t rv;
 
-    sess = calloc(1, sizeof *sess);
-    if (sess == NULL) {
-        return CKR_HOST_MEMORY;
-    }    
+       sess = calloc(1, sizeof *sess);
+       if (sess == NULL) {
+               return CKR_HOST_MEMORY;
+       }
+
+       rv = CALL(OpenSession, (slot_id, flags, sess, notify_thunk, &sh));
+       if (rv != CKR_OK) {
+               free(sess);
+               return rv;
+       }
 
-    rv = CALL(OpenSession, (slot_id, flags, sess, notify_thunk, &sh));
-    if (rv != CKR_OK) {
-        free(sess);
-        return rv;
-    }
-    
-    *session = sess;
-    sess->module = mod;
-    sess->id = sh;
+       *session = sess;
+       sess->module = mod;
+       sess->id = sh;
 
-    return insert_session(mod, sess, slot_id);
+       return insert_session(mod, sess, slot_id);
 }
 
-ck_rv_t pakchois_close_session(pakchois_session_t *sess)
+ck_rv_t pakchois_close_session(pakchois_session_t * sess)
 {
-    /* PKCS#11 says that all bets are off on failure, so destroy the
-     * session object and just return the error code. */
-    ck_rv_t rv = CALLS(CloseSession, (sess->id));
-    *sess->prevref = sess->next;
-    if (sess->next) {
-        sess->next->prevref = sess->prevref;
-    }
-    free(sess);
-    return rv;
+       /* PKCS#11 says that all bets are off on failure, so destroy the
+        * session object and just return the error code. */
+       ck_rv_t rv = CALLS(CloseSession, (sess->id));
+       *sess->prevref = sess->next;
+       if (sess->next) {
+               sess->next->prevref = sess->prevref;
+       }
+       free(sess);
+       return rv;
 }
 
-ck_rv_t pakchois_close_all_sessions(pakchois_module_t *mod,
+ck_rv_t pakchois_close_all_sessions(pakchois_module_t * mod,
                                    ck_slot_id_t slot_id)
 {
-    struct slot *slot;
-    ck_rv_t rv, frv = CKR_OK;
+       struct slot *slot;
+       ck_rv_t rv, frv = CKR_OK;
 
-    slot = find_slot(mod, slot_id);
+       slot = find_slot(mod, slot_id);
 
-    if (!slot) {
-        return CKR_SLOT_ID_INVALID;
-    }
+       if (!slot) {
+               return CKR_SLOT_ID_INVALID;
+       }
 
-    while (slot->sessions) {
-        rv = pakchois_close_session(slot->sessions);
-        if (rv != CKR_OK) {
-            frv = rv;
-        }
-    }
+       while (slot->sessions) {
+               rv = pakchois_close_session(slot->sessions);
+               if (rv != CKR_OK) {
+                       frv = rv;
+               }
+       }
 
-    return frv;
+       return frv;
 }
 
-ck_rv_t pakchois_get_session_info(pakchois_session_t *sess,
-                                 struct ck_session_info *info)
+ck_rv_t pakchois_get_session_info(pakchois_session_t * sess,
+                                 struct ck_session_info * info)
 {
-    return CALLS1(GetSessionInfo, info);
+       return CALLS1(GetSessionInfo, info);
 }
 
-ck_rv_t pakchois_get_operation_state(pakchois_session_t *sess,
+ck_rv_t pakchois_get_operation_state(pakchois_session_t * sess,
                                     unsigned char *operation_state,
                                     unsigned long *operation_state_len)
 {
-    return CALLS2(GetOperationState, operation_state, 
-                  operation_state_len);
+       return CALLS2(GetOperationState, operation_state,
+                     operation_state_len);
 }
 
-ck_rv_t pakchois_set_operation_state(pakchois_session_t *sess,
+ck_rv_t pakchois_set_operation_state(pakchois_session_t * sess,
                                     unsigned char *operation_state,
                                     unsigned long operation_state_len,
                                     ck_object_handle_t encryption_key,
                                     ck_object_handle_t authentiation_key)
 {
-    return CALLS4(SetOperationState, operation_state, operation_state_len,
-                  encryption_key, authentiation_key);
+       return CALLS4(SetOperationState, operation_state,
+                     operation_state_len, encryption_key,
+                     authentiation_key);
 }
 
-ck_rv_t pakchois_login(pakchois_session_t *sess, ck_user_type_t user_type,
+ck_rv_t pakchois_login(pakchois_session_t * sess, ck_user_type_t user_type,
                       unsigned char *pin, unsigned long pin_len)
 {
-    return CALLS3(Login, user_type, pin, pin_len);
+       return CALLS3(Login, user_type, pin, pin_len);
 }
 
-ck_rv_t pakchois_logout(pakchois_session_t *sess)
+ck_rv_t pakchois_logout(pakchois_session_t * sess)
 {
-    return CALLS(Logout, (sess->id));
+       return CALLS(Logout, (sess->id));
 }
 
-ck_rv_t pakchois_create_object(pakchois_session_t *sess,
-                              struct ck_attribute *templ,
+ck_rv_t pakchois_create_object(pakchois_session_t * sess,
+                              struct ck_attribute * templ,
                               unsigned long count,
-                              ck_object_handle_t *object)
+                              ck_object_handle_t * object)
 {
-    return CALLS3(CreateObject, templ, count, object);
+       return CALLS3(CreateObject, templ, count, object);
 }
 
-ck_rv_t pakchois_copy_object(pakchois_session_t *sess,
+ck_rv_t pakchois_copy_object(pakchois_session_t * sess,
                             ck_object_handle_t object,
-                            struct ck_attribute *templ, unsigned long count,
-                            ck_object_handle_t *new_object)
+                            struct ck_attribute * templ,
+                            unsigned long count,
+                            ck_object_handle_t * new_object)
 {
-    return CALLS4(CopyObject, object, templ, count, new_object);
+       return CALLS4(CopyObject, object, templ, count, new_object);
 }
 
-ck_rv_t pakchois_destroy_object(pakchois_session_t *sess,
+ck_rv_t pakchois_destroy_object(pakchois_session_t * sess,
                                ck_object_handle_t object)
 {
-    return CALLS1(DestroyObject, object);
-}    
+       return CALLS1(DestroyObject, object);
+}
 
-ck_rv_t pakchois_get_object_size(pakchois_session_t *sess,
+ck_rv_t pakchois_get_object_size(pakchois_session_t * sess,
                                 ck_object_handle_t object,
                                 unsigned long *size)
 {
-    return CALLS2(GetObjectSize, object, size);
+       return CALLS2(GetObjectSize, object, size);
 }
 
-ck_rv_t pakchois_get_attribute_value(pakchois_session_t *sess,
+ck_rv_t pakchois_get_attribute_value(pakchois_session_t * sess,
                                     ck_object_handle_t object,
-                                    struct ck_attribute *templ,
+                                    struct ck_attribute * templ,
                                     unsigned long count)
 {
-    return CALLS3(GetAttributeValue, object, templ, count);
+       return CALLS3(GetAttributeValue, object, templ, count);
 }
 
-ck_rv_t pakchois_set_attribute_value(pakchois_session_t *sess,
+ck_rv_t pakchois_set_attribute_value(pakchois_session_t * sess,
                                     ck_object_handle_t object,
-                                    struct ck_attribute *templ,
+                                    struct ck_attribute * templ,
                                     unsigned long count)
 {
-    return CALLS3(SetAttributeValue, object, templ, count);
+       return CALLS3(SetAttributeValue, object, templ, count);
 }
 
-ck_rv_t pakchois_find_objects_init(pakchois_session_t *sess,
-                                  struct ck_attribute *templ,
+ck_rv_t pakchois_find_objects_init(pakchois_session_t * sess,
+                                  struct ck_attribute * templ,
                                   unsigned long count)
 {
-    return CALLS2(FindObjectsInit, templ, count);
+       return CALLS2(FindObjectsInit, templ, count);
 }
 
-ck_rv_t pakchois_find_objects(pakchois_session_t *sess,
-                             ck_object_handle_t *object,
+ck_rv_t pakchois_find_objects(pakchois_session_t * sess,
+                             ck_object_handle_t * object,
                              unsigned long max_object_count,
                              unsigned long *object_count)
 {
-    return CALLS3(FindObjects, object, max_object_count, object_count);
+       return CALLS3(FindObjects, object, max_object_count, object_count);
 }
 
-ck_rv_t pakchois_find_objects_final(pakchois_session_t *sess)
+ck_rv_t pakchois_find_objects_final(pakchois_session_t * sess)
 {
-    return CALLS(FindObjectsFinal, (sess->id));
+       return CALLS(FindObjectsFinal, (sess->id));
 }
 
-ck_rv_t pakchois_encrypt_init(pakchois_session_t *sess,
-                             struct ck_mechanism *mechanism,
+ck_rv_t pakchois_encrypt_init(pakchois_session_t * sess,
+                             struct ck_mechanism * mechanism,
                              ck_object_handle_t key)
 {
-    return CALLS2(EncryptInit, mechanism, key);
+       return CALLS2(EncryptInit, mechanism, key);
 }
 
-ck_rv_t pakchois_encrypt(pakchois_session_t *sess,
+ck_rv_t pakchois_encrypt(pakchois_session_t * sess,
                         unsigned char *data, unsigned long data_len,
                         unsigned char *encrypted_data,
                         unsigned long *encrypted_data_len)
 {
-    return CALLS4(Encrypt, data, data_len, 
-                  encrypted_data, encrypted_data_len);
+       return CALLS4(Encrypt, data, data_len,
+                     encrypted_data, encrypted_data_len);
 }
 
-ck_rv_t pakchois_encrypt_update(pakchois_session_t *sess,
-                               unsigned char *part, unsigned long part_len,
+ck_rv_t pakchois_encrypt_update(pakchois_session_t * sess,
+                               unsigned char *part,
+                               unsigned long part_len,
                                unsigned char *encrypted_part,
                                unsigned long *encrypted_part_len)
 {
-    return CALLS4(EncryptUpdate, part, part_len, 
-                  encrypted_part, encrypted_part_len);
+       return CALLS4(EncryptUpdate, part, part_len,
+                     encrypted_part, encrypted_part_len);
 }
 
-ck_rv_t pakchois_encrypt_final(pakchois_session_t *sess,
+ck_rv_t pakchois_encrypt_final(pakchois_session_t * sess,
                               unsigned char *last_encrypted_part,
                               unsigned long *last_encrypted_part_len)
 {
-    return CALLS2(EncryptFinal, last_encrypted_part, last_encrypted_part_len);
+       return CALLS2(EncryptFinal, last_encrypted_part,
+                     last_encrypted_part_len);
 }
 
-ck_rv_t pakchois_decrypt_init(pakchois_session_t *sess,
-                             struct ck_mechanism *mechanism,
+ck_rv_t pakchois_decrypt_init(pakchois_session_t * sess,
+                             struct ck_mechanism * mechanism,
                              ck_object_handle_t key)
 {
-    return CALLS2(DecryptInit, mechanism, key);
+       return CALLS2(DecryptInit, mechanism, key);
 }
 
-ck_rv_t pakchois_decrypt(pakchois_session_t *sess,
+ck_rv_t pakchois_decrypt(pakchois_session_t * sess,
                         unsigned char *encrypted_data,
                         unsigned long encrypted_data_len,
                         unsigned char *data, unsigned long *data_len)
 {
-    return CALLS4(Decrypt, encrypted_data, encrypted_data_len, data, data_len);
+       return CALLS4(Decrypt, encrypted_data, encrypted_data_len, data,
+                     data_len);
 }
 
-ck_rv_t pakchois_decrypt_update(pakchois_session_t *sess,
+ck_rv_t pakchois_decrypt_update(pakchois_session_t * sess,
                                unsigned char *encrypted_part,
                                unsigned long encrypted_part_len,
-                               unsigned char *part, unsigned long *part_len)
+                               unsigned char *part,
+                               unsigned long *part_len)
 {
-    return CALLS4(DecryptUpdate, encrypted_part, encrypted_part_len,
-                  part, part_len);
+       return CALLS4(DecryptUpdate, encrypted_part, encrypted_part_len,
+                     part, part_len);
 }
 
-ck_rv_t pakchois_decrypt_final(pakchois_session_t *sess,
+ck_rv_t pakchois_decrypt_final(pakchois_session_t * sess,
                               unsigned char *last_part,
                               unsigned long *last_part_len)
 {
-    return CALLS2(DecryptFinal, last_part, last_part_len);
+       return CALLS2(DecryptFinal, last_part, last_part_len);
 }
 
-ck_rv_t pakchois_digest_init(pakchois_session_t *sess,
-                            struct ck_mechanism *mechanism)
+ck_rv_t pakchois_digest_init(pakchois_session_t * sess,
+                            struct ck_mechanism * mechanism)
 {
-    return CALLS1(DigestInit, mechanism);
+       return CALLS1(DigestInit, mechanism);
 }
 
-ck_rv_t pakchois_digest(pakchois_session_t *sess, unsigned char *data,
+ck_rv_t pakchois_digest(pakchois_session_t * sess, unsigned char *data,
                        unsigned long data_len, unsigned char *digest,
                        unsigned long *digest_len)
 {
-    return CALLS4(Digest, data, data_len, digest, digest_len);
+       return CALLS4(Digest, data, data_len, digest, digest_len);
 }
 
-ck_rv_t pakchois_digest_update(pakchois_session_t *sess,
+ck_rv_t pakchois_digest_update(pakchois_session_t * sess,
                               unsigned char *part, unsigned long part_len)
 {
-    return CALLS2(DigestUpdate, part, part_len);
+       return CALLS2(DigestUpdate, part, part_len);
 }
 
-ck_rv_t pakchois_digest_key(pakchois_session_t *sess,
+ck_rv_t pakchois_digest_key(pakchois_session_t * sess,
                            ck_object_handle_t key)
 {
-    return CALLS1(DigestKey, key);
+       return CALLS1(DigestKey, key);
 }
 
-ck_rv_t pakchois_digest_final(pakchois_session_t *sess,
+ck_rv_t pakchois_digest_final(pakchois_session_t * sess,
                              unsigned char *digest,
                              unsigned long *digest_len)
 {
-    return CALLS2(DigestFinal, digest, digest_len);
+       return CALLS2(DigestFinal, digest, digest_len);
 }
 
-ck_rv_t pakchois_sign_init(pakchois_session_t *sess,
-                          struct ck_mechanism *mechanism,
+ck_rv_t pakchois_sign_init(pakchois_session_t * sess,
+                          struct ck_mechanism * mechanism,
                           ck_object_handle_t key)
 {
-    return CALLS2(SignInit, mechanism, key);
+       return CALLS2(SignInit, mechanism, key);
 }
 
-ck_rv_t pakchois_sign(pakchois_session_t *sess, unsigned char *data,
+ck_rv_t pakchois_sign(pakchois_session_t * sess, unsigned char *data,
                      unsigned long data_len, unsigned char *signature,
                      unsigned long *signature_len)
 {
-    return CALLS4(Sign, data, data_len, signature, signature_len);
+       return CALLS4(Sign, data, data_len, signature, signature_len);
 }
 
-ck_rv_t pakchois_sign_update(pakchois_session_t *sess,
+ck_rv_t pakchois_sign_update(pakchois_session_t * sess,
                             unsigned char *part, unsigned long part_len)
 {
-    return CALLS2(SignUpdate, part, part_len);
+       return CALLS2(SignUpdate, part, part_len);
 }
 
-ck_rv_t pakchois_sign_final(pakchois_session_t *sess,
+ck_rv_t pakchois_sign_final(pakchois_session_t * sess,
                            unsigned char *signature,
                            unsigned long *signature_len)
 {
-    return CALLS2(SignFinal, signature, signature_len);
+       return CALLS2(SignFinal, signature, signature_len);
 }
 
-ck_rv_t pakchois_sign_recover_init(pakchois_session_t *sess,
-                                  struct ck_mechanism *mechanism,
+ck_rv_t pakchois_sign_recover_init(pakchois_session_t * sess,
+                                  struct ck_mechanism * mechanism,
                                   ck_object_handle_t key)
 {
-    return CALLS2(SignRecoverInit, mechanism, key);
+       return CALLS2(SignRecoverInit, mechanism, key);
 }
 
-ck_rv_t pakchois_sign_recover(pakchois_session_t *sess,
+ck_rv_t pakchois_sign_recover(pakchois_session_t * sess,
                              unsigned char *data, unsigned long data_len,
                              unsigned char *signature,
                              unsigned long *signature_len)
 {
-    return CALLS4(SignRecover, data, data_len, signature, signature_len);
+       return CALLS4(SignRecover, data, data_len, signature,
+                     signature_len);
 }
 
-ck_rv_t pakchois_verify_init(pakchois_session_t *sess,
-                            struct ck_mechanism *mechanism,
+ck_rv_t pakchois_verify_init(pakchois_session_t * sess,
+                            struct ck_mechanism * mechanism,
                             ck_object_handle_t key)
 {
-    return CALLS2(VerifyInit, mechanism, key);
+       return CALLS2(VerifyInit, mechanism, key);
 }
 
-ck_rv_t pakchois_verify(pakchois_session_t *sess, unsigned char *data,
+ck_rv_t pakchois_verify(pakchois_session_t * sess, unsigned char *data,
                        unsigned long data_len, unsigned char *signature,
                        unsigned long signature_len)
 {
-    return CALLS4(Verify, data, data_len, signature, signature_len);
+       return CALLS4(Verify, data, data_len, signature, signature_len);
 }
 
-ck_rv_t pakchois_verify_update(pakchois_session_t *sess,
+ck_rv_t pakchois_verify_update(pakchois_session_t * sess,
                               unsigned char *part, unsigned long part_len)
 {
-    return CALLS2(VerifyUpdate, part, part_len);
+       return CALLS2(VerifyUpdate, part, part_len);
 }
 
-ck_rv_t pakchois_verify_final(pakchois_session_t *sess,
+ck_rv_t pakchois_verify_final(pakchois_session_t * sess,
                              unsigned char *signature,
                              unsigned long signature_len)
 {
-    return CALLS2(VerifyFinal, signature, signature_len);
+       return CALLS2(VerifyFinal, signature, signature_len);
 }
 
-ck_rv_t pakchois_verify_recover_init(pakchois_session_t *sess,
-                                    struct ck_mechanism *mechanism,
+ck_rv_t pakchois_verify_recover_init(pakchois_session_t * sess,
+                                    struct ck_mechanism * mechanism,
                                     ck_object_handle_t key)
 {
-    return CALLS2(VerifyRecoverInit, mechanism, key);
+       return CALLS2(VerifyRecoverInit, mechanism, key);
 }
 
-ck_rv_t pakchois_verify_recover(pakchois_session_t *sess,
+ck_rv_t pakchois_verify_recover(pakchois_session_t * sess,
                                unsigned char *signature,
                                unsigned long signature_len,
-                               unsigned char *data, unsigned long *data_len)
+                               unsigned char *data,
+                               unsigned long *data_len)
 {
-    return CALLS4(VerifyRecover, signature, signature_len, data, data_len);
+       return CALLS4(VerifyRecover, signature, signature_len, data,
+                     data_len);
 }
 
-ck_rv_t pakchois_digest_encrypt_update(pakchois_session_t *sess,
+ck_rv_t pakchois_digest_encrypt_update(pakchois_session_t * sess,
                                       unsigned char *part,
                                       unsigned long part_len,
                                       unsigned char *encrypted_part,
                                       unsigned long *encrypted_part_len)
 {
-    return CALLS4(DigestEncryptUpdate, part, part_len,
-                  encrypted_part, encrypted_part_len);
+       return CALLS4(DigestEncryptUpdate, part, part_len,
+                     encrypted_part, encrypted_part_len);
 }
 
-ck_rv_t pakchois_decrypt_digest_update(pakchois_session_t *sess,
+ck_rv_t pakchois_decrypt_digest_update(pakchois_session_t * sess,
                                       unsigned char *encrypted_part,
                                       unsigned long encrypted_part_len,
                                       unsigned char *part,
                                       unsigned long *part_len)
 {
-    return CALLS4(DecryptDigestUpdate, encrypted_part, encrypted_part_len,
-                  part, part_len);
+       return CALLS4(DecryptDigestUpdate, encrypted_part,
+                     encrypted_part_len, part, part_len);
 }
 
-ck_rv_t pakchois_sign_encrypt_update(pakchois_session_t *sess,
+ck_rv_t pakchois_sign_encrypt_update(pakchois_session_t * sess,
                                     unsigned char *part,
                                     unsigned long part_len,
                                     unsigned char *encrypted_part,
                                     unsigned long *encrypted_part_len)
 {
-    return CALLS4(SignEncryptUpdate, part, part_len,
-                  encrypted_part, encrypted_part_len);
+       return CALLS4(SignEncryptUpdate, part, part_len,
+                     encrypted_part, encrypted_part_len);
 }
 
-ck_rv_t pakchois_decrypt_verify_update(pakchois_session_t *sess,
+ck_rv_t pakchois_decrypt_verify_update(pakchois_session_t * sess,
                                       unsigned char *encrypted_part,
                                       unsigned long encrypted_part_len,
                                       unsigned char *part,
                                       unsigned long *part_len)
 {
-    return CALLS4(DecryptVerifyUpdate, encrypted_part, encrypted_part_len,
-                  part, part_len);
+       return CALLS4(DecryptVerifyUpdate, encrypted_part,
+                     encrypted_part_len, part, part_len);
 }
 
-ck_rv_t pakchois_generate_key(pakchois_session_t *sess,
-                             struct ck_mechanism *mechanism,
-                             struct ck_attribute *templ,
-                             unsigned long count, ck_object_handle_t *key)
+ck_rv_t pakchois_generate_key(pakchois_session_t * sess,
+                             struct ck_mechanism * mechanism,
+                             struct ck_attribute * templ,
+                             unsigned long count,
+                             ck_object_handle_t * key)
 {
-    return CALLS4(GenerateKey, mechanism, templ, count, key);
+       return CALLS4(GenerateKey, mechanism, templ, count, key);
 }
 
-ck_rv_t pakchois_generate_key_pair(pakchois_session_t *sess,
-                                  struct ck_mechanism *mechanism,
-                                  struct ck_attribute *public_key_template,
-                                  unsigned long public_key_attribute_count,
-                                  struct ck_attribute *private_key_template,
-                                  unsigned long private_key_attribute_count,
-                                  ck_object_handle_t *public_key,
-                                  ck_object_handle_t *private_key)
+ck_rv_t pakchois_generate_key_pair(pakchois_session_t * sess,
+                                  struct ck_mechanism * mechanism,
+                                  struct ck_attribute *
+                                  public_key_template,
+                                  unsigned long
+                                  public_key_attribute_count,
+                                  struct ck_attribute *
+                                  private_key_template,
+                                  unsigned long
+                                  private_key_attribute_count,
+                                  ck_object_handle_t * public_key,
+                                  ck_object_handle_t * private_key)
 {
-    return CALLS7(GenerateKeyPair, mechanism,
-                  public_key_template, public_key_attribute_count,
-                  private_key_template, private_key_attribute_count,
-                  public_key, private_key);
+       return CALLS7(GenerateKeyPair, mechanism,
+                     public_key_template, public_key_attribute_count,
+                     private_key_template, private_key_attribute_count,
+                     public_key, private_key);
 }
 
-ck_rv_t pakchois_wrap_key(pakchois_session_t *sess,
-                         struct ck_mechanism *mechanism,
+ck_rv_t pakchois_wrap_key(pakchois_session_t * sess,
+                         struct ck_mechanism * mechanism,
                          ck_object_handle_t wrapping_key,
-                         ck_object_handle_t key, unsigned char *wrapped_key,
+                         ck_object_handle_t key,
+                         unsigned char *wrapped_key,
                          unsigned long *wrapped_key_len)
 {
-    return CALLS5(WrapKey, mechanism, wrapping_key,
-                  key, wrapped_key, wrapped_key_len);
-}    
+       return CALLS5(WrapKey, mechanism, wrapping_key,
+                     key, wrapped_key, wrapped_key_len);
+}
 
-ck_rv_t pakchois_unwrap_key(pakchois_session_t *sess,
-                           struct ck_mechanism *mechanism,
+ck_rv_t pakchois_unwrap_key(pakchois_session_t * sess,
+                           struct ck_mechanism * mechanism,
                            ck_object_handle_t unwrapping_key,
                            unsigned char *wrapped_key,
                            unsigned long wrapped_key_len,
-                           struct ck_attribute *templ,
+                           struct ck_attribute * templ,
                            unsigned long attribute_count,
-                           ck_object_handle_t *key)
+                           ck_object_handle_t * key)
 {
-    return CALLS7(UnwrapKey, mechanism, unwrapping_key, 
-                  wrapped_key, wrapped_key_len, templ, attribute_count,
-                  key);
+       return CALLS7(UnwrapKey, mechanism, unwrapping_key,
+                     wrapped_key, wrapped_key_len, templ, attribute_count,
+                     key);
 }
 
-ck_rv_t pakchois_derive_key(pakchois_session_t *sess,
-                           struct ck_mechanism *mechanism,
+ck_rv_t pakchois_derive_key(pakchois_session_t * sess,
+                           struct ck_mechanism * mechanism,
                            ck_object_handle_t base_key,
-                           struct ck_attribute *templ,
+                           struct ck_attribute * templ,
                            unsigned long attribute_count,
-                           ck_object_handle_t *key)
+                           ck_object_handle_t * key)
 {
-    return CALLS5(DeriveKey, mechanism, base_key, templ, attribute_count, key);
+       return CALLS5(DeriveKey, mechanism, base_key, templ,
+                     attribute_count, key);
 }
 
 
-ck_rv_t pakchois_seed_random(pakchois_session_t *sess,
+ck_rv_t pakchois_seed_random(pakchois_session_t * sess,
                             unsigned char *seed, unsigned long seed_len)
 {
-    return CALLS2(SeedRandom, seed, seed_len);
+       return CALLS2(SeedRandom, seed, seed_len);
 }
 
-ck_rv_t pakchois_generate_random(pakchois_session_t *sess,
+ck_rv_t pakchois_generate_random(pakchois_session_t * sess,
                                 unsigned char *random_data,
                                 unsigned long random_len)
 {
-    return CALLS2(GenerateRandom, random_data, random_len);
+       return CALLS2(GenerateRandom, random_data, random_len);
 }


hooks/post-receive
-- 
GNU gnutls



reply via email to

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