calculating CRCs in SSH v1 - SSH

This is a discussion on calculating CRCs in SSH v1 - SSH ; Calculating the CRC32 checksum of "test" using traditional CRC32 algorithims ( http://www.zorc.breitbandkatze.de/crc.html , 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 ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: calculating CRCs in SSH v1

  1. calculating CRCs in SSH v1

    Calculating the CRC32 checksum of "test" using traditional CRC32
    algorithims (http://www.zorc.breitbandkatze.de/crc.html, 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
    D87F7E0C.

    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!


  2. Re: calculating CRCs in SSH v1

    yawnmoth wrote:
    > Calculating the CRC32 checksum of "test" using traditional CRC32
    > algorithims (http://www.zorc.breitbandkatze.de/crc.html, 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
    > D87F7E0C.


    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.
    How do I start?" - my uncle

  3. Re: calculating CRCs in SSH v1

    yawnmoth wrote:

    > Calculating the CRC32 checksum of "test" using traditional CRC32
    > algorithims (http://www.zorc.breitbandkatze.de/crc.html, 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
    > D87F7E0C.


    Hi,
    the crc32 used for ssh1 is standard. you may have a look at the code from
    libssh svn (0xbadc0de.be)
    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
    blocksize=(session->current_crypto?session->current_crypto->out_cipher->blocksize:8);
    ssh_say(3,"Writing on the wire a packet having %ld bytes
    before",currentlen);
    padding=blocksize-(currentlen % blocksize);
    memset(padstring,0,padding);
    finallen=htonl(currentlen);
    buffer_add_data_begin(session->out_buffer,&padstring,padding);
    buffer_add_data_begin(session->out_buffer,&finallen,sizeof(u32));
    crc=ssh_crc3
    (buffer_get(session->out_buffer)+sizeof(u32),buffer_get_len(session->out_buffer)-sizeof(u32));

    buffer_add_u32(session->out_buffer,ntohl(crc));

    packet_encrypt(session,buffer_get(session->out_buffer)+sizeof(u32),buffer_get_len(session->out_buffer)-sizeof(u32));
    ret=socket_write(session);
    session->send_seq++;
    buffer_reinit(session->out_buffer);
    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).

    Aris

  4. Re: calculating CRCs in SSH v1


    Simon Tatham wrote:
    > yawnmoth wrote:
    > > Calculating the CRC32 checksum of "test" using traditional CRC32
    > > algorithims (http://www.zorc.breitbandkatze.de/crc.html, 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
    > > D87F7E0C.

    >
    > If you set both the `initial value' and `final XOR value' fields on
    > that web form to zero, you should get F93BA110.

    Tried 0 for each one, but hadn't tried 0 for both - thanks for the
    suggestion!


+ Reply to Thread