17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5ba5f469cSkrishna  * Common Development and Distribution License (the "License").
6ba5f469cSkrishna  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*4df55fdeSJanie Lu  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_KERNEL_SLOT_H
277c478bd9Sstevel@tonic-gate #define	_KERNEL_SLOT_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
307c478bd9Sstevel@tonic-gate extern "C" {
317c478bd9Sstevel@tonic-gate #endif
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate #include "kernelSession.h"
347c478bd9Sstevel@tonic-gate #include <sys/crypto/ioctl.h>
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #define	CKU_PUBLIC	2	/* default session auth. state */
377c478bd9Sstevel@tonic-gate 
384a5b2e70Shaimay typedef struct cipher_mechs_threshold {
394a5b2e70Shaimay 	int		mech_type;
404a5b2e70Shaimay 	uint32_t	mech_threshold;
414a5b2e70Shaimay } cipher_mechs_threshold_t;
424a5b2e70Shaimay 
43ba5f469cSkrishna /*
44ba5f469cSkrishna  * This slot has limited hash support. It can not do multi-part
45*4df55fdeSJanie Lu  * hashing (updates).
46ba5f469cSkrishna  */
47ba5f469cSkrishna #define	CRYPTO_LIMITED_HASH_SUPPORT	0x00000001
48ba5f469cSkrishna 
49*4df55fdeSJanie Lu /*
50*4df55fdeSJanie Lu  * This slot has limited hmac support. It can not do multi-part
51*4df55fdeSJanie Lu  * hmac (updates).
52*4df55fdeSJanie Lu  */
53*4df55fdeSJanie Lu #define	CRYPTO_LIMITED_HMAC_SUPPORT	0x00000002
54*4df55fdeSJanie Lu 
557c478bd9Sstevel@tonic-gate typedef struct kernel_slot {
567c478bd9Sstevel@tonic-gate 	CK_SLOT_ID		sl_provider_id;	/* kernel provider ID */
577c478bd9Sstevel@tonic-gate 	crypto_function_list_t	sl_func_list;	/* function list */
587c478bd9Sstevel@tonic-gate 	kernel_session_t 	*sl_sess_list;	/* all open sessions */
597c478bd9Sstevel@tonic-gate 	CK_USER_TYPE		sl_state;	/* session's auth. state */
607c478bd9Sstevel@tonic-gate 	struct object 		*sl_tobj_list; 	/* token object list */
617c478bd9Sstevel@tonic-gate 	pthread_mutex_t		sl_mutex;
62ba5f469cSkrishna 	/*
63ba5f469cSkrishna 	 * The valid values are defined above.
64ba5f469cSkrishna 	 */
65ba5f469cSkrishna 	uint32_t		sl_flags;
66ba5f469cSkrishna 
67ba5f469cSkrishna 	/*
68ba5f469cSkrishna 	 * The maximum input data that can be digested by this slot.
69ba5f469cSkrishna 	 * Used only if CRYPTO_LIMITED_HASH_SUPPORT is set in sl_flags.
70ba5f469cSkrishna 	 */
71*4df55fdeSJanie Lu 	int			sl_hash_max_inlen;
72*4df55fdeSJanie Lu 
73*4df55fdeSJanie Lu 	/*
74*4df55fdeSJanie Lu 	 * The maximum input data that can be hmac'ed by this slot.
75*4df55fdeSJanie Lu 	 * Used only if CRYPTO_LIMITED_HMAC_SUPPORT is set in sl_flags.
76*4df55fdeSJanie Lu 	 */
77*4df55fdeSJanie Lu 	int			sl_hmac_max_inlen;
78ba5f469cSkrishna 
79ba5f469cSkrishna 	/*
80ba5f469cSkrishna 	 * The threshold for input data size. We use this slot
81ba5f469cSkrishna 	 * only if data size is at or above this value. Used only if
82*4df55fdeSJanie Lu 	 * CRYPTO_LIMITED_HASH_SUPPORT or CRYPTO_LIMITED_HMAC_SUPPORT is set.
83ba5f469cSkrishna 	 */
84ba5f469cSkrishna 	int			sl_threshold;
854a5b2e70Shaimay 
864a5b2e70Shaimay 	int total_threshold_count;
874a5b2e70Shaimay 	cipher_mechs_threshold_t	sl_mechs_threshold[MAX_NUM_THRESHOLD];
887c478bd9Sstevel@tonic-gate } kernel_slot_t;
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate extern CK_ULONG slot_count;
917c478bd9Sstevel@tonic-gate extern kernel_slot_t **slot_table;
927c478bd9Sstevel@tonic-gate 
937c478bd9Sstevel@tonic-gate /*
947c478bd9Sstevel@tonic-gate  * Function Prototypes.
957c478bd9Sstevel@tonic-gate  */
967c478bd9Sstevel@tonic-gate CK_RV kernel_slottable_init();
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate #ifdef __cplusplus
997c478bd9Sstevel@tonic-gate }
1007c478bd9Sstevel@tonic-gate #endif
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate #endif /* _KERNEL_SLOT_H */
103