Hi,

I am new to the list, so apologies if I fail to follow any of the ground
rules.

I just ran into a bug where SHA384/512 were not being calculated
correctly on the Cell processor. I tracked it down to the definition of
the ROTR macro, which is assuming a 64 bit long, but in this case the
compiler is using the LP32 model so long is 32 bits and the values were
being truncated. Here is the patch I did that fixes the problem:

--- sha512.c    2009-07-27 15:04:52.546574000 -0700
+++ sha512.c    2009-07-27 15:08:07.373452100 -0700
@@ -344,7 +344,7 @@
                                ((SHA_LONG64)hi)<<32|lo;        })
 #   endif
 #  elif (defined(_ARCH_PPC) && defined(__64BIT__)) ||
defined(_ARCH_PPC64)
-#   define ROTR(a,n)   ({ unsigned long ret;           \
+#   define ROTR(a,n)   ({ SHA_LONG64 ret;              \
                                asm ("rotrdi %0,%1,%2"  \
                                : "=r"(ret)             \
                                : "r"(a),"K"(n)); ret;  })

If it is desirable to not use SHA_LONG64 in the macro, another option
would be to test for the __LP32__ preprocessor symbol and use "unsigned
long long" when that is defined.

I am using OpenSSL 0.9.8k, but looking at the latest snapshot it seems
this problem has not been fixed yet.

Questions or feedback welcome.

Thanks,
Benbuck Nason
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           majord...@openssl.org

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           majord...@openssl.org

Reply via email to