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 5b8bf75cbSkrishna * Common Development and Distribution License (the "License"). 6b8bf75cbSkrishna * 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*1b22764fSDaniel OpenSolaris Anderson * Copyright 2008 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 29*1b22764fSDaniel OpenSolaris Anderson #include <sys/types.h> 307c478bd9Sstevel@tonic-gate #include <sys/crypto/ioctladmin.h> 317c478bd9Sstevel@tonic-gate #include <cryptoutil.h> 327c478bd9Sstevel@tonic-gate #include <security/cryptoki.h> 337c478bd9Sstevel@tonic-gate 347c478bd9Sstevel@tonic-gate #ifdef __cplusplus 357c478bd9Sstevel@tonic-gate extern "C" { 367c478bd9Sstevel@tonic-gate #endif 377c478bd9Sstevel@tonic-gate 387c478bd9Sstevel@tonic-gate #define _PATH_KCF_CONF "/etc/crypto/kcf.conf" 39baf2c95cSsuha #define _PATH_KCFD "/usr/lib/crypto/kcfd" 407c478bd9Sstevel@tonic-gate #define TMPFILE_TEMPLATE "/etc/crypto/admXXXXXX" 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #define ERROR_USAGE 2 437c478bd9Sstevel@tonic-gate 447c478bd9Sstevel@tonic-gate /* 457c478bd9Sstevel@tonic-gate * Common keywords and delimiters for pkcs11.conf and kcf.conf files are 467c478bd9Sstevel@tonic-gate * defined in usr/lib/libcryptoutil/common/cryptoutil.h. The following is 477c478bd9Sstevel@tonic-gate * the extra keywords and delimiters used in kcf.conf file. 487c478bd9Sstevel@tonic-gate */ 497c478bd9Sstevel@tonic-gate #define SEP_SLASH '/' 507c478bd9Sstevel@tonic-gate #define EF_SUPPORTED "supportedlist=" 51*1b22764fSDaniel OpenSolaris Anderson #define EF_UNLOAD "unload" 527c478bd9Sstevel@tonic-gate #define RANDOM "random" 537c478bd9Sstevel@tonic-gate #define UEF_FRAME_LIB "/usr/lib/libpkcs11.so" 547c478bd9Sstevel@tonic-gate 557c478bd9Sstevel@tonic-gate #define ADD_MODE 1 567c478bd9Sstevel@tonic-gate #define DELETE_MODE 2 577c478bd9Sstevel@tonic-gate #define MODIFY_MODE 3 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate typedef char prov_name_t[MAXNAMELEN]; 607c478bd9Sstevel@tonic-gate typedef char mech_name_t[CRYPTO_MAX_MECH_NAME]; 617c478bd9Sstevel@tonic-gate 627c478bd9Sstevel@tonic-gate typedef struct mechlist { 637c478bd9Sstevel@tonic-gate mech_name_t name; 647c478bd9Sstevel@tonic-gate struct mechlist *next; 657c478bd9Sstevel@tonic-gate } mechlist_t; 667c478bd9Sstevel@tonic-gate 677c478bd9Sstevel@tonic-gate 687c478bd9Sstevel@tonic-gate typedef struct entry { 697c478bd9Sstevel@tonic-gate prov_name_t name; 707c478bd9Sstevel@tonic-gate mechlist_t *suplist; /* supported list */ 717c478bd9Sstevel@tonic-gate uint_t sup_count; 727c478bd9Sstevel@tonic-gate mechlist_t *dislist; /* disabled list */ 737c478bd9Sstevel@tonic-gate uint_t dis_count; 74*1b22764fSDaniel OpenSolaris Anderson boolean_t load; /* B_FALSE after cryptoadm unload */ 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 *); 98*1b22764fSDaniel OpenSolaris Anderson extern entry_t *getent_kef(char *provname, 99*1b22764fSDaniel OpenSolaris Anderson entrylist_t *pdevlist, entrylist_t *psoftlist); 100*1b22764fSDaniel OpenSolaris Anderson extern int check_kernel_for_soft(char *provname, 101*1b22764fSDaniel OpenSolaris Anderson crypto_get_soft_list_t *psoftlist, boolean_t *in_kernel); 102*1b22764fSDaniel OpenSolaris Anderson extern int check_kernel_for_hard(char *provname, 103*1b22764fSDaniel OpenSolaris Anderson crypto_get_dev_list_t *pdevlist, boolean_t *in_kernel); 1047c478bd9Sstevel@tonic-gate extern int disable_mechs(entry_t **, mechlist_t *, boolean_t, mechlist_t *); 1057c478bd9Sstevel@tonic-gate extern int enable_mechs(entry_t **, boolean_t, mechlist_t *); 1067c478bd9Sstevel@tonic-gate extern int get_kcfconf_info(entrylist_t **, entrylist_t **); 1077c478bd9Sstevel@tonic-gate extern int get_admindev_info(entrylist_t **, entrylist_t **); 1087c478bd9Sstevel@tonic-gate extern int get_mech_count(mechlist_t *); 109*1b22764fSDaniel OpenSolaris Anderson extern entry_t *create_entry(char *provname); 1107c478bd9Sstevel@tonic-gate extern int insert_kcfconf(entry_t *); 1117c478bd9Sstevel@tonic-gate extern int split_hw_provname(char *, char *, int *); 1127c478bd9Sstevel@tonic-gate extern int update_kcfconf(entry_t *, int); 1137c478bd9Sstevel@tonic-gate extern void free_entry(entry_t *); 1147c478bd9Sstevel@tonic-gate extern void free_entrylist(entrylist_t *); 1157c478bd9Sstevel@tonic-gate extern void print_mechlist(char *, mechlist_t *); 116*1b22764fSDaniel OpenSolaris Anderson extern void print_kef_policy(char *provname, entry_t *pent, 117*1b22764fSDaniel OpenSolaris Anderson boolean_t has_random, boolean_t has_mechs); 1187c478bd9Sstevel@tonic-gate extern boolean_t filter_mechlist(mechlist_t **, const char *); 1197c478bd9Sstevel@tonic-gate extern uentry_t *getent_uef(char *); 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate 1227c478bd9Sstevel@tonic-gate /* adm_uef */ 1237c478bd9Sstevel@tonic-gate extern int list_mechlist_for_lib(char *, mechlist_t *, flag_val_t *, 1247c478bd9Sstevel@tonic-gate boolean_t, boolean_t, boolean_t); 1257c478bd9Sstevel@tonic-gate extern int list_policy_for_lib(char *); 1267c478bd9Sstevel@tonic-gate extern int disable_uef_lib(char *, boolean_t, boolean_t, mechlist_t *); 1277c478bd9Sstevel@tonic-gate extern int enable_uef_lib(char *, boolean_t, boolean_t, mechlist_t *); 1287c478bd9Sstevel@tonic-gate extern int install_uef_lib(char *); 1297c478bd9Sstevel@tonic-gate extern int uninstall_uef_lib(char *); 1307c478bd9Sstevel@tonic-gate extern int print_uef_policy(uentry_t *); 1317c478bd9Sstevel@tonic-gate extern void display_token_flags(CK_FLAGS flags); 1327c478bd9Sstevel@tonic-gate extern int convert_mechlist(CK_MECHANISM_TYPE **, CK_ULONG *, mechlist_t *); 1337c478bd9Sstevel@tonic-gate extern void display_verbose_mech_header(); 1347c478bd9Sstevel@tonic-gate extern void display_mech_info(CK_MECHANISM_INFO *); 1357c478bd9Sstevel@tonic-gate extern int display_policy(uentry_t *); 1367c478bd9Sstevel@tonic-gate extern int update_pkcs11conf(uentry_t *); 1377c478bd9Sstevel@tonic-gate extern int update_policylist(uentry_t *, mechlist_t *, int); 1387c478bd9Sstevel@tonic-gate 1397c478bd9Sstevel@tonic-gate /* adm_kef */ 140*1b22764fSDaniel OpenSolaris Anderson extern int list_mechlist_for_soft(char *provname, 141*1b22764fSDaniel OpenSolaris Anderson entrylist_t *phardlist, entrylist_t *psoftlist); 1427c478bd9Sstevel@tonic-gate extern int list_mechlist_for_hard(char *); 143*1b22764fSDaniel OpenSolaris Anderson extern int list_policy_for_soft(char *provname, 144*1b22764fSDaniel OpenSolaris Anderson entrylist_t *phardlist, entrylist_t *psoftlist); 145*1b22764fSDaniel OpenSolaris Anderson extern int list_policy_for_hard(char *provname, 146*1b22764fSDaniel OpenSolaris Anderson entrylist_t *phardlist, entrylist_t *psoftlist, 147*1b22764fSDaniel OpenSolaris Anderson crypto_get_dev_list_t *pdevlist); 1487c478bd9Sstevel@tonic-gate extern int disable_kef_software(char *, boolean_t, boolean_t, mechlist_t *); 1497c478bd9Sstevel@tonic-gate extern int disable_kef_hardware(char *, boolean_t, boolean_t, mechlist_t *); 1507c478bd9Sstevel@tonic-gate extern int enable_kef(char *, boolean_t, boolean_t, mechlist_t *); 1517c478bd9Sstevel@tonic-gate extern int install_kef(char *, mechlist_t *); 1527c478bd9Sstevel@tonic-gate extern int uninstall_kef(char *); 153*1b22764fSDaniel OpenSolaris Anderson extern int unload_kef_soft(char *provname); 1547c478bd9Sstevel@tonic-gate extern int refresh(void); 1557c478bd9Sstevel@tonic-gate extern int start_daemon(void); 1567c478bd9Sstevel@tonic-gate extern int stop_daemon(void); 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate /* adm_ioctl */ 1597c478bd9Sstevel@tonic-gate extern crypto_load_soft_config_t *setup_soft_conf(entry_t *); 1607c478bd9Sstevel@tonic-gate extern crypto_load_soft_disabled_t *setup_soft_dis(entry_t *); 1617c478bd9Sstevel@tonic-gate extern crypto_load_dev_disabled_t *setup_dev_dis(entry_t *); 1627c478bd9Sstevel@tonic-gate extern crypto_unload_soft_module_t *setup_unload_soft(entry_t *); 1637c478bd9Sstevel@tonic-gate extern int get_dev_info(char *, int, int, mechlist_t **); 1647c478bd9Sstevel@tonic-gate extern int get_dev_list(crypto_get_dev_list_t **); 165*1b22764fSDaniel OpenSolaris Anderson extern int get_soft_info(char *provname, mechlist_t **ppmechlist, 166*1b22764fSDaniel OpenSolaris Anderson entrylist_t *phardlist, entrylist_t *psoftlist); 1677c478bd9Sstevel@tonic-gate extern int get_soft_list(crypto_get_soft_list_t **); 1687c478bd9Sstevel@tonic-gate 1697c478bd9Sstevel@tonic-gate /* adm_metaslot */ 1707c478bd9Sstevel@tonic-gate extern int list_metaslot_info(boolean_t, boolean_t, mechlist_t *); 1717c478bd9Sstevel@tonic-gate extern int list_metaslot_policy(); 1727c478bd9Sstevel@tonic-gate extern int disable_metaslot(mechlist_t *, boolean_t, boolean_t); 1737c478bd9Sstevel@tonic-gate extern int enable_metaslot(char *, char *, boolean_t, mechlist_t *, boolean_t, 1747c478bd9Sstevel@tonic-gate boolean_t); 1757c478bd9Sstevel@tonic-gate 1767c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1777c478bd9Sstevel@tonic-gate } 1787c478bd9Sstevel@tonic-gate #endif 1797c478bd9Sstevel@tonic-gate 1807c478bd9Sstevel@tonic-gate #endif /* _CRYPTOADM_H */ 181