- t->error = para_decrypt_buffer(ct->key_file, crypt_buf,
- (unsigned char *)ct->buf, ct->loaded);
- if (t->error < 0)
- goto err;
- 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);
- 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,
+ ret = client_recv_buffer(ct, &s->rfds, buf, sizeof(buf), &n);
+ if (ret < 0 || n == 0)
+ goto out;
+ PARA_INFO_LOG("<-- [challenge] (%zu bytes)\n", n);
+ ret = priv_decrypt(ct->key_file, crypt_buf,
+ (unsigned char *)buf, n);
+ if (ret < 0)
+ goto out;
+ hash_function((char *)crypt_buf, CHALLENGE_SIZE, challenge_hash);
+ ct->scc.send = sc_new(crypt_buf + CHALLENGE_SIZE, SESSION_KEY_LEN);
+ ct->scc.recv = sc_new(crypt_buf + CHALLENGE_SIZE + SESSION_KEY_LEN,
+ SESSION_KEY_LEN);
+ hash_to_asc(challenge_hash, buf);
+ PARA_INFO_LOG("--> %s\n", buf);
+ ret = send_bin_buffer(ct->scc.fd, (char *)challenge_hash,