metaSlotToken.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Slot and Token Management functions
* (as defined in PKCS#11 spec section 11.5)
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "metaGlobal.h"
extern CK_ULONG num_meta_sessions;
extern CK_ULONG num_rw_meta_sessions;
/*
* meta_GetSlotList
*
* For the metaslot, this is a trivial function. The metaslot module,
* by defination, provides exactly one slot. The token is always present.
*
* This function is actually not called.
*/
/* ARGSUSED */
{
return (CKR_ARGUMENTS_BAD);
*pulCount = 1;
return (CKR_OK);
}
if (*pulCount < 1) {
} else {
pSlotList[0] = METASLOT_SLOTID;
}
*pulCount = 1;
return (rv);
}
/*
* meta_GetSlotInfo
*
* Returns basic information about the metaslot.
*
* The slotID argument is ignored.
*/
/*ARGSUSED*/
{
if (!metaslot_enabled) {
return (CKR_SLOT_ID_INVALID);
}
return (CKR_ARGUMENTS_BAD);
}
/* Provide information about the slot in the provided buffer */
/* Find out token is present in the underlying keystore */
&slotinfo);
/*
* store the token present flag if it is successfully
* received from the keystore slot.
* If not, this flag will not be set.
*/
}
return (CKR_OK);
}
/*
* meta_GetTokenInfo
*
* Returns basic information about the metaslot "token."
*
* The slotID argument is ignored.
*
*/
/*ARGSUSED*/
{
if (!metaslot_enabled) {
return (CKR_SLOT_ID_INVALID);
}
return (CKR_ARGUMENTS_BAD);
&metainfo);
/*
* If we could not get information about the object token, use
* default values. This allows metaslot to be used even if there
* are problems with the object token (eg, it's not present).
*/
metainfo.ulMaxPinLen = 0;
metainfo.ulMinPinLen = 0;
}
/*
* Override some values that the object token may have set. They
* can be inappropriate/misleading when used in the context of
* metaslot.
*/
METASLOT_MANUFACTURER_ID, 32);
/* Clear the time field if the token does not have a clock. */
return (CKR_OK);
}
/*
* meta_WaitForSlotEvent
*
* The metaslot never generates events, so this function doesn't do anything
* useful. We do not pass on provider events because we want to hide details
* of the providers.
*
* If CKF_DONT_BLOCK flag is turned on, CKR_NO_EVENT will be return.
* Otherwise, return CKR_FUNCTION_FAILED.
*
*/
/* ARGSUSED */
{
if (flags & CKF_DONT_BLOCK) {
return (CKR_NO_EVENT);
} else {
return (CKR_FUNCTION_FAILED);
}
}
/*
* meta_GetMechanismList
*
* The slotID argument is not used.
*
*/
/*ARGSUSED*/
{
if (!metaslot_enabled) {
return (CKR_SLOT_ID_INVALID);
}
return (CKR_ARGUMENTS_BAD);
/*
* if pMechanismList is not provided, just need to
* return count
*/
}
return (rv);
}
/*
* meta_GetMechanismInfo
*
* The slotID argument is not used.
*/
/*ARGSUSED*/
{
unsigned long i, slotCount = 0;
if (!metaslot_enabled) {
return (CKR_SLOT_ID_INVALID);
}
return (CKR_ARGUMENTS_BAD);
}
return (CKR_HOST_MEMORY);
}
return (rv);
}
/* Merge mechanism info from all slots. */
sizeof (CK_MECHANISM_INFO));
/* no need to look at index 0, since that's what we started with */
for (i = 1; i < slotCount; i++) {
/* MinKeySize should be smallest of all slots. */
}
/* MaxKeySize should be largest of all slots. */
}
}
/* Clear the CKF_HW flag. We might select a software provider later. */
/* Clear the extenstion flag. Spec says is should never even be set. */
return (CKR_OK);
}
/*
* meta_InitToken
*
* Not supported. The metaslot "token" is always initialized. The token object
* token must already be initialized. Other vendors don't seem to support
* this anyway.
*/
/* ARGSUSED */
{
return (CKR_FUNCTION_NOT_SUPPORTED);
}
/*
* meta_InitPIN
*
* Not supported. Same reason as C_InitToken.
*/
/* ARGSUSED */
{
return (CKR_FUNCTION_NOT_SUPPORTED);
}
/*
* meta_SetPIN
*
* This is basically just a pass-thru to the object token. No need to
* even check the arguments, since we don't use them.
*/
{
return (rv);
return (CKR_SESSION_READ_ONLY);
}
return (rv);
}
return (rv);
}