xref: /titanic_53/usr/src/cmd/cmd-crypto/cryptoadm/cryptoadm.h (revision b8bf75cb74c7cf11bde9dc90fb021429968d7654)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*b8bf75cbSkrishna  * Common Development and Distribution License (the "License").
6*b8bf75cbSkrishna  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*b8bf75cbSkrishna  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_CRYPTOADM_H
277c478bd9Sstevel@tonic-gate #define	_CRYPTOADM_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/crypto/ioctladmin.h>
327c478bd9Sstevel@tonic-gate #include <cryptoutil.h>
337c478bd9Sstevel@tonic-gate #include <security/cryptoki.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifdef __cplusplus
367c478bd9Sstevel@tonic-gate extern "C" {
377c478bd9Sstevel@tonic-gate #endif
387c478bd9Sstevel@tonic-gate 
397c478bd9Sstevel@tonic-gate #define	_PATH_KCF_CONF		"/etc/crypto/kcf.conf"
407c478bd9Sstevel@tonic-gate #define	_PATH_KCFD		"/usr/lib/crypto/kcfd"
417c478bd9Sstevel@tonic-gate #define	TMPFILE_TEMPLATE	"/etc/crypto/admXXXXXX"
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate #define	ERROR_USAGE	2
447c478bd9Sstevel@tonic-gate 
457c478bd9Sstevel@tonic-gate /*
467c478bd9Sstevel@tonic-gate  * Common keywords and delimiters for pkcs11.conf and kcf.conf files are
477c478bd9Sstevel@tonic-gate  * defined in usr/lib/libcryptoutil/common/cryptoutil.h.  The following is
487c478bd9Sstevel@tonic-gate  * the extra keywords and delimiters used in kcf.conf file.
497c478bd9Sstevel@tonic-gate  */
507c478bd9Sstevel@tonic-gate #define	SEP_SLASH		'/'
517c478bd9Sstevel@tonic-gate #define	EF_SUPPORTED		"supportedlist="
527c478bd9Sstevel@tonic-gate #define	HW_DRIVER_STRING	"driver_names"
537c478bd9Sstevel@tonic-gate #define	RANDOM			"random"
547c478bd9Sstevel@tonic-gate #define	UEF_FRAME_LIB		"/usr/lib/libpkcs11.so"
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate #define	ADD_MODE	1
577c478bd9Sstevel@tonic-gate #define	DELETE_MODE	2
587c478bd9Sstevel@tonic-gate #define	MODIFY_MODE	3
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate typedef char prov_name_t[MAXNAMELEN];
617c478bd9Sstevel@tonic-gate typedef char mech_name_t[CRYPTO_MAX_MECH_NAME];
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate typedef struct mechlist {
647c478bd9Sstevel@tonic-gate 	mech_name_t	name;
657c478bd9Sstevel@tonic-gate 	struct mechlist	*next;
667c478bd9Sstevel@tonic-gate } mechlist_t;
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate 
697c478bd9Sstevel@tonic-gate typedef struct entry {
707c478bd9Sstevel@tonic-gate 	prov_name_t	name;
717c478bd9Sstevel@tonic-gate 	mechlist_t	*suplist; /* supported list */
727c478bd9Sstevel@tonic-gate 	uint_t 		sup_count;
737c478bd9Sstevel@tonic-gate 	mechlist_t	*dislist; /* disabled list */
747c478bd9Sstevel@tonic-gate 	uint_t 		dis_count;
757c478bd9Sstevel@tonic-gate } entry_t;
767c478bd9Sstevel@tonic-gate 
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate typedef struct entrylist {
797c478bd9Sstevel@tonic-gate 	entry_t	*pent;
807c478bd9Sstevel@tonic-gate 	struct entrylist *next;
817c478bd9Sstevel@tonic-gate } entrylist_t;
827c478bd9Sstevel@tonic-gate 
837c478bd9Sstevel@tonic-gate typedef enum {
847c478bd9Sstevel@tonic-gate 	NO_RNG,
857c478bd9Sstevel@tonic-gate 	HAS_RNG
867c478bd9Sstevel@tonic-gate } flag_val_t;
877c478bd9Sstevel@tonic-gate 
887c478bd9Sstevel@tonic-gate extern int errno;
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate /* adm_util */
917c478bd9Sstevel@tonic-gate extern boolean_t is_in_list(char *, mechlist_t *);
927c478bd9Sstevel@tonic-gate extern mechlist_t *create_mech(char *);
937c478bd9Sstevel@tonic-gate extern void free_mechlist(mechlist_t *);
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate /* adm_kef_util */
967c478bd9Sstevel@tonic-gate extern boolean_t is_device(char *);
977c478bd9Sstevel@tonic-gate extern char *ent2str(entry_t *);
987c478bd9Sstevel@tonic-gate extern entry_t *getent_kef(char *);
997c478bd9Sstevel@tonic-gate extern int check_active_for_soft(char *, boolean_t *);
1007c478bd9Sstevel@tonic-gate extern int check_active_for_hard(char *, boolean_t *);
1017c478bd9Sstevel@tonic-gate extern int disable_mechs(entry_t **, mechlist_t *, boolean_t, mechlist_t *);
1027c478bd9Sstevel@tonic-gate extern int enable_mechs(entry_t **, boolean_t, mechlist_t *);
1037c478bd9Sstevel@tonic-gate extern int get_kcfconf_info(entrylist_t **, entrylist_t **);
1047c478bd9Sstevel@tonic-gate extern int get_admindev_info(entrylist_t **, entrylist_t **);
1057c478bd9Sstevel@tonic-gate extern int get_mech_count(mechlist_t *);
1067c478bd9Sstevel@tonic-gate extern int insert_kcfconf(entry_t *);
1077c478bd9Sstevel@tonic-gate extern int split_hw_provname(char *, char *, int *);
1087c478bd9Sstevel@tonic-gate extern int update_kcfconf(entry_t *, int);
1097c478bd9Sstevel@tonic-gate extern void free_entry(entry_t *);
1107c478bd9Sstevel@tonic-gate extern void free_entrylist(entrylist_t *);
1117c478bd9Sstevel@tonic-gate extern void print_mechlist(char *, mechlist_t *);
1127c478bd9Sstevel@tonic-gate extern void print_kef_policy(entry_t *, boolean_t, boolean_t);
1137c478bd9Sstevel@tonic-gate extern boolean_t filter_mechlist(mechlist_t **, const char *);
1147c478bd9Sstevel@tonic-gate extern uentry_t *getent_uef(char *);
1157c478bd9Sstevel@tonic-gate 
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate /* adm_uef */
1187c478bd9Sstevel@tonic-gate extern int list_mechlist_for_lib(char *, mechlist_t *, flag_val_t *,
1197c478bd9Sstevel@tonic-gate 		boolean_t, boolean_t, boolean_t);
1207c478bd9Sstevel@tonic-gate extern int list_policy_for_lib(char *);
1217c478bd9Sstevel@tonic-gate extern int disable_uef_lib(char *, boolean_t, boolean_t, mechlist_t *);
1227c478bd9Sstevel@tonic-gate extern int enable_uef_lib(char *, boolean_t, boolean_t, mechlist_t *);
1237c478bd9Sstevel@tonic-gate extern int install_uef_lib(char *);
1247c478bd9Sstevel@tonic-gate extern int uninstall_uef_lib(char *);
1257c478bd9Sstevel@tonic-gate extern int print_uef_policy(uentry_t *);
1267c478bd9Sstevel@tonic-gate extern void display_token_flags(CK_FLAGS flags);
1277c478bd9Sstevel@tonic-gate extern int convert_mechlist(CK_MECHANISM_TYPE **, CK_ULONG *, mechlist_t *);
1287c478bd9Sstevel@tonic-gate extern void display_verbose_mech_header();
1297c478bd9Sstevel@tonic-gate extern void display_mech_info(CK_MECHANISM_INFO *);
1307c478bd9Sstevel@tonic-gate extern int display_policy(uentry_t *);
1317c478bd9Sstevel@tonic-gate extern int update_pkcs11conf(uentry_t *);
1327c478bd9Sstevel@tonic-gate extern int update_policylist(uentry_t *, mechlist_t *, int);
1337c478bd9Sstevel@tonic-gate 
1347c478bd9Sstevel@tonic-gate /* adm_kef */
1357c478bd9Sstevel@tonic-gate extern int list_mechlist_for_soft(char *);
1367c478bd9Sstevel@tonic-gate extern int list_mechlist_for_hard(char *);
1377c478bd9Sstevel@tonic-gate extern int list_policy_for_soft(char *);
1387c478bd9Sstevel@tonic-gate extern int list_policy_for_hard(char *);
1397c478bd9Sstevel@tonic-gate extern int disable_kef_software(char *, boolean_t, boolean_t, mechlist_t *);
1407c478bd9Sstevel@tonic-gate extern int disable_kef_hardware(char *, boolean_t, boolean_t, mechlist_t *);
1417c478bd9Sstevel@tonic-gate extern int enable_kef(char *, boolean_t, boolean_t, mechlist_t *);
1427c478bd9Sstevel@tonic-gate extern int install_kef(char *, mechlist_t *);
1437c478bd9Sstevel@tonic-gate extern int uninstall_kef(char *);
144*b8bf75cbSkrishna extern int unload_kef_soft(char *, boolean_t);
1457c478bd9Sstevel@tonic-gate extern int refresh(void);
1467c478bd9Sstevel@tonic-gate extern int start_daemon(void);
1477c478bd9Sstevel@tonic-gate extern int stop_daemon(void);
1487c478bd9Sstevel@tonic-gate 
1497c478bd9Sstevel@tonic-gate /* adm_ioctl */
1507c478bd9Sstevel@tonic-gate extern crypto_load_soft_config_t *setup_soft_conf(entry_t *);
1517c478bd9Sstevel@tonic-gate extern crypto_load_soft_disabled_t *setup_soft_dis(entry_t *);
1527c478bd9Sstevel@tonic-gate extern crypto_load_dev_disabled_t *setup_dev_dis(entry_t *);
1537c478bd9Sstevel@tonic-gate extern crypto_unload_soft_module_t *setup_unload_soft(entry_t *);
1547c478bd9Sstevel@tonic-gate extern int get_dev_info(char *, int, int, mechlist_t **);
1557c478bd9Sstevel@tonic-gate extern int get_dev_list(crypto_get_dev_list_t **);
1567c478bd9Sstevel@tonic-gate extern int get_soft_info(char *, mechlist_t **);
1577c478bd9Sstevel@tonic-gate extern int get_soft_list(crypto_get_soft_list_t **);
1587c478bd9Sstevel@tonic-gate 
1597c478bd9Sstevel@tonic-gate /* adm_metaslot */
1607c478bd9Sstevel@tonic-gate extern int list_metaslot_info(boolean_t, boolean_t, mechlist_t *);
1617c478bd9Sstevel@tonic-gate extern int list_metaslot_policy();
1627c478bd9Sstevel@tonic-gate extern int disable_metaslot(mechlist_t *, boolean_t, boolean_t);
1637c478bd9Sstevel@tonic-gate extern int enable_metaslot(char *, char *, boolean_t, mechlist_t *, boolean_t,
1647c478bd9Sstevel@tonic-gate     boolean_t);
1657c478bd9Sstevel@tonic-gate 
1667c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1677c478bd9Sstevel@tonic-gate }
1687c478bd9Sstevel@tonic-gate #endif
1697c478bd9Sstevel@tonic-gate 
1707c478bd9Sstevel@tonic-gate #endif /* _CRYPTOADM_H */
171