10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 51971Skrishna * Common Development and Distribution License (the "License"). 61971Skrishna * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*12929SMisaki.Miyashita@Oracle.COM * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. 230Sstevel@tonic-gate */ 240Sstevel@tonic-gate 250Sstevel@tonic-gate #ifndef _CRYPTOADM_H 260Sstevel@tonic-gate #define _CRYPTOADM_H 270Sstevel@tonic-gate 287968Sopensolaris@drydog.com #include <sys/types.h> 290Sstevel@tonic-gate #include <sys/crypto/ioctladmin.h> 300Sstevel@tonic-gate #include <cryptoutil.h> 310Sstevel@tonic-gate #include <security/cryptoki.h> 320Sstevel@tonic-gate 330Sstevel@tonic-gate #ifdef __cplusplus 340Sstevel@tonic-gate extern "C" { 350Sstevel@tonic-gate #endif 360Sstevel@tonic-gate 378192SJohn.Zolnowsky@Sun.COM #define _PATH_KCFD "/lib/crypto/kcfd" 380Sstevel@tonic-gate #define TMPFILE_TEMPLATE "/etc/crypto/admXXXXXX" 390Sstevel@tonic-gate 400Sstevel@tonic-gate #define ERROR_USAGE 2 410Sstevel@tonic-gate 42*12929SMisaki.Miyashita@Oracle.COM #define HW_PROVIDER_NCP 1 43*12929SMisaki.Miyashita@Oracle.COM #define HW_PROVIDER_N2CP 2 44*12929SMisaki.Miyashita@Oracle.COM #define HW_PROVIDER_N2RNG 3 45*12929SMisaki.Miyashita@Oracle.COM 460Sstevel@tonic-gate /* 470Sstevel@tonic-gate * Common keywords and delimiters for pkcs11.conf and kcf.conf files are 480Sstevel@tonic-gate * defined in usr/lib/libcryptoutil/common/cryptoutil.h. The following is 490Sstevel@tonic-gate * the extra keywords and delimiters used in kcf.conf file. 500Sstevel@tonic-gate */ 510Sstevel@tonic-gate #define SEP_SLASH '/' 520Sstevel@tonic-gate #define EF_SUPPORTED "supportedlist=" 537968Sopensolaris@drydog.com #define EF_UNLOAD "unload" 540Sstevel@tonic-gate #define RANDOM "random" 550Sstevel@tonic-gate #define UEF_FRAME_LIB "/usr/lib/libpkcs11.so" 560Sstevel@tonic-gate 570Sstevel@tonic-gate #define ADD_MODE 1 580Sstevel@tonic-gate #define DELETE_MODE 2 590Sstevel@tonic-gate #define MODIFY_MODE 3 600Sstevel@tonic-gate 6110500SHai-May.Chao@Sun.COM #define REFRESH 1 6210500SHai-May.Chao@Sun.COM #define NOT_REFRESH 0 6310500SHai-May.Chao@Sun.COM 640Sstevel@tonic-gate typedef char prov_name_t[MAXNAMELEN]; 650Sstevel@tonic-gate typedef char mech_name_t[CRYPTO_MAX_MECH_NAME]; 660Sstevel@tonic-gate 670Sstevel@tonic-gate typedef struct mechlist { 680Sstevel@tonic-gate mech_name_t name; 690Sstevel@tonic-gate struct mechlist *next; 700Sstevel@tonic-gate } mechlist_t; 710Sstevel@tonic-gate 720Sstevel@tonic-gate 730Sstevel@tonic-gate typedef struct entry { 740Sstevel@tonic-gate prov_name_t name; 750Sstevel@tonic-gate mechlist_t *suplist; /* supported list */ 767968Sopensolaris@drydog.com uint_t sup_count; 770Sstevel@tonic-gate mechlist_t *dislist; /* disabled list */ 787968Sopensolaris@drydog.com uint_t dis_count; 797968Sopensolaris@drydog.com boolean_t load; /* B_FALSE after cryptoadm unload */ 800Sstevel@tonic-gate } entry_t; 810Sstevel@tonic-gate 820Sstevel@tonic-gate 830Sstevel@tonic-gate typedef struct entrylist { 840Sstevel@tonic-gate entry_t *pent; 850Sstevel@tonic-gate struct entrylist *next; 860Sstevel@tonic-gate } entrylist_t; 870Sstevel@tonic-gate 880Sstevel@tonic-gate typedef enum { 890Sstevel@tonic-gate NO_RNG, 900Sstevel@tonic-gate HAS_RNG 910Sstevel@tonic-gate } flag_val_t; 920Sstevel@tonic-gate 930Sstevel@tonic-gate extern int errno; 940Sstevel@tonic-gate 950Sstevel@tonic-gate /* adm_util */ 960Sstevel@tonic-gate extern boolean_t is_in_list(char *, mechlist_t *); 970Sstevel@tonic-gate extern mechlist_t *create_mech(char *); 980Sstevel@tonic-gate extern void free_mechlist(mechlist_t *); 990Sstevel@tonic-gate 1000Sstevel@tonic-gate /* adm_kef_util */ 1010Sstevel@tonic-gate extern boolean_t is_device(char *); 10210979SHai-May.Chao@Sun.COM extern int fips_update_pkcs11conf(int); 10310979SHai-May.Chao@Sun.COM extern void fips_status_pkcs11conf(int *); 1040Sstevel@tonic-gate extern char *ent2str(entry_t *); 1057968Sopensolaris@drydog.com extern entry_t *getent_kef(char *provname, 10610979SHai-May.Chao@Sun.COM entrylist_t *pdevlist, entrylist_t *psoftlist); 1077968Sopensolaris@drydog.com extern int check_kernel_for_soft(char *provname, 1087968Sopensolaris@drydog.com crypto_get_soft_list_t *psoftlist, boolean_t *in_kernel); 1097968Sopensolaris@drydog.com extern int check_kernel_for_hard(char *provname, 1107968Sopensolaris@drydog.com crypto_get_dev_list_t *pdevlist, boolean_t *in_kernel); 1110Sstevel@tonic-gate extern int disable_mechs(entry_t **, mechlist_t *, boolean_t, mechlist_t *); 1120Sstevel@tonic-gate extern int enable_mechs(entry_t **, boolean_t, mechlist_t *); 11310979SHai-May.Chao@Sun.COM extern int get_kcfconf_info(entrylist_t **, entrylist_t **); 1140Sstevel@tonic-gate extern int get_admindev_info(entrylist_t **, entrylist_t **); 1150Sstevel@tonic-gate extern int get_mech_count(mechlist_t *); 1167968Sopensolaris@drydog.com extern entry_t *create_entry(char *provname); 1170Sstevel@tonic-gate extern int insert_kcfconf(entry_t *); 1180Sstevel@tonic-gate extern int split_hw_provname(char *, char *, int *); 1190Sstevel@tonic-gate extern int update_kcfconf(entry_t *, int); 1200Sstevel@tonic-gate extern void free_entry(entry_t *); 1210Sstevel@tonic-gate extern void free_entrylist(entrylist_t *); 1220Sstevel@tonic-gate extern void print_mechlist(char *, mechlist_t *); 1237968Sopensolaris@drydog.com extern void print_kef_policy(char *provname, entry_t *pent, 1247968Sopensolaris@drydog.com boolean_t has_random, boolean_t has_mechs); 1250Sstevel@tonic-gate extern boolean_t filter_mechlist(mechlist_t **, const char *); 1260Sstevel@tonic-gate extern uentry_t *getent_uef(char *); 1270Sstevel@tonic-gate 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate /* adm_uef */ 1300Sstevel@tonic-gate extern int list_mechlist_for_lib(char *, mechlist_t *, flag_val_t *, 1310Sstevel@tonic-gate boolean_t, boolean_t, boolean_t); 1320Sstevel@tonic-gate extern int list_policy_for_lib(char *); 1330Sstevel@tonic-gate extern int disable_uef_lib(char *, boolean_t, boolean_t, mechlist_t *); 1340Sstevel@tonic-gate extern int enable_uef_lib(char *, boolean_t, boolean_t, mechlist_t *); 1350Sstevel@tonic-gate extern int install_uef_lib(char *); 1360Sstevel@tonic-gate extern int uninstall_uef_lib(char *); 1370Sstevel@tonic-gate extern int print_uef_policy(uentry_t *); 1380Sstevel@tonic-gate extern void display_token_flags(CK_FLAGS flags); 1390Sstevel@tonic-gate extern int convert_mechlist(CK_MECHANISM_TYPE **, CK_ULONG *, mechlist_t *); 1400Sstevel@tonic-gate extern void display_verbose_mech_header(); 1410Sstevel@tonic-gate extern void display_mech_info(CK_MECHANISM_INFO *); 1420Sstevel@tonic-gate extern int display_policy(uentry_t *); 1430Sstevel@tonic-gate extern int update_pkcs11conf(uentry_t *); 1440Sstevel@tonic-gate extern int update_policylist(uentry_t *, mechlist_t *, int); 1450Sstevel@tonic-gate 1460Sstevel@tonic-gate /* adm_kef */ 1477968Sopensolaris@drydog.com extern int list_mechlist_for_soft(char *provname, 14810979SHai-May.Chao@Sun.COM entrylist_t *phardlist, entrylist_t *psoftlist); 1490Sstevel@tonic-gate extern int list_mechlist_for_hard(char *); 1507968Sopensolaris@drydog.com extern int list_policy_for_soft(char *provname, 15110979SHai-May.Chao@Sun.COM entrylist_t *phardlist, entrylist_t *psoftlist); 1527968Sopensolaris@drydog.com extern int list_policy_for_hard(char *provname, 1537968Sopensolaris@drydog.com entrylist_t *phardlist, entrylist_t *psoftlist, 1547968Sopensolaris@drydog.com crypto_get_dev_list_t *pdevlist); 1550Sstevel@tonic-gate extern int disable_kef_software(char *, boolean_t, boolean_t, mechlist_t *); 1560Sstevel@tonic-gate extern int disable_kef_hardware(char *, boolean_t, boolean_t, mechlist_t *); 1570Sstevel@tonic-gate extern int enable_kef(char *, boolean_t, boolean_t, mechlist_t *); 1580Sstevel@tonic-gate extern int install_kef(char *, mechlist_t *); 1590Sstevel@tonic-gate extern int uninstall_kef(char *); 1607968Sopensolaris@drydog.com extern int unload_kef_soft(char *provname); 1610Sstevel@tonic-gate extern int refresh(void); 1620Sstevel@tonic-gate extern int start_daemon(void); 1630Sstevel@tonic-gate extern int stop_daemon(void); 1640Sstevel@tonic-gate 1650Sstevel@tonic-gate /* adm_ioctl */ 1660Sstevel@tonic-gate extern crypto_load_soft_config_t *setup_soft_conf(entry_t *); 1670Sstevel@tonic-gate extern crypto_load_soft_disabled_t *setup_soft_dis(entry_t *); 1680Sstevel@tonic-gate extern crypto_load_dev_disabled_t *setup_dev_dis(entry_t *); 1690Sstevel@tonic-gate extern crypto_unload_soft_module_t *setup_unload_soft(entry_t *); 1700Sstevel@tonic-gate extern int get_dev_info(char *, int, int, mechlist_t **); 1710Sstevel@tonic-gate extern int get_dev_list(crypto_get_dev_list_t **); 1727968Sopensolaris@drydog.com extern int get_soft_info(char *provname, mechlist_t **ppmechlist, 17310979SHai-May.Chao@Sun.COM entrylist_t *phardlist, entrylist_t *psoftlist); 1740Sstevel@tonic-gate extern int get_soft_list(crypto_get_soft_list_t **); 17510500SHai-May.Chao@Sun.COM extern int do_fips_actions(int, int); 1760Sstevel@tonic-gate 1770Sstevel@tonic-gate /* adm_metaslot */ 1780Sstevel@tonic-gate extern int list_metaslot_info(boolean_t, boolean_t, mechlist_t *); 1790Sstevel@tonic-gate extern int list_metaslot_policy(); 1800Sstevel@tonic-gate extern int disable_metaslot(mechlist_t *, boolean_t, boolean_t); 1810Sstevel@tonic-gate extern int enable_metaslot(char *, char *, boolean_t, mechlist_t *, boolean_t, 1820Sstevel@tonic-gate boolean_t); 1830Sstevel@tonic-gate 184*12929SMisaki.Miyashita@Oracle.COM /* adm_hw */ 185*12929SMisaki.Miyashita@Oracle.COM extern int do_fips_hw_actions(int, int); 186*12929SMisaki.Miyashita@Oracle.COM 1870Sstevel@tonic-gate #ifdef __cplusplus 1880Sstevel@tonic-gate } 1890Sstevel@tonic-gate #endif 1900Sstevel@tonic-gate 1910Sstevel@tonic-gate #endif /* _CRYPTOADM_H */ 192