summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/evp/e_rc4.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/evp/e_rc4.c')
-rw-r--r--src/lib/libcrypto/evp/e_rc4.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/lib/libcrypto/evp/e_rc4.c b/src/lib/libcrypto/evp/e_rc4.c
index c7e58a75cc..1c1e3b3857 100644
--- a/src/lib/libcrypto/evp/e_rc4.c
+++ b/src/lib/libcrypto/evp/e_rc4.c
@@ -63,14 +63,15 @@
63#include <openssl/evp.h> 63#include <openssl/evp.h>
64#include <openssl/objects.h> 64#include <openssl/objects.h>
65 65
66static void rc4_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, 66static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
67 unsigned char *iv,int enc); 67 const unsigned char *iv,int enc);
68static void rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 68static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
69 unsigned char *in, unsigned int inl); 69 const unsigned char *in, unsigned int inl);
70static EVP_CIPHER r4_cipher= 70static EVP_CIPHER r4_cipher=
71 { 71 {
72 NID_rc4, 72 NID_rc4,
73 1,EVP_RC4_KEY_SIZE,0, 73 1,EVP_RC4_KEY_SIZE,0,
74 EVP_CIPH_VARIABLE_LENGTH,
74 rc4_init_key, 75 rc4_init_key,
75 rc4_cipher, 76 rc4_cipher,
76 NULL, 77 NULL,
@@ -78,14 +79,22 @@ static EVP_CIPHER r4_cipher=
78 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc4)), 79 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc4)),
79 NULL, 80 NULL,
80 NULL, 81 NULL,
82 NULL
81 }; 83 };
82 84
83static EVP_CIPHER r4_40_cipher= 85static EVP_CIPHER r4_40_cipher=
84 { 86 {
85 NID_rc4_40, 87 NID_rc4_40,
86 1,5 /* 40 bit */,0, 88 1,5 /* 40 bit */,0,
89 EVP_CIPH_VARIABLE_LENGTH,
87 rc4_init_key, 90 rc4_init_key,
88 rc4_cipher, 91 rc4_cipher,
92 NULL,
93 sizeof(EVP_CIPHER_CTX)-sizeof((((EVP_CIPHER_CTX *)NULL)->c))+
94 sizeof((((EVP_CIPHER_CTX *)NULL)->c.rc4)),
95 NULL,
96 NULL,
97 NULL
89 }; 98 };
90 99
91EVP_CIPHER *EVP_rc4(void) 100EVP_CIPHER *EVP_rc4(void)
@@ -98,18 +107,19 @@ EVP_CIPHER *EVP_rc4_40(void)
98 return(&r4_40_cipher); 107 return(&r4_40_cipher);
99 } 108 }
100 109
101static void rc4_init_key(EVP_CIPHER_CTX *ctx, unsigned char *key, 110static int rc4_init_key(EVP_CIPHER_CTX *ctx, const unsigned char *key,
102 unsigned char *iv, int enc) 111 const unsigned char *iv, int enc)
103 { 112 {
104 if (key != NULL) 113 memcpy(&(ctx->c.rc4.key[0]),key,EVP_CIPHER_CTX_key_length(ctx));
105 memcpy(&(ctx->c.rc4.key[0]),key,EVP_CIPHER_CTX_key_length(ctx));
106 RC4_set_key(&(ctx->c.rc4.ks),EVP_CIPHER_CTX_key_length(ctx), 114 RC4_set_key(&(ctx->c.rc4.ks),EVP_CIPHER_CTX_key_length(ctx),
107 ctx->c.rc4.key); 115 ctx->c.rc4.key);
116 return 1;
108 } 117 }
109 118
110static void rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out, 119static int rc4_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
111 unsigned char *in, unsigned int inl) 120 const unsigned char *in, unsigned int inl)
112 { 121 {
113 RC4(&(ctx->c.rc4.ks),inl,in,out); 122 RC4(&(ctx->c.rc4.ks),inl,in,out);
123 return 1;
114 } 124 }
115#endif 125#endif