/*
* 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"
#include <stdlib.h>
#include <strings.h>
#include <security/cryptoki.h>
#include <cryptoutil.h>
#include <errno.h>
#include "kernelGlobal.h"
#include "kernelSlot.h"
/* ARGSUSED */
{
int i;
if (!kernel_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
return (CKR_ARGUMENTS_BAD);
}
*pulCount = slot_count;
return (CKR_OK);
}
if (*pulCount < slot_count) {
*pulCount = slot_count;
return (CKR_BUFFER_TOO_SMALL);
}
*pulCount = slot_count;
/*
* The slotID returned to an application will be the index to
* the slot_table. The library will map to the provider_id when
* making any ioctl call.
*/
for (i = 0; i < slot_count; i++) {
pSlotList[i] = i;
}
return (CKR_OK);
}
{
int r;
if (!kernel_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
if (slotID >= slot_count) {
return (CKR_SLOT_ID_INVALID);
}
return (CKR_ARGUMENTS_BAD);
/* kernel provider numbers start with 0 */
break;
}
if (r < 0) {
} else {
} else {
}
}
}
return (rv);
}
{
int r;
if (!kernel_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
if (slotID >= slot_count)
return (CKR_SLOT_ID_INVALID);
return (CKR_ARGUMENTS_BAD);
break;
}
if (r < 0) {
} else {
}
pInfo->ulMaxPinLen =
pInfo->ulMinPinLen =
}
return (rv);
}
/*ARGSUSED*/
{
if (!kernel_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
return (CKR_FUNCTION_NOT_SUPPORTED);
}
{
int i, r;
if (!kernel_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
if (slotID >= slot_count)
return (CKR_SLOT_ID_INVALID);
/* kernel provider numbers start with 0 */
if (pMechanismList != NULL) {
return (CKR_ARGUMENTS_BAD);
} else if (*pulCount == 0) {
return (CKR_ARGUMENTS_BAD);
}
}
&tmp)) < 0) {
break;
}
if (r < 0) {
return (CKR_FUNCTION_FAILED);
} else {
return (rv);
}
alloc_bytes = sizeof (crypto_get_provider_mechanisms_t) +
}
return (CKR_HOST_MEMORY);
break;
}
if (r < 0) {
} else {
}
goto clean_exit;
sizeof (crypto_mech_name_t));
/*
* Get each mechanism's flags.
* The ioctl should not fail since the mechanism info is
* already in the kernel and a call doesn't have to be made
* to the provider. If it fails, nothing can be done other
* than skip the mechanism.
*/
&mechanism_info)) < 0) {
break;
}
if (r < 0) {
continue;
}
continue;
/*
* Atomic flags are not part of PKCS#11 so we filter
* them out here.
*/
/* mechanism has no PKCS#11 flags, so don't report it */
if (flags == 0)
continue;
/*
* The kernel framework has a pseudo mechanism
* for RNG which we remove from the list of mechanisms.
*/
continue;
(count < specified_count))
count++;
}
}
return (rv);
}
{
if (!kernel_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
if (slotID >= slot_count)
return (CKR_SLOT_ID_INVALID);
return (CKR_ARGUMENTS_BAD);
}
return (rv);
}
/*ARGSUSED*/
{
if (!kernel_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
return (CKR_FUNCTION_NOT_SUPPORTED);
}
/*ARGSUSED*/
{
if (!kernel_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
return (CKR_FUNCTION_NOT_SUPPORTED);
}
{
int r;
if (!kernel_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/*
* Obtain the session pointer. Also, increment the session
* reference count.
*/
return (rv);
/* Make sure it is a RW session. */
return (rv);
}
/* Lock the session and make the CRYPTO_SET_PIN ioctl call. */
break;
}
if (r < 0) {
} else {
}
return (rv);
}