From: Nikos Mavrogiannopoulos Date: Fri, 13 Jul 2012 11:47:43 +0000 (+0200) Subject: Added gnutls_pkcs11_advset_pin_function and gnutls_pkcs11_advset_token_function X-Git-Tag: gnutls_3_1_0pre0~68 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=aafed2cb248bc4c3834de32eee021e4cd3800e14;p=thirdparty%2Fgnutls.git Added gnutls_pkcs11_advset_pin_function and gnutls_pkcs11_advset_token_function --- diff --git a/.gitignore b/.gitignore index 622cd82bac..4cfbcd0136 100644 --- a/.gitignore +++ b/.gitignore @@ -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 b57d5f8151..d822a605d3 100644 --- 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 diff --git a/doc/cha-cert-auth2.texi b/doc/cha-cert-auth2.texi index 573b68d5f0..1b8cb3b084 100644 --- a/doc/cha-cert-auth2.texi +++ b/doc/cha-cert-auth2.texi @@ -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. diff --git a/lib/includes/gnutls/pkcs11.h b/lib/includes/gnutls/pkcs11.h index eb95f4c462..e1dd841210 100644 --- a/lib/includes/gnutls/pkcs11.h +++ b/lib/includes/gnutls/pkcs11.h @@ -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); diff --git a/lib/libgnutls.map b/lib/libgnutls.map index dd9aa1dd2a..4192ae271c 100644 --- a/lib/libgnutls.map +++ b/lib/libgnutls.map @@ -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; diff --git a/lib/pkcs11.c b/lib/pkcs11.c index ec8a482cf6..907cfbdc37 100644 --- a/lib/pkcs11.c +++ b/lib/pkcs11.c @@ -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) {