diff --git a/ssh.c b/ssh.c index 9b16d83b..7943d071 100644 --- a/ssh.c +++ b/ssh.c @@ -3499,15 +3499,6 @@ static int do_ssh2_transport(unsigned char *in, int inlen, int ispkt) crReturn(0); } - /* - * Expect SSH2_MSG_NEWKEYS from server. - */ - crWaitUntil(ispkt); - if (pktin.type != SSH2_MSG_NEWKEYS) { - bombout(("expected new-keys packet from server")); - crReturn(0); - } - /* * Authenticate remote host: verify host key. (We've already * checked the signature of the exchange hash.) @@ -3530,6 +3521,15 @@ static int do_ssh2_transport(unsigned char *in, int inlen, int ispkt) ssh2_pkt_init(SSH2_MSG_NEWKEYS); ssh2_pkt_send(); + /* + * Expect SSH2_MSG_NEWKEYS from server. + */ + crWaitUntil(ispkt); + if (pktin.type != SSH2_MSG_NEWKEYS) { + bombout(("expected new-keys packet from server")); + crReturn(0); + } + /* * Create and initialise session keys. */