/*
* 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 <string.h>
#include <strings.h>
#include <security/cryptoki.h>
#include <cryptoutil.h>
#include "softGlobal.h"
#include "softSession.h"
#include "softObject.h"
#include "softDSA.h"
#include "softOps.h"
#include "softMAC.h"
#include "softCrypt.h"
/*
* Allocate a DSA context for the active sign or verify operation.
* This function is called without the session lock held.
*/
{
if (sign) {
return (CKR_KEY_TYPE_INCONSISTENT);
} else {
return (CKR_KEY_TYPE_INCONSISTENT);
}
return (rv);
}
return (CKR_HOST_MEMORY);
}
/*
* Make a copy of the signature or verification key, and save it
* in the DSA 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.
*/
NULL);
/* Most likely we ran out of space. */
return (rv);
}
/* No need to hold the lock on the old object. */
if (sign) {
} else {
}
return (CKR_OK);
}
static CK_RV
{
DSAbytekey k;
goto clean1;
}
goto clean1;
}
goto clean1;
}
goto clean1;
}
k.prime = p;
k.subprime = q;
k.base = g;
k.base_bytes = glen;
k.private_x = x;
return (rv);
}
static CK_RV
{
DSAbytekey k;
goto clean1;
}
goto clean1;
}
goto clean1;
}
goto clean1;
}
k.prime = p;
k.subprime = q;
k.base = g;
k.base_bytes = glen;
k.public_y = y;
return (rv);
}
{
/* Check arguments before performing message digest. */
/* Application asks for the length of the output buffer. */
goto clean1;
}
/* Is the application-supplied buffer large enough? */
if (*pulSignedLen < DSA_SIGNATURE_LENGTH) {
goto clean1;
}
if (Final) {
} else {
}
/* free the signature key */
goto clean_exit;
}
/*
* Now, we are ready to sign the data
* soft_dsa_sign() will free the signature key.
*/
/* soft_digest_common() has freed the digest context */
return (rv);
}
{
goto clean_exit;
}
/* Output length is always 40 bytes. */
/* Application asks for the length of the output buffer. */
return (CKR_OK);
}
/* Input data length needs to be 20 bytes. */
if (ulDataLen != DSA_SUBPRIME_BYTES) {
goto clean_exit;
}
if (*pulSignedLen < DSA_SIGNATURE_LENGTH) {
return (CKR_BUFFER_TOO_SMALL);
}
}
return (rv);
}
{
goto clean_exit;
}
/* Input data length needs to be 20 bytes. */
if (ulDataLen != DSA_SUBPRIME_BYTES) {
goto clean_exit;
}
/* The signature length is always 40 bytes. */
if (ulSignatureLen != DSA_SIGNATURE_LENGTH) {
goto clean_exit;
}
return (rv);
}
{
if (Final) {
} else {
}
/* free the verification key */
goto clean_exit;
}
/*
* Now, we are ready to verify the data using signature.
* soft_dsa_verify() will free the verification key.
*/
/* soft_digest_common() has freed the digest context */
return (rv);
}
static CK_RV
{
switch (type) {
case CKA_VALUE:
if (public)
else
break;
case CKA_PRIME:
if (public)
else
break;
case CKA_SUBPRIME:
if (public)
else
break;
case CKA_BASE:
if (public)
else
break;
}
/* Note: removal of preceding 0x00 imitates similar code in RSA */
while (value[0] == 0) { /* remove preceding 0x00 */
value++;
value_len--;
}
goto cleanexit;
/* Copy the attribute in the key object. */
/* No need to free big_value because dst holds it now after copy. */
return (rv);
}
{
DSAbytekey k;
return (CKR_ARGUMENTS_BAD);
}
/* lookup prime, subprime and base */
goto cleanexit;
}
&subprime_len);
goto cleanexit;
}
goto cleanexit;
}
/* Inputs to DSA key pair generation. */
k.base_bytes = base_len;
/* Outputs from DSA key pair generation. */
rv = dsa_genkey_pair(&k);
goto cleanexit;
}
/* Update attribute in public key. */
goto cleanexit;
}
/* Update attributes in private key. */
goto cleanexit;
}
goto cleanexit;
}
goto cleanexit;
}
goto cleanexit;
}
return (rv);
}