softSign.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* 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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include <pthread.h>
#include <security/cryptoki.h>
#include "softGlobal.h"
#include "softObject.h"
#include "softOps.h"
#include "softSession.h"
{
if (!softtoken_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/* Obtain the session pointer. */
return (rv);
if (pMechanism == NULL) {
goto clean_exit;
}
/* Obtain the object pointer. */
goto clean_exit;
}
/* Check to see if key object supports signature. */
goto clean_exit1;
}
/* Check to see if sign operation is already active. */
/* free the memory to avoid memory leak */
}
/*
* This active flag will remain ON until application calls either
* C_Sign or C_SignFinal to actually obtain the signature.
*/
}
return (rv);
}
{
if (!softtoken_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/* Obatin the session pointer */
return (rv);
goto clean_exit;
}
/* Application must call C_SignInit before calling C_Sign. */
return (CKR_OPERATION_NOT_INITIALIZED);
}
/*
* C_Sign must be called without intervening C_SignUpdate
* calls.
*/
/*
* C_Sign can not be used to terminate a multi-part
* operation, so we'll leave the active sign operation
* flag on and let the application continue with the
* sign update operation.
*/
return (CKR_FUNCTION_FAILED);
}
if ((rv == CKR_BUFFER_TOO_SMALL) ||
/*
* We will not terminate the active sign operation flag,
* when the application-supplied buffer is too small, or
* the application asks for the length of buffer to hold
* the signature.
*/
return (rv);
}
/*
* Terminates the active sign operation.
* Application needs to call C_SignInit again for next
* sign operation.
*/
return (rv);
return (rv);
}
{
if (!softtoken_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/* Obtain the session pointer */
return (rv);
if (ulPartLen == 0) {
return (CKR_OK);
}
goto clean_exit;
}
/*
* Application must call C_SignInit before calling
* C_SignUpdate.
*/
return (CKR_OPERATION_NOT_INITIALIZED);
}
return (rv);
}
/*
* After an error occurred, terminate the current sign
* operation by resetting the active and update flags.
*/
return (rv);
}
{
if (!softtoken_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/* Obtain the session pointer */
return (rv);
if (pulSignatureLen == NULL) {
goto clean_exit;
}
/*
* Application must call C_SignInit before calling
* C_SignFinal.
*/
return (CKR_OPERATION_NOT_INITIALIZED);
}
if ((rv == CKR_BUFFER_TOO_SMALL) ||
/*
* We will not terminate the active sign operation flag,
* when the application-supplied buffer is too small, or
* the application asks for the length of buffer to hold
* the signature.
*/
return (rv);
}
/* Terminates the active sign operation */
return (rv);
return (rv);
}
{
if (!softtoken_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/* Obtain the session pointer. */
return (rv);
if (pMechanism == NULL) {
goto clean_exit;
}
/* Obtain the object pointer. */
goto clean_exit;
}
/* Check to see if key object supports sign_recover. */
goto clean_exit1;
}
/* Check to see if sign operation is already active. */
/* free the memory to avoid memory leak */
}
/*
* This active flag will remain ON until application calls either
* C_SignRecover to actually obtain the signature.
*/
}
return (rv);
}
{
if (!softtoken_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/* Obatin the session pointer */
return (rv);
goto clean_exit;
}
/* Application must call C_SignRecoverInit before C_SignRecover. */
return (CKR_OPERATION_NOT_INITIALIZED);
}
if ((rv == CKR_BUFFER_TOO_SMALL) ||
/*
* We will not terminate the active sign operation flag,
* when the application-supplied buffer is too small, or
* the application asks for the length of buffer to hold
* the signature.
*/
return (rv);
}
/*
* Free the active context right here. We don't need to call
* soft_sign_verify_cleanup() because this function is only
* applicable to CKM_RSA_PKCS and CKM_RSA_X_509 that only has
* one active context.
*/
}
return (rv);
}