1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _CRYPTOADM_H 28*0Sstevel@tonic-gate #define _CRYPTOADM_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #include <sys/crypto/ioctladmin.h> 33*0Sstevel@tonic-gate #include <cryptoutil.h> 34*0Sstevel@tonic-gate #include <security/cryptoki.h> 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #ifdef __cplusplus 37*0Sstevel@tonic-gate extern "C" { 38*0Sstevel@tonic-gate #endif 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate #define _PATH_KCF_CONF "/etc/crypto/kcf.conf" 41*0Sstevel@tonic-gate #define _PATH_KCFD "/usr/lib/crypto/kcfd" 42*0Sstevel@tonic-gate #define TMPFILE_TEMPLATE "/etc/crypto/admXXXXXX" 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate #define ERROR_USAGE 2 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate /* 47*0Sstevel@tonic-gate * Common keywords and delimiters for pkcs11.conf and kcf.conf files are 48*0Sstevel@tonic-gate * defined in usr/lib/libcryptoutil/common/cryptoutil.h. The following is 49*0Sstevel@tonic-gate * the extra keywords and delimiters used in kcf.conf file. 50*0Sstevel@tonic-gate */ 51*0Sstevel@tonic-gate #define SEP_SLASH '/' 52*0Sstevel@tonic-gate #define EF_SUPPORTED "supportedlist=" 53*0Sstevel@tonic-gate #define HW_DRIVER_STRING "driver_names" 54*0Sstevel@tonic-gate #define RANDOM "random" 55*0Sstevel@tonic-gate #define UEF_FRAME_LIB "/usr/lib/libpkcs11.so" 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate #define ADD_MODE 1 58*0Sstevel@tonic-gate #define DELETE_MODE 2 59*0Sstevel@tonic-gate #define MODIFY_MODE 3 60*0Sstevel@tonic-gate 61*0Sstevel@tonic-gate typedef char prov_name_t[MAXNAMELEN]; 62*0Sstevel@tonic-gate typedef char mech_name_t[CRYPTO_MAX_MECH_NAME]; 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate typedef struct mechlist { 65*0Sstevel@tonic-gate mech_name_t name; 66*0Sstevel@tonic-gate struct mechlist *next; 67*0Sstevel@tonic-gate } mechlist_t; 68*0Sstevel@tonic-gate 69*0Sstevel@tonic-gate 70*0Sstevel@tonic-gate typedef struct entry { 71*0Sstevel@tonic-gate prov_name_t name; 72*0Sstevel@tonic-gate mechlist_t *suplist; /* supported list */ 73*0Sstevel@tonic-gate uint_t sup_count; 74*0Sstevel@tonic-gate mechlist_t *dislist; /* disabled list */ 75*0Sstevel@tonic-gate uint_t dis_count; 76*0Sstevel@tonic-gate } entry_t; 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate typedef struct entrylist { 80*0Sstevel@tonic-gate entry_t *pent; 81*0Sstevel@tonic-gate struct entrylist *next; 82*0Sstevel@tonic-gate } entrylist_t; 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate typedef enum { 85*0Sstevel@tonic-gate NO_RNG, 86*0Sstevel@tonic-gate HAS_RNG 87*0Sstevel@tonic-gate } flag_val_t; 88*0Sstevel@tonic-gate 89*0Sstevel@tonic-gate extern int errno; 90*0Sstevel@tonic-gate 91*0Sstevel@tonic-gate /* adm_util */ 92*0Sstevel@tonic-gate extern boolean_t is_in_list(char *, mechlist_t *); 93*0Sstevel@tonic-gate extern mechlist_t *create_mech(char *); 94*0Sstevel@tonic-gate extern void free_mechlist(mechlist_t *); 95*0Sstevel@tonic-gate 96*0Sstevel@tonic-gate /* adm_kef_util */ 97*0Sstevel@tonic-gate extern boolean_t is_device(char *); 98*0Sstevel@tonic-gate extern char *ent2str(entry_t *); 99*0Sstevel@tonic-gate extern entry_t *getent_kef(char *); 100*0Sstevel@tonic-gate extern int check_active_for_soft(char *, boolean_t *); 101*0Sstevel@tonic-gate extern int check_active_for_hard(char *, boolean_t *); 102*0Sstevel@tonic-gate extern int disable_mechs(entry_t **, mechlist_t *, boolean_t, mechlist_t *); 103*0Sstevel@tonic-gate extern int enable_mechs(entry_t **, boolean_t, mechlist_t *); 104*0Sstevel@tonic-gate extern int get_kcfconf_info(entrylist_t **, entrylist_t **); 105*0Sstevel@tonic-gate extern int get_admindev_info(entrylist_t **, entrylist_t **); 106*0Sstevel@tonic-gate extern int get_mech_count(mechlist_t *); 107*0Sstevel@tonic-gate extern int insert_kcfconf(entry_t *); 108*0Sstevel@tonic-gate extern int split_hw_provname(char *, char *, int *); 109*0Sstevel@tonic-gate extern int update_kcfconf(entry_t *, int); 110*0Sstevel@tonic-gate extern void free_entry(entry_t *); 111*0Sstevel@tonic-gate extern void free_entrylist(entrylist_t *); 112*0Sstevel@tonic-gate extern void print_mechlist(char *, mechlist_t *); 113*0Sstevel@tonic-gate extern void print_kef_policy(entry_t *, boolean_t, boolean_t); 114*0Sstevel@tonic-gate extern boolean_t filter_mechlist(mechlist_t **, const char *); 115*0Sstevel@tonic-gate extern uentry_t *getent_uef(char *); 116*0Sstevel@tonic-gate 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate /* adm_uef */ 119*0Sstevel@tonic-gate extern int list_mechlist_for_lib(char *, mechlist_t *, flag_val_t *, 120*0Sstevel@tonic-gate boolean_t, boolean_t, boolean_t); 121*0Sstevel@tonic-gate extern int list_policy_for_lib(char *); 122*0Sstevel@tonic-gate extern int disable_uef_lib(char *, boolean_t, boolean_t, mechlist_t *); 123*0Sstevel@tonic-gate extern int enable_uef_lib(char *, boolean_t, boolean_t, mechlist_t *); 124*0Sstevel@tonic-gate extern int install_uef_lib(char *); 125*0Sstevel@tonic-gate extern int uninstall_uef_lib(char *); 126*0Sstevel@tonic-gate extern int print_uef_policy(uentry_t *); 127*0Sstevel@tonic-gate extern void display_token_flags(CK_FLAGS flags); 128*0Sstevel@tonic-gate extern int convert_mechlist(CK_MECHANISM_TYPE **, CK_ULONG *, mechlist_t *); 129*0Sstevel@tonic-gate extern void display_verbose_mech_header(); 130*0Sstevel@tonic-gate extern void display_mech_info(CK_MECHANISM_INFO *); 131*0Sstevel@tonic-gate extern int display_policy(uentry_t *); 132*0Sstevel@tonic-gate extern int update_pkcs11conf(uentry_t *); 133*0Sstevel@tonic-gate extern int update_policylist(uentry_t *, mechlist_t *, int); 134*0Sstevel@tonic-gate 135*0Sstevel@tonic-gate /* adm_kef */ 136*0Sstevel@tonic-gate extern int list_mechlist_for_soft(char *); 137*0Sstevel@tonic-gate extern int list_mechlist_for_hard(char *); 138*0Sstevel@tonic-gate extern int list_policy_for_soft(char *); 139*0Sstevel@tonic-gate extern int list_policy_for_hard(char *); 140*0Sstevel@tonic-gate extern int disable_kef_software(char *, boolean_t, boolean_t, mechlist_t *); 141*0Sstevel@tonic-gate extern int disable_kef_hardware(char *, boolean_t, boolean_t, mechlist_t *); 142*0Sstevel@tonic-gate extern int enable_kef(char *, boolean_t, boolean_t, mechlist_t *); 143*0Sstevel@tonic-gate extern int install_kef(char *, mechlist_t *); 144*0Sstevel@tonic-gate extern int uninstall_kef(char *); 145*0Sstevel@tonic-gate extern int unload_kef_soft(char *); 146*0Sstevel@tonic-gate extern int refresh(void); 147*0Sstevel@tonic-gate extern int start_daemon(void); 148*0Sstevel@tonic-gate extern int stop_daemon(void); 149*0Sstevel@tonic-gate 150*0Sstevel@tonic-gate /* adm_ioctl */ 151*0Sstevel@tonic-gate extern crypto_load_soft_config_t *setup_soft_conf(entry_t *); 152*0Sstevel@tonic-gate extern crypto_load_soft_disabled_t *setup_soft_dis(entry_t *); 153*0Sstevel@tonic-gate extern crypto_load_dev_disabled_t *setup_dev_dis(entry_t *); 154*0Sstevel@tonic-gate extern crypto_unload_soft_module_t *setup_unload_soft(entry_t *); 155*0Sstevel@tonic-gate extern int get_dev_info(char *, int, int, mechlist_t **); 156*0Sstevel@tonic-gate extern int get_dev_list(crypto_get_dev_list_t **); 157*0Sstevel@tonic-gate extern int get_soft_info(char *, mechlist_t **); 158*0Sstevel@tonic-gate extern int get_soft_list(crypto_get_soft_list_t **); 159*0Sstevel@tonic-gate 160*0Sstevel@tonic-gate /* adm_metaslot */ 161*0Sstevel@tonic-gate extern int list_metaslot_info(boolean_t, boolean_t, mechlist_t *); 162*0Sstevel@tonic-gate extern int list_metaslot_policy(); 163*0Sstevel@tonic-gate extern int disable_metaslot(mechlist_t *, boolean_t, boolean_t); 164*0Sstevel@tonic-gate extern int enable_metaslot(char *, char *, boolean_t, mechlist_t *, boolean_t, 165*0Sstevel@tonic-gate boolean_t); 166*0Sstevel@tonic-gate 167*0Sstevel@tonic-gate #ifdef __cplusplus 168*0Sstevel@tonic-gate } 169*0Sstevel@tonic-gate #endif 170*0Sstevel@tonic-gate 171*0Sstevel@tonic-gate #endif /* _CRYPTOADM_H */ 172