Replace direct use of RC4 by stream cipher abstraction.
[paraslash.git] / client_common.c
index 31bbc11..c55db47 100644 (file)
@@ -9,7 +9,6 @@
 #include <regex.h>
 #include <sys/types.h>
 #include <dirent.h>
-#include <openssl/rc4.h>
 
 #include "para.h"
 #include "error.h"
@@ -42,6 +41,8 @@ void client_close(struct client_task *ct)
                return;
        if (ct->rc4c.fd >= 0)
                close(ct->rc4c.fd);
+       stream_cipher_free(ct->rc4c.recv);
+       stream_cipher_free(ct->rc4c.send);
        free(ct->user);
        free(ct->config_file);
        free(ct->key_file);
@@ -193,10 +194,10 @@ static void client_post_select(struct sched *s, struct task *t)
                if (ret < 0)
                        goto out;
                sha1_hash((char *)crypt_buf, CHALLENGE_SIZE, challenge_sha1);
-               RC4_set_key(&ct->rc4c.send_key, RC4_KEY_LEN,
-                       crypt_buf + CHALLENGE_SIZE);
-               RC4_set_key(&ct->rc4c.recv_key, RC4_KEY_LEN,
-                       crypt_buf + CHALLENGE_SIZE + RC4_KEY_LEN);
+               ct->rc4c.send = stream_cipher_new(crypt_buf + CHALLENGE_SIZE,
+                       RC4_KEY_LEN);
+               ct->rc4c.recv = stream_cipher_new(crypt_buf + CHALLENGE_SIZE
+                       + RC4_KEY_LEN, RC4_KEY_LEN);
                hash_to_asc(challenge_sha1, buf);
                PARA_INFO_LOG("--> %s\n", buf);
                ret = send_bin_buffer(ct->rc4c.fd, (char *)challenge_sha1,