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