2 * GnuTLS PIN support for PKCS#11 or TPM
3 * Copyright (C) 2010-2012 Free Software Foundation, Inc.
5 * Authors: Nikos Mavrogiannopoulos
7 * The GnuTLS is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>
21 #include <gnutls_int.h>
22 #include <gnutls/pkcs11.h>
25 gnutls_pin_callback_t _gnutls_pin_func;
26 void *_gnutls_pin_data;
29 * gnutls_pkcs11_set_pin_function:
30 * @fn: The PIN callback, a gnutls_pin_callback_t() function.
31 * @userdata: data to be supplied to callback
33 * This function will set a callback function to be used when a PIN is
34 * required for PKCS 11 operations. See
35 * gnutls_pin_callback_t() on how the callback should behave.
40 gnutls_pkcs11_set_pin_function(gnutls_pin_callback_t fn, void *userdata)
42 _gnutls_pin_func = fn;
43 _gnutls_pin_data = userdata;
47 * gnutls_pkcs11_get_pin_function:
48 * @userdata: data to be supplied to callback
50 * This function will return the callback function set using
51 * gnutls_pkcs11_set_pin_function().
53 * Returns: The function set or NULL otherwise.
57 gnutls_pin_callback_t gnutls_pkcs11_get_pin_function(void **userdata)
59 if (_gnutls_pin_func != NULL) {
60 *userdata = _gnutls_pin_data;
61 return _gnutls_pin_func;