xref: /titanic_51/usr/src/lib/pkcs11/pkcs11_kernel/common/kernelSlot.h (revision bfed486ad8de8b8ebc6345a8e10accae08bf2f45)
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 2007 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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #include "kernelSession.h"
36 #include <sys/crypto/ioctl.h>
37 
38 #define	CKU_PUBLIC	2	/* default session auth. state */
39 
40 typedef struct cipher_mechs_threshold {
41 	int		mech_type;
42 	uint32_t	mech_threshold;
43 } cipher_mechs_threshold_t;
44 
45 /*
46  * This slot has limited hash support. It can not do multi-part
47  * hashing (updates) and it can not hash input data of size
48  * greater than sl_max_inlen.
49  */
50 #define	CRYPTO_LIMITED_HASH_SUPPORT	0x00000001
51 
52 typedef struct kernel_slot {
53 	CK_SLOT_ID		sl_provider_id;	/* kernel provider ID */
54 	crypto_function_list_t	sl_func_list;	/* function list */
55 	kernel_session_t 	*sl_sess_list;	/* all open sessions */
56 	CK_USER_TYPE		sl_state;	/* session's auth. state */
57 	struct object 		*sl_tobj_list; 	/* token object list */
58 	pthread_mutex_t		sl_mutex;
59 	/*
60 	 * The valid values are defined above.
61 	 */
62 	uint32_t		sl_flags;
63 
64 	/*
65 	 * The maximum input data that can be digested by this slot.
66 	 * Used only if CRYPTO_LIMITED_HASH_SUPPORT is set in sl_flags.
67 	 */
68 	int			sl_max_inlen;
69 
70 	/*
71 	 * The threshold for input data size. We use this slot
72 	 * only if data size is at or above this value. Used only if
73 	 * CRYPTO_LIMITED_HASH_SUPPORT is set.
74 	 */
75 	int			sl_threshold;
76 
77 	int total_threshold_count;
78 	cipher_mechs_threshold_t	sl_mechs_threshold[MAX_NUM_THRESHOLD];
79 } kernel_slot_t;
80 
81 extern CK_ULONG slot_count;
82 extern kernel_slot_t **slot_table;
83 
84 /*
85  * Function Prototypes.
86  */
87 CK_RV kernel_slottable_init();
88 
89 #ifdef __cplusplus
90 }
91 #endif
92 
93 #endif /* _KERNEL_SLOT_H */
94