added new functions
[gnutls.git] / lib / pin.c
blob5fc7fb8ec9c567b727e459ea3d024c4d1eaba5d1
1 /*
2 * GnuTLS PIN support for PKCS#11 or TPM
3 * Copyright (C) 2010-2012 Free Software Foundation, Inc.
4 *
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 3 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>
23 #include <pin.h>
25 gnutls_pin_callback_t _gnutls_pin_func;
26 void *_gnutls_pin_data;
28 /**
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.
37 * Since: 2.12.0
38 **/
39 void
40 gnutls_pkcs11_set_pin_function (gnutls_pin_callback_t fn,
41 void *userdata)
43 _gnutls_pin_func = fn;
44 _gnutls_pin_data = userdata;
47 /**
48 * gnutls_pkcs11_get_pin_function:
49 * @userdata: data to be supplied to callback
51 * This function will return the callback function set using
52 * gnutls_pkcs11_set_pin_function().
54 * Returns: The function set or NULL otherwise.
56 * Since: 3.1.0
57 **/
58 gnutls_pin_callback_t
59 gnutls_pkcs11_get_pin_function (void **userdata)
61 if (_gnutls_pin_func != NULL)
63 *userdata = _gnutls_pin_data;
64 return _gnutls_pin_func;
66 return NULL;