2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
2N/A * Use is subject to license terms.
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#include <security/cryptoki.h>
2N/A#include "pkcs11Global.h"
2N/A#include "pkcs11Session.h"
2N/A#include "pkcs11Slot.h"
2N/A
2N/A/*
2N/A * C_CreateObject is a pure wrapper to the underlying provider.
2N/A * The only argument checked is whether or not hSession is valid.
2N/A */
2N/ACK_RV
2N/AC_CreateObject(CK_SESSION_HANDLE hSession,
2N/A CK_ATTRIBUTE_PTR pTemplate,
2N/A CK_ULONG ulCount,
2N/A CK_OBJECT_HANDLE_PTR phObject)
2N/A{
2N/A
2N/A CK_RV rv;
2N/A pkcs11_session_t *sessp;
2N/A
2N/A /* Check for a fastpath */
2N/A if (purefastpath || policyfastpath) {
2N/A return (fast_funcs->C_CreateObject(hSession, pTemplate,
2N/A ulCount, phObject));
2N/A }
2N/A
2N/A if (!pkcs11_initialized) {
2N/A return (CKR_CRYPTOKI_NOT_INITIALIZED);
2N/A }
2N/A
2N/A /* Obtain the session pointer */
2N/A HANDLE2SESSION(hSession, sessp, rv);
2N/A
2N/A if (rv != CKR_OK) {
2N/A return (rv);
2N/A }
2N/A
2N/A /* Pass data to the provider */
2N/A rv = FUNCLIST(sessp->se_slotid)->C_CreateObject(sessp->se_handle,
2N/A pTemplate, ulCount, phObject);
2N/A
2N/A /* Present consistent interface to the application */
2N/A if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
2N/A return (CKR_FUNCTION_FAILED);
2N/A }
2N/A
2N/A return (rv);
2N/A}
2N/A
2N/A/*
2N/A * C_CopyObject is a pure wrapper to the underlying provider.
2N/A * The only argument checked is whether or not hSession is valid.
2N/A */
2N/ACK_RV
2N/AC_CopyObject(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
2N/A CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount,
2N/A CK_OBJECT_HANDLE_PTR phNewObject)
2N/A{
2N/A CK_RV rv;
2N/A pkcs11_session_t *sessp;
2N/A
2N/A /* Check for a fastpath */
2N/A if (purefastpath || policyfastpath) {
2N/A return (fast_funcs->C_CopyObject(hSession, hObject,
2N/A pTemplate, ulCount, phNewObject));
2N/A }
2N/A
2N/A if (!pkcs11_initialized) {
2N/A return (CKR_CRYPTOKI_NOT_INITIALIZED);
2N/A }
2N/A
2N/A /* Obtain the session pointer */
2N/A HANDLE2SESSION(hSession, sessp, rv);
2N/A
2N/A if (rv != CKR_OK) {
2N/A return (rv);
2N/A }
2N/A
2N/A /* Pass data to the provider */
2N/A rv = FUNCLIST(sessp->se_slotid)->C_CopyObject(sessp->se_handle,
2N/A hObject, pTemplate, ulCount, phNewObject);
2N/A
2N/A /* Present consistent interface to the application */
2N/A if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
2N/A return (CKR_FUNCTION_FAILED);
2N/A }
2N/A
2N/A return (rv);
2N/A}
2N/A
2N/A/*
2N/A * C_DestroyObject is a pure wrapper to the underlying provider.
2N/A * The only argument checked is whether or not hSession is valid.
2N/A */
2N/ACK_RV
2N/AC_DestroyObject(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject)
2N/A{
2N/A CK_RV rv;
2N/A pkcs11_session_t *sessp;
2N/A
2N/A /* Check for a fastpath */
2N/A if (purefastpath || policyfastpath) {
2N/A return (fast_funcs->C_DestroyObject(hSession, hObject));
2N/A }
2N/A
2N/A if (!pkcs11_initialized) {
2N/A return (CKR_CRYPTOKI_NOT_INITIALIZED);
2N/A }
2N/A
2N/A /* Obtain the session pointer */
2N/A HANDLE2SESSION(hSession, sessp, rv);
2N/A
2N/A if (rv != CKR_OK) {
2N/A return (rv);
2N/A }
2N/A
2N/A /* Pass data to the provider */
2N/A rv = FUNCLIST(sessp->se_slotid)->C_DestroyObject(sessp->se_handle,
2N/A hObject);
2N/A
2N/A /* Present consistent interface to the application */
2N/A if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
2N/A return (CKR_FUNCTION_FAILED);
2N/A }
2N/A
2N/A return (rv);
2N/A}
2N/A
2N/A/*
2N/A * C_GetAttributeValue is a pure wrapper to the underlying provider.
2N/A * The only argument checked is whether or not hSession is valid.
2N/A */
2N/ACK_RV
2N/AC_GetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
2N/A CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
2N/A{
2N/A CK_RV rv;
2N/A pkcs11_session_t *sessp;
2N/A
2N/A /* Check for a fastpath */
2N/A if (purefastpath || policyfastpath) {
2N/A return (fast_funcs->C_GetAttributeValue(hSession, hObject,
2N/A pTemplate, ulCount));
2N/A }
2N/A
2N/A if (!pkcs11_initialized) {
2N/A return (CKR_CRYPTOKI_NOT_INITIALIZED);
2N/A }
2N/A
2N/A /* Obtain the session pointer */
2N/A HANDLE2SESSION(hSession, sessp, rv);
2N/A
2N/A if (rv != CKR_OK) {
2N/A return (rv);
2N/A }
2N/A
2N/A /* Pass data to the provider */
2N/A rv = FUNCLIST(sessp->se_slotid)->C_GetAttributeValue(sessp->se_handle,
2N/A hObject, pTemplate, ulCount);
2N/A
2N/A /* Present consistent interface to the application */
2N/A if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
2N/A return (CKR_FUNCTION_FAILED);
2N/A }
2N/A
2N/A return (rv);
2N/A
2N/A}
2N/A
2N/A/*
2N/A * C_SetAttributeValue is a pure wrapper to the underlying provider.
2N/A * The only argument checked is whether or not hSession is valid.
2N/A */
2N/ACK_RV
2N/AC_SetAttributeValue(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
2N/A CK_ATTRIBUTE_PTR pTemplate, CK_ULONG ulCount)
2N/A{
2N/A CK_RV rv;
2N/A pkcs11_session_t *sessp;
2N/A
2N/A /* Check for a fastpath */
2N/A if (purefastpath || policyfastpath) {
2N/A return (fast_funcs->C_SetAttributeValue(hSession, hObject,
2N/A pTemplate, ulCount));
2N/A }
2N/A
2N/A if (!pkcs11_initialized) {
2N/A return (CKR_CRYPTOKI_NOT_INITIALIZED);
2N/A }
2N/A
2N/A /* Obtain the session pointer */
2N/A HANDLE2SESSION(hSession, sessp, rv);
2N/A
2N/A if (rv != CKR_OK) {
2N/A return (rv);
2N/A }
2N/A
2N/A /* Pass data to the provider */
2N/A rv = FUNCLIST(sessp->se_slotid)->C_SetAttributeValue(sessp->se_handle,
2N/A hObject, pTemplate, ulCount);
2N/A
2N/A /* Present consistent interface to the application */
2N/A if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
2N/A return (CKR_FUNCTION_FAILED);
2N/A }
2N/A
2N/A return (rv);
2N/A}
2N/A
2N/A/*
2N/A * C_GetObjectSize is a pure wrapper to the underlying provider.
2N/A * The only argument checked is whether or not hSession is valid.
2N/A */
2N/ACK_RV
2N/AC_GetObjectSize(CK_SESSION_HANDLE hSession, CK_OBJECT_HANDLE hObject,
2N/A CK_ULONG_PTR pulSize)
2N/A{
2N/A CK_RV rv;
2N/A pkcs11_session_t *sessp;
2N/A
2N/A /* Check for a fastpath */
2N/A if (purefastpath || policyfastpath) {
2N/A return (fast_funcs->C_GetObjectSize(hSession, hObject,
2N/A pulSize));
2N/A }
2N/A
2N/A if (!pkcs11_initialized) {
2N/A return (CKR_CRYPTOKI_NOT_INITIALIZED);
2N/A }
2N/A
2N/A /* Obtain the session pointer */
2N/A HANDLE2SESSION(hSession, sessp, rv);
2N/A
2N/A if (rv != CKR_OK) {
2N/A return (rv);
2N/A }
2N/A
2N/A /* Pass data to the provider */
2N/A rv = FUNCLIST(sessp->se_slotid)->C_GetObjectSize(sessp->se_handle,
2N/A hObject, pulSize);
2N/A
2N/A /* Present consistent interface to the application */
2N/A if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
2N/A return (CKR_FUNCTION_FAILED);
2N/A }
2N/A
2N/A return (rv);
2N/A}
2N/A
2N/A/*
2N/A * C_FindObjectsInit is a pure wrapper to the underlying provider.
2N/A * The only argument checked is whether or not hSession is valid.
2N/A */
2N/ACK_RV
2N/AC_FindObjectsInit(CK_SESSION_HANDLE hSession, CK_ATTRIBUTE_PTR pTemplate,
2N/A CK_ULONG ulCount)
2N/A{
2N/A CK_RV rv;
2N/A pkcs11_session_t *sessp;
2N/A
2N/A /* Check for a fastpath */
2N/A if (purefastpath || policyfastpath) {
2N/A return (fast_funcs->C_FindObjectsInit(hSession, pTemplate,
2N/A ulCount));
2N/A }
2N/A
2N/A if (!pkcs11_initialized) {
2N/A return (CKR_CRYPTOKI_NOT_INITIALIZED);
2N/A }
2N/A
2N/A /* Obtain the session pointer */
2N/A HANDLE2SESSION(hSession, sessp, rv);
2N/A
2N/A if (rv != CKR_OK) {
2N/A return (rv);
2N/A }
2N/A
2N/A /* Pass data to the provider */
2N/A rv = FUNCLIST(sessp->se_slotid)->C_FindObjectsInit(sessp->se_handle,
2N/A pTemplate, ulCount);
2N/A
2N/A /* Present consistent interface to the application */
2N/A if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
2N/A return (CKR_FUNCTION_FAILED);
2N/A }
2N/A
2N/A return (rv);
2N/A}
2N/A
2N/A/*
2N/A * C_FindObjects is a pure wrapper to the underlying provider.
2N/A * The only argument checked is whether or not hSession is valid.
2N/A */
2N/ACK_RV
2N/AC_FindObjects(CK_SESSION_HANDLE hSession,
2N/A CK_OBJECT_HANDLE_PTR phObject,
2N/A CK_ULONG ulMaxObjectCount,
2N/A CK_ULONG_PTR pulObjectCount)
2N/A{
2N/A CK_RV rv;
2N/A pkcs11_session_t *sessp;
2N/A
2N/A /* Check for a fastpath */
2N/A if (purefastpath || policyfastpath) {
2N/A return (fast_funcs->C_FindObjects(hSession, phObject,
2N/A ulMaxObjectCount, pulObjectCount));
2N/A }
2N/A
2N/A if (!pkcs11_initialized) {
2N/A return (CKR_CRYPTOKI_NOT_INITIALIZED);
2N/A }
2N/A
2N/A /* Obtain the session pointer */
2N/A HANDLE2SESSION(hSession, sessp, rv);
2N/A
2N/A if (rv != CKR_OK) {
2N/A return (rv);
2N/A }
2N/A
2N/A /* Pass data to the provider */
2N/A rv = FUNCLIST(sessp->se_slotid)->C_FindObjects(sessp->se_handle,
2N/A phObject, ulMaxObjectCount, pulObjectCount);
2N/A
2N/A /* Present consistent interface to the application */
2N/A if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
2N/A return (CKR_FUNCTION_FAILED);
2N/A }
2N/A
2N/A return (rv);
2N/A}
2N/A
2N/A/*
2N/A * C_FindObjectsFinal is a pure wrapper to the underlying provider.
2N/A * The only argument checked is whether or not hSession is valid.
2N/A */
2N/ACK_RV
2N/AC_FindObjectsFinal(CK_SESSION_HANDLE hSession)
2N/A{
2N/A CK_RV rv;
2N/A pkcs11_session_t *sessp;
2N/A
2N/A /* Check for a fastpath */
2N/A if (purefastpath || policyfastpath) {
2N/A return (fast_funcs->C_FindObjectsFinal(hSession));
2N/A }
2N/A
2N/A if (!pkcs11_initialized) {
2N/A return (CKR_CRYPTOKI_NOT_INITIALIZED);
2N/A }
2N/A
2N/A /* Obtain the session pointer */
2N/A HANDLE2SESSION(hSession, sessp, rv);
2N/A
2N/A if (rv != CKR_OK) {
2N/A return (rv);
2N/A }
2N/A
2N/A /* Pass data to the provider */
2N/A rv = FUNCLIST(sessp->se_slotid)->C_FindObjectsFinal(sessp->se_handle);
2N/A
2N/A /* Present consistent interface to the application */
2N/A if (rv == CKR_FUNCTION_NOT_SUPPORTED) {
2N/A return (CKR_FUNCTION_FAILED);
2N/A }
2N/A
2N/A return (rv);
2N/A}