Fourth phase EVP revision.
[openssl.git] / crypto / evp / e_cast.c
similarity index 79%
rename from crypto/evp/e_cbc_c.c
rename to crypto/evp/e_cast.c
index 8164f2b1cdded4c711d7d6b17712da882487ac1c..e0a9430b134b145ac17bea463636d5286aa06f01 100644 (file)
@@ -1,4 +1,4 @@
-/* crypto/evp/e_cbc_c.c */
+/* crypto/evp/e_cast.c */
 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
 #include "cryptlib.h"
 #include <openssl/evp.h>
 #include <openssl/objects.h>
+#include "evp_locl.h"
 
-static int cast_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
+static int cast_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
        unsigned char *iv,int enc);
-static int cast_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
-       unsigned char *in, unsigned int inl);
-static EVP_CIPHER cast5_cbc_cipher=
-       {
-       NID_cast5_cbc,
-       8,EVP_CAST5_KEY_SIZE,8,
-       EVP_CIPH_CBC_MODE | EVP_CIPH_VARIABLE_LENGTH,
-       cast_cbc_init_key,
-       cast_cbc_cipher,
-       NULL,
-       sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
-               sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
-       EVP_CIPHER_set_asn1_iv,
-       EVP_CIPHER_get_asn1_iv,
-       NULL
-       };
 
-EVP_CIPHER *EVP_cast5_cbc(void)
-       {
-       return(&cast5_cbc_cipher);
-       }
-       
-static int cast_cbc_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
+IMPLEMENT_BLOCK_CIPHER(cast5, cast_ks, CAST, cast_ks, 
+                       NID_cast5, 8, EVP_CAST5_KEY_SIZE, 8,
+                       EVP_CIPH_VARIABLE_LENGTH, cast_init_key, NULL,
+                       EVP_CIPHER_set_asn1_iv, EVP_CIPHER_get_asn1_iv, NULL)
+                       
+static int cast_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
        CAST_set_key(&(ctx->c.cast_ks),EVP_CIPHER_CTX_key_length(ctx),key);
        return 1;
        }
 
-static int cast_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
-            unsigned char *in, unsigned int inl)
-       {
-       CAST_cbc_encrypt(
-               in,out,(long)inl,
-               &(ctx->c.cast_ks),&(ctx->iv[0]),
-               ctx->encrypt);
-       return 1;
-       }
-
 #endif