X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=command.c;h=2c9d29dfca3c6202d61e222a1934b9d21e1357bf;hp=5217f9b487cd260aebe5d5a986f4fd8e957b0270;hb=037059c8a25ce134af1eaa6c3fa8ac96b9f7e0b6;hpb=69a7e7aa11d8bf9b05d6431c57276befbc9b35a3 diff --git a/command.c b/command.c index 5217f9b4..2c9d29df 100644 --- a/command.c +++ b/command.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include @@ -768,7 +767,7 @@ __noreturn void handle_connect(int fd, const char *peername) u = lookup_user(p); if (u) { get_random_bytes_or_die(rand_buf, sizeof(rand_buf)); - ret = para_encrypt_buffer(u->rsa, rand_buf, sizeof(rand_buf), + ret = pub_encrypt(u->pubkey, rand_buf, sizeof(rand_buf), (unsigned char *)buf); if (ret < 0) goto net_err; @@ -809,10 +808,10 @@ __noreturn void handle_connect(int fd, const char *peername) /* auth successful */ alarm(0); PARA_INFO_LOG("good auth for %s\n", u->name); - /* init rc4 keys with the second part of the random buffer */ - RC4_set_key(&rc4c.recv_key, RC4_KEY_LEN, rand_buf + CHALLENGE_SIZE); - RC4_set_key(&rc4c.send_key, RC4_KEY_LEN, rand_buf + CHALLENGE_SIZE - + RC4_KEY_LEN); + /* init stream cipher keys with the second part of the random buffer */ + rc4c.recv = stream_cipher_new(rand_buf + CHALLENGE_SIZE, RC4_KEY_LEN); + rc4c.send = stream_cipher_new(rand_buf + CHALLENGE_SIZE + RC4_KEY_LEN, + RC4_KEY_LEN); ret = rc4_send_buffer(&rc4c, PROCEED_MSG); if (ret < 0) goto net_err; @@ -849,6 +848,8 @@ net_err: PARA_NOTICE_LOG("%s\n", para_strerror(-ret)); out: free(command); + stream_cipher_free(rc4c.recv); + stream_cipher_free(rc4c.send); mutex_lock(mmd_mutex); if (cmd && (cmd->perms & AFS_WRITE) && ret >= 0) mmd->events++;