ssh_close_authentication_connection(auth);
try_agent_authentication(){	int type;	char *comment;	AuthenticationConnection *auth;	u_char response[16];	u_int i;	int plen, clen;	Key *key;	BIGNUM *challenge;	/* Get connection to the agent. */	auth = ssh_get_authentication_connection();	if (!auth)		return 0;	challenge = BN_new();	key = key_new(KEY_RSA1);	/* Loop through identities served by the agent. */	for (key = ssh_get_first_identity(auth, &comment, 1);	     key != NULL;	     key = ssh_get_next_identity(auth, &comment, 1)) {		/* Try this identity. */		debug("Trying RSA authentication via agent with '%.100s'", comment);		xfree(comment);		/* Tell the server that we are willing to authenticate using this key. */		packet_start(SSH_CMSG_AUTH_RSA);		packet_put_bignum(key->rsa->n);		packet_send();		packet_write_wait();		/* Wait for server's response. */		type = packet_read(&plen);		/* The server sends failure if it doesn\'t like our key or		   does not support RSA authentication. */		if (type == SSH_SMSG_FAILURE) {			debug("Server refused our key.");			key_free(key);			continue;		}		/* Otherwise it should have sent a challenge. */		if (type != SSH_SMSG_AUTH_RSA_CHALLENGE)			packet_disconnect("Protocol error during RSA authentication: %d",					  type);		packet_get_bignum(challenge, &clen);		packet_integrity_check(plen, clen, type);		debug("Received RSA challenge from server.");		/* Ask the agent to decrypt the challenge. */		if (!ssh_decrypt_challenge(auth, key, challenge, session_id, 1, response)) {			/*			 * The agent failed to authenticate this identifier			 * although it advertised it supports this.  Just			 * return a wrong value.			 */			log("Authentication agent failed to decrypt challenge.");			memset(response, 0, sizeof(response));		}		key_free(key);		debug("Sending response to RSA challenge.");		/* Send the decrypted challenge back to the server. */		packet_start(SSH_CMSG_AUTH_RSA_RESPONSE);		for (i = 0; i < 16; i++)			packet_put_char(response[i]);		packet_send();		packet_write_wait();		/* Wait for response from the server. */		type = packet_read(&plen);		/* The server returns success if it accepted the authentication. */		if (type == SSH_SMSG_SUCCESS) {			BN_clear_free(challenge);			debug("RSA authentication accepted by server.");			return 1;		}		/* Otherwise it should return failure. */		if (type != SSH_SMSG_FAILURE)			packet_disconnect("Protocol error waiting RSA auth response: %d",					  type);	}	BN_clear_free(challenge);	debug("RSA authentication using agent refused.");	return 0;}