xref: /onnv-gate/usr/src/lib/pkcs11/pkcs11_kernel/common/kernelGlobal.h (revision 4632:7c6f7a64ae85)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52935Skrishna  * Common Development and Distribution License (the "License").
62935Skrishna  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
224219Smcpowers  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate #ifndef _KERNELGLOBAL_H
270Sstevel@tonic-gate #define	_KERNELGLOBAL_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #ifdef __cplusplus
320Sstevel@tonic-gate extern "C" {
330Sstevel@tonic-gate #endif
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #include <sys/crypto/common.h>
360Sstevel@tonic-gate #include <security/cryptoki.h>
370Sstevel@tonic-gate #include <security/pkcs11t.h>
380Sstevel@tonic-gate #include "kernelObject.h"
390Sstevel@tonic-gate 
402935Skrishna typedef struct kmh_elem {
412935Skrishna 	CK_MECHANISM_TYPE type;
422935Skrishna 	crypto_mech_type_t kmech;	/* kCF mech number */
432935Skrishna 	struct kmh_elem *knext;		/* Next in hash chain */
442935Skrishna } kmh_elem_t;
452935Skrishna 
462935Skrishna extern kmh_elem_t **kernel_mechhash;
470Sstevel@tonic-gate extern boolean_t kernel_initialized;
480Sstevel@tonic-gate extern int kernel_fd;
490Sstevel@tonic-gate 
502935Skrishna #define	KMECH_HASHTABLE_SIZE	67
512935Skrishna 
520Sstevel@tonic-gate #define	CRYPTO_DEVICE		"/dev/crypto"
530Sstevel@tonic-gate 
540Sstevel@tonic-gate /* CK_INFO: Information about cryptoki */
550Sstevel@tonic-gate #define	CRYPTOKI_VERSION_MAJOR	2
56676Sizick #define	CRYPTOKI_VERSION_MINOR	20
570Sstevel@tonic-gate #define	MANUFACTURER_ID		"Sun Microsystems, Inc.          "
580Sstevel@tonic-gate #define	LIBRARY_DESCRIPTION	"Sun Crypto pkcs11_kernel        "
590Sstevel@tonic-gate #define	LIBRARY_VERSION_MAJOR	1
600Sstevel@tonic-gate #define	LIBRARY_VERSION_MINOR	1
610Sstevel@tonic-gate 
620Sstevel@tonic-gate 
630Sstevel@tonic-gate /* CK_SLOT_INFO: Information about our slot */
640Sstevel@tonic-gate #define	SLOT_DESCRIPTION	"Sun Crypto pkcs11_kernel        " \
650Sstevel@tonic-gate 				"                                "
660Sstevel@tonic-gate #define	HARDWARE_VERSION_MAJOR	0
670Sstevel@tonic-gate #define	HARDWARE_VERSION_MINOR	0
680Sstevel@tonic-gate #define	FIRMWARE_VERSION_MAJOR	0
690Sstevel@tonic-gate #define	FIRMWARE_VERSION_MINOR	0
700Sstevel@tonic-gate 
71*4632Smcpowers #define	INPLACE_MECHANISM(m)	((m) == CKM_DES_ECB || (m) == CKM_DES_CBC || \
72*4632Smcpowers 	(m) == CKM_DES3_ECB || (m) == CKM_DES3_CBC || (m) == CKM_AES_ECB || \
73*4632Smcpowers 	(m) == CKM_AES_CBC || (m) == CKM_RC4 || (m) == CKM_BLOWFISH_CBC)
74*4632Smcpowers 
750Sstevel@tonic-gate CK_RV crypto2pkcs11_error_number(uint_t);
760Sstevel@tonic-gate CK_RV kernel_mech(CK_MECHANISM_TYPE, crypto_mech_type_t *);
770Sstevel@tonic-gate unsigned char *get_symmetric_key_value(kernel_object_t *);
780Sstevel@tonic-gate CK_RV get_rsa_public_key(kernel_object_t *, crypto_key_t *);
790Sstevel@tonic-gate CK_RV get_rsa_private_key(kernel_object_t *, crypto_key_t *);
800Sstevel@tonic-gate CK_RV get_dsa_public_key(kernel_object_t *, crypto_key_t *);
810Sstevel@tonic-gate CK_RV get_dsa_private_key(kernel_object_t *, crypto_key_t *);
824219Smcpowers CK_RV get_ec_public_key(kernel_object_t *, crypto_key_t *);
834219Smcpowers CK_RV get_ec_private_key(kernel_object_t *, crypto_key_t *);
840Sstevel@tonic-gate void free_key_attributes(crypto_key_t *);
854219Smcpowers void get_ulong_attr_from_template(CK_ULONG *, CK_ATTRIBUTE_PTR);
860Sstevel@tonic-gate CK_RV process_object_attributes(CK_ATTRIBUTE_PTR, CK_ULONG, caddr_t *,
870Sstevel@tonic-gate     CK_BBOOL *);
880Sstevel@tonic-gate CK_RV get_object_attributes(CK_ATTRIBUTE_PTR, CK_ULONG, caddr_t);
890Sstevel@tonic-gate void free_object_attributes(caddr_t, CK_ULONG);
900Sstevel@tonic-gate CK_RV get_cka_private_value(kernel_session_t *, crypto_object_id_t,
910Sstevel@tonic-gate     CK_BBOOL *);
920Sstevel@tonic-gate CK_RV process_found_objects(kernel_session_t *, CK_OBJECT_HANDLE *,
930Sstevel@tonic-gate     CK_ULONG *, crypto_object_find_update_t);
940Sstevel@tonic-gate CK_RV get_mechanism_info(kernel_slot_t *, CK_MECHANISM_TYPE,
950Sstevel@tonic-gate     CK_MECHANISM_INFO_PTR, uint32_t *);
960Sstevel@tonic-gate CK_RV kernel_decrypt_init(kernel_session_t *, kernel_object_t *,
970Sstevel@tonic-gate     CK_MECHANISM_PTR);
980Sstevel@tonic-gate CK_RV kernel_decrypt(kernel_session_t *, CK_BYTE_PTR, CK_ULONG, CK_BYTE_PTR,
990Sstevel@tonic-gate     CK_ULONG_PTR);
1004219Smcpowers CK_RV kernel_add_extra_attr(CK_ATTRIBUTE_PTR, kernel_object_t *);
1010Sstevel@tonic-gate 
1020Sstevel@tonic-gate #ifdef	__cplusplus
1030Sstevel@tonic-gate }
1040Sstevel@tonic-gate #endif
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate #endif /* _KERNELGLOBAL_H */
107