- 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,
+ /* decrypted challenge/session key buffer */
+ unsigned char crypt_buf[1024];
+ /* the SHA1 of the decrypted challenge */
+ unsigned char challenge_hash[HASH_SIZE];
+
+ 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,