diff --git a/module/icp/api/kcf_cipher.c b/module/icp/api/kcf_cipher.c index 60a0e189cc..967d4f0292 100644 --- a/module/icp/api/kcf_cipher.c +++ b/module/icp/api/kcf_cipher.c @@ -159,7 +159,7 @@ crypto_cipher_init_prov(crypto_provider_t provider, crypto_session_id_t sid, KCF_CAN_SHARE_OPSTATE(pd, mech->cm_type)) { kcf_context_t *tctxp = (kcf_context_t *)ctx; kcf_provider_desc_t *tpd = NULL; - crypto_mech_info_t *sinfo; + const crypto_mech_info_t *sinfo; if ((kcf_get_sw_prov(mech->cm_type, &tpd, &tctxp->kc_mech, B_FALSE) == CRYPTO_SUCCESS)) { diff --git a/module/icp/core/kcf_mech_tabs.c b/module/icp/core/kcf_mech_tabs.c index 4f2e04e373..3d551afed2 100644 --- a/module/icp/core/kcf_mech_tabs.c +++ b/module/icp/core/kcf_mech_tabs.c @@ -280,7 +280,7 @@ kcf_init_mech_tabs(void) * KCF_SUCCESS otherwise. */ static int -kcf_create_mech_entry(kcf_ops_class_t class, char *mechname) +kcf_create_mech_entry(kcf_ops_class_t class, const char *mechname) { crypto_mech_type_t mt; kcf_mech_entry_t *me_tab; @@ -365,7 +365,7 @@ kcf_add_mech_provider(short mech_indx, { int error; kcf_mech_entry_t *mech_entry = NULL; - crypto_mech_info_t *mech_info; + const crypto_mech_info_t *mech_info; crypto_mech_type_t kcf_mech_type; kcf_prov_mech_desc_t *prov_mech; @@ -491,7 +491,7 @@ kcf_add_mech_provider(short mech_indx, * User context only. */ void -kcf_remove_mech_provider(char *mech_name, kcf_provider_desc_t *prov_desc) +kcf_remove_mech_provider(const char *mech_name, kcf_provider_desc_t *prov_desc) { crypto_mech_type_t mech_type; kcf_prov_mech_desc_t *prov_mech = NULL, *prov_chain; diff --git a/module/icp/core/kcf_prov_tabs.c b/module/icp/core/kcf_prov_tabs.c index ac18c66e9d..525872aab0 100644 --- a/module/icp/core/kcf_prov_tabs.c +++ b/module/icp/core/kcf_prov_tabs.c @@ -206,9 +206,6 @@ kcf_alloc_provider_desc(const crypto_provider_info_t *info) kcf_provider_desc_t *desc = kmem_zalloc(sizeof (kcf_provider_desc_t), KM_SLEEP); - desc->pd_mech_list_count = info->pi_mech_list_count; - desc->pd_mechanisms = kmem_zalloc(sizeof (crypto_mech_info_t) * - info->pi_mech_list_count, KM_SLEEP); for (int i = 0; i < KCF_OPS_CLASSSIZE; i++) for (int j = 0; j < KCF_MAXMECHTAB; j++) desc->pd_mech_indx[i][j] = KCF_INVALID_INDX; @@ -272,11 +269,6 @@ kcf_free_provider_desc(kcf_provider_desc_t *desc) /* free the kernel memory associated with the provider descriptor */ - if (desc->pd_mechanisms != NULL) - /* free the memory associated with the mechanism info's */ - kmem_free(desc->pd_mechanisms, sizeof (crypto_mech_info_t) * - desc->pd_mech_list_count); - if (desc->pd_sched_info.ks_taskq != NULL) taskq_destroy(desc->pd_sched_info.ks_taskq); diff --git a/module/icp/include/sys/crypto/impl.h b/module/icp/include/sys/crypto/impl.h index 39fa6dafed..7877cf9d20 100644 --- a/module/icp/include/sys/crypto/impl.h +++ b/module/icp/include/sys/crypto/impl.h @@ -213,7 +213,7 @@ typedef struct kcf_provider_desc { const crypto_ops_t *pd_ops_vector; ushort_t pd_mech_indx[KCF_OPS_CLASSSIZE]\ [KCF_MAXMECHTAB]; - crypto_mech_info_t *pd_mechanisms; + const crypto_mech_info_t *pd_mechanisms; kcf_sched_info_t pd_sched_info; uint_t pd_mech_list_count; // char *pd_name; @@ -669,7 +669,7 @@ extern void kcf_destroy_mech_tabs(void); extern void kcf_init_mech_tabs(void); extern int kcf_add_mech_provider(short, kcf_provider_desc_t *, kcf_prov_mech_desc_t **); -extern void kcf_remove_mech_provider(char *, kcf_provider_desc_t *); +extern void kcf_remove_mech_provider(const char *, kcf_provider_desc_t *); extern int kcf_get_mech_entry(crypto_mech_type_t, kcf_mech_entry_t **); extern kcf_provider_desc_t *kcf_alloc_provider_desc( const crypto_provider_info_t *); diff --git a/module/icp/spi/kcf_spi.c b/module/icp/spi/kcf_spi.c index 3e66123508..a9e3d35bea 100644 --- a/module/icp/spi/kcf_spi.c +++ b/module/icp/spi/kcf_spi.c @@ -338,13 +338,12 @@ init_prov_mechs(const crypto_provider_info_t *info, kcf_provider_desc_t *desc) int err = CRYPTO_SUCCESS; kcf_prov_mech_desc_t *pmd; int desc_use_count = 0; - int mcount = desc->pd_mech_list_count; if (desc->pd_prov_type == CRYPTO_LOGICAL_PROVIDER) { if (info != NULL) { ASSERT(info->pi_mechanisms != NULL); - bcopy(info->pi_mechanisms, desc->pd_mechanisms, - sizeof (crypto_mech_info_t) * mcount); + desc->pd_mech_list_count = info->pi_mech_list_count; + desc->pd_mechanisms = info->pi_mechanisms; } return (CRYPTO_SUCCESS); } @@ -357,8 +356,8 @@ init_prov_mechs(const crypto_provider_info_t *info, kcf_provider_desc_t *desc) */ if (info != NULL) { ASSERT(info->pi_mechanisms != NULL); - bcopy(info->pi_mechanisms, desc->pd_mechanisms, - sizeof (crypto_mech_info_t) * mcount); + desc->pd_mech_list_count = info->pi_mech_list_count; + desc->pd_mechanisms = info->pi_mechanisms; } /* @@ -366,7 +365,7 @@ init_prov_mechs(const crypto_provider_info_t *info, kcf_provider_desc_t *desc) * to the corresponding KCF mechanism mech_entry chain. */ for (mech_idx = 0; mech_idx < desc->pd_mech_list_count; mech_idx++) { - crypto_mech_info_t *mi = &desc->pd_mechanisms[mech_idx]; + const crypto_mech_info_t *mi = &desc->pd_mechanisms[mech_idx]; if ((mi->cm_mech_flags & CRYPTO_KEYSIZE_UNIT_IN_BITS) && (mi->cm_mech_flags & CRYPTO_KEYSIZE_UNIT_IN_BYTES)) {