move rc4_send_key and rc4_recv_key to struct private_client_data
authorAndre <maan@p133.(none)>
Mon, 12 Jun 2006 01:26:08 +0000 (03:26 +0200)
committerAndre <maan@p133.(none)>
Mon, 12 Jun 2006 01:26:08 +0000 (03:26 +0200)
client.c

index dba99a2..b77a2f6 100644 (file)
--- a/client.c
+++ b/client.c
@@ -38,6 +38,9 @@ struct private_client_data {
        char *config_file;
        char *key_file;
        char *user;
+       RC4_KEY rc4_recv_key;
+       RC4_KEY rc4_send_key;
+
        char *in_buf;
        size_t *in_loaded;
        char *out_buf;
@@ -116,19 +119,18 @@ out:
        return ret;
 }
 
-static RC4_KEY rc4_recv_key;
-static RC4_KEY rc4_send_key;
-static unsigned char rc4_buf[2 * RC4_KEY_LEN];
-
-static void rc4_send(unsigned long len, const unsigned char *indata, unsigned char *outdata)
+static void rc4_send(unsigned long len, const unsigned char *indata,
+               unsigned char *outdata)
 {
-       RC4(&rc4_send_key, len, indata, outdata);
+       RC4(&pcd->rc4_send_key, len, indata, outdata);
 }
 
-static void rc4_recv(unsigned long len, const unsigned char *indata, unsigned char *outdata)
+static void rc4_recv(unsigned long len, const unsigned char *indata,
+               unsigned char *outdata)
 {
-       RC4(&rc4_recv_key, len, indata, outdata);
+       RC4(&pcd->rc4_recv_key, len, indata, outdata);
 }
+
 void (*crypt_function_recv)(unsigned long len, const unsigned char *indata, unsigned char *outdata);
 void (*crypt_function_send)(unsigned long len, const unsigned char *indata, unsigned char *outdata);
 
@@ -174,6 +176,7 @@ int main(int argc, char *argv[])
        char buf[8192];
        char *auth_str;
        long unsigned challenge_nr;
+       unsigned char rc4_buf[2 * RC4_KEY_LEN] = "";
 
        ret = client_parse_config(argc, argv, &pcd);
        if (ret < 0)
@@ -264,8 +267,8 @@ int main(int argc, char *argv[])
                        numbytes - PROCEED_MSG_LEN - 1);
                if (ret < 0)
                        goto out;
-               RC4_set_key(&rc4_send_key, RC4_KEY_LEN, rc4_buf);
-               RC4_set_key(&rc4_recv_key, RC4_KEY_LEN, rc4_buf + RC4_KEY_LEN);
+               RC4_set_key(&pcd->rc4_send_key, RC4_KEY_LEN, rc4_buf);
+               RC4_set_key(&pcd->rc4_recv_key, RC4_KEY_LEN, rc4_buf + RC4_KEY_LEN);
                PARA_INFO_LOG("rc4 encrytion activated: %x:%x:%x:%x\n",
                        rc4_buf[0], rc4_buf[1], rc4_buf[2], rc4_buf[3]);
                crypt_function_recv = rc4_recv;