Third phase of EVP cipher overhaul.
[openssl.git] / crypto / evp / e_ofb_c.c
index fb7b501fb6dc3611a9b7b556d69e7b0aafaa7c61..20c843c22f86c758d628c15e193122dd9b4917b6 100644 (file)
 
 #include <stdio.h>
 #include "cryptlib.h"
-#include "evp.h"
-#include "objects.h"
+#include <openssl/evp.h>
+#include <openssl/objects.h>
 
-#ifndef NOPROTO
-static void cast_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
+static int cast_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
        unsigned char *iv,int enc);
-static void cast_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+static int cast_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
        unsigned char *in, unsigned int inl);
-#else
-static void cast_ofb_init_key();
-static void cast_ofb_cipher();
-#endif
-
 static EVP_CIPHER cast5_ofb_cipher=
        {
        NID_cast5_ofb64,
        1,EVP_CAST5_KEY_SIZE,8,
+       EVP_CIPH_OFB_MODE | EVP_CIPH_VARIABLE_LENGTH,
        cast_ofb_init_key,
        cast_ofb_cipher,
        NULL,
@@ -84,6 +79,7 @@ static EVP_CIPHER cast5_ofb_cipher=
                sizeof((((EVP_CIPHER_CTX *)NULL)->c.cast_ks)),
        EVP_CIPHER_set_asn1_iv,
        EVP_CIPHER_get_asn1_iv,
+       NULL
        };
 
 EVP_CIPHER *EVP_cast5_ofb(void)
@@ -91,19 +87,14 @@ EVP_CIPHER *EVP_cast5_ofb(void)
        return(&cast5_ofb_cipher);
        }
        
-static void cast_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
+static int cast_ofb_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key,
             unsigned char *iv, int enc)
        {
-       ctx->num=0;
-
-       if (iv != NULL)
-               memcpy(&(ctx->oiv[0]),iv,8);
-       memcpy(&(ctx->iv[0]),&(ctx->oiv[0]),8);
-       if (key != NULL)
-               CAST_set_key(&(ctx->c.cast_ks),EVP_CAST5_KEY_SIZE,key);
+       CAST_set_key(&(ctx->c.cast_ks),EVP_CIPHER_CTX_key_length(ctx),key);
+       return 1;
        }
 
-static void cast_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
+static int cast_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
             unsigned char *in, unsigned int inl)
        {
        CAST_ofb64_encrypt(
@@ -111,6 +102,7 @@ static void cast_ofb_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
                (long)inl, &(ctx->c.cast_ks),
                &(ctx->iv[0]),
                &ctx->num);
+       return 1;
        }
 
 #endif