/*
* 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 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include <security/cryptoki.h>
#include <bignum.h>
#include <des_impl.h>
#include "softGlobal.h"
#include "softSession.h"
#include "softObject.h"
#include "softEC.h"
#include "softCrypt.h"
#include "softOps.h"
#include "softMAC.h"
void
{
if (freeit)
}
static void
{
}
}
}
void
{
/*
* Don't free publicValue or privateValue
* as these values are copied into objects.
*/
}
/*
* Called from init routines to do basic sanity checks. Init routines,
* e.g. sign_init should fail rather than subsequent operations.
*/
static int
{
biginteger_t *p;
if (sign) {
return (CKR_KEY_TYPE_INCONSISTENT);
p = OBJ_PRI_EC_VALUE(key_p);
len = p->big_value_len;
len = 0;
return (CKR_KEY_SIZE_RANGE);
} else {
return (CKR_KEY_TYPE_INCONSISTENT);
p = OBJ_PUB_EC_POINT(key_p);
len = p->big_value_len;
len = 0;
return (CKR_KEY_SIZE_RANGE);
}
return (CKR_OK);
}
/*
* This function places the octet string of the specified attribute
* into the corresponding key object.
*/
static void
{
switch (type) {
case CKA_VALUE:
break;
case CKA_EC_POINT:
break;
}
}
{
return (CKR_KEY_TYPE_INCONSISTENT);
return (CKR_KEY_TYPE_INCONSISTENT);
return (rv);
}
/* private key also has CKA_EC_PARAMS attribute */
return (rv);
}
/* ASN1 check */
if (param_buffer[0] != 0x06 ||
return (CKR_ATTRIBUTE_VALUE_INVALID);
}
/* bad curve OID */
return (CKR_ARGUMENTS_BAD);
}
return (CKR_FUNCTION_FAILED);
}
return (CKR_OK);
}
{
if (mech_params_len != sizeof (CK_ECDH1_DERIVE_PARAMS) ||
return (CKR_MECHANISM_PARAM_INVALID);
}
return (rv);
}
return (rv);
}
case CKK_DES:
break;
case CKK_DES2:
break;
case CKK_DES3:
break;
case CKK_RC4:
case CKK_AES:
case CKK_GENERIC_SECRET:
#ifdef __sparcv9
/* LINTED */
#else /* !__sparcv9 */
#endif /* __sparcv9 */
break;
}
/* ASN1 check */
if (params[0] != 0x06 ||
return (CKR_ATTRIBUTE_VALUE_INVALID);
}
/* bad curve OID */
return (CKR_ARGUMENTS_BAD);
}
secret_item.len = 0;
return (CKR_FUNCTION_FAILED);
} else {
}
if (keylen == 0)
goto out;
}
goto out;
}
out:
return (rv);
}
/*
* Allocate a ECC context for the active sign or verify operation.
* This function is called without the session lock held.
*/
{
return (rv);
return (rv);
}
return (CKR_HOST_MEMORY);
}
/*
* Make a copy of the signature or verification key, and save it
* in the ECC crypto context since it will be used later for
* signing/verification. We don't want to hold any object reference
* on this original key while doing signing/verification.
*/
/* Most likely we ran out of space. */
return (rv);
}
goto out;
}
/* ASN1 check */
if (params[0] != 0x06 ||
goto out;
}
/* bad curve OID */
goto out;
}
if (sign) {
} else {
}
return (CKR_OK);
out:
return (rv);
}
{
if (Final) {
} else {
&hash_len);
}
return (rv);
}
}
/* soft_digest_common() has freed the digest context */
return (rv);
}
{
goto clean_exit;
}
if (ulDataLen > EC_MAX_DIGEST_LEN) {
goto clean_exit;
}
/* structure assignment */
goto clean_exit;
}
!= SECSuccess) {
if (ss == SECBufferTooSmall)
return (CKR_BUFFER_TOO_SMALL);
goto clean_exit;
}
return (rv);
}
return (rv);
}
{
goto clean_exit;
}
if (ulSignatureLen > EC_MAX_SIG_LEN) {
goto clean_exit;
}
if (ulDataLen > EC_MAX_DIGEST_LEN) {
goto clean_exit;
}
/* structure assignment */
goto clean_exit;
}
!= SECSuccess) {
} else {
}
return (rv);
}
{
if (Final) {
} else {
}
return (rv);
}
/*
* Now, we are ready to verify the data using signature.
* soft_ecc_verify() will free the verification key.
*/
/* soft_digest_common() has freed the digest context */
return (rv);
}