]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Added gnutls_pkcs11_advset_pin_function and gnutls_pkcs11_advset_token_function
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 13 Jul 2012 11:47:43 +0000 (13:47 +0200)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 13 Jul 2012 11:48:03 +0000 (13:48 +0200)
.gitignore
NEWS
doc/cha-cert-auth2.texi
lib/includes/gnutls/pkcs11.h
lib/libgnutls.map
lib/pkcs11.c

index 622cd82bac340a9619742348117250666538ea70..4cfbcd01369dbe3dd9258bf0a95502228206c887 100644 (file)
@@ -585,3 +585,5 @@ tests/mini-x509-2
 tests/pkcs12_simple
 win32
 win64
+src/tpmtool
+src/libcmd-tpmtool.la
diff --git a/NEWS b/NEWS
index b57d5f81511c642adbfd9a43a3081bc5b44bd5bc..d822a605d39c9e6a69910d3b57a8e446e3a5abaa 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -47,6 +47,8 @@ by Alexandre Bique.
 ** API and ABI modifications:
 GNUTLS_CERT_SIGNATURE_FAILURE: Added
 GNUTLS_CAMELLIA_192_CBC: Added
+gnutls_pkcs11_advset_pin_function: Added
+gnutls_pkcs11_advset_token_function: Added
 gnutls_privkey_import_tpm_raw: Added
 gnutls_privkey_import_pkcs11_url: Added
 gnutls_privkey_import_openpgp_raw: Added
index 573b68d5f0468585adda2feef37b846f9abdeaaa..1b8cb3b0847bc424c70465107b720d5f490c1414 100644 (file)
@@ -432,6 +432,10 @@ are sharing a module. To avoid this problem GnuTLS uses @acronym{p11-kit}
 that provides a middleware to control access to resources over the
 multiple users.
 
+To avoid conflicts with multiple registered callbacks for PIN and token functions,
+the following two functions set the callbacks if they have not already been set.
+@showfuncB{gnutls_pkcs11_advset_pin_function,gnutls_pkcs11_advset_token_function}
+
 Moreover PKCS #11 modules must be reinitialized on the child processes
 after a @funcintref{fork}. @acronym{GnuTLS} provides @funcref{gnutls_pkcs11_reinit}
 to be called for this purpose.
index eb95f4c4621678f7ea086245dcd30547bf189f74..e1dd8412100d5143ab970db8ee3193ffff93cded 100644 (file)
@@ -137,6 +137,13 @@ void gnutls_pkcs11_set_token_function (gnutls_pkcs11_token_callback_t fn,
 
 void gnutls_pkcs11_set_pin_function (gnutls_pkcs11_pin_callback_t fn,
                                      void *userdata);
+
+void gnutls_pkcs11_advset_token_function (gnutls_pkcs11_token_callback_t fn,
+                                       void *userdata);
+
+void gnutls_pkcs11_advset_pin_function (gnutls_pkcs11_pin_callback_t fn,
+                                     void *userdata);
+
 int gnutls_pkcs11_add_provider (const char *name, const char *params);
 int gnutls_pkcs11_obj_init (gnutls_pkcs11_obj_t * obj);
 
index dd9aa1dd2aee0fe4a58d94d2641273b21e3aadf2..4192ae271c1a843c9f9f12ef3312a5b3257622f6 100644 (file)
@@ -794,6 +794,8 @@ GNUTLS_3_0_0 {
 
 GNUTLS_3_1_0 {
   global:
+        gnutls_pkcs11_advset_pin_function;
+       gnutls_pkcs11_advset_token_function;
        gnutls_pkcs11_obj_list_import_url2;
        gnutls_x509_trust_list_add_system_trust;
        gnutls_x509_trust_list_add_trust_file;
index ec8a482cf629d9613016b9843c81b5930b41d34b..907cfbdc374742b3973d6394ecf627d0e72771d0 100644 (file)
@@ -630,10 +630,13 @@ gnutls_pkcs11_deinit (void)
         p11_kit_finalize_module (providers[i].module);
     }
   active_providers = 0;
-
+  
   if (initialized_registered != 0)
     p11_kit_finalize_registered ();
   initialized_registered = 0;
+  
+  gnutls_pkcs11_set_pin_function (NULL, NULL);
+  gnutls_pkcs11_set_token_function (NULL, NULL);
 }
 
 /**
@@ -655,6 +658,31 @@ gnutls_pkcs11_set_pin_function (gnutls_pkcs11_pin_callback_t fn,
   _gnutls_pin_data = userdata;
 }
 
+/**
+ * gnutls_pkcs11_advset_pin_function:
+ * @fn: The PIN callback, a gnutls_pkcs11_pin_callback_t() function.
+ * @userdata: data to be supplied to callback
+ *
+ * This function will set a callback function to be used when a PIN is
+ * required for PKCS 11 operations.  See
+ * gnutls_pkcs11_pin_callback_t() on how the callback should behave.
+ * 
+ * This function unlike gnutls_pkcs11_set_pin_function() will only
+ * set the provided function if it has not previously been set. 
+ *
+ * Since: 3.1.0
+ **/
+void
+gnutls_pkcs11_advset_pin_function (gnutls_pkcs11_pin_callback_t fn,
+                                void *userdata)
+{
+  if (_gnutls_pin_func == NULL)
+    {
+      _gnutls_pin_func = fn;
+      _gnutls_pin_data = userdata;
+    }
+}
+
 /**
  * gnutls_pkcs11_set_token_function:
  * @fn: The token callback
@@ -673,6 +701,30 @@ gnutls_pkcs11_set_token_function (gnutls_pkcs11_token_callback_t fn,
   _gnutls_token_data = userdata;
 }
 
+/**
+ * gnutls_pkcs11_advset_token_function:
+ * @fn: The token callback
+ * @userdata: data to be supplied to callback
+ *
+ * This function will set a callback function to be used when a token
+ * needs to be inserted to continue PKCS 11 operations.
+ *
+ * This function unlike gnutls_pkcs11_set_token_function() will only
+ * set the provided function if it has not previously been set. 
+ *
+ * Since: 3.1.0
+ **/
+void
+gnutls_pkcs11_advset_token_function (gnutls_pkcs11_token_callback_t fn,
+                                  void *userdata)
+{
+  if (_gnutls_token_func==NULL)
+    {
+      _gnutls_token_func = fn;
+      _gnutls_token_data = userdata;
+    }
+}
+
 int
 pkcs11_url_to_info (const char *url, struct p11_kit_uri **info)
 {