Why am I getting different results from different skein hash APIs?

664 views Asked by At

I've tried a few. Python's pyskein; a javascript skein calculator I found online somewhere; and the skein calculator being used for xkcd's april fools' comic all give the same output for a given input.

But when I download version 1.3 of the reference C source here I get different results. Worst of all, the results I get from the C API perfectly match the "known answer test" examples that come with the source code, so I assume I'm using it right.

My C code:

#include <stdio.h>
#include <stdlib.h>
#include "SHA3api_ref.h"

int main(int argc, const char * argv[])
{
    const int BITS = 256; // length of hash in bits
    const int LENGTH = 32; // length of data in bits
    BitSequence *hashval = calloc(BITS/8, 1);
    const BitSequence content[] = {0xC1, 0xEC, 0xFD, 0xFC};

    Hash(BITS, content, LENGTH, hashval);

    for (int i = 0; i < BITS/8; i++) {
        printf("%02X", hashval[i]);
    }
    return 0;
}

result hex: 2638B1711F1346D08BF02B5D1A575CD924140A608512AF5B8E4475632599A896

Python code for the same hash on the same data:

import skein
print( skein.skein256(bytes([0xC1, 0xEC, 0xFD, 0xFC])).hexdigest() )

result hex: 07e785ce898fa5cfa22e15294481717935923985ea90f67fc65cb5b3cb718190

Note that the C answer is the expected answer according to the KAT_MCT/ShortMsgKAT_256.txt file that comes with the code. But pyskein gives results that everyone else seems to agree are correct. What am I missing?

0

There are 0 answers