diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2012-07-23 16:25:52 +0300 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2012-07-23 16:25:52 +0300 |
commit | eb5efe93948b83a757dbb32d5c48f3e3040c76d2 (patch) | |
tree | 39501fc84fbfa5cdc121e924d274e4a1acce4de3 /lib/pin.c | |
parent | ef5bfbb0aea81b9ed9a20446b55d50b1237fce5c (diff) | |
download | gnutls-eb5efe93948b83a757dbb32d5c48f3e3040c76d2.tar.gz |
PIN-related functions common to TPM and PKCS #11 moved to pin.c.
Diffstat (limited to 'lib/pin.c')
-rw-r--r-- | lib/pin.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/lib/pin.c b/lib/pin.c new file mode 100644 index 0000000000..5fc7fb8ec9 --- /dev/null +++ b/lib/pin.c @@ -0,0 +1,67 @@ +/* + * GnuTLS PIN support for PKCS#11 or TPM + * Copyright (C) 2010-2012 Free Software Foundation, Inc. + * + * Authors: Nikos Mavrogiannopoulos + * + * The GnuTLS 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 3 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 program. If not, see <http://www.gnu.org/licenses/> + */ + +#include <gnutls_int.h> +#include <gnutls/pkcs11.h> +#include <pin.h> + +gnutls_pin_callback_t _gnutls_pin_func; +void *_gnutls_pin_data; + +/** + * gnutls_pkcs11_set_pin_function: + * @fn: The PIN callback, a gnutls_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_pin_callback_t() on how the callback should behave. + * + * Since: 2.12.0 + **/ +void +gnutls_pkcs11_set_pin_function (gnutls_pin_callback_t fn, + void *userdata) +{ + _gnutls_pin_func = fn; + _gnutls_pin_data = userdata; +} + +/** + * gnutls_pkcs11_get_pin_function: + * @userdata: data to be supplied to callback + * + * This function will return the callback function set using + * gnutls_pkcs11_set_pin_function(). + * + * Returns: The function set or NULL otherwise. + * + * Since: 3.1.0 + **/ +gnutls_pin_callback_t +gnutls_pkcs11_get_pin_function (void **userdata) +{ + if (_gnutls_pin_func != NULL) + { + *userdata = _gnutls_pin_data; + return _gnutls_pin_func; + } + return NULL; +} |