pkcs11Session.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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <pthread.h>
#include <security/cryptoki.h>
#include "pkcs11Global.h"
#include "pkcs11Session.h"
#include "pkcs11Slot.h"
#include "metaGlobal.h"
/*
* C_OpenSession will need to create a pseudo session associated
* with the session created by the plugged in provider. Only
* minimal argument checking is done here, as we rely on the
* underlying provider to catch most errors.
*/
{
if (!pkcs11_initialized) {
return (CKR_CRYPTOKI_NOT_INITIALIZED);
}
/* Check for a fastpath */
if (purefastpath || policyfastpath) {
if (metaslot_enabled) {
/*
* if metaslot is enabled and we are in fastpath
* mode, only one other slot is in the framework
* so, need to go to that slot's entry
* to look up the true slot ID for the slot
*/
} else {
}
}
if (slotID == METASLOT_FRAMEWORK_ID) {
} else {
/* Check that slotID is valid */
!= CKR_OK) {
return (CKR_SLOT_ID_INVALID);
}
}
/* Present consistent interface for framework */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
return (CKR_FUNCTION_FAILED);
/* could not create session with provider, return now */
return (rv);
}
/* Provider was successful, now create session in framework */
if (slotID == METASLOT_FRAMEWORK_ID) {
} else {
}
/* Trouble in the framework, clean up provider session */
}
return (rv);
}
/*
* C_CloseSession will close a session with the underlying provider,
* and if that's successful will close it in the framework.
*/
{
/* Check for a fastpath */
if (purefastpath || policyfastpath) {
}
if (!pkcs11_initialized) {
return (CKR_CRYPTOKI_NOT_INITIALIZED);
}
/* Obtain the session pointer */
return (rv);
}
/* Delete the session with the provider */
/* Present consistent interface for framework */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
return (CKR_FUNCTION_FAILED);
/* could not delete session with provider, return now */
return (rv);
}
/* Delete session from the framework */
return (rv);
}
/*
* C_CloseAllSessions will close all sessions associated with this
* slot with the underlying provider. If that is successful, will
* close the associated sessions in the framework. If the provider
* has not implemented C_CloseAllSessions, then we will loop through
* the list of sessions and individually call C_CloseSession.
*/
{
if (!pkcs11_initialized) {
return (CKR_CRYPTOKI_NOT_INITIALIZED);
}
/* Check for a fastpath */
if (purefastpath || policyfastpath) {
if (metaslot_enabled) {
/*
* if metaslot is enabled and we are in fastpath
* mode, only one other slot is in the framework
* so, need to go to that slot's entry
* to look up the true slot ID for the slot
*/
return (fast_funcs->C_CloseAllSessions(
} else {
}
}
/* Check that slotID is valid */
return (CKR_SLOT_ID_INVALID);
}
/* Present consistent interface for framework */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
/* Need to attempt to individually delete sessions */
/* reset rv */
while (sessp) {
/* Record the first error encountered */
}
sessp = sess_nextp;
}
}
/* could not delete sessionlist with provider, return now */
return (rv);
}
/* Delete sessions from the framework */
return (rv);
}
/*
* C_GetSessionInfo is a pure wrapper to the underlying provider.
* The only argument checked is whether or not hSession is valid.
*/
{
/* Check for a fastpath */
if (purefastpath || policyfastpath) {
/*
* If metaslot is enabled, and we are here, that
* that means there's only 1 other slot in the
* framework, and that slot should be hidden.
* so, override value of slot id to be metaslot's
* slot id.
*/
if (metaslot_enabled) {
}
return (rv);
}
if (!pkcs11_initialized) {
return (CKR_CRYPTOKI_NOT_INITIALIZED);
}
/* Obtain the session pointer */
return (rv);
}
/* Find the slot id for the framework */
/* Get session info from the provider */
/* Present consistent interface to the application */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
return (CKR_FUNCTION_FAILED);
}
/* Override value of slot id to framework's */
return (rv);
}
/*
* C_GetOperationState is a pure wrapper to the underlying provider.
* The only argument checked is whether or not hSession is valid.
*/
{
/* Check for a fastpath */
if (purefastpath || policyfastpath) {
}
if (!pkcs11_initialized) {
return (CKR_CRYPTOKI_NOT_INITIALIZED);
}
/* Obtain the session pointer */
return (rv);
}
/* Get the operation state with the provider */
/* Present consistent interface to the application */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
return (CKR_FUNCTION_FAILED);
}
return (rv);
}
/*
* C_SetOperationState is a pure wrapper to the underlying provider.
* The only argument checked is whether or not hSession is valid.
*/
{
/* Check for a fastpath */
if (purefastpath || policyfastpath) {
}
if (!pkcs11_initialized) {
return (CKR_CRYPTOKI_NOT_INITIALIZED);
}
/* Obtain the session pointer */
return (rv);
}
/* Set the operation state with the provider */
/* Present consistent interface to the application */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
return (CKR_FUNCTION_FAILED);
}
return (rv);
}
/*
* C_Login is a pure wrapper to the underlying provider.
* The only argument checked is whether or not hSession is valid.
*/
{
/* Check for a fastpath */
if (purefastpath || policyfastpath) {
ulPinLen));
}
if (!pkcs11_initialized) {
return (CKR_CRYPTOKI_NOT_INITIALIZED);
}
/* Obtain the session pointer */
return (rv);
}
/* Login with the provider */
/* Present consistent interface to the application */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
return (CKR_FUNCTION_FAILED);
}
return (rv);
}
/*
* C_Logout is a pure wrapper to the underlying provider.
* The only argument checked is whether or not hSession is valid.
*/
{
/* Check for a fastpath */
if (purefastpath || policyfastpath) {
}
if (!pkcs11_initialized) {
return (CKR_CRYPTOKI_NOT_INITIALIZED);
}
/* Obtain the session pointer */
return (rv);
}
/* Present consistent interface to the application */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
return (CKR_FUNCTION_FAILED);
}
return (rv);
}