summaryrefslogtreecommitdiffstats
path: root/crypto/evp/e_rc4.c
diff options
context:
space:
mode:
authorBen Laurie <ben@openssl.org>2001-07-30 23:57:25 +0000
committerBen Laurie <ben@openssl.org>2001-07-30 23:57:25 +0000
commitdbad169019598981174ff46c7a9bf58373b0e53a (patch)
treece8ca1188d5614648f24b03967785543f1edc8f5 /crypto/evp/e_rc4.c
parent3ba5d1cf2eb6ef28ac5f6d9f3d28020d00c5be50 (diff)
Really add the EVP and all of the DES changes.
Diffstat (limited to 'crypto/evp/e_rc4.c')
-rw-r--r--crypto/evp/e_rc4.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/crypto/evp/e_rc4.c b/crypto/evp/e_rc4.c
index 7e212b3be5..4064cc5fa0 100644
--- a/crypto/evp/e_rc4.c
+++ b/crypto/evp/e_rc4.c
@@ -62,6 +62,19 @@
#include "cryptlib.h"
#include <openssl/evp.h>
#include <openssl/objects.h>
+#include <openssl/rc4.h>
+
+/* FIXME: surely this is available elsewhere? */
+#define EVP_RC4_KEY_SIZE 16
+
+typedef struct
+ {
+ /* FIXME: what is the key for? */
+ unsigned char key[EVP_RC4_KEY_SIZE];
+ RC4_KEY ks; /* working key */
+ } EVP_RC4_KEY;
+
+#define data(ctx) ((EVP_RC4_KEY *)(ctx)->cipher_data)
static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv,int enc);
@@ -75,8 +88,7 @@ static const EVP_CIPHER r4_cipher=
rc4_init_key,
rc4_cipher,
NULL,
- sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
- sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc4)),
+ sizeof(EVP_RC4_KEY),
NULL,
NULL,
NULL
@@ -90,8 +102,7 @@ static const EVP_CIPHER r4_40_cipher=
rc4_init_key,
rc4_cipher,
NULL,
- sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
- sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc4)),
+ sizeof(EVP_RC4_KEY),
NULL,
NULL,
NULL
@@ -110,16 +121,16 @@ const EVP_CIPHER *EVP_rc4_40(void)
static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
const unsigned char *iv, int enc)
{
- memcpy(&(ctx->c.rc4.key[0]),key,EVP_CIPHER_CTX_key_length(ctx));
- RC4_set_key(&(ctx->c.rc4.ks),EVP_CIPHER_CTX_key_length(ctx),
- ctx->c.rc4.key);
+ memcpy(&data(ctx)->key[0],key,EVP_CIPHER_CTX_key_length(ctx));
+ RC4_set_key(&data(ctx)->ks,EVP_CIPHER_CTX_key_length(ctx),
+ data(ctx)->key);
return 1;
}
static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const unsigned char *in, unsigned int inl)
{
- RC4(&(ctx->c.rc4.ks),inl,in,out);
+ RC4(&data(ctx)->ks,inl,in,out);
return 1;
}
#endif