xref: /illumos-gate/usr/src/lib/pkcs11/pkcs11_kernel/common/kernelGlobal.h (revision f498645a3eecf2ddd304b4ea9c7f1b4c155ff79e)
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, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _KERNELGLOBAL_H
28 #define	_KERNELGLOBAL_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/crypto/common.h>
37 #include <security/cryptoki.h>
38 #include <security/pkcs11t.h>
39 #include "kernelObject.h"
40 
41 extern boolean_t kernel_initialized;
42 extern int kernel_fd;
43 
44 #define	CRYPTO_DEVICE		"/dev/crypto"
45 
46 /* CK_INFO: Information about cryptoki */
47 #define	CRYPTOKI_VERSION_MAJOR	2
48 #define	CRYPTOKI_VERSION_MINOR	20
49 #define	MANUFACTURER_ID		"Sun Microsystems, Inc.          "
50 #define	LIBRARY_DESCRIPTION	"Sun Crypto pkcs11_kernel        "
51 #define	LIBRARY_VERSION_MAJOR	1
52 #define	LIBRARY_VERSION_MINOR	1
53 
54 
55 /* CK_SLOT_INFO: Information about our slot */
56 #define	SLOT_DESCRIPTION	"Sun Crypto pkcs11_kernel        " \
57 				"                                "
58 #define	HARDWARE_VERSION_MAJOR	0
59 #define	HARDWARE_VERSION_MINOR	0
60 #define	FIRMWARE_VERSION_MAJOR	0
61 #define	FIRMWARE_VERSION_MINOR	0
62 
63 CK_RV crypto2pkcs11_error_number(uint_t);
64 CK_RV kernel_mech(CK_MECHANISM_TYPE, crypto_mech_type_t *);
65 unsigned char *get_symmetric_key_value(kernel_object_t *);
66 CK_RV get_rsa_public_key(kernel_object_t *, crypto_key_t *);
67 CK_RV get_rsa_private_key(kernel_object_t *, crypto_key_t *);
68 CK_RV get_dsa_public_key(kernel_object_t *, crypto_key_t *);
69 CK_RV get_dsa_private_key(kernel_object_t *, crypto_key_t *);
70 void free_key_attributes(crypto_key_t *);
71 CK_RV process_object_attributes(CK_ATTRIBUTE_PTR, CK_ULONG, caddr_t *,
72     CK_BBOOL *);
73 CK_RV get_object_attributes(CK_ATTRIBUTE_PTR, CK_ULONG, caddr_t);
74 void free_object_attributes(caddr_t, CK_ULONG);
75 CK_RV get_cka_private_value(kernel_session_t *, crypto_object_id_t,
76     CK_BBOOL *);
77 CK_RV process_found_objects(kernel_session_t *, CK_OBJECT_HANDLE *,
78     CK_ULONG *, crypto_object_find_update_t);
79 CK_RV get_mechanism_info(kernel_slot_t *, CK_MECHANISM_TYPE,
80     CK_MECHANISM_INFO_PTR, uint32_t *);
81 CK_RV kernel_decrypt_init(kernel_session_t *, kernel_object_t *,
82     CK_MECHANISM_PTR);
83 CK_RV kernel_decrypt(kernel_session_t *, CK_BYTE_PTR, CK_ULONG, CK_BYTE_PTR,
84     CK_ULONG_PTR);
85 
86 #ifdef	__cplusplus
87 }
88 #endif
89 
90 #endif /* _KERNELGLOBAL_H */
91