add new error messages for protocol version and hostkey loading

This commit is contained in:
Markus Friedl
2012-01-19 09:33:46 +01:00
parent 746db96b80
commit 6da9f87abc
6 changed files with 17 additions and 5 deletions

View File

@@ -93,6 +93,14 @@ ssh_err(int n)
return "no matching key exchange method found";
case SSH_ERR_NO_HOSTKEY_ALG_MATCH:
return "no matching host key type found";
case SSH_ERR_PROTOCOL_MISMATCH:
return "protocol version mismatch";
case SSH_ERR_NO_PROTOCOL_VERSION:
return "failed to not read protocol version";
case SSH_ERR_NO_HOSTKEY_LOADED:
return "could not load host key";
case SSH_ERR_NEED_REKEY:
return "rekeying not supported by peer";
default:
return "unknown error";
}

View File

@@ -56,6 +56,10 @@
#define SSH_ERR_NO_COMPRESS_ALG_MATCH -32
#define SSH_ERR_NO_KEX_ALG_MATCH -33
#define SSH_ERR_NO_HOSTKEY_ALG_MATCH -34
#define SSH_ERR_NO_HOSTKEY_LOADED -35
#define SSH_ERR_PROTOCOL_MISMATCH -36
#define SSH_ERR_NO_PROTOCOL_VERSION -37
#define SSH_ERR_NEED_REKEY -38
/* Translate a numeric error code to a human-readable error string */
const char *ssh_err(int n);

View File

@@ -101,7 +101,7 @@ input_kex_dh_init(int type, u_int32_t seq, struct ssh *ssh)
ssh)) == NULL ||
(server_host_private = kex->load_host_private_key(kex->hostkey_type,
ssh)) == NULL) {
r = SSH_ERR_KEY_TYPE_MISMATCH; /* XXX */
r = SSH_ERR_NO_HOSTKEY_LOADED;
goto out;
}

View File

@@ -101,7 +101,7 @@ input_kex_ecdh_init(int type, u_int32_t seq, struct ssh *ssh)
ssh)) == NULL ||
(server_host_private = kex->load_host_private_key(kex->hostkey_type,
ssh)) == NULL) {
r = SSH_ERR_KEY_TYPE_MISMATCH; /* XXX */
r = SSH_ERR_NO_HOSTKEY_LOADED;
goto out;
}
if ((client_public = EC_POINT_new(group)) == NULL) {

View File

@@ -154,7 +154,7 @@ input_kex_dh_gex_init(int type, u_int32_t seq, struct ssh *ssh)
ssh)) == NULL ||
(server_host_private = kex->load_host_private_key(kex->hostkey_type,
ssh)) == NULL) {
r = SSH_ERR_KEY_TYPE_MISMATCH; /* XXX */
r = SSH_ERR_NO_HOSTKEY_LOADED;
goto out;
}

View File

@@ -1323,7 +1323,7 @@ ssh_packet_send2_wrapped(struct ssh *ssh)
logit("outgoing seqnr wraps around");
if (++state->p_send.packets == 0)
if (!(ssh->datafellows & SSH_BUG_NOREKEY))
return SSH_ERR_INTERNAL_ERROR; /* XXX */
return SSH_ERR_NEED_REKEY;
state->p_send.blocks += (packet_length + 4) / block_size;
state->p_send.bytes += packet_length + 4;
sshbuf_reset(state->outgoing_packet);
@@ -1759,7 +1759,7 @@ ssh_packet_read_poll2(struct ssh *ssh, u_char *typep, u_int32_t *seqnr_p)
logit("incoming seqnr wraps around");
if (++state->p_read.packets == 0)
if (!(ssh->datafellows & SSH_BUG_NOREKEY))
return SSH_ERR_INTERNAL_ERROR; /* XXX */
return SSH_ERR_NEED_REKEY;
state->p_read.blocks += (state->packlen + 4) / block_size;
state->p_read.bytes += state->packlen + 4;