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 /* 22b5a2d845SHai-May Chao * Copyright 2009 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 291b22764fSDaniel 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 38257873cfSJohn.Zolnowsky@Sun.COM #define _PATH_KCFD "/lib/crypto/kcfd" 397c478bd9Sstevel@tonic-gate #define TMPFILE_TEMPLATE "/etc/crypto/admXXXXXX" 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate #define ERROR_USAGE 2 427c478bd9Sstevel@tonic-gate 437c478bd9Sstevel@tonic-gate /* 447c478bd9Sstevel@tonic-gate * Common keywords and delimiters for pkcs11.conf and kcf.conf files are 457c478bd9Sstevel@tonic-gate * defined in usr/lib/libcryptoutil/common/cryptoutil.h. The following is 467c478bd9Sstevel@tonic-gate * the extra keywords and delimiters used in kcf.conf file. 477c478bd9Sstevel@tonic-gate */ 487c478bd9Sstevel@tonic-gate #define SEP_SLASH '/' 497c478bd9Sstevel@tonic-gate #define EF_SUPPORTED "supportedlist=" 501b22764fSDaniel OpenSolaris Anderson #define EF_UNLOAD "unload" 517c478bd9Sstevel@tonic-gate #define RANDOM "random" 527c478bd9Sstevel@tonic-gate #define UEF_FRAME_LIB "/usr/lib/libpkcs11.so" 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate #define ADD_MODE 1 557c478bd9Sstevel@tonic-gate #define DELETE_MODE 2 567c478bd9Sstevel@tonic-gate #define MODIFY_MODE 3 577c478bd9Sstevel@tonic-gate 58b5a2d845SHai-May Chao #define REFRESH 1 59b5a2d845SHai-May Chao #define NOT_REFRESH 0 60b5a2d845SHai-May Chao 617c478bd9Sstevel@tonic-gate typedef char prov_name_t[MAXNAMELEN]; 627c478bd9Sstevel@tonic-gate typedef char mech_name_t[CRYPTO_MAX_MECH_NAME]; 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate typedef struct mechlist { 657c478bd9Sstevel@tonic-gate mech_name_t name; 667c478bd9Sstevel@tonic-gate struct mechlist *next; 677c478bd9Sstevel@tonic-gate } mechlist_t; 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate 707c478bd9Sstevel@tonic-gate typedef struct entry { 717c478bd9Sstevel@tonic-gate prov_name_t name; 727c478bd9Sstevel@tonic-gate mechlist_t *suplist; /* supported list */ 737c478bd9Sstevel@tonic-gate uint_t sup_count; 747c478bd9Sstevel@tonic-gate mechlist_t *dislist; /* disabled list */ 757c478bd9Sstevel@tonic-gate uint_t dis_count; 761b22764fSDaniel OpenSolaris Anderson boolean_t load; /* B_FALSE after cryptoadm unload */ 777c478bd9Sstevel@tonic-gate } entry_t; 787c478bd9Sstevel@tonic-gate 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate typedef struct entrylist { 817c478bd9Sstevel@tonic-gate entry_t *pent; 827c478bd9Sstevel@tonic-gate struct entrylist *next; 837c478bd9Sstevel@tonic-gate } entrylist_t; 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate typedef enum { 867c478bd9Sstevel@tonic-gate NO_RNG, 877c478bd9Sstevel@tonic-gate HAS_RNG 887c478bd9Sstevel@tonic-gate } flag_val_t; 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate extern int errno; 917c478bd9Sstevel@tonic-gate 927c478bd9Sstevel@tonic-gate /* adm_util */ 937c478bd9Sstevel@tonic-gate extern boolean_t is_in_list(char *, mechlist_t *); 947c478bd9Sstevel@tonic-gate extern mechlist_t *create_mech(char *); 957c478bd9Sstevel@tonic-gate extern void free_mechlist(mechlist_t *); 967c478bd9Sstevel@tonic-gate 977c478bd9Sstevel@tonic-gate /* adm_kef_util */ 987c478bd9Sstevel@tonic-gate extern boolean_t is_device(char *); 99*d616ad8eSHai-May Chao extern int fips_update_pkcs11conf(int); 100*d616ad8eSHai-May Chao extern void fips_status_pkcs11conf(int *); 1017c478bd9Sstevel@tonic-gate extern char *ent2str(entry_t *); 1021b22764fSDaniel OpenSolaris Anderson extern entry_t *getent_kef(char *provname, 103*d616ad8eSHai-May Chao entrylist_t *pdevlist, entrylist_t *psoftlist); 1041b22764fSDaniel OpenSolaris Anderson extern int check_kernel_for_soft(char *provname, 1051b22764fSDaniel OpenSolaris Anderson crypto_get_soft_list_t *psoftlist, boolean_t *in_kernel); 1061b22764fSDaniel OpenSolaris Anderson extern int check_kernel_for_hard(char *provname, 1071b22764fSDaniel OpenSolaris Anderson crypto_get_dev_list_t *pdevlist, boolean_t *in_kernel); 1087c478bd9Sstevel@tonic-gate extern int disable_mechs(entry_t **, mechlist_t *, boolean_t, mechlist_t *); 1097c478bd9Sstevel@tonic-gate extern int enable_mechs(entry_t **, boolean_t, mechlist_t *); 110*d616ad8eSHai-May Chao extern int get_kcfconf_info(entrylist_t **, entrylist_t **); 1117c478bd9Sstevel@tonic-gate extern int get_admindev_info(entrylist_t **, entrylist_t **); 1127c478bd9Sstevel@tonic-gate extern int get_mech_count(mechlist_t *); 1131b22764fSDaniel OpenSolaris Anderson extern entry_t *create_entry(char *provname); 1147c478bd9Sstevel@tonic-gate extern int insert_kcfconf(entry_t *); 1157c478bd9Sstevel@tonic-gate extern int split_hw_provname(char *, char *, int *); 1167c478bd9Sstevel@tonic-gate extern int update_kcfconf(entry_t *, int); 1177c478bd9Sstevel@tonic-gate extern void free_entry(entry_t *); 1187c478bd9Sstevel@tonic-gate extern void free_entrylist(entrylist_t *); 1197c478bd9Sstevel@tonic-gate extern void print_mechlist(char *, mechlist_t *); 1201b22764fSDaniel OpenSolaris Anderson extern void print_kef_policy(char *provname, entry_t *pent, 1211b22764fSDaniel OpenSolaris Anderson boolean_t has_random, boolean_t has_mechs); 1227c478bd9Sstevel@tonic-gate extern boolean_t filter_mechlist(mechlist_t **, const char *); 1237c478bd9Sstevel@tonic-gate extern uentry_t *getent_uef(char *); 1247c478bd9Sstevel@tonic-gate 1257c478bd9Sstevel@tonic-gate 1267c478bd9Sstevel@tonic-gate /* adm_uef */ 1277c478bd9Sstevel@tonic-gate extern int list_mechlist_for_lib(char *, mechlist_t *, flag_val_t *, 1287c478bd9Sstevel@tonic-gate boolean_t, boolean_t, boolean_t); 1297c478bd9Sstevel@tonic-gate extern int list_policy_for_lib(char *); 1307c478bd9Sstevel@tonic-gate extern int disable_uef_lib(char *, boolean_t, boolean_t, mechlist_t *); 1317c478bd9Sstevel@tonic-gate extern int enable_uef_lib(char *, boolean_t, boolean_t, mechlist_t *); 1327c478bd9Sstevel@tonic-gate extern int install_uef_lib(char *); 1337c478bd9Sstevel@tonic-gate extern int uninstall_uef_lib(char *); 1347c478bd9Sstevel@tonic-gate extern int print_uef_policy(uentry_t *); 1357c478bd9Sstevel@tonic-gate extern void display_token_flags(CK_FLAGS flags); 1367c478bd9Sstevel@tonic-gate extern int convert_mechlist(CK_MECHANISM_TYPE **, CK_ULONG *, mechlist_t *); 1377c478bd9Sstevel@tonic-gate extern void display_verbose_mech_header(); 1387c478bd9Sstevel@tonic-gate extern void display_mech_info(CK_MECHANISM_INFO *); 1397c478bd9Sstevel@tonic-gate extern int display_policy(uentry_t *); 1407c478bd9Sstevel@tonic-gate extern int update_pkcs11conf(uentry_t *); 1417c478bd9Sstevel@tonic-gate extern int update_policylist(uentry_t *, mechlist_t *, int); 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate /* adm_kef */ 1441b22764fSDaniel OpenSolaris Anderson extern int list_mechlist_for_soft(char *provname, 145*d616ad8eSHai-May Chao entrylist_t *phardlist, entrylist_t *psoftlist); 1467c478bd9Sstevel@tonic-gate extern int list_mechlist_for_hard(char *); 1471b22764fSDaniel OpenSolaris Anderson extern int list_policy_for_soft(char *provname, 148*d616ad8eSHai-May Chao entrylist_t *phardlist, entrylist_t *psoftlist); 1491b22764fSDaniel OpenSolaris Anderson extern int list_policy_for_hard(char *provname, 1501b22764fSDaniel OpenSolaris Anderson entrylist_t *phardlist, entrylist_t *psoftlist, 1511b22764fSDaniel OpenSolaris Anderson crypto_get_dev_list_t *pdevlist); 1527c478bd9Sstevel@tonic-gate extern int disable_kef_software(char *, boolean_t, boolean_t, mechlist_t *); 1537c478bd9Sstevel@tonic-gate extern int disable_kef_hardware(char *, boolean_t, boolean_t, mechlist_t *); 1547c478bd9Sstevel@tonic-gate extern int enable_kef(char *, boolean_t, boolean_t, mechlist_t *); 1557c478bd9Sstevel@tonic-gate extern int install_kef(char *, mechlist_t *); 1567c478bd9Sstevel@tonic-gate extern int uninstall_kef(char *); 1571b22764fSDaniel OpenSolaris Anderson extern int unload_kef_soft(char *provname); 1587c478bd9Sstevel@tonic-gate extern int refresh(void); 1597c478bd9Sstevel@tonic-gate extern int start_daemon(void); 1607c478bd9Sstevel@tonic-gate extern int stop_daemon(void); 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate /* adm_ioctl */ 1637c478bd9Sstevel@tonic-gate extern crypto_load_soft_config_t *setup_soft_conf(entry_t *); 1647c478bd9Sstevel@tonic-gate extern crypto_load_soft_disabled_t *setup_soft_dis(entry_t *); 1657c478bd9Sstevel@tonic-gate extern crypto_load_dev_disabled_t *setup_dev_dis(entry_t *); 1667c478bd9Sstevel@tonic-gate extern crypto_unload_soft_module_t *setup_unload_soft(entry_t *); 1677c478bd9Sstevel@tonic-gate extern int get_dev_info(char *, int, int, mechlist_t **); 1687c478bd9Sstevel@tonic-gate extern int get_dev_list(crypto_get_dev_list_t **); 1691b22764fSDaniel OpenSolaris Anderson extern int get_soft_info(char *provname, mechlist_t **ppmechlist, 170*d616ad8eSHai-May Chao entrylist_t *phardlist, entrylist_t *psoftlist); 1717c478bd9Sstevel@tonic-gate extern int get_soft_list(crypto_get_soft_list_t **); 172b5a2d845SHai-May Chao extern int do_fips_actions(int, int); 1737c478bd9Sstevel@tonic-gate 1747c478bd9Sstevel@tonic-gate /* adm_metaslot */ 1757c478bd9Sstevel@tonic-gate extern int list_metaslot_info(boolean_t, boolean_t, mechlist_t *); 1767c478bd9Sstevel@tonic-gate extern int list_metaslot_policy(); 1777c478bd9Sstevel@tonic-gate extern int disable_metaslot(mechlist_t *, boolean_t, boolean_t); 1787c478bd9Sstevel@tonic-gate extern int enable_metaslot(char *, char *, boolean_t, mechlist_t *, boolean_t, 1797c478bd9Sstevel@tonic-gate boolean_t); 1807c478bd9Sstevel@tonic-gate 1817c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1827c478bd9Sstevel@tonic-gate } 1837c478bd9Sstevel@tonic-gate #endif 1847c478bd9Sstevel@tonic-gate 1857c478bd9Sstevel@tonic-gate #endif /* _CRYPTOADM_H */ 186