Print this page
5031131 perf: pkcs11_kernel can benefit from a more efficient pkcs11_mech2str()
@@ -17,15 +17,15 @@
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
- * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "@(#)adm_uef.c 1.12 06/11/02 SMI"
+#pragma ident "@(#)adm_uef.c 1.13 08/06/27 SMI"
#include <cryptoutil.h>
#include <fcntl.h>
#include <libintl.h>
#include <stdio.h>
@@ -137,11 +137,11 @@
(mechInfo->flags & ec_flags) ? "X" : ".");
}
/*
* Converts the provided list of mechanism names in their string format to
- * their corrsponding PKCS#11 mechanism IDs.
+ * 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,11 +195,11 @@
CK_ULONG mech_count;
uentry_t *puent = NULL;
boolean_t lib_initialized = B_FALSE;
void *dldesc = NULL;
char *dl_error;
- char *mech_name;
+ const char *mech_name;
char *isa;
char libpath[MAXPATHLEN];
char buf[MAXPATHLEN];
int i, j;
int rc = SUCCESS;
@@ -444,16 +444,23 @@
/*
* 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]);
+ 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], pmech_list[j], &mech_info);
+ prov_slots[i], mech, &mech_info);
if (rv != CKR_OK) {
cryptodebug(
"failed to call "
"C_GetMechanismInfo() from %s.",
libname);
@@ -1113,11 +1120,11 @@
int
display_policy(uentry_t *puent)
{
CK_MECHANISM_TYPE mech_id;
- char *mech_name;
+ const char *mech_name;
umechlist_t *ptr;
if (puent == NULL) {
return (SUCCESS);
}
@@ -1134,17 +1141,21 @@
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_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);
- free(mech_name);
}
+ }
ptr = ptr->next;
if (ptr == NULL) {
(void) printf(".");
} else {
@@ -1169,11 +1180,10 @@
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 {