/*
* 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 <pthread.h>
#include <stdlib.h>
#include <errno.h>
#include <errno.h>
#include <string.h>
#include <security/cryptoki.h>
#include "kmsGlobal.h"
#include "kmsObject.h"
#include "kmsSession.h"
{
if (!kms_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
return (CKR_ARGUMENTS_BAD);
}
/*
* Obtain the session pointer. Also, increment the session
* reference count.
*/
return (rv);
/* Create a new object. */
/*
* Decrement the session reference count.
* We do not hold the session lock.
*/
return (rv);
}
{
int i;
if (!kms_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/* Check arguments */
(phNewObject == NULL)) {
return (CKR_ARGUMENTS_BAD);
}
/*
* Obtain the session pointer. Also, increment the session
* reference count.
*/
return (rv);
/* Obtain the object pointer. */
/*
* Decrement the session reference count.
* We do not hold the session lock.
*/
return (rv);
}
if (old_object->is_lib_obj) {
/*
* Copy the old object to a new object.
* The 3rd argument with TRUE value indicates that
* everything in the object will be duplicated.
*/
/*
* Most likely we ran out of space.
* Decrement the session reference count.
* We do not hold the session lock.
*/
return (rv);
}
/* Modify the object attribute if requested */
for (i = 0; i < ulCount; i++) {
/* Set the requested attribute into the new object. */
B_TRUE);
return (rv);
}
}
/* Insert the new object into this session's object list. */
/*
* Decrement the session reference count.
* We do not hold the session lock.
*/
/* set handle of the new object */
}
return (rv);
if (new_object != NULL) {
(void) kms_free_object(new_object);
}
return (rv);
}
{
if (!kms_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/*
* The reason that we don't call handle2session is because
* the argument hSession may not be the creating_session of
* the object to be destroyed, and we want to avoid the lock
* contention. The handle2session will be called later for
* the creating_session.
*/
return (CKR_SESSION_HANDLE_INVALID);
}
/* Obtain the object pointer without incrementing reference count. */
return (rv);
}
/* Only session objects can be destroyed at a read-only session. */
return (CKR_SESSION_READ_ONLY);
}
/*
* If the object is a session object, obtain the session handle
* which object belongs to. For a token object, we will use the
* session handle from the caller, because the session used to
* create the token object may no longer exist.
*/
else
return (rv);
}
/*
* Set OBJECT_IS_DELETING flag so any access to this
* object will be rejected.
*/
return (CKR_OBJECT_HANDLE_INVALID);
}
/*
* The first FALSE boolean argument indicates that the caller
* does not hold the slot lock. The second FALSE boolean
* argument indicates that the caller wants to clean up the
* object in the HW provider also.
*/
pslot = get_slotinfo();
} else {
/*
* The first FALSE boolean argument indicates that the caller
* does not hold the session lock. The second FALSE boolean
* argument indicates that the caller wants to clean the object
* in the HW provider also.
*/
B_FALSE);
}
/*
* Decrement the session reference count.
* We do not hold the session lock.
*/
return (rv);
}
{
int i;
if (!kms_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
return (CKR_ARGUMENTS_BAD);
/*
* Obtain the session pointer. Also, increment the session
* reference count.
*/
return (rv);
/* Obtain the object pointer. */
/*
* Decrement the session reference count.
* We do not hold the session lock.
*/
return (rv);
}
/* Acquire the lock on the object. */
/*
* The object was created in the library. The library
* contains the value information of each attribute.
*/
for (i = 0; i < ulCount; i++) {
/*
* Get the value of each attribute in the template.
* (We must process EVERY attribute in the template.)
*/
}
/*
* Decrement the session reference count.
* We do not hold the session lock.
*/
return (rv);
}
{
int i;
if (!kms_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
return (CKR_ARGUMENTS_BAD);
/*
* Obtain the session pointer. Also, increment the session
* reference count.
*/
return (rv);
/* Obtain the object pointer. */
/*
* Decrement the session reference count.
* We do not hold the session lock.
*/
return (rv);
}
/* lock the object */
/*
* If the object was created in the HW provider, changing its
* attributes' values need to be done in the provider too.
*/
if (!object_p->is_lib_obj) {
/* Cannot modify a token object with a READ-ONLY session */
goto clean_exit;
}
}
/*
* if we come here, the object must have been created in the
* library. The work will be done completely in the library.
*
* Copy the old object to a new object. We work on the copied
* version because in case of error we still keep the old one
* intact.
*/
/*
* Most likely we ran out of space.
* Decrement the session reference count.
* We do not hold the session lock.
*/
goto clean_exit;
}
for (i = 0; i < ulCount; i++) {
/* Set the requested attribute into the new object. */
goto clean_exit;
}
}
/*
* We've successfully set all the requested attributes.
* Merge the new object with the old object, then destory
* the new one. The reason to do the merging is because we
* have to keep the original object handle (address of object).
*/
if (new_object != NULL)
(void) kms_free_object(new_object);
/*
* Decrement the session reference count.
* We do not hold the session lock.
*/
return (rv);
}
{
if (!kms_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/* Check if pulSize is valid */
return (CKR_ARGUMENTS_BAD);
}
/*
* Obtain the session pointer. Also, increment the session
* reference count.
*/
return (rv);
/* Obtain the object pointer. */
/*
* Decrement the session reference count.
* We do not hold the session lock.
*/
return (rv);
}
/* Acquire the lock on the object. */
/*
* Decrement the session reference count.
* We do not hold the session lock.
*/
return (rv);
}
{
if (!kms_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/* Check the arguments */
return (CKR_ARGUMENTS_BAD);
}
/*
* Obtain the session pointer. Also, increment the session
* reference count.
*/
return (rv);
/* Acquire the session lock */
/* Check to see if find operation is already active */
/* decrement the session count, and unlock the mutex */
return (CKR_OPERATION_ACTIVE);
} else {
/*
* This active flag will remain ON until application calls
* C_FindObjectsFinal.
*/
}
/*
* If the KMS provider supports object creation, we call the
* CRYPTO_OBJECT_FIND_INIT to initialize object finding.
* Otherwise, all the objects are created in the library and we
* do the find objects solely in the library.
*/
}
/* decrement the session count, and unlock the mutex */
return (rv);
}
{
if (!kms_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/* check for invalid arguments */
(pulObjectCount == NULL)) {
return (CKR_ARGUMENTS_BAD);
}
if (ulMaxObjectCount == 0) {
/* don't need to do anything, just return */
*pulObjectCount = 0;
return (CKR_OK);
}
/*
* Obtain the session pointer. Also, increment the session
* reference count.
*/
return (rv);
/* Acquire the slot lock */
pslot = get_slotinfo();
/* Acquire the session lock */
/* Check to see if find operation is active */
goto clean_exit;
}
/*
* Similar to C_FindObjectInit(), if the KMS provider supports object
* creation, we need to find objects.
* Otherwise, all the objects are created in the library and we do
* the find objects solely in the library.
*/
/* decrement the session count, and release the session lock */
/* release the slot lock */
if (pslot)
return (rv);
}
{
if (!kms_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/*
* Obtain the session pointer. Also, increment the session
* reference count.
*/
return (rv);
/* Acquire the session lock */
/* Check to see if find operation is active */
return (CKR_OPERATION_NOT_INITIALIZED);
}
/*
* Similar to C_FindObjectInit(), if the KMS provider supports object
* creation, we need to finalize the search on the KMS side.
*/
/* decrement the session count, and release the lock */
return (rv);
}