static void client_post_select(struct sched *s, struct task *t)
{
struct client_task *ct = container_of(t, struct client_task, task);
- unsigned char crypt_buf[1024];
t->error = 0;
if (ct->rc4c.fd < 0)
t->error = client_recv_buffer(ct);
if (t->error < 0)
goto err;
- PARA_INFO_LOG("<-- [challenge] (%d bytes)\n", t->error);
- /* decrypt challenge/rc4 buffer */
+ ct->loaded = t->error;
+ PARA_INFO_LOG("<-- [challenge] (%d bytes)\n", ct->loaded);
+ ct->status = CL_RECEIVED_CHALLENGE;
+ return;
+ case CL_RECEIVED_CHALLENGE:
+ {
+ /* decrypted challenge/rc4 buffer */
+ unsigned char crypt_buf[1024];
+ /* the SHA1 of the decrypted challenge */
+ unsigned char challenge_sha1[HASH_SIZE];
+
t->error = para_decrypt_buffer(ct->key_file, crypt_buf,
- (unsigned char *)ct->buf, t->error);
+ (unsigned char *)ct->buf, ct->loaded);
if (t->error < 0)
goto err;
- ct->status = CL_RECEIVED_CHALLENGE;
+ 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);
- return;
- case CL_RECEIVED_CHALLENGE:
- {
- unsigned char challenge_sha1[HASH_SIZE];
- /* send sha1 of decrypted challenge */
- sha1_hash((char *)crypt_buf, CHALLENGE_SIZE, challenge_sha1);
hash_to_asc(challenge_sha1, ct->buf);
PARA_INFO_LOG("--> %s\n", ct->buf);
t->error = send_bin_buffer(ct->rc4c.fd, (char *)challenge_sha1,