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 (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. 2N/A * If this is a non-sensitive key and it does NOT have 2N/A * a key schedule yet, then allocate one and expand it. 2N/A * Otherwise, if it's a non-sensitive key, and it DOES have 2N/A * a key schedule already attached to it, just copy the 2N/A * pre-expanded schedule to the context and avoid the 2N/A * extra key schedule expansion operation. 2N/A * Initialize key schedule for Blowfish. 2N/A * blowfish_init_keysched() requires key length in bits. 2N/A * soft_blowfish_encrypt_common() 2N/A * session_p: pointer to soft_session_t struct 2N/A * pData: pointer to the input data to be encrypted 2N/A * ulDataLen: length of the input data 2N/A * pEncrypted: pointer to the output data after encryption 2N/A * pulEncryptedLen: pointer to the length of the output data 2N/A * update: boolean flag indicates caller is soft_encrypt 2N/A * or soft_encrypt_update 2N/A * This function calls the corresponding encrypt routine based 2N/A * CKR_BUFFER_TOO_SMALL: the output buffer provided by application 2N/A * CKR_FUNCTION_FAILED: encrypt function failed 2N/A * CKR_DATA_LEN_RANGE: the input data is not a multiple of blocksize 2N/A * Blowfish only takes input length that is a multiple of blocksize 2N/A * for C_Encrypt function with the mechanism CKM_BLOWFISH_CBC. 2N/A * If application asks for the length of the output buffer 2N/A * to hold the ciphertext? 2N/A /* Is the application-supplied buffer large enough? */ 2N/A * Called by C_EncryptUpdate 2N/A * Add the lengths of last remaining data and current 2N/A * plaintext together to get the total input length. 2N/A * If the total input length is less than one blocksize, 2N/A * we will need to delay encryption until when more data 2N/A * comes in next C_EncryptUpdate or when C_EncryptFinal 2N/A * Save input data and its length in 2N/A * the remaining buffer of BLOWFISH context. 2N/A /* Set encrypted data length to 0. */ 2N/A /* Compute the length of remaining data. */ 2N/A * Make sure that the output length is a multiple of 2N/A * If application asks for the length of the output buffer 2N/A * to hold the ciphertext? 2N/A /* Is the application-supplied buffer large enough? */ 2N/A * Copy last remaining data and current input data 2N/A * to the output buffer. 2N/A * Begin Encryption now. 2N/A /* Encrypt multiple blocks of data. */ 2N/A * For encrypt update, if there is remaining data, 2N/A * save it and it's length in the context. 2N/A * Blowfish only takes input length that is a multiple of 16 bytes 2N/A * for C_Decrypt function using CKM_BLOWFISH_CBC. 2N/A /* Called by C_Decrypt */ 2N/A * If application asks for the length of the output buffer 2N/A * to hold the plaintext? 2N/A /* Is the application-supplied buffer large enough? */ 2N/A * Called by C_DecryptUpdate 2N/A * Add the lengths of last remaining data and current 2N/A * input data together to get the total input length. 2N/A /* Set output data length to 0. */ 2N/A /* Compute the length of remaining data. */ 2N/A * Make sure that the output length is a multiple of 2N/A * if application asks for the length of the output buffer 2N/A * to hold the plaintext? 2N/A * Is the application-supplied buffer large enough? 2N/A * Copy last remaining data and current input data 2N/A * to the output buffer. 2N/A /* Decrypt multiple blocks of data. */ 2N/A * For decrypt update, if there is remaining data, 2N/A * save it and its length in the context. 2N/A * Allocate and initialize a context for BLOWFISH CBC mode of operation.