#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,
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)
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(
(long)inl, &(ctx->c.cast_ks),
&(ctx->iv[0]),
&ctx->num);
+ return 1;
}
#endif