Print this page
5031131 perf: pkcs11_kernel can benefit from a more efficient pkcs11_mech2str()

*** 17,31 **** * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* ! * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ ! #pragma ident "@(#)adm_uef.c 1.12 06/11/02 SMI" #include <cryptoutil.h> #include <fcntl.h> #include <libintl.h> #include <stdio.h> --- 17,31 ---- * information: Portions Copyright [yyyy] [name of copyright owner] * * CDDL HEADER END */ /* ! * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ ! #pragma ident "@(#)adm_uef.c 1.13 08/06/27 SMI" #include <cryptoutil.h> #include <fcntl.h> #include <libintl.h> #include <stdio.h>
*** 137,147 **** (mechInfo->flags & ec_flags) ? "X" : "."); } /* * Converts the provided list of mechanism names in their string format to ! * their corrsponding PKCS#11 mechanism IDs. * * The list of mechanism names to be converted is provided in the * "mlist" argument. The list of converted mechanism IDs is returned * in the "pmech_list" argument. * --- 137,147 ---- (mechInfo->flags & ec_flags) ? "X" : "."); } /* * Converts the provided list of mechanism names in their string format to ! * their corresponding PKCS#11 mechanism IDs. * * The list of mechanism names to be converted is provided in the * "mlist" argument. The list of converted mechanism IDs is returned * in the "pmech_list" argument. *
*** 195,205 **** CK_ULONG mech_count; uentry_t *puent = NULL; boolean_t lib_initialized = B_FALSE; void *dldesc = NULL; char *dl_error; ! char *mech_name; char *isa; char libpath[MAXPATHLEN]; char buf[MAXPATHLEN]; int i, j; int rc = SUCCESS; --- 195,205 ---- CK_ULONG mech_count; uentry_t *puent = NULL; boolean_t lib_initialized = B_FALSE; void *dldesc = NULL; char *dl_error; ! const char *mech_name; char *isa; char libpath[MAXPATHLEN]; char buf[MAXPATHLEN]; int i, j; int rc = SUCCESS;
*** 444,459 **** /* * Merge the current mechanism list into the returning * mechanism list. */ for (j = 0; show_mechs && j < mech_count; j++) { ! mech_name = pkcs11_mech2str(pmech_list[j]); (void) printf("%-29s", mech_name); if (verbose) { CK_MECHANISM_INFO mech_info; rv = prov_funcs->C_GetMechanismInfo( ! prov_slots[i], pmech_list[j], &mech_info); if (rv != CKR_OK) { cryptodebug( "failed to call " "C_GetMechanismInfo() from %s.", libname); --- 444,466 ---- /* * Merge the current mechanism list into the returning * mechanism list. */ for (j = 0; show_mechs && j < mech_count; j++) { ! CK_MECHANISM_TYPE mech = pmech_list[j]; ! ! if (mech > CKM_VENDOR_DEFINED) { ! (void) printf("%#lx", mech); ! } else { ! mech_name = pkcs11_mech2str(mech); (void) printf("%-29s", mech_name); + } + if (verbose) { CK_MECHANISM_INFO mech_info; rv = prov_funcs->C_GetMechanismInfo( ! prov_slots[i], mech, &mech_info); if (rv != CKR_OK) { cryptodebug( "failed to call " "C_GetMechanismInfo() from %s.", libname);
*** 1113,1123 **** int display_policy(uentry_t *puent) { CK_MECHANISM_TYPE mech_id; ! char *mech_name; umechlist_t *ptr; if (puent == NULL) { return (SUCCESS); } --- 1120,1130 ---- int display_policy(uentry_t *puent) { CK_MECHANISM_TYPE mech_id; ! const char *mech_name; umechlist_t *ptr; if (puent == NULL) { return (SUCCESS); }
*** 1134,1150 **** mech_id = strtoul(ptr->name, NULL, 0); if (mech_id & CKO_VENDOR_DEFINED) { /* vendor defined mechanism */ (void) printf("%s", ptr->name); } else { ! mech_name = pkcs11_mech2str(mech_id); if (mech_name == NULL) { return (FAILURE); } (void) printf("%s", mech_name); - free(mech_name); } ptr = ptr->next; if (ptr == NULL) { (void) printf("."); } else { --- 1141,1161 ---- mech_id = strtoul(ptr->name, NULL, 0); if (mech_id & CKO_VENDOR_DEFINED) { /* vendor defined mechanism */ (void) printf("%s", ptr->name); } else { ! if (mech_id > CKM_VENDOR_DEFINED) { ! (void) printf("%#lx", mech_id); ! } else { ! mech_name = pkcs11_mech2str( ! mech_id); if (mech_name == NULL) { return (FAILURE); } (void) printf("%s", mech_name); } + } ptr = ptr->next; if (ptr == NULL) { (void) printf("."); } else {
*** 1169,1179 **** mech_name = pkcs11_mech2str(mech_id); if (mech_name == NULL) { return (FAILURE); } (void) printf("%s", mech_name); - free(mech_name); } ptr = ptr->next; if (ptr == NULL) { (void) printf("."); } else { --- 1180,1189 ----