HI, We have been using older version of Openssl (0.9.8c) and this one has same problem. Used compiler is not perfect and often has prolem with O3 so i already tried Os (doesn't work) and O2 - thats work ok. So I suppose that optimalisations are not the issue. I tested both SMALL FOOTPRINT and normal code and both has same problem. I also have own SHA256 implementation ( implemented as defined in standard ) from another project. So when I replace the core of SHA256 computation (sha256 hash update ) with my implementation it works ok. Then all tests (make tests) passed without errors. So it's not exactly endian problem, but SHA256 implementation on SH architecture. Our implementation is using rotation as defined in standart but Openssl uses opposite. SH3 architecture in Big endian is not so common so there could be some unexpected bahaviour in compiler. What we can say is that problem is not in padding but only in hash update. SH3E - this is renesas SuperH architrecture with DSP also so there could be some instructions to modify only part of word etc. I found suspected code in OpenSSL - union of long and unsigned char - to detect endiannes. This could be one of problem, but when I tried to force edian into code it still does not work. If I will have more time i'll try to check where could be problem (but on SMALL footprint code). Best regards Pavel ______________________________________________________________ > Od: "Andy Polyakov via RT" > Komu: > Datum: 13.04.2012 11:38 > P?edm?t: Re: [openssl.org #2789] SHA-256 bug - Big endian arch > > I think that there is a bug in SHA-256 implementation. > > I have tried to compile least Openssl of 0.9.8 branch - 0.9.8u > but make test failed on SHA-256 test. > > ../util/shlib_wrap.sh ./shatest > test 1 ok > test 2 ok > test 3 ok > ../util/shlib_wrap.sh ./sha1test > test 1 ok > test 2 ok > test 3 ok > ../util/shlib_wrap.sh ./sha256t > Testing SHA-256 > TEST 1 of 3 failed. > make[1]: *** [test_sha] Error 1 > > > I also notice that previous version of OpenSSL also calculate wrong SHA-256 > hash of data. > Compared to little endian machines where the hash is correct.
What exactly do you mean by that? Code is maintained and was observed to work correctly on either endian system. There are two possibilities: system is not believed endianness or compiler is buggy. If first was case, then even SHA1 test would fail too, so the failure sounds more like compiler bug. Try to drop optimization level: edit Makefile in text editor and replace -O3 with -O0, remove crypto/sha/sha256.o and 'make'. This, dropping optimization level, is suggested in README. > Platform is Renesas SH3E in BIG-endian mode > ( used compiler sh3eb-linux-gcc) ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List openssl-dev@openssl.org Automated List Manager majord...@openssl.org