xref: /titanic_52/usr/src/cmd/cmd-crypto/cryptoadm/cryptoadm.h (revision 9512fe850e98fdd448c638ca63fdd92a8a510255)
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 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_CRYPTOADM_H
27 #define	_CRYPTOADM_H
28 
29 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/crypto/ioctladmin.h>
32 #include <cryptoutil.h>
33 #include <security/cryptoki.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #define	_PATH_KCF_CONF		"/etc/crypto/kcf.conf"
40 #define	_PATH_KCFD		"/usr/lib/crypto/kcfd"
41 #define	TMPFILE_TEMPLATE	"/etc/crypto/admXXXXXX"
42 
43 #define	ERROR_USAGE	2
44 
45 /*
46  * Common keywords and delimiters for pkcs11.conf and kcf.conf files are
47  * defined in usr/lib/libcryptoutil/common/cryptoutil.h.  The following is
48  * the extra keywords and delimiters used in kcf.conf file.
49  */
50 #define	SEP_SLASH		'/'
51 #define	EF_SUPPORTED		"supportedlist="
52 #define	HW_DRIVER_STRING	"driver_names"
53 #define	RANDOM			"random"
54 #define	UEF_FRAME_LIB		"/usr/lib/libpkcs11.so"
55 
56 #define	ADD_MODE	1
57 #define	DELETE_MODE	2
58 #define	MODIFY_MODE	3
59 
60 typedef char prov_name_t[MAXNAMELEN];
61 typedef char mech_name_t[CRYPTO_MAX_MECH_NAME];
62 
63 typedef struct mechlist {
64 	mech_name_t	name;
65 	struct mechlist	*next;
66 } mechlist_t;
67 
68 
69 typedef struct entry {
70 	prov_name_t	name;
71 	mechlist_t	*suplist; /* supported list */
72 	uint_t 		sup_count;
73 	mechlist_t	*dislist; /* disabled list */
74 	uint_t 		dis_count;
75 } entry_t;
76 
77 
78 typedef struct entrylist {
79 	entry_t	*pent;
80 	struct entrylist *next;
81 } entrylist_t;
82 
83 typedef enum {
84 	NO_RNG,
85 	HAS_RNG
86 } flag_val_t;
87 
88 extern int errno;
89 
90 /* adm_util */
91 extern boolean_t is_in_list(char *, mechlist_t *);
92 extern mechlist_t *create_mech(char *);
93 extern void free_mechlist(mechlist_t *);
94 
95 /* adm_kef_util */
96 extern boolean_t is_device(char *);
97 extern char *ent2str(entry_t *);
98 extern entry_t *getent_kef(char *);
99 extern int check_active_for_soft(char *, boolean_t *);
100 extern int check_active_for_hard(char *, boolean_t *);
101 extern int disable_mechs(entry_t **, mechlist_t *, boolean_t, mechlist_t *);
102 extern int enable_mechs(entry_t **, boolean_t, mechlist_t *);
103 extern int get_kcfconf_info(entrylist_t **, entrylist_t **);
104 extern int get_admindev_info(entrylist_t **, entrylist_t **);
105 extern int get_mech_count(mechlist_t *);
106 extern int insert_kcfconf(entry_t *);
107 extern int split_hw_provname(char *, char *, int *);
108 extern int update_kcfconf(entry_t *, int);
109 extern void free_entry(entry_t *);
110 extern void free_entrylist(entrylist_t *);
111 extern void print_mechlist(char *, mechlist_t *);
112 extern void print_kef_policy(entry_t *, boolean_t, boolean_t);
113 extern boolean_t filter_mechlist(mechlist_t **, const char *);
114 extern uentry_t *getent_uef(char *);
115 
116 
117 /* adm_uef */
118 extern int list_mechlist_for_lib(char *, mechlist_t *, flag_val_t *,
119 		boolean_t, boolean_t, boolean_t);
120 extern int list_policy_for_lib(char *);
121 extern int disable_uef_lib(char *, boolean_t, boolean_t, mechlist_t *);
122 extern int enable_uef_lib(char *, boolean_t, boolean_t, mechlist_t *);
123 extern int install_uef_lib(char *);
124 extern int uninstall_uef_lib(char *);
125 extern int print_uef_policy(uentry_t *);
126 extern void display_token_flags(CK_FLAGS flags);
127 extern int convert_mechlist(CK_MECHANISM_TYPE **, CK_ULONG *, mechlist_t *);
128 extern void display_verbose_mech_header();
129 extern void display_mech_info(CK_MECHANISM_INFO *);
130 extern int display_policy(uentry_t *);
131 extern int update_pkcs11conf(uentry_t *);
132 extern int update_policylist(uentry_t *, mechlist_t *, int);
133 
134 /* adm_kef */
135 extern int list_mechlist_for_soft(char *);
136 extern int list_mechlist_for_hard(char *);
137 extern int list_policy_for_soft(char *);
138 extern int list_policy_for_hard(char *);
139 extern int disable_kef_software(char *, boolean_t, boolean_t, mechlist_t *);
140 extern int disable_kef_hardware(char *, boolean_t, boolean_t, mechlist_t *);
141 extern int enable_kef(char *, boolean_t, boolean_t, mechlist_t *);
142 extern int install_kef(char *, mechlist_t *);
143 extern int uninstall_kef(char *);
144 extern int unload_kef_soft(char *, boolean_t);
145 extern int refresh(void);
146 extern int start_daemon(void);
147 extern int stop_daemon(void);
148 
149 /* adm_ioctl */
150 extern crypto_load_soft_config_t *setup_soft_conf(entry_t *);
151 extern crypto_load_soft_disabled_t *setup_soft_dis(entry_t *);
152 extern crypto_load_dev_disabled_t *setup_dev_dis(entry_t *);
153 extern crypto_unload_soft_module_t *setup_unload_soft(entry_t *);
154 extern int get_dev_info(char *, int, int, mechlist_t **);
155 extern int get_dev_list(crypto_get_dev_list_t **);
156 extern int get_soft_info(char *, mechlist_t **);
157 extern int get_soft_list(crypto_get_soft_list_t **);
158 
159 /* adm_metaslot */
160 extern int list_metaslot_info(boolean_t, boolean_t, mechlist_t *);
161 extern int list_metaslot_policy();
162 extern int disable_metaslot(mechlist_t *, boolean_t, boolean_t);
163 extern int enable_metaslot(char *, char *, boolean_t, mechlist_t *, boolean_t,
164     boolean_t);
165 
166 #ifdef __cplusplus
167 }
168 #endif
169 
170 #endif /* _CRYPTOADM_H */
171