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 2005 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 _SYS_CRYPTO_IMPL_H 28*0Sstevel@tonic-gate #define _SYS_CRYPTO_IMPL_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate /* 33*0Sstevel@tonic-gate * Kernel Cryptographic Framework private implementation definitions. 34*0Sstevel@tonic-gate */ 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #include <sys/types.h> 37*0Sstevel@tonic-gate #include <sys/param.h> 38*0Sstevel@tonic-gate 39*0Sstevel@tonic-gate #ifdef _KERNEL 40*0Sstevel@tonic-gate #include <sys/crypto/common.h> 41*0Sstevel@tonic-gate #include <sys/crypto/api.h> 42*0Sstevel@tonic-gate #include <sys/crypto/spi.h> 43*0Sstevel@tonic-gate #include <sys/crypto/ioctl.h> 44*0Sstevel@tonic-gate #include <sys/tnf_probe.h> 45*0Sstevel@tonic-gate #include <sys/atomic.h> 46*0Sstevel@tonic-gate #include <sys/project.h> 47*0Sstevel@tonic-gate #include <sys/taskq.h> 48*0Sstevel@tonic-gate #include <sys/rctl.h> 49*0Sstevel@tonic-gate #endif /* _KERNEL */ 50*0Sstevel@tonic-gate 51*0Sstevel@tonic-gate #ifdef __cplusplus 52*0Sstevel@tonic-gate extern "C" { 53*0Sstevel@tonic-gate #endif 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate #ifdef _KERNEL 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate #define KCF_MODULE "kcf" 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate /* 60*0Sstevel@tonic-gate * Prefixes convention: structures internal to the kernel cryptographic 61*0Sstevel@tonic-gate * framework start with 'kcf_'. Exposed structure start with 'crypto_'. 62*0Sstevel@tonic-gate */ 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate /* Provider stats. Not protected. */ 65*0Sstevel@tonic-gate typedef struct kcf_prov_stats { 66*0Sstevel@tonic-gate kstat_named_t ps_ops_total; 67*0Sstevel@tonic-gate kstat_named_t ps_ops_passed; 68*0Sstevel@tonic-gate kstat_named_t ps_ops_failed; 69*0Sstevel@tonic-gate kstat_named_t ps_ops_busy_rval; 70*0Sstevel@tonic-gate } kcf_prov_stats_t; 71*0Sstevel@tonic-gate 72*0Sstevel@tonic-gate /* Various kcf stats. Not protected. */ 73*0Sstevel@tonic-gate typedef struct kcf_stats { 74*0Sstevel@tonic-gate kstat_named_t ks_thrs_in_pool; 75*0Sstevel@tonic-gate kstat_named_t ks_idle_thrs; 76*0Sstevel@tonic-gate kstat_named_t ks_minthrs; 77*0Sstevel@tonic-gate kstat_named_t ks_maxthrs; 78*0Sstevel@tonic-gate kstat_named_t ks_swq_njobs; 79*0Sstevel@tonic-gate kstat_named_t ks_swq_maxjobs; 80*0Sstevel@tonic-gate kstat_named_t ks_taskq_minalloc; 81*0Sstevel@tonic-gate kstat_named_t ks_taskq_maxalloc; 82*0Sstevel@tonic-gate } kcf_stats_t; 83*0Sstevel@tonic-gate 84*0Sstevel@tonic-gate /* 85*0Sstevel@tonic-gate * Keep all the information needed by the scheduler from 86*0Sstevel@tonic-gate * this provider. 87*0Sstevel@tonic-gate */ 88*0Sstevel@tonic-gate typedef struct kcf_sched_info { 89*0Sstevel@tonic-gate /* The number of operations dispatched. */ 90*0Sstevel@tonic-gate uint64_t ks_ndispatches; 91*0Sstevel@tonic-gate 92*0Sstevel@tonic-gate /* The number of operations that failed. */ 93*0Sstevel@tonic-gate uint64_t ks_nfails; 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate /* The number of operations that returned CRYPTO_BUSY. */ 96*0Sstevel@tonic-gate uint64_t ks_nbusy_rval; 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate /* taskq used to dispatch crypto requests */ 99*0Sstevel@tonic-gate taskq_t *ks_taskq; 100*0Sstevel@tonic-gate } kcf_sched_info_t; 101*0Sstevel@tonic-gate 102*0Sstevel@tonic-gate #define KCF_PROV_INCRSTATS(pd, error) { \ 103*0Sstevel@tonic-gate (pd)->pd_sched_info.ks_ndispatches++; \ 104*0Sstevel@tonic-gate if (error == CRYPTO_BUSY) \ 105*0Sstevel@tonic-gate (pd)->pd_sched_info.ks_nbusy_rval++; \ 106*0Sstevel@tonic-gate else if (error != CRYPTO_SUCCESS && error != CRYPTO_QUEUED) \ 107*0Sstevel@tonic-gate (pd)->pd_sched_info.ks_nfails++; \ 108*0Sstevel@tonic-gate } 109*0Sstevel@tonic-gate 110*0Sstevel@tonic-gate 111*0Sstevel@tonic-gate /* 112*0Sstevel@tonic-gate * The following two macros should be 113*0Sstevel@tonic-gate * #define KCF_OPS_CLASSSIZE (KCF_LAST_OPSCLASS - KCF_FIRST_OPSCLASS + 2) 114*0Sstevel@tonic-gate * #define KCF_MAXMECHTAB KCF_MAXCIPHER 115*0Sstevel@tonic-gate * 116*0Sstevel@tonic-gate * However, doing that would involve reorganizing the header file a bit. 117*0Sstevel@tonic-gate * When impl.h is broken up (bug# 4703218), this will be done. For now, 118*0Sstevel@tonic-gate * we hardcode these values. 119*0Sstevel@tonic-gate */ 120*0Sstevel@tonic-gate #define KCF_OPS_CLASSSIZE 8 121*0Sstevel@tonic-gate #define KCF_MAXMECHTAB 32 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gate /* 124*0Sstevel@tonic-gate * Valid values for the state of a provider. The order of 125*0Sstevel@tonic-gate * the elements is important. 126*0Sstevel@tonic-gate * 127*0Sstevel@tonic-gate * Routines which get a provider or the list of providers 128*0Sstevel@tonic-gate * should pick only those that are either in KCF_PROV_READY state 129*0Sstevel@tonic-gate * or in KCF_PROV_BUSY state. 130*0Sstevel@tonic-gate */ 131*0Sstevel@tonic-gate typedef enum { 132*0Sstevel@tonic-gate KCF_PROV_ALLOCATED = 1, 133*0Sstevel@tonic-gate KCF_PROV_UNVERIFIED, 134*0Sstevel@tonic-gate /* 135*0Sstevel@tonic-gate * state < KCF_PROV_READY means the provider can not 136*0Sstevel@tonic-gate * be used at all. 137*0Sstevel@tonic-gate */ 138*0Sstevel@tonic-gate KCF_PROV_READY, 139*0Sstevel@tonic-gate KCF_PROV_BUSY, 140*0Sstevel@tonic-gate /* 141*0Sstevel@tonic-gate * state > KCF_PROV_BUSY means the provider can not 142*0Sstevel@tonic-gate * be used for new requests. 143*0Sstevel@tonic-gate */ 144*0Sstevel@tonic-gate KCF_PROV_FAILED, 145*0Sstevel@tonic-gate /* 146*0Sstevel@tonic-gate * Threads setting the following two states should do so only 147*0Sstevel@tonic-gate * if the current state < KCF_PROV_DISABLED. 148*0Sstevel@tonic-gate */ 149*0Sstevel@tonic-gate KCF_PROV_DISABLED, 150*0Sstevel@tonic-gate KCF_PROV_REMOVED, 151*0Sstevel@tonic-gate KCF_PROV_FREED 152*0Sstevel@tonic-gate } kcf_prov_state_t; 153*0Sstevel@tonic-gate 154*0Sstevel@tonic-gate #define KCF_IS_PROV_UNVERIFIED(pd) ((pd)->pd_state == KCF_PROV_UNVERIFIED) 155*0Sstevel@tonic-gate #define KCF_IS_PROV_USABLE(pd) ((pd)->pd_state == KCF_PROV_READY || \ 156*0Sstevel@tonic-gate (pd)->pd_state == KCF_PROV_BUSY) 157*0Sstevel@tonic-gate #define KCF_IS_PROV_REMOVED(pd) ((pd)->pd_state >= KCF_PROV_REMOVED) 158*0Sstevel@tonic-gate 159*0Sstevel@tonic-gate /* 160*0Sstevel@tonic-gate * A provider descriptor structure. There is one such structure per 161*0Sstevel@tonic-gate * provider. It is allocated and initialized at registration time and 162*0Sstevel@tonic-gate * freed when the provider unregisters. 163*0Sstevel@tonic-gate * 164*0Sstevel@tonic-gate * pd_prov_type: Provider type, hardware or software 165*0Sstevel@tonic-gate * pd_prov_handle: Provider handle specified by provider 166*0Sstevel@tonic-gate * pd_kcf_prov_handle: KCF-private handle assigned by KCF 167*0Sstevel@tonic-gate * pd_prov_id: Identification # assigned by KCF to provider 168*0Sstevel@tonic-gate * pd_description: Provider description string 169*0Sstevel@tonic-gate * pd_ops_vector: The ops vector specified by Provider 170*0Sstevel@tonic-gate * pd_mech_list_count: The number of entries in pi_mechanisms, specified 171*0Sstevel@tonic-gate * by the provider during registration 172*0Sstevel@tonic-gate * pd_mechanisms: Mechanisms supported by the provider, specified 173*0Sstevel@tonic-gate * by the provider during registration 174*0Sstevel@tonic-gate * pd_map_mechnums: Lookup table which maps a core framework mechanism 175*0Sstevel@tonic-gate * number to a number understood by this provider 176*0Sstevel@tonic-gate * pd_ks_data: kstat data 177*0Sstevel@tonic-gate * pd_kstat: kstat associated with the provider 178*0Sstevel@tonic-gate * pd_sched_info: Scheduling information associated with the provider 179*0Sstevel@tonic-gate * pd_refcnt: Reference counter to this provider descriptor 180*0Sstevel@tonic-gate * pd_irefcnt: References held by the framework internal structs 181*0Sstevel@tonic-gate * pd_name: Device name or module name 182*0Sstevel@tonic-gate * pd_instance: Device instance 183*0Sstevel@tonic-gate * pd_module_id: Module ID returned by modload 184*0Sstevel@tonic-gate * pd_mctlp: Pointer to modctl structure for this provider 185*0Sstevel@tonic-gate * pd_sid: Session ID of the provider used by kernel clients. 186*0Sstevel@tonic-gate * This is valid only for session-oriented providers. 187*0Sstevel@tonic-gate * pd_lock: lock protects pd_state and pd_real_provider_list 188*0Sstevel@tonic-gate * pd_state: State value of the provider 189*0Sstevel@tonic-gate * pd_resume_cv: cv to wait for state to change from KCF_PROV_BUSY 190*0Sstevel@tonic-gate * pd_remove_cv: cv to wait on while the provider queue drains 191*0Sstevel@tonic-gate * pd_restricted: true if this is an export restricted provider 192*0Sstevel@tonic-gate * pd_provider_list: Used to cross-reference logical providers and their 193*0Sstevel@tonic-gate * members. Not used for software providers. 194*0Sstevel@tonic-gate */ 195*0Sstevel@tonic-gate typedef struct kcf_provider_desc { 196*0Sstevel@tonic-gate crypto_provider_type_t pd_prov_type; 197*0Sstevel@tonic-gate crypto_provider_handle_t pd_prov_handle; 198*0Sstevel@tonic-gate crypto_kcf_provider_handle_t pd_kcf_prov_handle; 199*0Sstevel@tonic-gate crypto_provider_id_t pd_prov_id; 200*0Sstevel@tonic-gate char *pd_description; 201*0Sstevel@tonic-gate crypto_ops_t *pd_ops_vector; 202*0Sstevel@tonic-gate uint_t pd_mech_list_count; 203*0Sstevel@tonic-gate crypto_mech_info_t *pd_mechanisms; 204*0Sstevel@tonic-gate crypto_mech_type_t pd_map_mechnums[KCF_OPS_CLASSSIZE]\ 205*0Sstevel@tonic-gate [KCF_MAXMECHTAB]; 206*0Sstevel@tonic-gate kcf_stats_t *pd_stats; 207*0Sstevel@tonic-gate kcf_prov_stats_t pd_ks_data; 208*0Sstevel@tonic-gate kstat_t *pd_kstat; 209*0Sstevel@tonic-gate kcf_sched_info_t pd_sched_info; 210*0Sstevel@tonic-gate uint_t pd_refcnt; 211*0Sstevel@tonic-gate uint_t pd_irefcnt; 212*0Sstevel@tonic-gate char *pd_name; 213*0Sstevel@tonic-gate uint_t pd_instance; 214*0Sstevel@tonic-gate int pd_module_id; 215*0Sstevel@tonic-gate struct modctl *pd_mctlp; 216*0Sstevel@tonic-gate crypto_session_id_t pd_sid; 217*0Sstevel@tonic-gate kmutex_t pd_lock; 218*0Sstevel@tonic-gate kcf_prov_state_t pd_state; 219*0Sstevel@tonic-gate kcondvar_t pd_resume_cv; 220*0Sstevel@tonic-gate kcondvar_t pd_remove_cv; 221*0Sstevel@tonic-gate boolean_t pd_restricted; 222*0Sstevel@tonic-gate struct kcf_provider_list *pd_provider_list; 223*0Sstevel@tonic-gate } kcf_provider_desc_t; 224*0Sstevel@tonic-gate 225*0Sstevel@tonic-gate /* useful for making a list of providers */ 226*0Sstevel@tonic-gate typedef struct kcf_provider_list { 227*0Sstevel@tonic-gate struct kcf_provider_list *pl_next; 228*0Sstevel@tonic-gate struct kcf_provider_desc *pl_provider; 229*0Sstevel@tonic-gate } kcf_provider_list_t; 230*0Sstevel@tonic-gate 231*0Sstevel@tonic-gate /* 232*0Sstevel@tonic-gate * If a component has a reference to a kcf_provider_desc_t, 233*0Sstevel@tonic-gate * it REFHOLD()s. A new provider descriptor which is referenced only 234*0Sstevel@tonic-gate * by the providers table has a reference counter of one. 235*0Sstevel@tonic-gate */ 236*0Sstevel@tonic-gate #define KCF_PROV_REFHOLD(desc) { \ 237*0Sstevel@tonic-gate atomic_add_32(&(desc)->pd_refcnt, 1); \ 238*0Sstevel@tonic-gate ASSERT((desc)->pd_refcnt != 0); \ 239*0Sstevel@tonic-gate } 240*0Sstevel@tonic-gate 241*0Sstevel@tonic-gate #define KCF_PROV_IREFHOLD(desc) { \ 242*0Sstevel@tonic-gate atomic_add_32(&(desc)->pd_irefcnt, 1); \ 243*0Sstevel@tonic-gate ASSERT((desc)->pd_irefcnt != 0); \ 244*0Sstevel@tonic-gate } 245*0Sstevel@tonic-gate 246*0Sstevel@tonic-gate #define KCF_PROV_IREFRELE(desc) { \ 247*0Sstevel@tonic-gate ASSERT((desc)->pd_irefcnt != 0); \ 248*0Sstevel@tonic-gate membar_exit(); \ 249*0Sstevel@tonic-gate if (atomic_add_32_nv(&(desc)->pd_irefcnt, -1) == 0) { \ 250*0Sstevel@tonic-gate cv_broadcast(&(desc)->pd_remove_cv); \ 251*0Sstevel@tonic-gate } \ 252*0Sstevel@tonic-gate } 253*0Sstevel@tonic-gate 254*0Sstevel@tonic-gate #define KCF_PROV_REFHELD(desc) ((desc)->pd_refcnt >= 1) 255*0Sstevel@tonic-gate 256*0Sstevel@tonic-gate #define KCF_PROV_REFRELE(desc) { \ 257*0Sstevel@tonic-gate ASSERT((desc)->pd_refcnt != 0); \ 258*0Sstevel@tonic-gate membar_exit(); \ 259*0Sstevel@tonic-gate if (atomic_add_32_nv(&(desc)->pd_refcnt, -1) == 0) { \ 260*0Sstevel@tonic-gate kcf_provider_zero_refcnt((desc)); \ 261*0Sstevel@tonic-gate } \ 262*0Sstevel@tonic-gate } 263*0Sstevel@tonic-gate 264*0Sstevel@tonic-gate 265*0Sstevel@tonic-gate /* list of crypto_mech_info_t valid as the second mech in a dual operation */ 266*0Sstevel@tonic-gate 267*0Sstevel@tonic-gate typedef struct crypto_mech_info_list { 268*0Sstevel@tonic-gate struct crypto_mech_info_list *ml_next; 269*0Sstevel@tonic-gate crypto_mech_type_t ml_kcf_mechid; /* KCF's id */ 270*0Sstevel@tonic-gate crypto_mech_info_t ml_mech_info; 271*0Sstevel@tonic-gate } crypto_mech_info_list_t; 272*0Sstevel@tonic-gate 273*0Sstevel@tonic-gate /* 274*0Sstevel@tonic-gate * An element in a mechanism provider descriptors chain. 275*0Sstevel@tonic-gate * The kcf_prov_mech_desc_t is duplicated in every chain the provider belongs 276*0Sstevel@tonic-gate * to. This is a small tradeoff memory vs mutex spinning time to access the 277*0Sstevel@tonic-gate * common provider field. 278*0Sstevel@tonic-gate */ 279*0Sstevel@tonic-gate 280*0Sstevel@tonic-gate typedef struct kcf_prov_mech_desc { 281*0Sstevel@tonic-gate struct kcf_mech_entry *pm_me; /* Back to the head */ 282*0Sstevel@tonic-gate struct kcf_prov_mech_desc *pm_next; /* Next in the chain */ 283*0Sstevel@tonic-gate crypto_mech_info_t pm_mech_info; /* Provider mech info */ 284*0Sstevel@tonic-gate crypto_mech_info_list_t *pm_mi_list; /* list for duals */ 285*0Sstevel@tonic-gate kcf_provider_desc_t *pm_prov_desc; /* Common desc. */ 286*0Sstevel@tonic-gate } kcf_prov_mech_desc_t; 287*0Sstevel@tonic-gate 288*0Sstevel@tonic-gate /* and the notation shortcuts ... */ 289*0Sstevel@tonic-gate #define pm_provider_type pm_prov_desc.pd_provider_type 290*0Sstevel@tonic-gate #define pm_provider_handle pm_prov_desc.pd_provider_handle 291*0Sstevel@tonic-gate #define pm_ops_vector pm_prov_desc.pd_ops_vector 292*0Sstevel@tonic-gate 293*0Sstevel@tonic-gate 294*0Sstevel@tonic-gate /* 295*0Sstevel@tonic-gate * A mechanism entry in an xxx_mech_tab[]. 296*0Sstevel@tonic-gate * 297*0Sstevel@tonic-gate * NOTE: We need to avoid false sharing involving me_mutex. This can be 298*0Sstevel@tonic-gate * done by padding this structure so that its size is a multiple of the 299*0Sstevel@tonic-gate * cache line size, i.e. 64 bytes. However, the size of this structure is 300*0Sstevel@tonic-gate * already 64 bytes (on a 64-bit kernel). A pad field should be added if 301*0Sstevel@tonic-gate * this size were to ever change. 302*0Sstevel@tonic-gate */ 303*0Sstevel@tonic-gate typedef struct kcf_mech_entry { 304*0Sstevel@tonic-gate crypto_mech_name_t me_name; /* mechanism name */ 305*0Sstevel@tonic-gate kmutex_t me_mutex; /* access protection */ 306*0Sstevel@tonic-gate kcf_prov_mech_desc_t *me_hw_prov_chain; /* list of HW providers */ 307*0Sstevel@tonic-gate kcf_prov_mech_desc_t *me_sw_prov; /* SW provider */ 308*0Sstevel@tonic-gate /* 309*0Sstevel@tonic-gate * Number of HW providers in the chain. There is only one 310*0Sstevel@tonic-gate * SW provider. So, we need only a count of HW providers. 311*0Sstevel@tonic-gate */ 312*0Sstevel@tonic-gate int me_num_hwprov; 313*0Sstevel@tonic-gate /* 314*0Sstevel@tonic-gate * When a SW provider is present, this is the generation number that 315*0Sstevel@tonic-gate * ensures no objects from old SW providers are used in the new one 316*0Sstevel@tonic-gate */ 317*0Sstevel@tonic-gate uint32_t me_gen_swprov; 318*0Sstevel@tonic-gate /* 319*0Sstevel@tonic-gate * threshold for using hardware providers for this mech 320*0Sstevel@tonic-gate */ 321*0Sstevel@tonic-gate size_t me_threshold; 322*0Sstevel@tonic-gate } kcf_mech_entry_t; 323*0Sstevel@tonic-gate 324*0Sstevel@tonic-gate /* 325*0Sstevel@tonic-gate * A policy descriptor structure. It is allocated and initialized 326*0Sstevel@tonic-gate * when administrative ioctls load disabled mechanisms. 327*0Sstevel@tonic-gate * 328*0Sstevel@tonic-gate * pd_prov_type: Provider type, hardware or software 329*0Sstevel@tonic-gate * pd_name: Device name or module name. 330*0Sstevel@tonic-gate * pd_instance: Device instance. 331*0Sstevel@tonic-gate * pd_refcnt: Reference counter for this policy descriptor 332*0Sstevel@tonic-gate * pd_mutex: Protects array and count of disabled mechanisms. 333*0Sstevel@tonic-gate * pd_disabled_count: Count of disabled mechanisms. 334*0Sstevel@tonic-gate * pd_disabled_mechs: Array of disabled mechanisms. 335*0Sstevel@tonic-gate */ 336*0Sstevel@tonic-gate typedef struct kcf_policy_desc { 337*0Sstevel@tonic-gate crypto_provider_type_t pd_prov_type; 338*0Sstevel@tonic-gate char *pd_name; 339*0Sstevel@tonic-gate uint_t pd_instance; 340*0Sstevel@tonic-gate uint_t pd_refcnt; 341*0Sstevel@tonic-gate kmutex_t pd_mutex; 342*0Sstevel@tonic-gate uint_t pd_disabled_count; 343*0Sstevel@tonic-gate crypto_mech_name_t *pd_disabled_mechs; 344*0Sstevel@tonic-gate } kcf_policy_desc_t; 345*0Sstevel@tonic-gate 346*0Sstevel@tonic-gate /* 347*0Sstevel@tonic-gate * If a component has a reference to a kcf_policy_desc_t, 348*0Sstevel@tonic-gate * it REFHOLD()s. A new policy descriptor which is referenced only 349*0Sstevel@tonic-gate * by the policy table has a reference count of one. 350*0Sstevel@tonic-gate */ 351*0Sstevel@tonic-gate #define KCF_POLICY_REFHOLD(desc) { \ 352*0Sstevel@tonic-gate atomic_add_32(&(desc)->pd_refcnt, 1); \ 353*0Sstevel@tonic-gate ASSERT((desc)->pd_refcnt != 0); \ 354*0Sstevel@tonic-gate } 355*0Sstevel@tonic-gate 356*0Sstevel@tonic-gate /* 357*0Sstevel@tonic-gate * Releases a reference to a policy descriptor. When the last 358*0Sstevel@tonic-gate * reference is released, the descriptor is freed. 359*0Sstevel@tonic-gate */ 360*0Sstevel@tonic-gate #define KCF_POLICY_REFRELE(desc) { \ 361*0Sstevel@tonic-gate ASSERT((desc)->pd_refcnt != 0); \ 362*0Sstevel@tonic-gate membar_exit(); \ 363*0Sstevel@tonic-gate if (atomic_add_32_nv(&(desc)->pd_refcnt, -1) == 0) \ 364*0Sstevel@tonic-gate kcf_policy_free_desc(desc); \ 365*0Sstevel@tonic-gate } 366*0Sstevel@tonic-gate 367*0Sstevel@tonic-gate /* 368*0Sstevel@tonic-gate * This entry stores the name of a software module and its 369*0Sstevel@tonic-gate * mechanisms. The mechanisms are 'hints' that are used to 370*0Sstevel@tonic-gate * trigger loading of the module. 371*0Sstevel@tonic-gate */ 372*0Sstevel@tonic-gate typedef struct kcf_soft_conf_entry { 373*0Sstevel@tonic-gate struct kcf_soft_conf_entry *ce_next; 374*0Sstevel@tonic-gate char *ce_name; 375*0Sstevel@tonic-gate crypto_mech_name_t *ce_mechs; 376*0Sstevel@tonic-gate uint_t ce_count; 377*0Sstevel@tonic-gate } kcf_soft_conf_entry_t; 378*0Sstevel@tonic-gate 379*0Sstevel@tonic-gate extern kmutex_t soft_config_mutex; 380*0Sstevel@tonic-gate extern kcf_soft_conf_entry_t *soft_config_list; 381*0Sstevel@tonic-gate 382*0Sstevel@tonic-gate /* 383*0Sstevel@tonic-gate * Global tables. The sizes are from the predefined PKCS#11 v2.20 mechanisms, 384*0Sstevel@tonic-gate * with a margin of few extra empty entry points 385*0Sstevel@tonic-gate */ 386*0Sstevel@tonic-gate 387*0Sstevel@tonic-gate #define KCF_MAXDIGEST 16 /* Digests */ 388*0Sstevel@tonic-gate #define KCF_MAXCIPHER 64 /* Ciphers */ 389*0Sstevel@tonic-gate #define KCF_MAXMAC 40 /* Message authentication codes */ 390*0Sstevel@tonic-gate #define KCF_MAXSIGN 24 /* Sign/Verify */ 391*0Sstevel@tonic-gate #define KCF_MAXKEYOPS 116 /* Key generation and derivation */ 392*0Sstevel@tonic-gate #define KCF_MAXMISC 16 /* Others ... */ 393*0Sstevel@tonic-gate 394*0Sstevel@tonic-gate #define KCF_MAXMECHS KCF_MAXDIGEST + KCF_MAXCIPHER + KCF_MAXMAC + \ 395*0Sstevel@tonic-gate KCF_MAXSIGN + KCF_MAXKEYOPS + \ 396*0Sstevel@tonic-gate KCF_MAXMISC 397*0Sstevel@tonic-gate 398*0Sstevel@tonic-gate extern kcf_mech_entry_t kcf_digest_mechs_tab[]; 399*0Sstevel@tonic-gate extern kcf_mech_entry_t kcf_cipher_mechs_tab[]; 400*0Sstevel@tonic-gate extern kcf_mech_entry_t kcf_mac_mechs_tab[]; 401*0Sstevel@tonic-gate extern kcf_mech_entry_t kcf_sign_mechs_tab[]; 402*0Sstevel@tonic-gate extern kcf_mech_entry_t kcf_keyops_mechs_tab[]; 403*0Sstevel@tonic-gate extern kcf_mech_entry_t kcf_misc_mechs_tab[]; 404*0Sstevel@tonic-gate 405*0Sstevel@tonic-gate extern kmutex_t kcf_mech_tabs_lock; 406*0Sstevel@tonic-gate 407*0Sstevel@tonic-gate typedef enum { 408*0Sstevel@tonic-gate KCF_DIGEST_CLASS = 1, 409*0Sstevel@tonic-gate KCF_CIPHER_CLASS, 410*0Sstevel@tonic-gate KCF_MAC_CLASS, 411*0Sstevel@tonic-gate KCF_SIGN_CLASS, 412*0Sstevel@tonic-gate KCF_KEYOPS_CLASS, 413*0Sstevel@tonic-gate KCF_MISC_CLASS 414*0Sstevel@tonic-gate } kcf_ops_class_t; 415*0Sstevel@tonic-gate 416*0Sstevel@tonic-gate #define KCF_FIRST_OPSCLASS KCF_DIGEST_CLASS 417*0Sstevel@tonic-gate #define KCF_LAST_OPSCLASS KCF_MISC_CLASS 418*0Sstevel@tonic-gate 419*0Sstevel@tonic-gate /* The table of all the kcf_xxx_mech_tab[]s, indexed by kcf_ops_class */ 420*0Sstevel@tonic-gate 421*0Sstevel@tonic-gate typedef struct kcf_mech_entry_tab { 422*0Sstevel@tonic-gate int met_size; /* Size of the met_tab[] */ 423*0Sstevel@tonic-gate kcf_mech_entry_t *met_tab; /* the table */ 424*0Sstevel@tonic-gate } kcf_mech_entry_tab_t; 425*0Sstevel@tonic-gate 426*0Sstevel@tonic-gate extern kcf_mech_entry_tab_t kcf_mech_tabs_tab[]; 427*0Sstevel@tonic-gate 428*0Sstevel@tonic-gate #define KCF_MECHID(class, index) \ 429*0Sstevel@tonic-gate (((crypto_mech_type_t)(class) << 32) | (crypto_mech_type_t)(index)) 430*0Sstevel@tonic-gate 431*0Sstevel@tonic-gate #define KCF_MECH2CLASS(mech_type) ((kcf_ops_class_t)((mech_type) >> 32)) 432*0Sstevel@tonic-gate 433*0Sstevel@tonic-gate #define KCF_MECH2INDEX(mech_type) ((int)(mech_type)) 434*0Sstevel@tonic-gate 435*0Sstevel@tonic-gate /* ps_refcnt is protected by cm_lock in the crypto_minor structure */ 436*0Sstevel@tonic-gate typedef struct crypto_provider_session { 437*0Sstevel@tonic-gate struct crypto_provider_session *ps_next; 438*0Sstevel@tonic-gate crypto_session_id_t ps_session; 439*0Sstevel@tonic-gate kcf_provider_desc_t *ps_provider; 440*0Sstevel@tonic-gate kcf_provider_desc_t *ps_real_provider; 441*0Sstevel@tonic-gate uint_t ps_refcnt; 442*0Sstevel@tonic-gate } crypto_provider_session_t; 443*0Sstevel@tonic-gate 444*0Sstevel@tonic-gate typedef struct crypto_session_data { 445*0Sstevel@tonic-gate kmutex_t sd_lock; 446*0Sstevel@tonic-gate kcondvar_t sd_cv; 447*0Sstevel@tonic-gate uint32_t sd_flags; 448*0Sstevel@tonic-gate crypto_ctx_t *sd_digest_ctx; 449*0Sstevel@tonic-gate crypto_ctx_t *sd_encr_ctx; 450*0Sstevel@tonic-gate crypto_ctx_t *sd_decr_ctx; 451*0Sstevel@tonic-gate crypto_ctx_t *sd_sign_ctx; 452*0Sstevel@tonic-gate crypto_ctx_t *sd_verify_ctx; 453*0Sstevel@tonic-gate crypto_ctx_t *sd_sign_recover_ctx; 454*0Sstevel@tonic-gate crypto_ctx_t *sd_verify_recover_ctx; 455*0Sstevel@tonic-gate kcf_provider_desc_t *sd_provider; 456*0Sstevel@tonic-gate void *sd_find_init_cookie; 457*0Sstevel@tonic-gate crypto_provider_session_t *sd_provider_session; 458*0Sstevel@tonic-gate } crypto_session_data_t; 459*0Sstevel@tonic-gate 460*0Sstevel@tonic-gate #define CRYPTO_SESSION_IN_USE 0x00000001 461*0Sstevel@tonic-gate #define CRYPTO_SESSION_IS_BUSY 0x00000002 462*0Sstevel@tonic-gate #define CRYPTO_SESSION_IS_CLOSED 0x00000004 463*0Sstevel@tonic-gate 464*0Sstevel@tonic-gate #define KCF_MAX_PIN_LEN 1024 465*0Sstevel@tonic-gate 466*0Sstevel@tonic-gate /* 467*0Sstevel@tonic-gate * Per-minor info. 468*0Sstevel@tonic-gate * 469*0Sstevel@tonic-gate * cm_lock protects everything in this structure except for cm_refcnt. 470*0Sstevel@tonic-gate */ 471*0Sstevel@tonic-gate typedef struct crypto_minor { 472*0Sstevel@tonic-gate uint_t cm_refcnt; 473*0Sstevel@tonic-gate kmutex_t cm_lock; 474*0Sstevel@tonic-gate kcondvar_t cm_cv; 475*0Sstevel@tonic-gate crypto_session_data_t **cm_session_table; 476*0Sstevel@tonic-gate uint_t cm_session_table_count; 477*0Sstevel@tonic-gate kcf_provider_desc_t **cm_provider_array; 478*0Sstevel@tonic-gate uint_t cm_provider_count; 479*0Sstevel@tonic-gate crypto_provider_session_t *cm_provider_session; 480*0Sstevel@tonic-gate kproject_t *cm_projp; 481*0Sstevel@tonic-gate } crypto_minor_t; 482*0Sstevel@tonic-gate 483*0Sstevel@tonic-gate /* resource control framework handle used by /dev/crypto */ 484*0Sstevel@tonic-gate extern rctl_hndl_t rc_project_crypto_mem; 485*0Sstevel@tonic-gate /* 486*0Sstevel@tonic-gate * Return codes for internal functions 487*0Sstevel@tonic-gate */ 488*0Sstevel@tonic-gate #define KCF_SUCCESS 0x0 /* Successful call */ 489*0Sstevel@tonic-gate #define KCF_INVALID_MECH_NUMBER 0x1 /* invalid mechanism number */ 490*0Sstevel@tonic-gate #define KCF_INVALID_MECH_NAME 0x2 /* invalid mechanism name */ 491*0Sstevel@tonic-gate #define KCF_INVALID_MECH_CLASS 0x3 /* invalid mechanism class */ 492*0Sstevel@tonic-gate #define KCF_MECH_TAB_FULL 0x4 /* Need more room in the mech tabs. */ 493*0Sstevel@tonic-gate 494*0Sstevel@tonic-gate /* 495*0Sstevel@tonic-gate * kCF internal mechanism and function group for tracking RNG providers. 496*0Sstevel@tonic-gate */ 497*0Sstevel@tonic-gate #define SUN_RANDOM "random" 498*0Sstevel@tonic-gate #define CRYPTO_FG_RANDOM 0x80000000 /* generate_random() */ 499*0Sstevel@tonic-gate 500*0Sstevel@tonic-gate /* 501*0Sstevel@tonic-gate * Wrappers for ops vectors. In the wrapper definitions below, the pd 502*0Sstevel@tonic-gate * argument always corresponds to a pointer to a provider descriptor 503*0Sstevel@tonic-gate * of type kcf_prov_desc_t. 504*0Sstevel@tonic-gate */ 505*0Sstevel@tonic-gate 506*0Sstevel@tonic-gate #define KCF_PROV_CONTROL_OPS(pd) ((pd)->pd_ops_vector->control_ops) 507*0Sstevel@tonic-gate #define KCF_PROV_CTX_OPS(pd) ((pd)->pd_ops_vector->ctx_ops) 508*0Sstevel@tonic-gate #define KCF_PROV_DIGEST_OPS(pd) ((pd)->pd_ops_vector->digest_ops) 509*0Sstevel@tonic-gate #define KCF_PROV_CIPHER_OPS(pd) ((pd)->pd_ops_vector->cipher_ops) 510*0Sstevel@tonic-gate #define KCF_PROV_MAC_OPS(pd) ((pd)->pd_ops_vector->mac_ops) 511*0Sstevel@tonic-gate #define KCF_PROV_SIGN_OPS(pd) ((pd)->pd_ops_vector->sign_ops) 512*0Sstevel@tonic-gate #define KCF_PROV_VERIFY_OPS(pd) ((pd)->pd_ops_vector->verify_ops) 513*0Sstevel@tonic-gate #define KCF_PROV_DUAL_OPS(pd) ((pd)->pd_ops_vector->dual_ops) 514*0Sstevel@tonic-gate #define KCF_PROV_DUAL_CIPHER_MAC_OPS(pd) \ 515*0Sstevel@tonic-gate ((pd)->pd_ops_vector->dual_cipher_mac_ops) 516*0Sstevel@tonic-gate #define KCF_PROV_RANDOM_OPS(pd) ((pd)->pd_ops_vector->random_ops) 517*0Sstevel@tonic-gate #define KCF_PROV_SESSION_OPS(pd) ((pd)->pd_ops_vector->session_ops) 518*0Sstevel@tonic-gate #define KCF_PROV_OBJECT_OPS(pd) ((pd)->pd_ops_vector->object_ops) 519*0Sstevel@tonic-gate #define KCF_PROV_KEY_OPS(pd) ((pd)->pd_ops_vector->key_ops) 520*0Sstevel@tonic-gate #define KCF_PROV_PROVIDER_OPS(pd) ((pd)->pd_ops_vector->provider_ops) 521*0Sstevel@tonic-gate 522*0Sstevel@tonic-gate /* 523*0Sstevel@tonic-gate * Wrappers for crypto_control_ops(9S) entry points. 524*0Sstevel@tonic-gate */ 525*0Sstevel@tonic-gate 526*0Sstevel@tonic-gate #define KCF_PROV_STATUS(pd, status) ( \ 527*0Sstevel@tonic-gate (KCF_PROV_CONTROL_OPS(pd) && \ 528*0Sstevel@tonic-gate KCF_PROV_CONTROL_OPS(pd)->provider_status) ? \ 529*0Sstevel@tonic-gate KCF_PROV_CONTROL_OPS(pd)->provider_status( \ 530*0Sstevel@tonic-gate (pd)->pd_prov_handle, status) : \ 531*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 532*0Sstevel@tonic-gate 533*0Sstevel@tonic-gate /* 534*0Sstevel@tonic-gate * Wrappers for crypto_ctx_ops(9S) entry points. 535*0Sstevel@tonic-gate */ 536*0Sstevel@tonic-gate 537*0Sstevel@tonic-gate #define KCF_PROV_CREATE_CTX_TEMPLATE(pd, mech, key, template, size, req) ( \ 538*0Sstevel@tonic-gate (KCF_PROV_CTX_OPS(pd) && KCF_PROV_CTX_OPS(pd)->create_ctx_template) ? \ 539*0Sstevel@tonic-gate KCF_PROV_CTX_OPS(pd)->create_ctx_template( \ 540*0Sstevel@tonic-gate (pd)->pd_prov_handle, mech, key, template, size, req) : \ 541*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 542*0Sstevel@tonic-gate 543*0Sstevel@tonic-gate #define KCF_PROV_FREE_CONTEXT(pd, ctx) ( \ 544*0Sstevel@tonic-gate (KCF_PROV_CTX_OPS(pd) && KCF_PROV_CTX_OPS(pd)->free_context) ? \ 545*0Sstevel@tonic-gate KCF_PROV_CTX_OPS(pd)->free_context(ctx) : CRYPTO_NOT_SUPPORTED) 546*0Sstevel@tonic-gate 547*0Sstevel@tonic-gate /* 548*0Sstevel@tonic-gate * Wrappers for crypto_digest_ops(9S) entry points. 549*0Sstevel@tonic-gate */ 550*0Sstevel@tonic-gate 551*0Sstevel@tonic-gate #define KCF_PROV_DIGEST_INIT(pd, ctx, mech, req) ( \ 552*0Sstevel@tonic-gate (KCF_PROV_DIGEST_OPS(pd) && KCF_PROV_DIGEST_OPS(pd)->digest_init) ? \ 553*0Sstevel@tonic-gate KCF_PROV_DIGEST_OPS(pd)->digest_init(ctx, mech, req) : \ 554*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 555*0Sstevel@tonic-gate 556*0Sstevel@tonic-gate /* 557*0Sstevel@tonic-gate * The _ (underscore) in _digest is needed to avoid replacing the 558*0Sstevel@tonic-gate * function digest(). 559*0Sstevel@tonic-gate */ 560*0Sstevel@tonic-gate #define KCF_PROV_DIGEST(pd, ctx, data, _digest, req) ( \ 561*0Sstevel@tonic-gate (KCF_PROV_DIGEST_OPS(pd) && KCF_PROV_DIGEST_OPS(pd)->digest) ? \ 562*0Sstevel@tonic-gate KCF_PROV_DIGEST_OPS(pd)->digest(ctx, data, _digest, req) : \ 563*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 564*0Sstevel@tonic-gate 565*0Sstevel@tonic-gate #define KCF_PROV_DIGEST_UPDATE(pd, ctx, data, req) ( \ 566*0Sstevel@tonic-gate (KCF_PROV_DIGEST_OPS(pd) && KCF_PROV_DIGEST_OPS(pd)->digest_update) ? \ 567*0Sstevel@tonic-gate KCF_PROV_DIGEST_OPS(pd)->digest_update(ctx, data, req) : \ 568*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 569*0Sstevel@tonic-gate 570*0Sstevel@tonic-gate #define KCF_PROV_DIGEST_KEY(pd, ctx, key, req) ( \ 571*0Sstevel@tonic-gate (KCF_PROV_DIGEST_OPS(pd) && KCF_PROV_DIGEST_OPS(pd)->digest_key) ? \ 572*0Sstevel@tonic-gate KCF_PROV_DIGEST_OPS(pd)->digest_key(ctx, key, req) : \ 573*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 574*0Sstevel@tonic-gate 575*0Sstevel@tonic-gate #define KCF_PROV_DIGEST_FINAL(pd, ctx, digest, req) ( \ 576*0Sstevel@tonic-gate (KCF_PROV_DIGEST_OPS(pd) && KCF_PROV_DIGEST_OPS(pd)->digest_final) ? \ 577*0Sstevel@tonic-gate KCF_PROV_DIGEST_OPS(pd)->digest_final(ctx, digest, req) : \ 578*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 579*0Sstevel@tonic-gate 580*0Sstevel@tonic-gate #define KCF_PROV_DIGEST_ATOMIC(pd, session, mech, data, digest, req) ( \ 581*0Sstevel@tonic-gate (KCF_PROV_DIGEST_OPS(pd) && KCF_PROV_DIGEST_OPS(pd)->digest_atomic) ? \ 582*0Sstevel@tonic-gate KCF_PROV_DIGEST_OPS(pd)->digest_atomic( \ 583*0Sstevel@tonic-gate (pd)->pd_prov_handle, session, mech, data, digest, req) : \ 584*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 585*0Sstevel@tonic-gate 586*0Sstevel@tonic-gate /* 587*0Sstevel@tonic-gate * Wrappers for crypto_cipher_ops(9S) entry points. 588*0Sstevel@tonic-gate */ 589*0Sstevel@tonic-gate 590*0Sstevel@tonic-gate #define KCF_PROV_ENCRYPT_INIT(pd, ctx, mech, key, template, req) ( \ 591*0Sstevel@tonic-gate (KCF_PROV_CIPHER_OPS(pd) && KCF_PROV_CIPHER_OPS(pd)->encrypt_init) ? \ 592*0Sstevel@tonic-gate KCF_PROV_CIPHER_OPS(pd)->encrypt_init(ctx, mech, key, template, \ 593*0Sstevel@tonic-gate req) : \ 594*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 595*0Sstevel@tonic-gate 596*0Sstevel@tonic-gate #define KCF_PROV_ENCRYPT(pd, ctx, plaintext, ciphertext, req) ( \ 597*0Sstevel@tonic-gate (KCF_PROV_CIPHER_OPS(pd) && KCF_PROV_CIPHER_OPS(pd)->encrypt) ? \ 598*0Sstevel@tonic-gate KCF_PROV_CIPHER_OPS(pd)->encrypt(ctx, plaintext, ciphertext, req) : \ 599*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 600*0Sstevel@tonic-gate 601*0Sstevel@tonic-gate #define KCF_PROV_ENCRYPT_UPDATE(pd, ctx, plaintext, ciphertext, req) ( \ 602*0Sstevel@tonic-gate (KCF_PROV_CIPHER_OPS(pd) && KCF_PROV_CIPHER_OPS(pd)->encrypt_update) ? \ 603*0Sstevel@tonic-gate KCF_PROV_CIPHER_OPS(pd)->encrypt_update(ctx, plaintext, \ 604*0Sstevel@tonic-gate ciphertext, req) : \ 605*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 606*0Sstevel@tonic-gate 607*0Sstevel@tonic-gate #define KCF_PROV_ENCRYPT_FINAL(pd, ctx, ciphertext, req) ( \ 608*0Sstevel@tonic-gate (KCF_PROV_CIPHER_OPS(pd) && KCF_PROV_CIPHER_OPS(pd)->encrypt_final) ? \ 609*0Sstevel@tonic-gate KCF_PROV_CIPHER_OPS(pd)->encrypt_final(ctx, ciphertext, req) : \ 610*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 611*0Sstevel@tonic-gate 612*0Sstevel@tonic-gate #define KCF_PROV_ENCRYPT_ATOMIC(pd, session, mech, key, plaintext, ciphertext, \ 613*0Sstevel@tonic-gate template, req) ( \ 614*0Sstevel@tonic-gate (KCF_PROV_CIPHER_OPS(pd) && KCF_PROV_CIPHER_OPS(pd)->encrypt_atomic) ? \ 615*0Sstevel@tonic-gate KCF_PROV_CIPHER_OPS(pd)->encrypt_atomic( \ 616*0Sstevel@tonic-gate (pd)->pd_prov_handle, session, mech, key, plaintext, ciphertext, \ 617*0Sstevel@tonic-gate template, req) : \ 618*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 619*0Sstevel@tonic-gate 620*0Sstevel@tonic-gate #define KCF_PROV_DECRYPT_INIT(pd, ctx, mech, key, template, req) ( \ 621*0Sstevel@tonic-gate (KCF_PROV_CIPHER_OPS(pd) && KCF_PROV_CIPHER_OPS(pd)->decrypt_init) ? \ 622*0Sstevel@tonic-gate KCF_PROV_CIPHER_OPS(pd)->decrypt_init(ctx, mech, key, template, \ 623*0Sstevel@tonic-gate req) : \ 624*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 625*0Sstevel@tonic-gate 626*0Sstevel@tonic-gate #define KCF_PROV_DECRYPT(pd, ctx, ciphertext, plaintext, req) ( \ 627*0Sstevel@tonic-gate (KCF_PROV_CIPHER_OPS(pd) && KCF_PROV_CIPHER_OPS(pd)->decrypt) ? \ 628*0Sstevel@tonic-gate KCF_PROV_CIPHER_OPS(pd)->decrypt(ctx, ciphertext, plaintext, req) : \ 629*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 630*0Sstevel@tonic-gate 631*0Sstevel@tonic-gate #define KCF_PROV_DECRYPT_UPDATE(pd, ctx, ciphertext, plaintext, req) ( \ 632*0Sstevel@tonic-gate (KCF_PROV_CIPHER_OPS(pd) && KCF_PROV_CIPHER_OPS(pd)->decrypt_update) ? \ 633*0Sstevel@tonic-gate KCF_PROV_CIPHER_OPS(pd)->decrypt_update(ctx, ciphertext, \ 634*0Sstevel@tonic-gate plaintext, req) : \ 635*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 636*0Sstevel@tonic-gate 637*0Sstevel@tonic-gate #define KCF_PROV_DECRYPT_FINAL(pd, ctx, plaintext, req) ( \ 638*0Sstevel@tonic-gate (KCF_PROV_CIPHER_OPS(pd) && KCF_PROV_CIPHER_OPS(pd)->decrypt_final) ? \ 639*0Sstevel@tonic-gate KCF_PROV_CIPHER_OPS(pd)->decrypt_final(ctx, plaintext, req) : \ 640*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 641*0Sstevel@tonic-gate 642*0Sstevel@tonic-gate #define KCF_PROV_DECRYPT_ATOMIC(pd, session, mech, key, ciphertext, plaintext, \ 643*0Sstevel@tonic-gate template, req) ( \ 644*0Sstevel@tonic-gate (KCF_PROV_CIPHER_OPS(pd) && KCF_PROV_CIPHER_OPS(pd)->decrypt_atomic) ? \ 645*0Sstevel@tonic-gate KCF_PROV_CIPHER_OPS(pd)->decrypt_atomic( \ 646*0Sstevel@tonic-gate (pd)->pd_prov_handle, session, mech, key, ciphertext, plaintext, \ 647*0Sstevel@tonic-gate template, req) : \ 648*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 649*0Sstevel@tonic-gate 650*0Sstevel@tonic-gate /* 651*0Sstevel@tonic-gate * Wrappers for crypto_mac_ops(9S) entry points. 652*0Sstevel@tonic-gate */ 653*0Sstevel@tonic-gate 654*0Sstevel@tonic-gate #define KCF_PROV_MAC_INIT(pd, ctx, mech, key, template, req) ( \ 655*0Sstevel@tonic-gate (KCF_PROV_MAC_OPS(pd) && KCF_PROV_MAC_OPS(pd)->mac_init) ? \ 656*0Sstevel@tonic-gate KCF_PROV_MAC_OPS(pd)->mac_init(ctx, mech, key, template, req) \ 657*0Sstevel@tonic-gate : CRYPTO_NOT_SUPPORTED) 658*0Sstevel@tonic-gate 659*0Sstevel@tonic-gate /* 660*0Sstevel@tonic-gate * The _ (underscore) in _mac is needed to avoid replacing the 661*0Sstevel@tonic-gate * function mac(). 662*0Sstevel@tonic-gate */ 663*0Sstevel@tonic-gate #define KCF_PROV_MAC(pd, ctx, data, _mac, req) ( \ 664*0Sstevel@tonic-gate (KCF_PROV_MAC_OPS(pd) && KCF_PROV_MAC_OPS(pd)->mac) ? \ 665*0Sstevel@tonic-gate KCF_PROV_MAC_OPS(pd)->mac(ctx, data, _mac, req) : \ 666*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 667*0Sstevel@tonic-gate 668*0Sstevel@tonic-gate #define KCF_PROV_MAC_UPDATE(pd, ctx, data, req) ( \ 669*0Sstevel@tonic-gate (KCF_PROV_MAC_OPS(pd) && KCF_PROV_MAC_OPS(pd)->mac_update) ? \ 670*0Sstevel@tonic-gate KCF_PROV_MAC_OPS(pd)->mac_update(ctx, data, req) : \ 671*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 672*0Sstevel@tonic-gate 673*0Sstevel@tonic-gate #define KCF_PROV_MAC_FINAL(pd, ctx, mac, req) ( \ 674*0Sstevel@tonic-gate (KCF_PROV_MAC_OPS(pd) && KCF_PROV_MAC_OPS(pd)->mac_final) ? \ 675*0Sstevel@tonic-gate KCF_PROV_MAC_OPS(pd)->mac_final(ctx, mac, req) : \ 676*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 677*0Sstevel@tonic-gate 678*0Sstevel@tonic-gate #define KCF_PROV_MAC_ATOMIC(pd, session, mech, key, data, mac, template, \ 679*0Sstevel@tonic-gate req) ( \ 680*0Sstevel@tonic-gate (KCF_PROV_MAC_OPS(pd) && KCF_PROV_MAC_OPS(pd)->mac_atomic) ? \ 681*0Sstevel@tonic-gate KCF_PROV_MAC_OPS(pd)->mac_atomic( \ 682*0Sstevel@tonic-gate (pd)->pd_prov_handle, session, mech, key, data, mac, template, \ 683*0Sstevel@tonic-gate req) : \ 684*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 685*0Sstevel@tonic-gate 686*0Sstevel@tonic-gate #define KCF_PROV_MAC_VERIFY_ATOMIC(pd, session, mech, key, data, mac, \ 687*0Sstevel@tonic-gate template, req) ( \ 688*0Sstevel@tonic-gate (KCF_PROV_MAC_OPS(pd) && KCF_PROV_MAC_OPS(pd)->mac_verify_atomic) ? \ 689*0Sstevel@tonic-gate KCF_PROV_MAC_OPS(pd)->mac_verify_atomic( \ 690*0Sstevel@tonic-gate (pd)->pd_prov_handle, session, mech, key, data, mac, template, \ 691*0Sstevel@tonic-gate req) : \ 692*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 693*0Sstevel@tonic-gate 694*0Sstevel@tonic-gate /* 695*0Sstevel@tonic-gate * Wrappers for crypto_sign_ops(9S) entry points. 696*0Sstevel@tonic-gate */ 697*0Sstevel@tonic-gate 698*0Sstevel@tonic-gate #define KCF_PROV_SIGN_INIT(pd, ctx, mech, key, template, req) ( \ 699*0Sstevel@tonic-gate (KCF_PROV_SIGN_OPS(pd) && KCF_PROV_SIGN_OPS(pd)->sign_init) ? \ 700*0Sstevel@tonic-gate KCF_PROV_SIGN_OPS(pd)->sign_init( \ 701*0Sstevel@tonic-gate ctx, mech, key, template, req) : CRYPTO_NOT_SUPPORTED) 702*0Sstevel@tonic-gate 703*0Sstevel@tonic-gate #define KCF_PROV_SIGN(pd, ctx, data, sig, req) ( \ 704*0Sstevel@tonic-gate (KCF_PROV_SIGN_OPS(pd) && KCF_PROV_SIGN_OPS(pd)->sign) ? \ 705*0Sstevel@tonic-gate KCF_PROV_SIGN_OPS(pd)->sign(ctx, data, sig, req) : \ 706*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 707*0Sstevel@tonic-gate 708*0Sstevel@tonic-gate #define KCF_PROV_SIGN_UPDATE(pd, ctx, data, req) ( \ 709*0Sstevel@tonic-gate (KCF_PROV_SIGN_OPS(pd) && KCF_PROV_SIGN_OPS(pd)->sign_update) ? \ 710*0Sstevel@tonic-gate KCF_PROV_SIGN_OPS(pd)->sign_update(ctx, data, req) : \ 711*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 712*0Sstevel@tonic-gate 713*0Sstevel@tonic-gate #define KCF_PROV_SIGN_FINAL(pd, ctx, sig, req) ( \ 714*0Sstevel@tonic-gate (KCF_PROV_SIGN_OPS(pd) && KCF_PROV_SIGN_OPS(pd)->sign_final) ? \ 715*0Sstevel@tonic-gate KCF_PROV_SIGN_OPS(pd)->sign_final(ctx, sig, req) : \ 716*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 717*0Sstevel@tonic-gate 718*0Sstevel@tonic-gate #define KCF_PROV_SIGN_ATOMIC(pd, session, mech, key, data, template, \ 719*0Sstevel@tonic-gate sig, req) ( \ 720*0Sstevel@tonic-gate (KCF_PROV_SIGN_OPS(pd) && KCF_PROV_SIGN_OPS(pd)->sign_atomic) ? \ 721*0Sstevel@tonic-gate KCF_PROV_SIGN_OPS(pd)->sign_atomic( \ 722*0Sstevel@tonic-gate (pd)->pd_prov_handle, session, mech, key, data, sig, template, \ 723*0Sstevel@tonic-gate req) : CRYPTO_NOT_SUPPORTED) 724*0Sstevel@tonic-gate 725*0Sstevel@tonic-gate #define KCF_PROV_SIGN_RECOVER_INIT(pd, ctx, mech, key, template, \ 726*0Sstevel@tonic-gate req) ( \ 727*0Sstevel@tonic-gate (KCF_PROV_SIGN_OPS(pd) && KCF_PROV_SIGN_OPS(pd)->sign_recover_init) ? \ 728*0Sstevel@tonic-gate KCF_PROV_SIGN_OPS(pd)->sign_recover_init(ctx, mech, key, template, \ 729*0Sstevel@tonic-gate req) : CRYPTO_NOT_SUPPORTED) 730*0Sstevel@tonic-gate 731*0Sstevel@tonic-gate #define KCF_PROV_SIGN_RECOVER(pd, ctx, data, sig, req) ( \ 732*0Sstevel@tonic-gate (KCF_PROV_SIGN_OPS(pd) && KCF_PROV_SIGN_OPS(pd)->sign_recover) ? \ 733*0Sstevel@tonic-gate KCF_PROV_SIGN_OPS(pd)->sign_recover(ctx, data, sig, req) : \ 734*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 735*0Sstevel@tonic-gate 736*0Sstevel@tonic-gate #define KCF_PROV_SIGN_RECOVER_ATOMIC(pd, session, mech, key, data, template, \ 737*0Sstevel@tonic-gate sig, req) ( \ 738*0Sstevel@tonic-gate (KCF_PROV_SIGN_OPS(pd) && \ 739*0Sstevel@tonic-gate KCF_PROV_SIGN_OPS(pd)->sign_recover_atomic) ? \ 740*0Sstevel@tonic-gate KCF_PROV_SIGN_OPS(pd)->sign_recover_atomic( \ 741*0Sstevel@tonic-gate (pd)->pd_prov_handle, session, mech, key, data, sig, template, \ 742*0Sstevel@tonic-gate req) : CRYPTO_NOT_SUPPORTED) 743*0Sstevel@tonic-gate 744*0Sstevel@tonic-gate /* 745*0Sstevel@tonic-gate * Wrappers for crypto_verify_ops(9S) entry points. 746*0Sstevel@tonic-gate */ 747*0Sstevel@tonic-gate 748*0Sstevel@tonic-gate #define KCF_PROV_VERIFY_INIT(pd, ctx, mech, key, template, req) ( \ 749*0Sstevel@tonic-gate (KCF_PROV_VERIFY_OPS(pd) && KCF_PROV_VERIFY_OPS(pd)->verify_init) ? \ 750*0Sstevel@tonic-gate KCF_PROV_VERIFY_OPS(pd)->verify_init(ctx, mech, key, template, \ 751*0Sstevel@tonic-gate req) : CRYPTO_NOT_SUPPORTED) 752*0Sstevel@tonic-gate 753*0Sstevel@tonic-gate #define KCF_PROV_VERIFY(pd, ctx, data, sig, req) ( \ 754*0Sstevel@tonic-gate (KCF_PROV_VERIFY_OPS(pd) && KCF_PROV_VERIFY_OPS(pd)->verify) ? \ 755*0Sstevel@tonic-gate KCF_PROV_VERIFY_OPS(pd)->verify(ctx, data, sig, req) : \ 756*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 757*0Sstevel@tonic-gate 758*0Sstevel@tonic-gate #define KCF_PROV_VERIFY_UPDATE(pd, ctx, data, req) ( \ 759*0Sstevel@tonic-gate (KCF_PROV_VERIFY_OPS(pd) && KCF_PROV_VERIFY_OPS(pd)->verify_update) ? \ 760*0Sstevel@tonic-gate KCF_PROV_VERIFY_OPS(pd)->verify_update(ctx, data, req) : \ 761*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 762*0Sstevel@tonic-gate 763*0Sstevel@tonic-gate #define KCF_PROV_VERIFY_FINAL(pd, ctx, sig, req) ( \ 764*0Sstevel@tonic-gate (KCF_PROV_VERIFY_OPS(pd) && KCF_PROV_VERIFY_OPS(pd)->verify_final) ? \ 765*0Sstevel@tonic-gate KCF_PROV_VERIFY_OPS(pd)->verify_final(ctx, sig, req) : \ 766*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 767*0Sstevel@tonic-gate 768*0Sstevel@tonic-gate #define KCF_PROV_VERIFY_ATOMIC(pd, session, mech, key, data, template, sig, \ 769*0Sstevel@tonic-gate req) ( \ 770*0Sstevel@tonic-gate (KCF_PROV_VERIFY_OPS(pd) && KCF_PROV_VERIFY_OPS(pd)->verify_atomic) ? \ 771*0Sstevel@tonic-gate KCF_PROV_VERIFY_OPS(pd)->verify_atomic( \ 772*0Sstevel@tonic-gate (pd)->pd_prov_handle, session, mech, key, data, sig, template, \ 773*0Sstevel@tonic-gate req) : CRYPTO_NOT_SUPPORTED) 774*0Sstevel@tonic-gate 775*0Sstevel@tonic-gate #define KCF_PROV_VERIFY_RECOVER_INIT(pd, ctx, mech, key, template, \ 776*0Sstevel@tonic-gate req) ( \ 777*0Sstevel@tonic-gate (KCF_PROV_VERIFY_OPS(pd) && \ 778*0Sstevel@tonic-gate KCF_PROV_VERIFY_OPS(pd)->verify_recover_init) ? \ 779*0Sstevel@tonic-gate KCF_PROV_VERIFY_OPS(pd)->verify_recover_init(ctx, mech, key, \ 780*0Sstevel@tonic-gate template, req) : CRYPTO_NOT_SUPPORTED) 781*0Sstevel@tonic-gate 782*0Sstevel@tonic-gate /* verify_recover() CSPI routine has different argument order than verify() */ 783*0Sstevel@tonic-gate #define KCF_PROV_VERIFY_RECOVER(pd, ctx, sig, data, req) ( \ 784*0Sstevel@tonic-gate (KCF_PROV_VERIFY_OPS(pd) && KCF_PROV_VERIFY_OPS(pd)->verify_recover) ? \ 785*0Sstevel@tonic-gate KCF_PROV_VERIFY_OPS(pd)->verify_recover(ctx, sig, data, req) : \ 786*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 787*0Sstevel@tonic-gate 788*0Sstevel@tonic-gate /* 789*0Sstevel@tonic-gate * verify_recover_atomic() CSPI routine has different argument order 790*0Sstevel@tonic-gate * than verify_atomic(). 791*0Sstevel@tonic-gate */ 792*0Sstevel@tonic-gate #define KCF_PROV_VERIFY_RECOVER_ATOMIC(pd, session, mech, key, sig, \ 793*0Sstevel@tonic-gate template, data, req) ( \ 794*0Sstevel@tonic-gate (KCF_PROV_VERIFY_OPS(pd) && \ 795*0Sstevel@tonic-gate KCF_PROV_VERIFY_OPS(pd)->verify_recover_atomic) ? \ 796*0Sstevel@tonic-gate KCF_PROV_VERIFY_OPS(pd)->verify_recover_atomic( \ 797*0Sstevel@tonic-gate (pd)->pd_prov_handle, session, mech, key, sig, data, template, \ 798*0Sstevel@tonic-gate req) : CRYPTO_NOT_SUPPORTED) 799*0Sstevel@tonic-gate 800*0Sstevel@tonic-gate /* 801*0Sstevel@tonic-gate * Wrappers for crypto_dual_ops(9S) entry points. 802*0Sstevel@tonic-gate */ 803*0Sstevel@tonic-gate 804*0Sstevel@tonic-gate #define KCF_PROV_DIGEST_ENCRYPT_UPDATE(digest_ctx, encrypt_ctx, plaintext, \ 805*0Sstevel@tonic-gate ciphertext, req) ( \ 806*0Sstevel@tonic-gate (KCF_PROV_DUAL_OPS(pd) && \ 807*0Sstevel@tonic-gate KCF_PROV_DUAL_OPS(pd)->digest_encrypt_update) ? \ 808*0Sstevel@tonic-gate KCF_PROV_DUAL_OPS(pd)->digest_encrypt_update( \ 809*0Sstevel@tonic-gate digest_ctx, encrypt_ctx, plaintext, ciphertext, req) : \ 810*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 811*0Sstevel@tonic-gate 812*0Sstevel@tonic-gate #define KCF_PROV_DECRYPT_DIGEST_UPDATE(decrypt_ctx, digest_ctx, ciphertext, \ 813*0Sstevel@tonic-gate plaintext, req) ( \ 814*0Sstevel@tonic-gate (KCF_PROV_DUAL_OPS(pd) && \ 815*0Sstevel@tonic-gate KCF_PROV_DUAL_OPS(pd)->decrypt_digest_update) ? \ 816*0Sstevel@tonic-gate KCF_PROV_DUAL_OPS(pd)->decrypt_digest_update( \ 817*0Sstevel@tonic-gate decrypt_ctx, digest_ctx, ciphertext, plaintext, req) : \ 818*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 819*0Sstevel@tonic-gate 820*0Sstevel@tonic-gate #define KCF_PROV_SIGN_ENCRYPT_UPDATE(sign_ctx, encrypt_ctx, plaintext, \ 821*0Sstevel@tonic-gate ciphertext, req) ( \ 822*0Sstevel@tonic-gate (KCF_PROV_DUAL_OPS(pd) && \ 823*0Sstevel@tonic-gate KCF_PROV_DUAL_OPS(pd)->sign_encrypt_update) ? \ 824*0Sstevel@tonic-gate KCF_PROV_DUAL_OPS(pd)->sign_encrypt_update( \ 825*0Sstevel@tonic-gate sign_ctx, encrypt_ctx, plaintext, ciphertext, req) : \ 826*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 827*0Sstevel@tonic-gate 828*0Sstevel@tonic-gate #define KCF_PROV_DECRYPT_VERIFY_UPDATE(decrypt_ctx, verify_ctx, ciphertext, \ 829*0Sstevel@tonic-gate plaintext, req) ( \ 830*0Sstevel@tonic-gate (KCF_PROV_DUAL_OPS(pd) && \ 831*0Sstevel@tonic-gate KCF_PROV_DUAL_OPS(pd)->decrypt_verify_update) ? \ 832*0Sstevel@tonic-gate KCF_PROV_DUAL_OPS(pd)->decrypt_verify_update( \ 833*0Sstevel@tonic-gate decrypt_ctx, verify_ctx, ciphertext, plaintext, req) : \ 834*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 835*0Sstevel@tonic-gate 836*0Sstevel@tonic-gate /* 837*0Sstevel@tonic-gate * Wrappers for crypto_dual_cipher_mac_ops(9S) entry points. 838*0Sstevel@tonic-gate */ 839*0Sstevel@tonic-gate 840*0Sstevel@tonic-gate #define KCF_PROV_ENCRYPT_MAC_INIT(pd, ctx, encr_mech, encr_key, mac_mech, \ 841*0Sstevel@tonic-gate mac_key, encr_ctx_template, mac_ctx_template, req) ( \ 842*0Sstevel@tonic-gate (KCF_PROV_DUAL_CIPHER_MAC_OPS(pd) && \ 843*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->encrypt_mac_init) ? \ 844*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->encrypt_mac_init( \ 845*0Sstevel@tonic-gate ctx, encr_mech, encr_key, mac_mech, mac_key, encr_ctx_template, \ 846*0Sstevel@tonic-gate mac_ctx_template, req) : \ 847*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 848*0Sstevel@tonic-gate 849*0Sstevel@tonic-gate #define KCF_PROV_ENCRYPT_MAC(pd, ctx, plaintext, ciphertext, mac, req) ( \ 850*0Sstevel@tonic-gate (KCF_PROV_DUAL_CIPHER_MAC_OPS(pd) && \ 851*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->encrypt_mac) ? \ 852*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->encrypt_mac( \ 853*0Sstevel@tonic-gate ctx, plaintext, ciphertext, mac, req) : \ 854*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 855*0Sstevel@tonic-gate 856*0Sstevel@tonic-gate #define KCF_PROV_ENCRYPT_MAC_UPDATE(pd, ctx, plaintext, ciphertext, req) ( \ 857*0Sstevel@tonic-gate (KCF_PROV_DUAL_CIPHER_MAC_OPS(pd) && \ 858*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->encrypt_mac_update) ? \ 859*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->encrypt_mac_update( \ 860*0Sstevel@tonic-gate ctx, plaintext, ciphertext, req) : \ 861*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 862*0Sstevel@tonic-gate 863*0Sstevel@tonic-gate #define KCF_PROV_ENCRYPT_MAC_FINAL(pd, ctx, ciphertext, mac, req) ( \ 864*0Sstevel@tonic-gate (KCF_PROV_DUAL_CIPHER_MAC_OPS(pd) && \ 865*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->encrypt_mac_final) ? \ 866*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->encrypt_mac_final( \ 867*0Sstevel@tonic-gate ctx, ciphertext, mac, req) : \ 868*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 869*0Sstevel@tonic-gate 870*0Sstevel@tonic-gate #define KCF_PROV_ENCRYPT_MAC_ATOMIC(pd, session, encr_mech, encr_key, \ 871*0Sstevel@tonic-gate mac_mech, mac_key, plaintext, ciphertext, mac, \ 872*0Sstevel@tonic-gate encr_ctx_template, mac_ctx_template, req) ( \ 873*0Sstevel@tonic-gate (KCF_PROV_DUAL_CIPHER_MAC_OPS(pd) && \ 874*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->encrypt_mac_atomic) ? \ 875*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->encrypt_mac_atomic( \ 876*0Sstevel@tonic-gate (pd)->pd_prov_handle, session, encr_mech, encr_key, \ 877*0Sstevel@tonic-gate mac_mech, mac_key, plaintext, ciphertext, mac, \ 878*0Sstevel@tonic-gate encr_ctx_template, mac_ctx_template, req) : \ 879*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 880*0Sstevel@tonic-gate 881*0Sstevel@tonic-gate #define KCF_PROV_MAC_DECRYPT_INIT(pd, ctx, mac_mech, mac_key, decr_mech, \ 882*0Sstevel@tonic-gate decr_key, mac_ctx_template, decr_ctx_template, req) ( \ 883*0Sstevel@tonic-gate (KCF_PROV_DUAL_CIPHER_MAC_OPS(pd) && \ 884*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->mac_decrypt_init) ? \ 885*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->mac_decrypt_init( \ 886*0Sstevel@tonic-gate ctx, mac_mech, mac_key, decr_mech, decr_key, mac_ctx_template, \ 887*0Sstevel@tonic-gate decr_ctx_template, req) : \ 888*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 889*0Sstevel@tonic-gate 890*0Sstevel@tonic-gate #define KCF_PROV_MAC_DECRYPT(pd, ctx, ciphertext, mac, plaintext, req) ( \ 891*0Sstevel@tonic-gate (KCF_PROV_DUAL_CIPHER_MAC_OPS(pd) && \ 892*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->mac_decrypt) ? \ 893*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->mac_decrypt( \ 894*0Sstevel@tonic-gate ctx, ciphertext, mac, plaintext, req) : \ 895*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 896*0Sstevel@tonic-gate 897*0Sstevel@tonic-gate #define KCF_PROV_MAC_DECRYPT_UPDATE(pd, ctx, ciphertext, plaintext, req) ( \ 898*0Sstevel@tonic-gate (KCF_PROV_DUAL_CIPHER_MAC_OPS(pd) && \ 899*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->mac_decrypt_update) ? \ 900*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->mac_decrypt_update( \ 901*0Sstevel@tonic-gate ctx, ciphertext, plaintext, req) : \ 902*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 903*0Sstevel@tonic-gate 904*0Sstevel@tonic-gate #define KCF_PROV_MAC_DECRYPT_FINAL(pd, ctx, mac, plaintext, req) ( \ 905*0Sstevel@tonic-gate (KCF_PROV_DUAL_CIPHER_MAC_OPS(pd) && \ 906*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->mac_decrypt_final) ? \ 907*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->mac_decrypt_final( \ 908*0Sstevel@tonic-gate ctx, mac, plaintext, req) : \ 909*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 910*0Sstevel@tonic-gate 911*0Sstevel@tonic-gate #define KCF_PROV_MAC_DECRYPT_ATOMIC(pd, session, mac_mech, mac_key, \ 912*0Sstevel@tonic-gate decr_mech, decr_key, ciphertext, mac, plaintext, \ 913*0Sstevel@tonic-gate mac_ctx_template, decr_ctx_template, req) ( \ 914*0Sstevel@tonic-gate (KCF_PROV_DUAL_CIPHER_MAC_OPS(pd) && \ 915*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->mac_decrypt_atomic) ? \ 916*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->mac_decrypt_atomic( \ 917*0Sstevel@tonic-gate (pd)->pd_prov_handle, session, mac_mech, mac_key, \ 918*0Sstevel@tonic-gate decr_mech, decr_key, ciphertext, mac, plaintext, \ 919*0Sstevel@tonic-gate mac_ctx_template, decr_ctx_template, req) : \ 920*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 921*0Sstevel@tonic-gate 922*0Sstevel@tonic-gate #define KCF_PROV_MAC_VERIFY_DECRYPT_ATOMIC(pd, session, mac_mech, mac_key, \ 923*0Sstevel@tonic-gate decr_mech, decr_key, ciphertext, mac, plaintext, \ 924*0Sstevel@tonic-gate mac_ctx_template, decr_ctx_template, req) ( \ 925*0Sstevel@tonic-gate (KCF_PROV_DUAL_CIPHER_MAC_OPS(pd) && \ 926*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->mac_verify_decrypt_atomic \ 927*0Sstevel@tonic-gate != NULL) ? \ 928*0Sstevel@tonic-gate KCF_PROV_DUAL_CIPHER_MAC_OPS(pd)->mac_verify_decrypt_atomic( \ 929*0Sstevel@tonic-gate (pd)->pd_prov_handle, session, mac_mech, mac_key, \ 930*0Sstevel@tonic-gate decr_mech, decr_key, ciphertext, mac, plaintext, \ 931*0Sstevel@tonic-gate mac_ctx_template, decr_ctx_template, req) : \ 932*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 933*0Sstevel@tonic-gate 934*0Sstevel@tonic-gate /* 935*0Sstevel@tonic-gate * Wrappers for crypto_random_number_ops(9S) entry points. 936*0Sstevel@tonic-gate */ 937*0Sstevel@tonic-gate 938*0Sstevel@tonic-gate #define KCF_PROV_SEED_RANDOM(pd, session, buf, len, req) ( \ 939*0Sstevel@tonic-gate (KCF_PROV_RANDOM_OPS(pd) && KCF_PROV_RANDOM_OPS(pd)->seed_random) ? \ 940*0Sstevel@tonic-gate KCF_PROV_RANDOM_OPS(pd)->seed_random((pd)->pd_prov_handle, \ 941*0Sstevel@tonic-gate session, buf, len, req) : CRYPTO_NOT_SUPPORTED) 942*0Sstevel@tonic-gate 943*0Sstevel@tonic-gate #define KCF_PROV_GENERATE_RANDOM(pd, session, buf, len, req) ( \ 944*0Sstevel@tonic-gate (KCF_PROV_RANDOM_OPS(pd) && \ 945*0Sstevel@tonic-gate KCF_PROV_RANDOM_OPS(pd)->generate_random) ? \ 946*0Sstevel@tonic-gate KCF_PROV_RANDOM_OPS(pd)->generate_random((pd)->pd_prov_handle, \ 947*0Sstevel@tonic-gate session, buf, len, req) : CRYPTO_NOT_SUPPORTED) 948*0Sstevel@tonic-gate 949*0Sstevel@tonic-gate /* 950*0Sstevel@tonic-gate * Wrappers for crypto_session_ops(9S) entry points. 951*0Sstevel@tonic-gate * 952*0Sstevel@tonic-gate * ops_pd is the provider descriptor that supplies the ops_vector. 953*0Sstevel@tonic-gate * pd is the descriptor that supplies the provider handle. 954*0Sstevel@tonic-gate * Only session open/close needs two handles. 955*0Sstevel@tonic-gate */ 956*0Sstevel@tonic-gate 957*0Sstevel@tonic-gate #define KCF_PROV_SESSION_OPEN(ops_pd, session, req, pd) ( \ 958*0Sstevel@tonic-gate (KCF_PROV_SESSION_OPS(ops_pd) && \ 959*0Sstevel@tonic-gate KCF_PROV_SESSION_OPS(ops_pd)->session_open) ? \ 960*0Sstevel@tonic-gate KCF_PROV_SESSION_OPS(ops_pd)->session_open((pd)->pd_prov_handle, \ 961*0Sstevel@tonic-gate session, req) : CRYPTO_NOT_SUPPORTED) 962*0Sstevel@tonic-gate 963*0Sstevel@tonic-gate #define KCF_PROV_SESSION_CLOSE(ops_pd, session, req, pd) ( \ 964*0Sstevel@tonic-gate (KCF_PROV_SESSION_OPS(ops_pd) && \ 965*0Sstevel@tonic-gate KCF_PROV_SESSION_OPS(ops_pd)->session_close) ? \ 966*0Sstevel@tonic-gate KCF_PROV_SESSION_OPS(ops_pd)->session_close((pd)->pd_prov_handle, \ 967*0Sstevel@tonic-gate session, req) : CRYPTO_NOT_SUPPORTED) 968*0Sstevel@tonic-gate 969*0Sstevel@tonic-gate #define KCF_PROV_SESSION_LOGIN(pd, session, user_type, pin, len, req) ( \ 970*0Sstevel@tonic-gate (KCF_PROV_SESSION_OPS(pd) && \ 971*0Sstevel@tonic-gate KCF_PROV_SESSION_OPS(pd)->session_login) ? \ 972*0Sstevel@tonic-gate KCF_PROV_SESSION_OPS(pd)->session_login((pd)->pd_prov_handle, \ 973*0Sstevel@tonic-gate session, user_type, pin, len, req) : CRYPTO_NOT_SUPPORTED) 974*0Sstevel@tonic-gate 975*0Sstevel@tonic-gate #define KCF_PROV_SESSION_LOGOUT(pd, session, req) ( \ 976*0Sstevel@tonic-gate (KCF_PROV_SESSION_OPS(pd) && \ 977*0Sstevel@tonic-gate KCF_PROV_SESSION_OPS(pd)->session_logout) ? \ 978*0Sstevel@tonic-gate KCF_PROV_SESSION_OPS(pd)->session_logout((pd)->pd_prov_handle, \ 979*0Sstevel@tonic-gate session, req) : CRYPTO_NOT_SUPPORTED) 980*0Sstevel@tonic-gate 981*0Sstevel@tonic-gate /* 982*0Sstevel@tonic-gate * Wrappers for crypto_object_ops(9S) entry points. 983*0Sstevel@tonic-gate */ 984*0Sstevel@tonic-gate 985*0Sstevel@tonic-gate #define KCF_PROV_OBJECT_CREATE(pd, session, template, count, object, req) ( \ 986*0Sstevel@tonic-gate (KCF_PROV_OBJECT_OPS(pd) && KCF_PROV_OBJECT_OPS(pd)->object_create) ? \ 987*0Sstevel@tonic-gate KCF_PROV_OBJECT_OPS(pd)->object_create((pd)->pd_prov_handle, \ 988*0Sstevel@tonic-gate session, template, count, object, req) : CRYPTO_NOT_SUPPORTED) 989*0Sstevel@tonic-gate 990*0Sstevel@tonic-gate #define KCF_PROV_OBJECT_COPY(pd, session, object, template, count, \ 991*0Sstevel@tonic-gate new_object, req) ( \ 992*0Sstevel@tonic-gate (KCF_PROV_OBJECT_OPS(pd) && KCF_PROV_OBJECT_OPS(pd)->object_copy) ? \ 993*0Sstevel@tonic-gate KCF_PROV_OBJECT_OPS(pd)->object_copy((pd)->pd_prov_handle, \ 994*0Sstevel@tonic-gate session, object, template, count, new_object, req) : \ 995*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 996*0Sstevel@tonic-gate 997*0Sstevel@tonic-gate #define KCF_PROV_OBJECT_DESTROY(pd, session, object, req) ( \ 998*0Sstevel@tonic-gate (KCF_PROV_OBJECT_OPS(pd) && KCF_PROV_OBJECT_OPS(pd)->object_destroy) ? \ 999*0Sstevel@tonic-gate KCF_PROV_OBJECT_OPS(pd)->object_destroy((pd)->pd_prov_handle, \ 1000*0Sstevel@tonic-gate session, object, req) : CRYPTO_NOT_SUPPORTED) 1001*0Sstevel@tonic-gate 1002*0Sstevel@tonic-gate #define KCF_PROV_OBJECT_GET_SIZE(pd, session, object, size, req) ( \ 1003*0Sstevel@tonic-gate (KCF_PROV_OBJECT_OPS(pd) && \ 1004*0Sstevel@tonic-gate KCF_PROV_OBJECT_OPS(pd)->object_get_size) ? \ 1005*0Sstevel@tonic-gate KCF_PROV_OBJECT_OPS(pd)->object_get_size((pd)->pd_prov_handle, \ 1006*0Sstevel@tonic-gate session, object, size, req) : CRYPTO_NOT_SUPPORTED) 1007*0Sstevel@tonic-gate 1008*0Sstevel@tonic-gate #define KCF_PROV_OBJECT_GET_ATTRIBUTE_VALUE(pd, session, object, template, \ 1009*0Sstevel@tonic-gate count, req) ( \ 1010*0Sstevel@tonic-gate (KCF_PROV_OBJECT_OPS(pd) && \ 1011*0Sstevel@tonic-gate KCF_PROV_OBJECT_OPS(pd)->object_get_attribute_value) ? \ 1012*0Sstevel@tonic-gate KCF_PROV_OBJECT_OPS(pd)->object_get_attribute_value( \ 1013*0Sstevel@tonic-gate (pd)->pd_prov_handle, session, object, template, count, req) : \ 1014*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 1015*0Sstevel@tonic-gate 1016*0Sstevel@tonic-gate #define KCF_PROV_OBJECT_SET_ATTRIBUTE_VALUE(pd, session, object, template, \ 1017*0Sstevel@tonic-gate count, req) ( \ 1018*0Sstevel@tonic-gate (KCF_PROV_OBJECT_OPS(pd) && \ 1019*0Sstevel@tonic-gate KCF_PROV_OBJECT_OPS(pd)->object_set_attribute_value) ? \ 1020*0Sstevel@tonic-gate KCF_PROV_OBJECT_OPS(pd)->object_set_attribute_value( \ 1021*0Sstevel@tonic-gate (pd)->pd_prov_handle, session, object, template, count, req) : \ 1022*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 1023*0Sstevel@tonic-gate 1024*0Sstevel@tonic-gate #define KCF_PROV_OBJECT_FIND_INIT(pd, session, template, count, ppriv, \ 1025*0Sstevel@tonic-gate req) ( \ 1026*0Sstevel@tonic-gate (KCF_PROV_OBJECT_OPS(pd) && \ 1027*0Sstevel@tonic-gate KCF_PROV_OBJECT_OPS(pd)->object_find_init) ? \ 1028*0Sstevel@tonic-gate KCF_PROV_OBJECT_OPS(pd)->object_find_init((pd)->pd_prov_handle, \ 1029*0Sstevel@tonic-gate session, template, count, ppriv, req) : CRYPTO_NOT_SUPPORTED) 1030*0Sstevel@tonic-gate 1031*0Sstevel@tonic-gate #define KCF_PROV_OBJECT_FIND(pd, ppriv, objects, max_objects, object_count, \ 1032*0Sstevel@tonic-gate req) ( \ 1033*0Sstevel@tonic-gate (KCF_PROV_OBJECT_OPS(pd) && KCF_PROV_OBJECT_OPS(pd)->object_find) ? \ 1034*0Sstevel@tonic-gate KCF_PROV_OBJECT_OPS(pd)->object_find( \ 1035*0Sstevel@tonic-gate (pd)->pd_prov_handle, ppriv, objects, max_objects, object_count, \ 1036*0Sstevel@tonic-gate req) : CRYPTO_NOT_SUPPORTED) 1037*0Sstevel@tonic-gate 1038*0Sstevel@tonic-gate #define KCF_PROV_OBJECT_FIND_FINAL(pd, ppriv, req) ( \ 1039*0Sstevel@tonic-gate (KCF_PROV_OBJECT_OPS(pd) && \ 1040*0Sstevel@tonic-gate KCF_PROV_OBJECT_OPS(pd)->object_find_final) ? \ 1041*0Sstevel@tonic-gate KCF_PROV_OBJECT_OPS(pd)->object_find_final( \ 1042*0Sstevel@tonic-gate (pd)->pd_prov_handle, ppriv, req) : CRYPTO_NOT_SUPPORTED) 1043*0Sstevel@tonic-gate 1044*0Sstevel@tonic-gate /* 1045*0Sstevel@tonic-gate * Wrappers for crypto_key_ops(9S) entry points. 1046*0Sstevel@tonic-gate */ 1047*0Sstevel@tonic-gate 1048*0Sstevel@tonic-gate #define KCF_PROV_KEY_GENERATE(pd, session, mech, template, count, object, \ 1049*0Sstevel@tonic-gate req) ( \ 1050*0Sstevel@tonic-gate (KCF_PROV_KEY_OPS(pd) && KCF_PROV_KEY_OPS(pd)->key_generate) ? \ 1051*0Sstevel@tonic-gate KCF_PROV_KEY_OPS(pd)->key_generate((pd)->pd_prov_handle, \ 1052*0Sstevel@tonic-gate session, mech, template, count, object, req) : \ 1053*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 1054*0Sstevel@tonic-gate 1055*0Sstevel@tonic-gate #define KCF_PROV_KEY_GENERATE_PAIR(pd, session, mech, pub_template, \ 1056*0Sstevel@tonic-gate pub_count, priv_template, priv_count, pub_key, priv_key, req) ( \ 1057*0Sstevel@tonic-gate (KCF_PROV_KEY_OPS(pd) && KCF_PROV_KEY_OPS(pd)->key_generate_pair) ? \ 1058*0Sstevel@tonic-gate KCF_PROV_KEY_OPS(pd)->key_generate_pair((pd)->pd_prov_handle, \ 1059*0Sstevel@tonic-gate session, mech, pub_template, pub_count, priv_template, \ 1060*0Sstevel@tonic-gate priv_count, pub_key, priv_key, req) : \ 1061*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 1062*0Sstevel@tonic-gate 1063*0Sstevel@tonic-gate #define KCF_PROV_KEY_WRAP(pd, session, mech, wrapping_key, key, wrapped_key, \ 1064*0Sstevel@tonic-gate wrapped_key_len, req) ( \ 1065*0Sstevel@tonic-gate (KCF_PROV_KEY_OPS(pd) && KCF_PROV_KEY_OPS(pd)->key_wrap) ? \ 1066*0Sstevel@tonic-gate KCF_PROV_KEY_OPS(pd)->key_wrap((pd)->pd_prov_handle, \ 1067*0Sstevel@tonic-gate session, mech, wrapping_key, key, wrapped_key, wrapped_key_len, \ 1068*0Sstevel@tonic-gate req) : \ 1069*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 1070*0Sstevel@tonic-gate 1071*0Sstevel@tonic-gate #define KCF_PROV_KEY_UNWRAP(pd, session, mech, unwrapping_key, wrapped_key, \ 1072*0Sstevel@tonic-gate wrapped_key_len, template, count, key, req) ( \ 1073*0Sstevel@tonic-gate (KCF_PROV_KEY_OPS(pd) && KCF_PROV_KEY_OPS(pd)->key_unwrap) ? \ 1074*0Sstevel@tonic-gate KCF_PROV_KEY_OPS(pd)->key_unwrap((pd)->pd_prov_handle, \ 1075*0Sstevel@tonic-gate session, mech, unwrapping_key, wrapped_key, wrapped_key_len, \ 1076*0Sstevel@tonic-gate template, count, key, req) : \ 1077*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 1078*0Sstevel@tonic-gate 1079*0Sstevel@tonic-gate #define KCF_PROV_KEY_DERIVE(pd, session, mech, base_key, template, count, \ 1080*0Sstevel@tonic-gate key, req) ( \ 1081*0Sstevel@tonic-gate (KCF_PROV_KEY_OPS(pd) && KCF_PROV_KEY_OPS(pd)->key_derive) ? \ 1082*0Sstevel@tonic-gate KCF_PROV_KEY_OPS(pd)->key_derive((pd)->pd_prov_handle, \ 1083*0Sstevel@tonic-gate session, mech, base_key, template, count, key, req) : \ 1084*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 1085*0Sstevel@tonic-gate 1086*0Sstevel@tonic-gate #define KCF_PROV_KEY_CHECK(pd, mech, key) ( \ 1087*0Sstevel@tonic-gate (KCF_PROV_KEY_OPS(pd) && KCF_PROV_KEY_OPS(pd)->key_check) ? \ 1088*0Sstevel@tonic-gate KCF_PROV_KEY_OPS(pd)->key_check((pd)->pd_prov_handle, mech, key) : \ 1089*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 1090*0Sstevel@tonic-gate 1091*0Sstevel@tonic-gate /* 1092*0Sstevel@tonic-gate * Wrappers for crypto_provider_management_ops(9S) entry points. 1093*0Sstevel@tonic-gate * 1094*0Sstevel@tonic-gate * ops_pd is the provider descriptor that supplies the ops_vector. 1095*0Sstevel@tonic-gate * pd is the descriptor that supplies the provider handle. 1096*0Sstevel@tonic-gate * Only ext_info needs two handles. 1097*0Sstevel@tonic-gate */ 1098*0Sstevel@tonic-gate 1099*0Sstevel@tonic-gate #define KCF_PROV_EXT_INFO(ops_pd, provext_info, req, pd) ( \ 1100*0Sstevel@tonic-gate (KCF_PROV_PROVIDER_OPS(ops_pd) && \ 1101*0Sstevel@tonic-gate KCF_PROV_PROVIDER_OPS(ops_pd)->ext_info) ? \ 1102*0Sstevel@tonic-gate KCF_PROV_PROVIDER_OPS(ops_pd)->ext_info((pd)->pd_prov_handle, \ 1103*0Sstevel@tonic-gate provext_info, req) : CRYPTO_NOT_SUPPORTED) 1104*0Sstevel@tonic-gate 1105*0Sstevel@tonic-gate #define KCF_PROV_INIT_TOKEN(pd, pin, pin_len, label, req) ( \ 1106*0Sstevel@tonic-gate (KCF_PROV_PROVIDER_OPS(pd) && KCF_PROV_PROVIDER_OPS(pd)->init_token) ? \ 1107*0Sstevel@tonic-gate KCF_PROV_PROVIDER_OPS(pd)->init_token((pd)->pd_prov_handle, \ 1108*0Sstevel@tonic-gate pin, pin_len, label, req) : CRYPTO_NOT_SUPPORTED) 1109*0Sstevel@tonic-gate 1110*0Sstevel@tonic-gate #define KCF_PROV_INIT_PIN(pd, session, pin, pin_len, req) ( \ 1111*0Sstevel@tonic-gate (KCF_PROV_PROVIDER_OPS(pd) && KCF_PROV_PROVIDER_OPS(pd)->init_pin) ? \ 1112*0Sstevel@tonic-gate KCF_PROV_PROVIDER_OPS(pd)->init_pin((pd)->pd_prov_handle, \ 1113*0Sstevel@tonic-gate session, pin, pin_len, req) : CRYPTO_NOT_SUPPORTED) 1114*0Sstevel@tonic-gate 1115*0Sstevel@tonic-gate #define KCF_PROV_SET_PIN(pd, session, old_pin, old_len, new_pin, new_len, \ 1116*0Sstevel@tonic-gate req) ( \ 1117*0Sstevel@tonic-gate (KCF_PROV_PROVIDER_OPS(pd) && KCF_PROV_PROVIDER_OPS(pd)->set_pin) ? \ 1118*0Sstevel@tonic-gate KCF_PROV_PROVIDER_OPS(pd)->set_pin((pd)->pd_prov_handle, \ 1119*0Sstevel@tonic-gate session, old_pin, old_len, new_pin, new_len, req) : \ 1120*0Sstevel@tonic-gate CRYPTO_NOT_SUPPORTED) 1121*0Sstevel@tonic-gate 1122*0Sstevel@tonic-gate /* 1123*0Sstevel@tonic-gate * The following routines are exported by the kcf module (/kernel/misc/kcf) 1124*0Sstevel@tonic-gate * to the crypto and cryptoadmin modules. 1125*0Sstevel@tonic-gate */ 1126*0Sstevel@tonic-gate 1127*0Sstevel@tonic-gate /* Digest/mac/cipher entry points that take a provider descriptor and session */ 1128*0Sstevel@tonic-gate extern int crypto_digest_prov(crypto_mechanism_t *, crypto_data_t *, 1129*0Sstevel@tonic-gate crypto_data_t *, crypto_call_req_t *, kcf_provider_desc_t *, 1130*0Sstevel@tonic-gate crypto_session_id_t); 1131*0Sstevel@tonic-gate extern int crypto_digest_init_prov(kcf_provider_desc_t *, crypto_session_id_t, 1132*0Sstevel@tonic-gate crypto_mechanism_t *, crypto_context_t *, crypto_call_req_t *); 1133*0Sstevel@tonic-gate extern int crypto_digest_single(crypto_context_t, crypto_data_t *, 1134*0Sstevel@tonic-gate crypto_data_t *, crypto_call_req_t *); 1135*0Sstevel@tonic-gate 1136*0Sstevel@tonic-gate extern int crypto_mac_prov(crypto_mechanism_t *, crypto_data_t *, 1137*0Sstevel@tonic-gate crypto_key_t *, crypto_ctx_template_t, crypto_data_t *, 1138*0Sstevel@tonic-gate crypto_call_req_t *, kcf_provider_desc_t *, crypto_session_id_t); 1139*0Sstevel@tonic-gate extern int crypto_mac_verify_prov(crypto_mechanism_t *, crypto_data_t *, 1140*0Sstevel@tonic-gate crypto_key_t *, crypto_ctx_template_t, crypto_data_t *, 1141*0Sstevel@tonic-gate crypto_call_req_t *, kcf_provider_desc_t *, crypto_session_id_t); 1142*0Sstevel@tonic-gate extern int crypto_mac_init_prov(kcf_provider_desc_t *, crypto_session_id_t, 1143*0Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t, 1144*0Sstevel@tonic-gate crypto_context_t *, crypto_call_req_t *); 1145*0Sstevel@tonic-gate extern int crypto_mac_single(crypto_context_t, crypto_data_t *, 1146*0Sstevel@tonic-gate crypto_data_t *, crypto_call_req_t *); 1147*0Sstevel@tonic-gate 1148*0Sstevel@tonic-gate extern int crypto_encrypt_prov(crypto_mechanism_t *, crypto_data_t *, 1149*0Sstevel@tonic-gate crypto_key_t *, crypto_ctx_template_t, crypto_data_t *, 1150*0Sstevel@tonic-gate crypto_call_req_t *, kcf_provider_desc_t *, crypto_session_id_t); 1151*0Sstevel@tonic-gate extern int crypto_encrypt_init_prov(kcf_provider_desc_t *, 1152*0Sstevel@tonic-gate crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, 1153*0Sstevel@tonic-gate crypto_ctx_template_t, crypto_context_t *, crypto_call_req_t *); 1154*0Sstevel@tonic-gate extern int crypto_encrypt_single(crypto_context_t, crypto_data_t *, 1155*0Sstevel@tonic-gate crypto_data_t *, crypto_call_req_t *); 1156*0Sstevel@tonic-gate 1157*0Sstevel@tonic-gate extern int crypto_decrypt_prov(crypto_mechanism_t *, crypto_data_t *, 1158*0Sstevel@tonic-gate crypto_key_t *, crypto_ctx_template_t, crypto_data_t *, 1159*0Sstevel@tonic-gate crypto_call_req_t *, kcf_provider_desc_t *, crypto_session_id_t); 1160*0Sstevel@tonic-gate extern int crypto_decrypt_init_prov(kcf_provider_desc_t *, crypto_session_id_t, 1161*0Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t, 1162*0Sstevel@tonic-gate crypto_context_t *, crypto_call_req_t *); 1163*0Sstevel@tonic-gate extern int crypto_decrypt_single(crypto_context_t, crypto_data_t *, 1164*0Sstevel@tonic-gate crypto_data_t *, crypto_call_req_t *); 1165*0Sstevel@tonic-gate 1166*0Sstevel@tonic-gate 1167*0Sstevel@tonic-gate /* Other private digest/mac/cipher entry points not exported through k-API */ 1168*0Sstevel@tonic-gate extern int crypto_digest_key_prov(crypto_context_t, crypto_key_t *, 1169*0Sstevel@tonic-gate crypto_call_req_t *); 1170*0Sstevel@tonic-gate 1171*0Sstevel@tonic-gate /* Private sign entry points exported by KCF */ 1172*0Sstevel@tonic-gate extern int crypto_sign_init_prov(kcf_provider_desc_t *, crypto_session_id_t, 1173*0Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t, 1174*0Sstevel@tonic-gate crypto_context_t *, crypto_call_req_t *); 1175*0Sstevel@tonic-gate extern int crypto_sign_single(crypto_context_t, crypto_data_t *, 1176*0Sstevel@tonic-gate crypto_data_t *, crypto_call_req_t *); 1177*0Sstevel@tonic-gate extern int crypto_sign_prov(kcf_provider_desc_t *, crypto_session_id_t, 1178*0Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, 1179*0Sstevel@tonic-gate crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); 1180*0Sstevel@tonic-gate 1181*0Sstevel@tonic-gate extern int crypto_sign_recover_init_prov(kcf_provider_desc_t *, 1182*0Sstevel@tonic-gate crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, 1183*0Sstevel@tonic-gate crypto_ctx_template_t tmpl, crypto_context_t *, crypto_call_req_t *); 1184*0Sstevel@tonic-gate extern int crypto_sign_recover_single(crypto_context_t, crypto_data_t *, 1185*0Sstevel@tonic-gate crypto_data_t *, crypto_call_req_t *); 1186*0Sstevel@tonic-gate extern int crypto_sign_recover_prov(kcf_provider_desc_t *, 1187*0Sstevel@tonic-gate crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, 1188*0Sstevel@tonic-gate crypto_data_t *, crypto_ctx_template_t, crypto_data_t *, 1189*0Sstevel@tonic-gate crypto_call_req_t *); 1190*0Sstevel@tonic-gate 1191*0Sstevel@tonic-gate /* Private verify entry points exported by KCF */ 1192*0Sstevel@tonic-gate extern int crypto_verify_init_prov(kcf_provider_desc_t *, crypto_session_id_t, 1193*0Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_ctx_template_t, 1194*0Sstevel@tonic-gate crypto_context_t *, crypto_call_req_t *); 1195*0Sstevel@tonic-gate extern int crypto_verify_single(crypto_context_t, crypto_data_t *, 1196*0Sstevel@tonic-gate crypto_data_t *, crypto_call_req_t *); 1197*0Sstevel@tonic-gate extern int crypto_verify_prov(kcf_provider_desc_t *, crypto_session_id_t, 1198*0Sstevel@tonic-gate crypto_mechanism_t *, crypto_key_t *, crypto_data_t *, 1199*0Sstevel@tonic-gate crypto_ctx_template_t, crypto_data_t *, crypto_call_req_t *); 1200*0Sstevel@tonic-gate 1201*0Sstevel@tonic-gate extern int crypto_verify_recover_init_prov(kcf_provider_desc_t *, 1202*0Sstevel@tonic-gate crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, 1203*0Sstevel@tonic-gate crypto_ctx_template_t tmpl, crypto_context_t *, crypto_call_req_t *); 1204*0Sstevel@tonic-gate extern int crypto_verify_recover_single(crypto_context_t, crypto_data_t *, 1205*0Sstevel@tonic-gate crypto_data_t *, crypto_call_req_t *); 1206*0Sstevel@tonic-gate extern int crypto_verify_recover_prov(kcf_provider_desc_t *, 1207*0Sstevel@tonic-gate crypto_session_id_t, crypto_mechanism_t *, crypto_key_t *, 1208*0Sstevel@tonic-gate crypto_data_t *, crypto_ctx_template_t, crypto_data_t *, 1209*0Sstevel@tonic-gate crypto_call_req_t *); 1210*0Sstevel@tonic-gate 1211*0Sstevel@tonic-gate /* Private dual operations entry points exported by KCF */ 1212*0Sstevel@tonic-gate extern int crypto_digest_encrypt_update(crypto_context_t, crypto_context_t, 1213*0Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_call_req_t *); 1214*0Sstevel@tonic-gate extern int crypto_decrypt_digest_update(crypto_context_t, crypto_context_t, 1215*0Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_call_req_t *); 1216*0Sstevel@tonic-gate extern int crypto_sign_encrypt_update(crypto_context_t, crypto_context_t, 1217*0Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_call_req_t *); 1218*0Sstevel@tonic-gate extern int crypto_decrypt_verify_update(crypto_context_t, crypto_context_t, 1219*0Sstevel@tonic-gate crypto_data_t *, crypto_data_t *, crypto_call_req_t *); 1220*0Sstevel@tonic-gate 1221*0Sstevel@tonic-gate /* Random Number Generation */ 1222*0Sstevel@tonic-gate int crypto_seed_random(crypto_provider_handle_t provider, uchar_t *buf, 1223*0Sstevel@tonic-gate size_t len, crypto_call_req_t *req); 1224*0Sstevel@tonic-gate int crypto_generate_random(crypto_provider_handle_t provider, uchar_t *buf, 1225*0Sstevel@tonic-gate size_t len, crypto_call_req_t *req); 1226*0Sstevel@tonic-gate 1227*0Sstevel@tonic-gate /* Session Management */ 1228*0Sstevel@tonic-gate int crypto_session_open(crypto_provider_handle_t provider, 1229*0Sstevel@tonic-gate crypto_session_id_t *session_id, crypto_call_req_t *req); 1230*0Sstevel@tonic-gate int crypto_session_close(crypto_provider_handle_t provider, 1231*0Sstevel@tonic-gate crypto_session_id_t session_id, crypto_call_req_t *req); 1232*0Sstevel@tonic-gate int crypto_session_login(crypto_provider_handle_t provider, 1233*0Sstevel@tonic-gate crypto_session_id_t session_id, crypto_user_type_t user_type, char *pin, 1234*0Sstevel@tonic-gate size_t pin_len, crypto_call_req_t *req); 1235*0Sstevel@tonic-gate int crypto_session_logout(crypto_provider_handle_t provider, 1236*0Sstevel@tonic-gate crypto_session_id_t session_id, crypto_call_req_t *req); 1237*0Sstevel@tonic-gate 1238*0Sstevel@tonic-gate /* Object Management */ 1239*0Sstevel@tonic-gate int crypto_object_create(crypto_provider_handle_t provider, 1240*0Sstevel@tonic-gate crypto_session_id_t session_id, crypto_object_attribute_t *template, 1241*0Sstevel@tonic-gate uint_t attribute_count, crypto_object_id_t *object_handle, 1242*0Sstevel@tonic-gate crypto_call_req_t *req); 1243*0Sstevel@tonic-gate int crypto_object_copy(crypto_provider_handle_t provider, 1244*0Sstevel@tonic-gate crypto_session_id_t session_id, crypto_object_id_t object_handle, 1245*0Sstevel@tonic-gate crypto_object_attribute_t *template, uint_t attribute_count, 1246*0Sstevel@tonic-gate crypto_object_id_t *new_object_handle, crypto_call_req_t *req); 1247*0Sstevel@tonic-gate int crypto_object_destroy(crypto_provider_handle_t provider, 1248*0Sstevel@tonic-gate crypto_session_id_t session_id, crypto_object_id_t object_handle, 1249*0Sstevel@tonic-gate crypto_call_req_t *req); 1250*0Sstevel@tonic-gate int crypto_object_get_size(crypto_provider_handle_t provider, 1251*0Sstevel@tonic-gate crypto_session_id_t session_id, crypto_object_id_t object_handle, 1252*0Sstevel@tonic-gate size_t *size, crypto_call_req_t *req); 1253*0Sstevel@tonic-gate int crypto_object_get_attribute_value(crypto_provider_handle_t provider, 1254*0Sstevel@tonic-gate crypto_session_id_t session_id, crypto_object_id_t object_handle, 1255*0Sstevel@tonic-gate crypto_object_attribute_t *template, uint_t attribute_count, 1256*0Sstevel@tonic-gate crypto_call_req_t *req); 1257*0Sstevel@tonic-gate int crypto_object_set_attribute_value(crypto_provider_handle_t provider, 1258*0Sstevel@tonic-gate crypto_session_id_t session_id, crypto_object_id_t object_handle, 1259*0Sstevel@tonic-gate crypto_object_attribute_t *template, uint_t count, crypto_call_req_t *req); 1260*0Sstevel@tonic-gate int crypto_object_find_init(crypto_provider_handle_t provider, 1261*0Sstevel@tonic-gate crypto_session_id_t session_id, crypto_object_attribute_t *template, 1262*0Sstevel@tonic-gate uint_t attribute_count, void **provider_private, crypto_call_req_t *req); 1263*0Sstevel@tonic-gate int crypto_object_find(crypto_provider_handle_t provider, 1264*0Sstevel@tonic-gate void *provider_private, crypto_object_id_t *objects, 1265*0Sstevel@tonic-gate uint_t max_object_count, uint_t *object_count, crypto_call_req_t *req); 1266*0Sstevel@tonic-gate int crypto_object_find_final(crypto_provider_handle_t provider, 1267*0Sstevel@tonic-gate void *provider_private, crypto_call_req_t *req); 1268*0Sstevel@tonic-gate 1269*0Sstevel@tonic-gate /* Key Generation */ 1270*0Sstevel@tonic-gate int crypto_generate_key(crypto_provider_handle_t provider, 1271*0Sstevel@tonic-gate crypto_session_id_t session_id, crypto_mechanism_t *mech, 1272*0Sstevel@tonic-gate crypto_object_attribute_t *key_attributes, uint_t attributes_count, 1273*0Sstevel@tonic-gate crypto_object_id_t *key_handle, crypto_call_req_t *req); 1274*0Sstevel@tonic-gate int crypto_generate_key_pair(crypto_provider_handle_t provider, 1275*0Sstevel@tonic-gate crypto_session_id_t session_id, crypto_mechanism_t *mech, 1276*0Sstevel@tonic-gate crypto_object_attribute_t *public_attributes, uint_t public_count, 1277*0Sstevel@tonic-gate crypto_object_attribute_t *private_attributes, uint_t private_count, 1278*0Sstevel@tonic-gate crypto_object_id_t *public_handle, crypto_object_id_t *private_handle, 1279*0Sstevel@tonic-gate crypto_call_req_t *req); 1280*0Sstevel@tonic-gate int crypto_wrap_key(crypto_provider_handle_t provider, 1281*0Sstevel@tonic-gate crypto_session_id_t session_id, crypto_mechanism_t *mech, 1282*0Sstevel@tonic-gate crypto_key_t *wrapping_key, crypto_object_id_t *key_handle, 1283*0Sstevel@tonic-gate uchar_t *wrapped_key, size_t wrapped_key_len, crypto_call_req_t *req); 1284*0Sstevel@tonic-gate int crypto_unwrap_key(crypto_provider_handle_t provider, 1285*0Sstevel@tonic-gate crypto_session_id_t session_id, crypto_mechanism_t *mech, crypto_key_t *key, 1286*0Sstevel@tonic-gate uchar_t *wrapped_key, size_t wrapped_key_len, 1287*0Sstevel@tonic-gate crypto_object_id_t *key_handle, crypto_call_req_t *req); 1288*0Sstevel@tonic-gate int crypto_derive_key(crypto_provider_handle_t provider, 1289*0Sstevel@tonic-gate crypto_session_id_t session_id, crypto_mechanism_t *mech, crypto_key_t *key, 1290*0Sstevel@tonic-gate crypto_object_attribute_t *attributes, uint_t attribute_count, 1291*0Sstevel@tonic-gate crypto_object_id_t *object_handle, crypto_call_req_t *req); 1292*0Sstevel@tonic-gate 1293*0Sstevel@tonic-gate /* Provider Management */ 1294*0Sstevel@tonic-gate int crypto_get_provider_info(crypto_provider_id_t id, 1295*0Sstevel@tonic-gate crypto_provider_info_t **info, crypto_call_req_t *req); 1296*0Sstevel@tonic-gate int crypto_get_provider_mechanisms(crypto_minor_t *, crypto_provider_id_t id, 1297*0Sstevel@tonic-gate uint_t *count, crypto_mech_name_t **list); 1298*0Sstevel@tonic-gate int crypto_init_token(crypto_provider_handle_t provider, char *pin, 1299*0Sstevel@tonic-gate size_t pin_len, char *label, crypto_call_req_t *); 1300*0Sstevel@tonic-gate int crypto_init_pin(crypto_provider_handle_t provider, char *pin, 1301*0Sstevel@tonic-gate size_t pin_len, crypto_call_req_t *req); 1302*0Sstevel@tonic-gate int crypto_set_pin(crypto_provider_handle_t provider, char *old_pin, 1303*0Sstevel@tonic-gate size_t old_len, char *new_pin, size_t new_len, crypto_call_req_t *req); 1304*0Sstevel@tonic-gate void crypto_free_provider_list(crypto_provider_entry_t *list, uint_t count); 1305*0Sstevel@tonic-gate void crypto_free_provider_info(crypto_provider_info_t *info); 1306*0Sstevel@tonic-gate 1307*0Sstevel@tonic-gate /* Administrative */ 1308*0Sstevel@tonic-gate int crypto_get_dev_list(uint_t *count, crypto_dev_list_entry_t **list); 1309*0Sstevel@tonic-gate int crypto_get_soft_list(uint_t *count, char **list, size_t *len); 1310*0Sstevel@tonic-gate int crypto_get_dev_info(char *name, uint_t instance, uint_t *count, 1311*0Sstevel@tonic-gate crypto_mech_name_t **list); 1312*0Sstevel@tonic-gate int crypto_get_soft_info(caddr_t name, uint_t *count, 1313*0Sstevel@tonic-gate crypto_mech_name_t **list); 1314*0Sstevel@tonic-gate int crypto_load_dev_disabled(char *name, uint_t instance, uint_t count, 1315*0Sstevel@tonic-gate crypto_mech_name_t *list); 1316*0Sstevel@tonic-gate int crypto_load_soft_disabled(caddr_t name, uint_t count, 1317*0Sstevel@tonic-gate crypto_mech_name_t *list); 1318*0Sstevel@tonic-gate int crypto_unload_soft_module(caddr_t path); 1319*0Sstevel@tonic-gate int crypto_load_soft_config(caddr_t name, uint_t count, 1320*0Sstevel@tonic-gate crypto_mech_name_t *list); 1321*0Sstevel@tonic-gate int crypto_load_door(uint_t did); 1322*0Sstevel@tonic-gate void crypto_free_mech_list(crypto_mech_name_t *list, uint_t count); 1323*0Sstevel@tonic-gate void crypto_free_dev_list(crypto_dev_list_entry_t *list, uint_t count); 1324*0Sstevel@tonic-gate 1325*0Sstevel@tonic-gate /* Miscellaneous */ 1326*0Sstevel@tonic-gate int crypto_get_mechanism_number(caddr_t name, crypto_mech_type_t *number); 1327*0Sstevel@tonic-gate int crypto_get_function_list(crypto_provider_id_t id, 1328*0Sstevel@tonic-gate crypto_function_list_t **list, int kmflag); 1329*0Sstevel@tonic-gate void crypto_free_function_list(crypto_function_list_t *list); 1330*0Sstevel@tonic-gate int crypto_build_permitted_mech_names(kcf_provider_desc_t *, 1331*0Sstevel@tonic-gate crypto_mech_name_t **, uint_t *, int); 1332*0Sstevel@tonic-gate extern void kcf_init_mech_tabs(void); 1333*0Sstevel@tonic-gate extern int kcf_add_mech_provider(crypto_mech_info_t *, kcf_provider_desc_t *, 1334*0Sstevel@tonic-gate kcf_prov_mech_desc_t **); 1335*0Sstevel@tonic-gate extern void kcf_remove_mech_provider(char *, kcf_provider_desc_t *); 1336*0Sstevel@tonic-gate extern int kcf_get_mech_entry(crypto_mech_type_t, kcf_mech_entry_t **); 1337*0Sstevel@tonic-gate extern kcf_provider_desc_t *kcf_alloc_provider_desc(crypto_provider_info_t *); 1338*0Sstevel@tonic-gate extern void kcf_provider_zero_refcnt(kcf_provider_desc_t *); 1339*0Sstevel@tonic-gate extern void kcf_free_provider_desc(kcf_provider_desc_t *); 1340*0Sstevel@tonic-gate extern void kcf_soft_config_init(void); 1341*0Sstevel@tonic-gate extern int get_sw_provider_for_mech(crypto_mech_name_t, char **); 1342*0Sstevel@tonic-gate extern void kcf_dup_mech(crypto_mechanism_t *, crypto_mechanism_t *, 1343*0Sstevel@tonic-gate crypto_mech_type_t *); 1344*0Sstevel@tonic-gate extern crypto_mech_type_t crypto_mech2id_common(char *, boolean_t); 1345*0Sstevel@tonic-gate extern void undo_register_provider(kcf_provider_desc_t *, boolean_t); 1346*0Sstevel@tonic-gate extern void redo_register_provider(kcf_provider_desc_t *); 1347*0Sstevel@tonic-gate extern void kcf_rnd_init(); 1348*0Sstevel@tonic-gate extern boolean_t kcf_rngprov_check(void); 1349*0Sstevel@tonic-gate extern int kcf_rnd_get_pseudo_bytes(uint8_t *, size_t); 1350*0Sstevel@tonic-gate extern int kcf_rnd_get_bytes(uint8_t *, size_t, boolean_t, boolean_t); 1351*0Sstevel@tonic-gate extern void kcf_rnd_chpoll(int, short *, struct pollhead **); 1352*0Sstevel@tonic-gate extern void kcf_rnd_schedule_timeout(boolean_t); 1353*0Sstevel@tonic-gate 1354*0Sstevel@tonic-gate /* Access to the provider's table */ 1355*0Sstevel@tonic-gate extern void kcf_prov_tab_init(void); 1356*0Sstevel@tonic-gate extern int kcf_prov_tab_add_provider(kcf_provider_desc_t *); 1357*0Sstevel@tonic-gate extern int kcf_prov_tab_rem_provider(crypto_provider_id_t); 1358*0Sstevel@tonic-gate extern kcf_provider_desc_t *kcf_prov_tab_lookup_by_name(char *); 1359*0Sstevel@tonic-gate extern kcf_provider_desc_t *kcf_prov_tab_lookup_by_dev(char *, uint_t); 1360*0Sstevel@tonic-gate extern int kcf_get_hw_prov_tab(uint_t *, kcf_provider_desc_t ***, int, 1361*0Sstevel@tonic-gate char *, uint_t, boolean_t); 1362*0Sstevel@tonic-gate extern int kcf_get_slot_list(uint_t *, kcf_provider_desc_t ***, boolean_t); 1363*0Sstevel@tonic-gate extern void kcf_free_provider_tab(uint_t, kcf_provider_desc_t **); 1364*0Sstevel@tonic-gate extern kcf_provider_desc_t *kcf_prov_tab_lookup(crypto_provider_id_t); 1365*0Sstevel@tonic-gate extern int kcf_get_sw_prov(crypto_mech_type_t, kcf_provider_desc_t **, 1366*0Sstevel@tonic-gate boolean_t); 1367*0Sstevel@tonic-gate 1368*0Sstevel@tonic-gate /* Access to the policy table */ 1369*0Sstevel@tonic-gate extern boolean_t is_mech_disabled(kcf_provider_desc_t *, crypto_mech_name_t); 1370*0Sstevel@tonic-gate extern boolean_t is_mech_disabled_byname(crypto_provider_type_t, char *, 1371*0Sstevel@tonic-gate uint_t, crypto_mech_name_t); 1372*0Sstevel@tonic-gate extern void kcf_policy_tab_init(void); 1373*0Sstevel@tonic-gate extern void kcf_policy_free_desc(kcf_policy_desc_t *); 1374*0Sstevel@tonic-gate extern void kcf_policy_remove_by_name(char *, uint_t *, crypto_mech_name_t **); 1375*0Sstevel@tonic-gate extern void kcf_policy_remove_by_dev(char *, uint_t, uint_t *, 1376*0Sstevel@tonic-gate crypto_mech_name_t **); 1377*0Sstevel@tonic-gate extern kcf_policy_desc_t *kcf_policy_lookup_by_name(char *); 1378*0Sstevel@tonic-gate extern kcf_policy_desc_t *kcf_policy_lookup_by_dev(char *, uint_t); 1379*0Sstevel@tonic-gate extern int kcf_policy_load_soft_disabled(char *, uint_t, crypto_mech_name_t *, 1380*0Sstevel@tonic-gate uint_t *, crypto_mech_name_t **); 1381*0Sstevel@tonic-gate extern int kcf_policy_load_dev_disabled(char *, uint_t, uint_t, 1382*0Sstevel@tonic-gate crypto_mech_name_t *, uint_t *, crypto_mech_name_t **); 1383*0Sstevel@tonic-gate 1384*0Sstevel@tonic-gate #endif /* _KERNEL */ 1385*0Sstevel@tonic-gate 1386*0Sstevel@tonic-gate #ifdef __cplusplus 1387*0Sstevel@tonic-gate } 1388*0Sstevel@tonic-gate #endif 1389*0Sstevel@tonic-gate 1390*0Sstevel@tonic-gate #endif /* _SYS_CRYPTO_IMPL_H */ 1391