2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License (the "License"). 2N/A * You may not use this file except in compliance with the License. 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A /* Get the kernel's internal mechanism number. */ 2N/A /* Obtain the session pointer. */ 2N/A /* Obtain the object pointer. */ 2N/A /* Check to see if key object allows for encryption. */ 2N/A * This active flag will remain ON until application calls either 2N/A * C_Encrypt or C_EncryptFinal to actually obtain the final piece 2N/A /* set up key data */ 2N/A /* Cache this capability value for efficiency */ 2N/A /* Free memory allocated for decrypt_init.di_key */ 2N/A /* Obtain the session pointer. */ 2N/A * Only check if pulEncryptedDataLen is NULL. 2N/A * No need to check if pEncryptedData is NULL because 2N/A * application might just ask for the length of buffer to hold 2N/A /* Application must call C_EncryptInit before calling C_Encrypt. */ 2N/A * C_Encrypt must be called without intervening C_EncryptUpdate 2N/A * C_Encrypt can not be used to terminate a multi-part 2N/A * operation, so we'll leave the active encrypt operation 2N/A * flag on and let the application continue with the 2N/A * encrypt update operation. 2N/A * Certain mechanisms, where the length of the ciphertext is 2N/A * same as the transformed plaintext, can be optimized 2N/A * by the kernel into an in-place operation. Unfortunately, 2N/A * some applications use a ciphertext buffer that is larger 2N/A * than it needs to be. We fix that here. 2N/A * We will not terminate the active encrypt operation flag, 2N/A * when the application-supplied buffer is too small, or 2N/A * the application asks for the length of buffer to hold 2N/A * Terminates the active encrypt operation. 2N/A * Application needs to call C_EncryptInit again for next 2N/A * encrypt operation. 2N/A /* Obtain the session pointer. */ 2N/A * Only check if pulEncryptedPartLen is NULL. 2N/A * No need to check if pEncryptedPart is NULL because 2N/A * application might just ask for the length of buffer to hold 2N/A * Application must call C_EncryptInit before calling 2N/A * If CKR_OK or CKR_BUFFER_TOO_SMALL, set the output length. 2N/A * We don't terminate the current encryption operation. 2N/A * After an error occurred, terminate the current encrypt 2N/A * operation by resetting the active and update flags. 2N/A /* Obtain the session pointer. */ 2N/A * Application must call C_EncryptInit before calling 2N/A * We will not terminate the active encrypt operation flag, 2N/A * when the application-supplied buffer is too small, or 2N/A * the application asks for the length of buffer to hold 2N/A /* Terminates the active encrypt operation. */