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