11539Srgrimes/* crypto/evp/e_cast.c */ 21539Srgrimes/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 31539Srgrimes * All rights reserved. 41539Srgrimes * 51539Srgrimes * This package is an SSL implementation written 61539Srgrimes * by Eric Young (eay@cryptsoft.com). 71539Srgrimes * The implementation was written so as to conform with Netscapes SSL. 81539Srgrimes * 91539Srgrimes * This library is free for commercial and non-commercial use as long as 101539Srgrimes * the following conditions are aheared to. The following conditions 111539Srgrimes * apply to all code found in this distribution, be it the RC4, RSA, 121539Srgrimes * lhash, DES, etc., code; not just the SSL code. The SSL documentation 131539Srgrimes * included with this distribution is covered by the same copyright terms 141539Srgrimes * except that the holder is Tim Hudson (tjh@cryptsoft.com). 151539Srgrimes * 161539Srgrimes * Copyright remains Eric Young's, and as such any Copyright notices in 171539Srgrimes * the code are not to be removed. 181539Srgrimes * If this package is used in a product, Eric Young should be given attribution 191539Srgrimes * as the author of the parts of the library used. 201539Srgrimes * This can be in the form of a textual message at program startup or 211539Srgrimes * in documentation (online or textual) provided with the package. 221539Srgrimes * 231539Srgrimes * Redistribution and use in source and binary forms, with or without 241539Srgrimes * modification, are permitted provided that the following conditions 251539Srgrimes * are met: 261539Srgrimes * 1. Redistributions of source code must retain the copyright 271539Srgrimes * notice, this list of conditions and the following disclaimer. 281539Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 291539Srgrimes * notice, this list of conditions and the following disclaimer in the 301539Srgrimes * documentation and/or other materials provided with the distribution. 311539Srgrimes * 3. All advertising materials mentioning features or use of this software 321539Srgrimes * must display the following acknowledgement: 331539Srgrimes * "This product includes cryptographic software written by 341539Srgrimes * Eric Young (eay@cryptsoft.com)" 351539Srgrimes * The word 'cryptographic' can be left out if the rouines from the library 361539Srgrimes * being used are not cryptographic related :-). 371539Srgrimes * 4. If you include any Windows specific code (or a derivative thereof) from 381539Srgrimes * the apps directory (application code) you must include an acknowledgement: 391539Srgrimes * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 401539Srgrimes * 411539Srgrimes * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 421539Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 431539Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 441539Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 4534925Sdufault * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 461539Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 476164Sbde * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 486164Sbde * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 496164Sbde * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 506164Sbde * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 516164Sbde * SUCH DAMAGE. 526243Sbde * 536164Sbde * The licence and distribution terms for any publically available version or 546164Sbde * derivative of this code cannot be changed. i.e. this code cannot simply be 556164Sbde * copied and put under another distribution licence 566164Sbde * [including the GNU Public Licence.] 576164Sbde */ 581539Srgrimes 591539Srgrimes#include <stdio.h> 601539Srgrimes#include "cryptlib.h" 611539Srgrimes 621539Srgrimes#ifndef OPENSSL_NO_CAST 631539Srgrimes# include <openssl/evp.h> 641539Srgrimes# include <openssl/objects.h> 651539Srgrimes# include "evp_locl.h" 661539Srgrimes# include <openssl/cast.h> 671539Srgrimes 681539Srgrimesstatic int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 691539Srgrimes const unsigned char *iv, int enc); 701539Srgrimes 711539Srgrimestypedef struct { 7225773Speter CAST_KEY ks; 7325773Speter} EVP_CAST_KEY; 7425773Speter 7525773Speter# define data(ctx) EVP_C_DATA(EVP_CAST_KEY,ctx) 7625773Speter 7734925SdufaultIMPLEMENT_BLOCK_CIPHER(cast5, ks, CAST, EVP_CAST_KEY, 7834925Sdufault NID_cast5, 8, CAST_KEY_LENGTH, 8, 64, 7934925Sdufault EVP_CIPH_VARIABLE_LENGTH, cast_init_key, NULL, 8034925Sdufault EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL) 8125773Speter 8225773Speterstatic int cast_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key, 8325773Speter const unsigned char *iv, int enc) 8425769Sache{ 8525769Sache CAST_set_key(&data(ctx)->ks, EVP_CIPHER_CTX_key_length(ctx), key); 8625769Sache return 1; 8725769Sache} 8825769Sache 8925773Speter#endif 9025773Speter