SHA2 algorithm is defined using 32-bit and 64-bit variables in
big-endian. This patch updates sha512-ppc.pl to generate code that byte
swaps the input data when needed.

Signed-off-by: Marcelo Cerri <[email protected]>
---
 crypto/sha/asm/sha512-ppc.pl | 196 +++++++++++++++++++++++++++++--------------
 1 file changed, 133 insertions(+), 63 deletions(-)

...
+$code.=<<___ if ($SZ==8 && $LITTLE_ENDIAN);
+       ; load 64 bit value
+       lwz     $t0,`$i*$SZ+4`($inp)
+       lwz     @X[$i],`$i*$SZ`($inp)
+       insrdi  @X[$i],$t0,32,0
+       ; swap bytes
+       rldicl  $t0,@X[$i],32,32
+       rotlwi  $a0,$t0,8
+       rlwimi  $a0,$t0,24,0,7
+       rlwimi  $a0,$t0,24,16,23
+       rotlwi  $t0,@X[$i],8
+       rlwimi  $t0,@X[$i],24,0,7
+       rlwimi  $t0,@X[$i],24,16,23
+       rldicr  $t0,$t0,32,31
+       or      @X[$i],$t0,$a0
+___

http://git.openssl.org/gitweb/?p=openssl.git;a=commitdiff;h=8ff8a829b053274124c3f2231570af3ae96806c0 eliminates 3 redundant instructions and interleaves remaining ones to favour in-order P6. Please verify and confirm if it's working.

+sub long64 {
+       foreach $n (@_) {
+               my $lo = (0xffffffff & $n);
+               my $hi = ($n >> 32);
^^^^^^^^ this would break if build on system with 32-bit perl. I've chosen to resolve it through ppc-xlate.pl and .quad directive.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [email protected]

Reply via email to