/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* 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.
*/
/*
* Administration for metaslot
*
* All the "list" operations will call functions in libpkcs11.so
* Normally, it doesn't make sense to call functions in libpkcs11.so directly
* because libpkcs11.so depends on the configuration file (pkcs11.conf) the
* cryptoadm command is trying to administer. However, since metaslot
* is part of the framework, it is not possible to get information about
* it without actually calling functions in libpkcs11.so.
*
* So, for the listing operation, which won't modify the value of pkcs11.conf
* it is safe to call libpkcs11.so.
*
* For other operations that modifies the pkcs11.conf file, libpkcs11.so
* will not be called.
*
*/
#include <cryptoutil.h>
#include <stdio.h>
#include <libintl.h>
#include <dlfcn.h>
#include <link.h>
#include <strings.h>
#include <security/cryptoki.h>
#include <cryptoutil.h>
#include "cryptoadm.h"
#define METASLOT_ID 0
int
{
int i;
/*
* Display the system-wide metaslot settings as specified
* in pkcs11.conf file.
*/
gettext("metaslot entry doesn't exist."));
return (FAILURE);
}
/*
* TRANSLATION_NOTE
* Strictly for appearance's sake, this line should be as long as
* the length of the translated text above.
*/
gettext("disabled"));
}
}
if ((!verbose) && (!show_mechs)) {
return (SUCCESS);
}
if (verbose) {
/*
* TRANSLATION_NOTE
* Strictly for appearance's sake, this line should be as
* long as the length of the translated text above.
*/
}
/*
* Need to actually make calls to libpkcs11.so to get
* information about metaslot.
*/
char *dl_error;
cryptodebug("Cannot load PKCS#11 framework library. "
"dlerror:%s", dl_error);
return (FAILURE);
}
/* Get the pointer to library's C_GetFunctionList() */
if (Tmp_C_GetFunctionList == NULL) {
cryptodebug("Cannot get the address of the C_GetFunctionList "
"from framework");
goto finish;
}
/* Get the provider's function list */
cryptodebug("failed to call C_GetFunctionList in "
"framework library");
goto finish;
}
/* Initialize this provider */
goto finish;
} else {
}
/*
* We know for sure that metaslot is slot 0 in the framework,
* so, we will do a C_GetSlotInfo() trying to see if it works.
* If it fails with CKR_SLOT_ID_INVALID, we know that metaslot
* is not really enabled.
*/
if (rv == CKR_SLOT_ID_INVALID) {
/*
* Even if the -m and -v flag is supplied, there's nothing
* interesting to display about metaslot since it is disabled,
* so, just stop right here.
*/
goto finish;
}
cryptodebug("C_GetSlotInfo failed with error "
"code 0x%x\n", rv);
goto finish;
}
if (!verbose) {
goto display_mechs;
}
cryptodebug("C_GetTokenInfo failed with error "
"code 0x%x\n", rv);
goto finish;
}
"Manufacturer ID: %.32s\n"
"Model: %.16s\n"
"Serial Number: %.16s\n"
"Hardware Version: %d.%d\n"
"Firmware Version: %d.%d\n"
"UTC Time: %.16s\n"
"PIN Min Length: %d\n"
"PIN Max Length: %d\n"),
if (!show_mechs) {
goto finish;
}
&mech_count);
cryptodebug("C_GetMechanismList failed with error "
"code 0x%x\n", rv);
goto finish;
}
if (mech_count > 0) {
sizeof (CK_MECHANISM_TYPE));
if (pmech_list == NULL) {
cryptodebug("out of memory");
goto finish;
}
&mech_count);
cryptodebug("C_GetMechanismList failed with "
"error code 0x%x\n", rv);
goto finish;
}
}
} else {
goto finish;
}
}
if (mech_count == 0) {
/* should never be this case */
goto finish;
}
if (verbose) {
}
for (i = 0; i < mech_count; i++) {
if (mech >= CKM_VENDOR_DEFINED) {
} else {
}
if (verbose) {
cryptodebug("C_GetMechanismInfo failed with "
"error code 0x%x\n", rv);
goto finish;
}
}
(void) printf("\n");
}
"metaslot: failed to retrieve the mechanism list.\n"));
}
if (lib_initialized) {
}
}
if (pmech_list != NULL) {
(void) free(pmech_list);
}
return (rc);
}
int
{
int rc;
gettext("metaslot entry doesn't exist."));
return (FAILURE);
}
(void) printf("\n");
return (rc);
}
/*
* disable metaslot and some of its configuration options
*
* If mechlist==NULL, and the other 2 flags are false, just disabled
* the metaslot feature.
*
* mechlist: list of mechanisms to disable
* allflag: if true, indicates all mechanisms should be disabled.
* auto_key_migrate_flag: if true, indicates auto key migrate should be disabled
*/
int
{
gettext("metaslot entry doesn't exist."));
return (FAILURE);
}
/* disable metaslot */
goto write_to_file;
}
if (auto_key_migrate_flag) {
/* need to disable auto_key_migrate */
}
goto write_to_file;
}
/* disable specified mechanisms */
if (allflag) {
} else {
/*
* The current default policy mode
* is "all are disabled, except ...", so if a
* specified mechanism is in the exception list
* (the policylist), delete it from the policylist.
*/
} else {
/*
* The current default policy mode of this library
* is "all are enabled", so if a specified mechanism
* is not in the exception list (policylist), add
* it into the policylist.
*/
}
}
goto finish;
}
/* If all mechanisms are disabled, metaslot will be disabled as well */
}
return (rc);
}
/*
* enable metaslot and some of its configuration options
*
* If mechlist==NULL, and the other flags are false, or not specified,
* just enable the metaslot feature.
*
* token: if specified, indicate label of token to be used as keystore.
* slot: if specified, indicate slot to be used as keystore.
* use_default: if true, indicate to use the default keystore. It should
* not be specified if either token or slot is specified.
* mechlist: list of mechanisms to enable
* allflag: if true, indicates all mechanisms should be enabled.
* auto_key_migrate_flag: if true, indicates auto key migrate should be enabled
*/
int
{
gettext("metaslot entry doesn't exist."));
return (FAILURE);
}
if (auto_key_migrate_flag) {
/* need to enable auto_key_migrate */
}
if (allflag) {
/*
* If enabling all, what needs to be done are cleaning up the
* policylist and setting the "flag_enabledlist" flag to
* B_FALSE.
*/
} else {
if (mechlist) {
/*
* The current default policy mode of this
* library is "all are disabled, except ...",
* so if a specified mechanism is not in the
* exception list (policylist), add it.
*/
ADD_MODE);
} else {
/*
* The current default policy mode of this
* library is "all are enabled, except", so if
* a specified mechanism is in the exception
* list (policylist), delete it.
*/
}
}
}
goto finish;
}
/* no need to change metaslot keystore */
goto write_to_file;
}
if (use_default) {
} else {
if (token) {
}
if (slot) {
}
}
return (rc);
}