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
51971Skrishna  * Common Development and Distribution License (the "License").
61971Skrishna  * 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 /*
22*7291Ssuha  * Copyright 2006 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	_CRYPTOADM_H
270Sstevel@tonic-gate #define	_CRYPTOADM_H
280Sstevel@tonic-gate 
290Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
300Sstevel@tonic-gate 
310Sstevel@tonic-gate #include <sys/crypto/ioctladmin.h>
320Sstevel@tonic-gate #include <cryptoutil.h>
330Sstevel@tonic-gate #include <security/cryptoki.h>
340Sstevel@tonic-gate 
350Sstevel@tonic-gate #ifdef __cplusplus
360Sstevel@tonic-gate extern "C" {
370Sstevel@tonic-gate #endif
380Sstevel@tonic-gate 
390Sstevel@tonic-gate #define	_PATH_KCF_CONF		"/etc/crypto/kcf.conf"
40*7291Ssuha #define	_PATH_KCFD		"/usr/lib/crypto/kcfd"
410Sstevel@tonic-gate #define	TMPFILE_TEMPLATE	"/etc/crypto/admXXXXXX"
420Sstevel@tonic-gate 
430Sstevel@tonic-gate #define	ERROR_USAGE	2
440Sstevel@tonic-gate 
450Sstevel@tonic-gate /*
460Sstevel@tonic-gate  * Common keywords and delimiters for pkcs11.conf and kcf.conf files are
470Sstevel@tonic-gate  * defined in usr/lib/libcryptoutil/common/cryptoutil.h.  The following is
480Sstevel@tonic-gate  * the extra keywords and delimiters used in kcf.conf file.
490Sstevel@tonic-gate  */
500Sstevel@tonic-gate #define	SEP_SLASH		'/'
510Sstevel@tonic-gate #define	EF_SUPPORTED		"supportedlist="
520Sstevel@tonic-gate #define	HW_DRIVER_STRING	"driver_names"
530Sstevel@tonic-gate #define	RANDOM			"random"
540Sstevel@tonic-gate #define	UEF_FRAME_LIB		"/usr/lib/libpkcs11.so"
550Sstevel@tonic-gate 
560Sstevel@tonic-gate #define	ADD_MODE	1
570Sstevel@tonic-gate #define	DELETE_MODE	2
580Sstevel@tonic-gate #define	MODIFY_MODE	3
590Sstevel@tonic-gate 
600Sstevel@tonic-gate typedef char prov_name_t[MAXNAMELEN];
610Sstevel@tonic-gate typedef char mech_name_t[CRYPTO_MAX_MECH_NAME];
620Sstevel@tonic-gate 
630Sstevel@tonic-gate typedef struct mechlist {
640Sstevel@tonic-gate 	mech_name_t	name;
650Sstevel@tonic-gate 	struct mechlist	*next;
660Sstevel@tonic-gate } mechlist_t;
670Sstevel@tonic-gate 
680Sstevel@tonic-gate 
690Sstevel@tonic-gate typedef struct entry {
700Sstevel@tonic-gate 	prov_name_t	name;
710Sstevel@tonic-gate 	mechlist_t	*suplist; /* supported list */
720Sstevel@tonic-gate 	uint_t 		sup_count;
730Sstevel@tonic-gate 	mechlist_t	*dislist; /* disabled list */
740Sstevel@tonic-gate 	uint_t 		dis_count;
750Sstevel@tonic-gate } entry_t;
760Sstevel@tonic-gate 
770Sstevel@tonic-gate 
780Sstevel@tonic-gate typedef struct entrylist {
790Sstevel@tonic-gate 	entry_t	*pent;
800Sstevel@tonic-gate 	struct entrylist *next;
810Sstevel@tonic-gate } entrylist_t;
820Sstevel@tonic-gate 
830Sstevel@tonic-gate typedef enum {
840Sstevel@tonic-gate 	NO_RNG,
850Sstevel@tonic-gate 	HAS_RNG
860Sstevel@tonic-gate } flag_val_t;
870Sstevel@tonic-gate 
880Sstevel@tonic-gate extern int errno;
890Sstevel@tonic-gate 
900Sstevel@tonic-gate /* adm_util */
910Sstevel@tonic-gate extern boolean_t is_in_list(char *, mechlist_t *);
920Sstevel@tonic-gate extern mechlist_t *create_mech(char *);
930Sstevel@tonic-gate extern void free_mechlist(mechlist_t *);
940Sstevel@tonic-gate 
950Sstevel@tonic-gate /* adm_kef_util */
960Sstevel@tonic-gate extern boolean_t is_device(char *);
970Sstevel@tonic-gate extern char *ent2str(entry_t *);
980Sstevel@tonic-gate extern entry_t *getent_kef(char *);
990Sstevel@tonic-gate extern int check_active_for_soft(char *, boolean_t *);
1000Sstevel@tonic-gate extern int check_active_for_hard(char *, boolean_t *);
1010Sstevel@tonic-gate extern int disable_mechs(entry_t **, mechlist_t *, boolean_t, mechlist_t *);
1020Sstevel@tonic-gate extern int enable_mechs(entry_t **, boolean_t, mechlist_t *);
1030Sstevel@tonic-gate extern int get_kcfconf_info(entrylist_t **, entrylist_t **);
1040Sstevel@tonic-gate extern int get_admindev_info(entrylist_t **, entrylist_t **);
1050Sstevel@tonic-gate extern int get_mech_count(mechlist_t *);
1060Sstevel@tonic-gate extern int insert_kcfconf(entry_t *);
1070Sstevel@tonic-gate extern int split_hw_provname(char *, char *, int *);
1080Sstevel@tonic-gate extern int update_kcfconf(entry_t *, int);
1090Sstevel@tonic-gate extern void free_entry(entry_t *);
1100Sstevel@tonic-gate extern void free_entrylist(entrylist_t *);
1110Sstevel@tonic-gate extern void print_mechlist(char *, mechlist_t *);
1120Sstevel@tonic-gate extern void print_kef_policy(entry_t *, boolean_t, boolean_t);
1130Sstevel@tonic-gate extern boolean_t filter_mechlist(mechlist_t **, const char *);
1140Sstevel@tonic-gate extern uentry_t *getent_uef(char *);
1150Sstevel@tonic-gate 
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate /* adm_uef */
1180Sstevel@tonic-gate extern int list_mechlist_for_lib(char *, mechlist_t *, flag_val_t *,
1190Sstevel@tonic-gate 		boolean_t, boolean_t, boolean_t);
1200Sstevel@tonic-gate extern int list_policy_for_lib(char *);
1210Sstevel@tonic-gate extern int disable_uef_lib(char *, boolean_t, boolean_t, mechlist_t *);
1220Sstevel@tonic-gate extern int enable_uef_lib(char *, boolean_t, boolean_t, mechlist_t *);
1230Sstevel@tonic-gate extern int install_uef_lib(char *);
1240Sstevel@tonic-gate extern int uninstall_uef_lib(char *);
1250Sstevel@tonic-gate extern int print_uef_policy(uentry_t *);
1260Sstevel@tonic-gate extern void display_token_flags(CK_FLAGS flags);
1270Sstevel@tonic-gate extern int convert_mechlist(CK_MECHANISM_TYPE **, CK_ULONG *, mechlist_t *);
1280Sstevel@tonic-gate extern void display_verbose_mech_header();
1290Sstevel@tonic-gate extern void display_mech_info(CK_MECHANISM_INFO *);
1300Sstevel@tonic-gate extern int display_policy(uentry_t *);
1310Sstevel@tonic-gate extern int update_pkcs11conf(uentry_t *);
1320Sstevel@tonic-gate extern int update_policylist(uentry_t *, mechlist_t *, int);
1330Sstevel@tonic-gate 
1340Sstevel@tonic-gate /* adm_kef */
1350Sstevel@tonic-gate extern int list_mechlist_for_soft(char *);
1360Sstevel@tonic-gate extern int list_mechlist_for_hard(char *);
1370Sstevel@tonic-gate extern int list_policy_for_soft(char *);
1380Sstevel@tonic-gate extern int list_policy_for_hard(char *);
1390Sstevel@tonic-gate extern int disable_kef_software(char *, boolean_t, boolean_t, mechlist_t *);
1400Sstevel@tonic-gate extern int disable_kef_hardware(char *, boolean_t, boolean_t, mechlist_t *);
1410Sstevel@tonic-gate extern int enable_kef(char *, boolean_t, boolean_t, mechlist_t *);
1420Sstevel@tonic-gate extern int install_kef(char *, mechlist_t *);
1430Sstevel@tonic-gate extern int uninstall_kef(char *);
1441971Skrishna extern int unload_kef_soft(char *, boolean_t);
1450Sstevel@tonic-gate extern int refresh(void);
1460Sstevel@tonic-gate extern int start_daemon(void);
1470Sstevel@tonic-gate extern int stop_daemon(void);
1480Sstevel@tonic-gate 
1490Sstevel@tonic-gate /* adm_ioctl */
1500Sstevel@tonic-gate extern crypto_load_soft_config_t *setup_soft_conf(entry_t *);
1510Sstevel@tonic-gate extern crypto_load_soft_disabled_t *setup_soft_dis(entry_t *);
1520Sstevel@tonic-gate extern crypto_load_dev_disabled_t *setup_dev_dis(entry_t *);
1530Sstevel@tonic-gate extern crypto_unload_soft_module_t *setup_unload_soft(entry_t *);
1540Sstevel@tonic-gate extern int get_dev_info(char *, int, int, mechlist_t **);
1550Sstevel@tonic-gate extern int get_dev_list(crypto_get_dev_list_t **);
1560Sstevel@tonic-gate extern int get_soft_info(char *, mechlist_t **);
1570Sstevel@tonic-gate extern int get_soft_list(crypto_get_soft_list_t **);
1580Sstevel@tonic-gate 
1590Sstevel@tonic-gate /* adm_metaslot */
1600Sstevel@tonic-gate extern int list_metaslot_info(boolean_t, boolean_t, mechlist_t *);
1610Sstevel@tonic-gate extern int list_metaslot_policy();
1620Sstevel@tonic-gate extern int disable_metaslot(mechlist_t *, boolean_t, boolean_t);
1630Sstevel@tonic-gate extern int enable_metaslot(char *, char *, boolean_t, mechlist_t *, boolean_t,
1640Sstevel@tonic-gate     boolean_t);
1650Sstevel@tonic-gate 
1660Sstevel@tonic-gate #ifdef __cplusplus
1670Sstevel@tonic-gate }
1680Sstevel@tonic-gate #endif
1690Sstevel@tonic-gate 
1700Sstevel@tonic-gate #endif /* _CRYPTOADM_H */
171