key re-exchange problem?

Andre Charbonneau <[email protected]>
Newsgroups gmane.comp.java.sshtools.user
Message-ID <[email protected]>
Hi,
I have a problem with sshtools where the connection is being closed and 
I get a protocol error.  According to the debug output, it looks like 
this occurs during key re-exchange.

Here is the debug output:

    (...)
    DEBUG - Received 16384 bytes of data for channel id 2
    DEBUG - SshMsgKexInit:
    Supported Kex [diffie-hellman-group1-sha1]
    Supported Public Keys [ssh-dss, ssh-rsa]
    Supported Encryption Client->Server [blowfish-cbc, 3des-cbc]
    Supported Encryption Server->Client [blowfish-cbc, 3des-cbc]
    Supported Mac Client->Server [hmac-sha1, hmac-md5-96, hmac-md5,
    hmac-sha1-96]
    Supported Mac Server->Client [hmac-sha1, hmac-md5-96, hmac-md5,
    hmac-sha1-96]
    Supported Compression Client->Server [none]
    Supported Compression Server->Client [none]
    Supported Languages Client->Server []
    Supported Languages Server->Client []
    First Kex Packet Follows [FALSE]
    INFO - Sending SSH_MSG_KEX_INIT
    DEBUG - Received SSH_MSG_CHANNEL_DATA
    DEBUG - Received 16384 bytes of data for channel id 2
    DEBUG - SshMsgKexInit:
    Supported Kex [diffie-hellman-group1-sha1]
    Supported Public Keys [ssh-dss, ssh-rsa]
    Supported Encryption Client->Server [blowfish-cbc, 3des-cbc]
    Supported Encryption Server->Client [blowfish-cbc, 3des-cbc]
    Supported Mac Client->Server [hmac-sha1, hmac-md5-96, hmac-md5,
    hmac-sha1-96]
    Supported Mac Server->Client [hmac-sha1, hmac-md5-96, hmac-md5,
    hmac-sha1-96]
    Supported Compression Client->Server [none]
    Supported Compression Server->Client [none]
    Supported Languages Client->Server []
    Supported Languages Server->Client []
    First Kex Packet Follows [FALSE]
    INFO - Sending SSH_MSG_KEX_INIT
    DEBUG - Received SSH_MSG_CHANNEL_DATA
    DEBUG - Received 16384 bytes of data for channel id 2
    DEBUG - SshMsgKexInit:
    Supported Kex [diffie-hellman-group1-sha1]
    Supported Public Keys [ssh-dss, ssh-rsa]
    Supported Encryption Client->Server [blowfish-cbc, 3des-cbc]
    Supported Encryption Server->Client [blowfish-cbc, 3des-cbc]
    Supported Mac Client->Server [hmac-sha1, hmac-md5-96, hmac-md5,
    hmac-sha1-96]
    Supported Mac Server->Client [hmac-sha1, hmac-md5-96, hmac-md5,
    hmac-sha1-96]
    Supported Compression Client->Server [none]
    Supported Compression Server->Client [none]
    Supported Languages Client->Server []
    Supported Languages Server->Client []
    First Kex Packet Follows [FALSE]
    INFO - Sending SSH_MSG_KEX_INIT
    DEBUG - Received SSH_MSG_CHANNEL_DATA
    DEBUG - Received 16384 bytes of data for channel id 2
    DEBUG - SshMsgKexInit:
    Supported Kex [diffie-hellman-group1-sha1]
    Supported Public Keys [ssh-dss, ssh-rsa]
    Supported Encryption Client->Server [blowfish-cbc, 3des-cbc]
    Supported Encryption Server->Client [blowfish-cbc, 3des-cbc]
    Supported Mac Client->Server [hmac-sha1, hmac-md5-96, hmac-md5,
    hmac-sha1-96]
    Supported Mac Server->Client [hmac-sha1, hmac-md5-96, hmac-md5,
    hmac-sha1-96]
    Supported Compression Client->Server [none]
    Supported Compression Server->Client [none]
    Supported Languages Client->Server []
    Supported Languages Server->Client []
    First Kex Packet Follows [FALSE]
    INFO - Sending SSH_MSG_KEX_INIT
    DEBUG - Received SSH_MSG_KEX_INIT
    DEBUG - SshMsgKexInit:
    Supported Kex [gss-group1-sha1-dZuIebMjgUqaxvbF7hDbAw==,
    gss-group1-sha1-N3+k7/4wGxHyuP8Yxi4RhA==,
    diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1,
    diffie-hellman-group1-sha1]
    Supported Public Keys [ssh-rsa, ssh-dss]
    Supported Encryption Client->Server [aes128-cbc, 3des-cbc,
    blowfish-cbc, cast128-cbc, arcfour, aes192-cbc, aes256-cbc,
    [email protected], aes128-ctr, aes192-ctr, aes256-ctr]
    Supported Encryption Server->Client [aes128-cbc, 3des-cbc,
    blowfish-cbc, cast128-cbc, arcfour, aes192-cbc, aes256-cbc,
    [email protected], aes128-ctr, aes192-ctr, aes256-ctr]
    Supported Mac Client->Server [hmac-md5, hmac-sha1, hmac-ripemd160,
    [email protected], hmac-sha1-96, hmac-md5-96]
    Supported Mac Server->Client [hmac-md5, hmac-sha1, hmac-ripemd160,
    [email protected], hmac-sha1-96, hmac-md5-96]
    Supported Compression Client->Server [none, zlib]
    Supported Compression Server->Client [none, zlib]
    Supported Languages Client->Server []
    Supported Languages Server->Client []
    First Kex Packet Follows [FALSE]
    DEBUG - Determine AlgorithmKEXD
    DEBUG - Client Algorithms: [blowfish-cbc, 3des-cbc]
    DEBUG - Server Algorithms: [aes128-cbc, 3des-cbc, blowfish-cbc,
    cast128-cbc, arcfour, aes192-cbc, aes256-cbc,
    [email protected], aes128-ctr, aes192-ctr, aes256-ctr]
    DEBUG - Returning blowfish-cbc
    DEBUG - Determine Algorithm
    DEBUG - Client Algorithms: [blowfish-cbc, 3des-cbc]
    DEBUG - Server Algorithms: [aes128-cbc, 3des-cbc, blowfish-cbc,
    cast128-cbc, arcfour, aes192-cbc, aes256-cbc,
    [email protected], aes128-ctr, aes192-ctr, aes256-ctr]
    DEBUG - Returning blowfish-cbc
    DEBUG - Determine Algorithm
    DEBUG - Client Algorithms: [hmac-sha1, hmac-md5-96, hmac-md5,
    hmac-sha1-96]
    DEBUG - Server Algorithms: [hmac-md5, hmac-sha1, hmac-ripemd160,
    [email protected], hmac-sha1-96, hmac-md5-96]
    DEBUG - Returning hmac-sha1
    DEBUG - Determine Algorithm
    DEBUG - Client Algorithms: [hmac-sha1, hmac-md5-96, hmac-md5,
    hmac-sha1-96]
    DEBUG - Server Algorithms: [hmac-md5, hmac-sha1, hmac-ripemd160,
    [email protected], hmac-sha1-96, hmac-md5-96]
    DEBUG - Returning hmac-sha1
    DEBUG - Determine Algorithm
    DEBUG - Client Algorithms: [none]
    DEBUG - Server Algorithms: [none, zlib]
    DEBUG - Returning none
    DEBUG - Determine Algorithm
    DEBUG - Client Algorithms: [none]
    DEBUG - Server Algorithms: [none, zlib]
    DEBUG - Returning none
    INFO - Starting key exchange
    DEBUG - Determine Algorithm
    DEBUG - Client Algorithms: [diffie-hellman-group1-sha1]
    DEBUG - Server Algorithms:
    [gss-group1-sha1-dZuIebMjgUqaxvbF7hDbAw==,
    gss-group1-sha1-N3+k7/4wGxHyuP8Yxi4RhA==,
    diffie-hellman-group-exchange-sha1, diffie-hellman-group14-sha1,
    diffie-hellman-group1-sha1]
    DEBUG - Returning diffie-hellman-group1-sha1
    DEBUG - Key exchange algorithm: diffie-hellman-group1-sha1
    INFO - Starting client side key exchange.
    INFO - Sending SSH_MSG_KEXDH_INIT
    INFO - The remote computer disconnected: Protocol error: expected
    packet type 30, got 20
    INFO - The Transport Protocol has been stopped


So according to the debug output, the server is expecting 
SSH_MSG_KEXDH_INIT (30), but got SSH_MSG_KEX_INIT (20) instead.  If I 
look at the debug output above, it looks like the client sent more than 
one SSH_MSG_KEX_INIT message, which goes against the rfc4253 
recommendations (section 7.1), which says that once a SSH_MSG_KEX_INIT 
message is sent, then more SSH_MSG_KEY_INIT *MUST NOT* be sent until it 
has sent a SSH_MSG_NEWKEYS message.  (Maybe somehow the extra 
(redundant) SSH_MSG_KEX_INIT messages get queued and the server received 
one of those redundant  SSH_MSG_KEX_INIT instead of the 
SSH_MSG_KEXDH_INIT it is suppose to get.)

Could this be what is causing the protocol error?

Any help/advice with this will be much appreciated.


Regards,
    Andre

-- 
Andre Charbonneau

100 Sussex Drive, Rm 2025
Research Computing Support, IMSB
National Research Council Canada
Ottawa, ON, Canada K1A 0R6
613-993-3129  Fax: 613-993-3127     



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.