blob: b80d67324e50d41925bc329639200a6de71d3e58 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
/*
* Copyright (C) 2010 Martin Willi
* Copyright (C) 2010 revosec AG
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
*
* This program 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 General Public License
* for more details.
*/
/**
* @defgroup pkcs11_manager pkcs11_manager
* @{ @ingroup pkcs11
*/
#ifndef PKCS11_MANAGER_H_
#define PKCS11_MANAGER_H_
typedef struct pkcs11_manager_t pkcs11_manager_t;
#include <library.h>
#include "pkcs11_library.h"
/**
* Token event callback function.
*
* @param data user supplied data, as passed to pkcs11_manager_create()
* @param p11 loaded PKCS#11 library token belongs to
* @param slot slot number the event occured in
* @param add TRUE if token was added to the slot, FALSE if removed
*/
typedef void (*pkcs11_manager_token_event_t)(void *data, pkcs11_library_t *p11,
CK_SLOT_ID slot, bool add);
/**
* Manages multiple PKCS#11 libraries with hot pluggable slots
*/
struct pkcs11_manager_t {
/**
* Create an enumerator over all tokens.
*
* @return enumerator over (pkcs11_library_t*,CK_SLOT_ID)
*/
enumerator_t* (*create_token_enumerator)(pkcs11_manager_t *this);
/**
* Destroy a pkcs11_manager_t.
*/
void (*destroy)(pkcs11_manager_t *this);
};
/**
* Create a pkcs11_manager instance.
*
* @param cb token event callback function
* @param data user data to pass to token event callback
* @return instance
*/
pkcs11_manager_t *pkcs11_manager_create(pkcs11_manager_token_event_t cb,
void *data);
/**
* Get the singleton instance of the manager
*
* @return instance, NULL if none available
*/
pkcs11_manager_t *pkcs11_manager_get();
#endif /** PKCS11_MANAGER_H_ @}*/
|