pkcs11SUNWExtensions.c revision 90e0e8c47a01eef8d256571579d8acabd7cf681c
/*
* 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
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Solaris specific functions to reduce the initialization
* overhead of using PKCS #11
*/
#include <stdlib.h>
#include <security/cryptoki.h>
#include <assert.h>
#include <cryptoutil.h>
#include <pkcs11Global.h>
#define NUM_SECRETKEY_ATTRS 8
typedef struct _ATTRTYPE_MECHINFO_MAPPING {
/* possible attribute types for creating key */
};
/*
* List of mechanisms that only supports asymmetric key operations
* in PKCS #11 V2.11
*/
};
/*
* SUNW_C_GetMechSession will initialize the framework and do all
* of the neccessary work of calling C_GetSlotList(), C_GetMechanismInfo()
* C_OpenSession() to provide a session capable of providing the requested
* mechanism.
*
* If the function is called multiple times, it will return a new session
* without reinitializing the framework.
*/
{
CK_ULONG i;
return (CKR_ARGUMENTS_BAD);
}
/* initialize PKCS #11 */
if (!pkcs11_initialized) {
(rv != CKR_CRYPTOKI_ALREADY_INITIALIZED)) {
return (rv);
}
}
/* get slot count */
return (rv);
}
if (slotcount == 0) {
return (CKR_FUNCTION_FAILED);
}
/* allocate memory for slot list */
return (CKR_HOST_MEMORY);
}
return (rv);
}
/* find slot with matching mechanism */
for (i = 0; i < slotcount; i++) {
/* found mechanism */
break;
}
}
if (i == slotcount) {
/* no matching mechanism found */
return (CKR_MECHANISM_INVALID);
}
return (rv);
}
/*
* SUNW_C_KeyToObject creates a secret key object for the given
* mechanism from the rawkey data.
*/
{
CK_ULONG i, j;
/* template for creating generic secret key object */
return (CKR_ARGUMENTS_BAD);
}
/*
* Check to make sure mechanism type is not for asymmetric key
* only operations. This function is only applicable to
* generating secret key.
*/
for (i = 0; i < num_asym_mechs; i++) {
if (mech == asymmetric_mechs[i]) {
return (CKR_MECHANISM_INVALID);
}
}
/* set the attribute type flag on object based on mechanism */
goto cleanup;
}
/* create a generic object first */
i = 0;
i++;
/* get the key type for this mechanism */
return (rv);
}
assert(i < NUM_SECRETKEY_ATTRS);
i++;
goto cleanup;
}
for (j = 0; j < num_mapping; j++) {
assert(i < NUM_SECRETKEY_ATTRS);
} else {
}
i++;
}
assert(i < NUM_SECRETKEY_ATTRS);
i++;
assert(i < NUM_SECRETKEY_ATTRS);
i++;
return (rv);
}
return (rv);
/* This cleanup is only for failure cases */
return (rv);
}