Skip to content

Commit

Permalink
* options.h, common-kex.c: fix support of 4096 byte host keys
Browse files Browse the repository at this point in the history
--HG--
extra : convert_revision : 096f29c430c23f0140f0cf272942a13046483ec6
  • Loading branch information
mkj committed Nov 30, 2005
1 parent 4a4e1b4 commit 736f370
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
44 changes: 24 additions & 20 deletions common-kex.c
Expand Up @@ -394,18 +394,28 @@ static void gen_new_zstreams() {
/* Belongs in common_kex.c where it should be moved after review */
void recv_msg_kexinit() {

unsigned int kexhashbuf_len = 0;
unsigned int remote_ident_len = 0;
unsigned int local_ident_len = 0;

TRACE(("<- KEXINIT"))
TRACE(("enter recv_msg_kexinit"))

/* start the kex hash */
ses.kexhashbuf = buf_new(MAX_KEXHASHBUF);

if (!ses.kexstate.sentkexinit) {
/* we need to send a kex packet */
send_msg_kexinit();
TRACE(("continue recv_msg_kexinit: sent kexinit"))
}

/* start the kex hash */
local_ident_len = strlen(LOCAL_IDENT);
remote_ident_len = strlen((char*)ses.remoteident);

kexhashbuf_len = local_ident_len + remote_ident_len
+ ses.transkexinit->len + ses.payload->len
+ KEXHASHBUF_MAX_INTS;

ses.kexhashbuf = buf_new(kexhashbuf_len);

if (IS_DROPBEAR_CLIENT) {

Expand All @@ -414,42 +424,36 @@ void recv_msg_kexinit() {

/* V_C, the client's version string (CR and NL excluded) */
buf_putstring(ses.kexhashbuf,
(unsigned char*)LOCAL_IDENT, strlen(LOCAL_IDENT));
(unsigned char*)LOCAL_IDENT, local_ident_len);
/* V_S, the server's version string (CR and NL excluded) */
buf_putstring(ses.kexhashbuf,
ses.remoteident, strlen((char*)ses.remoteident));
buf_putstring(ses.kexhashbuf, ses.remoteident, remote_ident_len);

/* I_C, the payload of the client's SSH_MSG_KEXINIT */
buf_putstring(ses.kexhashbuf,
buf_getptr(ses.transkexinit, ses.transkexinit->len),
ses.transkexinit->len);
ses.transkexinit->data, ses.transkexinit->len);
/* I_S, the payload of the server's SSH_MSG_KEXINIT */
buf_setpos(ses.payload, 0);
buf_putstring(ses.kexhashbuf,
buf_getptr(ses.payload, ses.payload->len),
ses.payload->len);
buf_putstring(ses.kexhashbuf, ses.payload->data, ses.payload->len);

} else {
/* SERVER */

/* read the peer's choice of algos */
read_kex_algos();
/* V_C, the client's version string (CR and NL excluded) */
buf_putstring(ses.kexhashbuf,
ses.remoteident, strlen((char*)ses.remoteident));
buf_putstring(ses.kexhashbuf, ses.remoteident, remote_ident_len);
/* V_S, the server's version string (CR and NL excluded) */
buf_putstring(ses.kexhashbuf,
(unsigned char*)LOCAL_IDENT, strlen(LOCAL_IDENT));
buf_putstring(ses.kexhashbuf,
(unsigned char*)LOCAL_IDENT, local_ident_len);

/* I_C, the payload of the client's SSH_MSG_KEXINIT */
buf_setpos(ses.payload, 0);
buf_putstring(ses.kexhashbuf,
buf_getptr(ses.payload, ses.payload->len),
ses.payload->len);
buf_putstring(ses.kexhashbuf, ses.payload->data, ses.payload->len);

/* I_S, the payload of the server's SSH_MSG_KEXINIT */
buf_putstring(ses.kexhashbuf,
buf_getptr(ses.transkexinit, ses.transkexinit->len),
ses.transkexinit->len);
ses.transkexinit->data, ses.transkexinit->len);

ses.requirenext = SSH_MSG_KEXDH_INIT;
}

Expand Down
12 changes: 8 additions & 4 deletions options.h
Expand Up @@ -306,10 +306,14 @@ etc) slower (perhaps by 50%). Recommended for most small systems. */
#define MAX_STRING_LEN 1400 /* ~= MAX_PROPOSED_ALGO * MAX_NAME_LEN, also
is the max length for a password etc */

/* For a 4096 bit DSS key, empirically determined to be 1590 bytes */
#define MAX_PUBKEY_SIZE 1600
/* For a 4096 bit DSS key, empirically determined to be 1590 bytes */
#define MAX_PRIVKEY_SIZE 1600
/* For a 4096 bit DSS key, empirically determined */
#define MAX_PUBKEY_SIZE 1700
/* For a 4096 bit DSS key, empirically determined */
#define MAX_PRIVKEY_SIZE 1700

/* The maximum size of the bignum portion of the kexhash buffer */
/* Sect. 8 of the transport draft, K_S + e + f + K */
#define KEXHASHBUF_MAX_INTS (1700 + 130 + 130 + 130)

#define DROPBEAR_MAX_SOCKS 2 /* IPv4, IPv6 are all we'll get for now. Revisit
in a few years time.... */
Expand Down

0 comments on commit 736f370

Please sign in to comment.