/*
* 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
*/
/*
*/
#include <security/cryptoki.h>
#include "pkcs11Global.h"
#include "pkcs11Conf.h"
#include "pkcs11Session.h"
#include "pkcs11Slot.h"
#include "metaGlobal.h"
#define META_HANDLE2SESSION \
(meta_session_t *)(hSession); \
\
/* \
* Check for bad args (eg CK_INVALID_HANDLE, \
* which is 0/NULL). \
*/ \
if (tmp_session == NULL || \
tmp_session->magic_marker != \
return (CKR_SESSION_HANDLE_INVALID); \
} \
\
/* \
* sessions can only be used by a single thread \
* at a time. So, we need to get a write-lock. \
*/ \
(void) pthread_rwlock_wrlock( \
&tmp_session->session_lock); \
\
/* \
* Make sure this session is not in the process \
* of being deleted \
*/ \
(void) pthread_mutex_lock( \
if (tmp_session->isClosingSession) { \
(void) pthread_mutex_unlock( \
(void) pthread_rwlock_unlock( \
&tmp_session->session_lock); \
return (CKR_SESSION_HANDLE_INVALID); \
} \
(void) pthread_mutex_unlock( \
/*
* C_EncryptInit will verify that the session handle is valid within
* the framework, that the mechanism is not disabled for the slot
* associated with this session, and then redirect to the underlying
* provider. Policy is checked for C_EncryptInit, and not C_Encrypt
* or C_EncryptUpdate, since C_EncryptInit is required to be called
* before C_Encrypt and C_EncryptUpdate.
*/
{
/* Check for a fastpath */
if (purefastpath || policyfastpath) {
if (policyfastpath &&
return (CKR_MECHANISM_INVALID);
}
}
if (!pkcs11_initialized) {
return (CKR_CRYPTOKI_NOT_INITIALIZED);
}
/* Obtain the session pointer */
return (rv);
}
/* Make sure this is not a disabled mechanism */
return (CKR_MECHANISM_INVALID);
}
/* Initialize the digest with the underlying provider */
pMechanism, hKey);
/* Present consistent interface to the application */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
return (CKR_FUNCTION_FAILED);
}
return (rv);
}
/*
* C_Encrypt 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);
}
/* Initialize the digest with the underlying provider */
return (CKR_ARGUMENTS_BAD);
}
} else {
}
/* Present consistent interface to the application */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
return (CKR_FUNCTION_FAILED);
}
return (rv);
}
/*
* C_EncryptUpdate 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);
}
/* Initialize the digest with the underlying provider */
return (CKR_ARGUMENTS_BAD);
}
} else {
}
/* Present consistent interface to the application */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
return (CKR_FUNCTION_FAILED);
}
return (rv);
}
/*
* C_EncryptFinal 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);
}
/* Initialize the digest with the underlying provider */
/* Present consistent interface to the application */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
return (CKR_FUNCTION_FAILED);
}
return (rv);
}
/*
* C_DecryptInit will verify that the session handle is valid within
* the framework, that the mechanism is not disabled for the slot
* associated with this session, and then redirect to the underlying
* provider. Policy is checked for C_DecryptInit, and not C_Decrypt
* or C_DecryptUpdate, since C_DecryptInit is required to be called
* before C_Decrypt and C_DecryptUpdate.
*/
{
/* Check for a fastpath */
if (purefastpath || policyfastpath) {
if (policyfastpath &&
return (CKR_MECHANISM_INVALID);
}
}
if (!pkcs11_initialized) {
return (CKR_CRYPTOKI_NOT_INITIALIZED);
}
/* Obtain the session pointer */
return (rv);
}
/* Make sure this is not a disabled mechanism */
return (CKR_MECHANISM_INVALID);
}
/* Initialize the digest with the underlying provider */
pMechanism, hKey);
/* Present consistent interface to the application */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
return (CKR_FUNCTION_FAILED);
}
return (rv);
}
/*
* C_Decrypt 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);
}
/* Initialize the digest with the underlying provider */
return (CKR_ARGUMENTS_BAD);
}
} else {
}
/* Present consistent interface to the application */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
return (CKR_FUNCTION_FAILED);
}
return (rv);
}
/*
* C_DecryptUpdate 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);
}
/* Initialize the digest with the underlying provider */
return (CKR_ARGUMENTS_BAD);
}
} else {
pPart, pulPartLen);
}
/* Present consistent interface to the application */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
return (CKR_FUNCTION_FAILED);
}
return (rv);
}
/*
* C_DecryptFinal 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);
}
/* Initialize the digest with the underlying provider */
/* Present consistent interface to the application */
if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
return (CKR_FUNCTION_FAILED);
}
return (rv);
}