Putty Problem On Particular Machine

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
General Description: Putty Binary Fails On Lone Machine

On a brand new HP Compaq DC5100, P4 3Ghz 512mb ram, Runnign XP PRO SP2,
PuTTY Release 0.54 fails to negotiate crytographic communication with
any remote hosts.

Not only Putty Release 0.54, but earlier releases, Nutty (a modifeid
version of putty), and my own home brew modifications of putty.

Meanwhile other SSH clients such as, CYGWIN ssh, and SecureCRT function
fine on the questionable machine.

The remote sshd servers we tested ran OpenSSH_3.7.1p1 and

For SSH1 the error was: "Incorrect CRC received on packet"
For SSH2 the error was: "Server's host key did not match the signature

Specific Problem Description: PuTTY ssh1 rsaencrypt() fails to decrypt
on server

I spent a long time debugging this last night and this is basically
what I found out:

1. The Host/Server keys are exchanged properly.  I say this because the
RSA fingerprints match those displayed by PuTTY on a workign machine.
(Putty was modified to show both host & server rsa key fingerprints)

2. Putty sends the encrypted session key, which is 32 random bytes
where the first 16 are XOR'd by the 'session id' and then RSA encrypted
by both the Host and Server key starting with the longer of the 2.

3. OpenSSH receives the encrypted session key message (there is no
network stream 'offset problem', or some mysterious demon replacing
bits in net packets)

4. OpenSSH attempts to decrypt the session key with RSA in the proper

5. The server side RSA decrypt fails, OpenSSH 3.9.1.p1 sshd.c line
rsafail = PRIVSEP(ssh1_session_key(session_key_int));

rsafail is 2 meaning both RSA decrypts failed.

This causes the server to use a different session key than the client,

6. The server sends the SSH_SMSG_SUCCESS encrypted with Blowfish 128
    (With a differing notion of the session key used for the blowfish

7. The blowfish decrypt on PuTTY side does not produce correct results
    (different session keys)

8. A few calls later PuTTY bombs out when the CRC check fails for the

By printing hex string after hex string in both putty client and
server, and comparing to my normal working machince versus 'the
mysteriously failing machine':

I've pretty much narrowed this issue down to the RSA session key
exchange, and furthermore to the rsaencrypt() functionality of PuTTY.
The RSA BIGNUM stuff is difficult to debug and trace through, and I'm
hitting a wall with it.

The biggest question here for me, is that this is a win32 BINARY, that
works on 99% of machines but dosnt happen to work on my friends 1
machine?  What could possibly be the cause of that?  Especially with
the symptoms described above.  A look at all the dll import functions
putty calls from system turns up no likely culprits.  Theres no
optimization instruction that is producing different results on his
32bit x86 machine.  It's not some unicode thing.  I'm really out of
ideas.  What is going on here?


Re: Putty Problem On Particular Machine

OK.  Update.  My friend finally got visual studio, and built a putty
exe on his machine.  And it works!

So is this an optimization problem?  I got rid of /O2 and everything
else when I made him bins that failed.
(He didn't change anything like MSCRYPTOAPI)

I'm attaching the working putty.exe he built.
It's also avialable at http://pleep.com/~justin/putty.exe .
Really interested to know the details on this.


Re: Putty Problem On Particular Machine

Quoted text here. Click to load it

No comment on the rest of your post, but PuTTY 0.54 is very old, and
has a number of security holes that have been fixed since.  You should
be using at least version 0.57.


Re: Putty Problem On Particular Machine

Thanks, I've since upgraded.

In regards to the rest of the issue, it was found that explicitly
disabling optimizations with '/Od' fixes the problem (not just removing
'/O2').  As best I can tell there is a binary incompatibiliy for
putty's built with /O2 on Intel Pentium 4 3GHz's.  For at least cl
vs.net 2003 and whatever the putty distributions are built with.  That
would pretty much amount to a compiler bug depending on what u believe
/O2 should produce for you.  So I'm still in disbelief...   Time wil

Site Timeline