calculating CRCs in SSH v1

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

Threaded View
Calculating the CRC32 checksum of "test" using traditional CRC32
algorithims ( , for example)
yields D87F7E0C.  Calculating it, however, with the CRC32 checksum that
PuTTY's CRC32 checksum code disagrees with.  Namely, when PuTTY's code
is used to calculate the checksum of "test", I get F93BA110 - not

Looking / playing around with the code suggests that PuTTY's code use
the same CRC32 tables - they just reference the varrious elements
within the table in different ways.

My question is...  why?  The protocol documentation doesn't say
anything about requiring a non-standard implementation of CRC32.  It
does mention a polynomial that is supposed to be used, but that's only
used in the table generation, which isn't the source of the
inconsistancy, anyway.

Also, the language I'm working with already has a crc32 function
built-in.  Granted, it's not the one that SSH v1 apparently expects,
but is there a way to convert the output of the built-in crc32 function
to what it ought to be for SSH v1?

Any help would be appreciated - thanks!

Re: calculating CRCs in SSH v1

Quoted text here. Click to load it

If you set both the `initial value' and `final XOR value' fields on
that web form to zero, you should get F93BA110.
Simon Tatham         "I'm cross. I'm going to have a tantrum.

Re: calculating CRCs in SSH v1

Simon Tatham wrote:
Quoted text here. Click to load it
Tried 0 for each one, but hadn't tried 0 for both - thanks for the
suggestion! :)

Re: calculating CRCs in SSH v1

yawnmoth wrote:

Quoted text here. Click to load it

the crc32 used for ssh1 is standard. you may have a look at the code from
libssh svn (
here is a stripped version of packet_send1 :

static int packet_send1(SSH_SESSION *session){
    char padstring[32];
    u32 finallen;
    u8 padding;
    u32 crc;
    u32 currentlen=buffer_get_len(session->out_buffer)+sizeof(u32);
    int ret=0;
    unsigned int
    ssh_say(3,"Writing on the wire a packet having %ld bytes
    padding=blocksize-(currentlen % blocksize);
    return ret;     /* SSH_OK, AGAIN or ERROR */

so, you need to put the length, the padding, the packet, the crc32 of the
packet, then encrypt the *whole* (except the size of the packet).


Site Timeline