- case CL_SENT_AUTH: /* receive challenge and rc4 keys */
- ct->loaded = 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 */
- t->error = para_decrypt_buffer(ct->key_file, crypt_buf,
- (unsigned char *)ct->buf, t->error);
- if (t->error < 0)
+ case CL_SENT_AUTH:
+ /*
+ * Receive challenge and rc4 keys, decrypt the challenge and
+ * send back the hash of the decrypted challenge.
+ */
+ {
+ /* decrypted challenge/rc4 buffer */
+ unsigned char crypt_buf[1024];
+ /* the SHA1 of the decrypted challenge */
+ unsigned char challenge_sha1[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 = para_decrypt_buffer(ct->key_file, crypt_buf,
+ (unsigned char *)buf, n);
+ if (ret < 0)