xref: /illumos-gate/usr/src/lib/pkcs11/pkcs11_kernel/common/kernelSlot.h (revision fb2a9bae0030340ad72b9c26ba1ffee2ee3cafec)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_KERNEL_SLOT_H
27 #define	_KERNEL_SLOT_H
28 
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include "kernelSession.h"
34 #include <sys/crypto/ioctl.h>
35 
36 #define	CKU_PUBLIC	2	/* default session auth. state */
37 
38 typedef struct cipher_mechs_threshold {
39 	int		mech_type;
40 	uint32_t	mech_threshold;
41 } cipher_mechs_threshold_t;
42 
43 /*
44  * This slot has limited hash support. It can not do multi-part
45  * hashing (updates).
46  */
47 #define	CRYPTO_LIMITED_HASH_SUPPORT	0x00000001
48 
49 /*
50  * This slot has limited hmac support. It can not do multi-part
51  * hmac (updates).
52  */
53 #define	CRYPTO_LIMITED_HMAC_SUPPORT	0x00000002
54 
55 typedef struct kernel_slot {
56 	CK_SLOT_ID		sl_provider_id;	/* kernel provider ID */
57 	crypto_function_list_t	sl_func_list;	/* function list */
58 	kernel_session_t 	*sl_sess_list;	/* all open sessions */
59 	CK_USER_TYPE		sl_state;	/* session's auth. state */
60 	struct object 		*sl_tobj_list; 	/* token object list */
61 	pthread_mutex_t		sl_mutex;
62 	/*
63 	 * The valid values are defined above.
64 	 */
65 	uint32_t		sl_flags;
66 
67 	/*
68 	 * The maximum input data that can be digested by this slot.
69 	 * Used only if CRYPTO_LIMITED_HASH_SUPPORT is set in sl_flags.
70 	 */
71 	int			sl_hash_max_inlen;
72 
73 	/*
74 	 * The maximum input data that can be hmac'ed by this slot.
75 	 * Used only if CRYPTO_LIMITED_HMAC_SUPPORT is set in sl_flags.
76 	 */
77 	int			sl_hmac_max_inlen;
78 
79 	/*
80 	 * The threshold for input data size. We use this slot
81 	 * only if data size is at or above this value. Used only if
82 	 * CRYPTO_LIMITED_HASH_SUPPORT or CRYPTO_LIMITED_HMAC_SUPPORT is set.
83 	 */
84 	int			sl_threshold;
85 
86 	int total_threshold_count;
87 	cipher_mechs_threshold_t	sl_mechs_threshold[MAX_NUM_THRESHOLD];
88 } kernel_slot_t;
89 
90 extern CK_ULONG slot_count;
91 extern kernel_slot_t **slot_table;
92 
93 /*
94  * Function Prototypes.
95  */
96 CK_RV kernel_slottable_init();
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif /* _KERNEL_SLOT_H */
103