/*
* 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 <pthread.h>
#include <stdlib.h>
#include <errno.h>
#include <security/cryptoki.h>
#include "kernelGlobal.h"
#include "kernelSession.h"
#include "kernelObject.h"
{
int r;
if (!kernel_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
if (pMechanism == NULL) {
return (CKR_ARGUMENTS_BAD);
}
/* Get the kernel's internal mechanism number. */
return (rv);
/* Obtain the session pointer. */
return (rv);
/* Obtain the object pointer. */
return (rv);
}
/* Check to see if key object allows for encryption. */
goto clean_exit;
}
/*
* This active flag will remain ON until application calls either
* C_Encrypt or C_EncryptFinal to actually obtain the final piece
* of ciphertext.
*/
/* set up key data */
if (!key_p->is_lib_obj) {
} else {
goto clean_exit;
}
CKR_OK) {
goto clean_exit;
}
} else {
goto clean_exit;
}
}
/* Cache this capability value for efficiency */
}
break;
}
if (r < 0) {
} else {
}
}
/* Free memory allocated for decrypt_init.di_key */
if (key_p->is_lib_obj) {
}
}
}
return (rv);
}
{
int r;
if (!kernel_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/* Obtain the session pointer. */
return (rv);
goto clean_exit;
}
/*
* Only check if pulEncryptedDataLen is NULL.
* No need to check if pEncryptedData is NULL because
* application might just ask for the length of buffer to hold
* the ciphertext.
*/
if (pulEncryptedDataLen == NULL) {
goto clean_exit;
}
/* Application must call C_EncryptInit before calling C_Encrypt. */
return (CKR_OPERATION_NOT_INITIALIZED);
}
/*
* C_Encrypt must be called without intervening C_EncryptUpdate
* calls.
*/
/*
* C_Encrypt can not be used to terminate a multi-part
* operation, so we'll leave the active encrypt operation
* flag on and let the application continue with the
* encrypt update operation.
*/
return (CKR_FUNCTION_FAILED);
}
/*
* Certain mechanisms, where the length of the ciphertext is
* same as the transformed plaintext, can be optimized
* by the kernel into an in-place operation. Unfortunately,
* some applications use a ciphertext buffer that is larger
* than it needs to be. We fix that here.
*/
} else {
}
(pData == pEncryptedData)) &&
break;
}
if (r < 0) {
} else {
}
if ((rv == CKR_BUFFER_TOO_SMALL) ||
/*
* We will not terminate the active encrypt operation flag,
* when the application-supplied buffer is too small, or
* the application asks for the length of buffer to hold
* the ciphertext.
*/
return (rv);
}
/*
* Terminates the active encrypt operation.
* Application needs to call C_EncryptInit again for next
* encrypt operation.
*/
return (rv);
}
{
int r;
if (!kernel_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/* Obtain the session pointer. */
return (rv);
goto clean_exit;
}
/*
* Only check if pulEncryptedPartLen is NULL.
* No need to check if pEncryptedPart is NULL because
* application might just ask for the length of buffer to hold
* the ciphertext.
*/
if (pulEncryptedPartLen == NULL) {
goto clean_exit;
}
/*
* Application must call C_EncryptInit before calling
* C_EncryptUpdate.
*/
return (CKR_OPERATION_NOT_INITIALIZED);
}
(pPart == pEncryptedPart)) &&
&encrypt_update)) < 0) {
break;
}
if (r < 0) {
} else {
}
/*
* If CKR_OK or CKR_BUFFER_TOO_SMALL, set the output length.
* We don't terminate the current encryption operation.
*/
return (rv);
}
/*
* After an error occurred, terminate the current encrypt
* operation by resetting the active and update flags.
*/
return (rv);
}
{
int r;
if (!kernel_initialized)
return (CKR_CRYPTOKI_NOT_INITIALIZED);
/* Obtain the session pointer. */
return (rv);
if (pulLastEncryptedPartLen == NULL) {
goto clean_exit;
}
/*
* Application must call C_EncryptInit before calling
* C_EncryptFinal.
*/
return (CKR_OPERATION_NOT_INITIALIZED);
}
&encrypt_final)) < 0) {
break;
}
if (r < 0) {
} else {
}
if ((rv == CKR_BUFFER_TOO_SMALL) ||
/*
* We will not terminate the active encrypt operation flag,
* when the application-supplied buffer is too small, or
* the application asks for the length of buffer to hold
* the ciphertext.
*/
return (rv);
}
/* Terminates the active encrypt operation. */
return (rv);
}