From c242dda4a40301ae284e6756969e9735c80c885d Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Fri, 22 Oct 2010 20:16:22 +0000 Subject: [PATCH] sha512-mips.pl: add missing 64-bit byte swap. --- crypto/sha/asm/sha512-mips.pl | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/crypto/sha/asm/sha512-mips.pl b/crypto/sha/asm/sha512-mips.pl index d8f95308b4..8cd88dbda2 100644 --- a/crypto/sha/asm/sha512-mips.pl +++ b/crypto/sha/asm/sha512-mips.pl @@ -123,8 +123,8 @@ $code.=<<___ if ($i<15); ${LD}l @X[1],`($i+1)*$SZ+$MSB`($inp) ${LD}r @X[1],`($i+1)*$SZ+$LSB`($inp) ___ -$code.=<<___ if (!$big_endian && $i<16); # XXX no 64-bit byte swap yet - srl $tmp0,@X[0],24 # byte swap($i) +$code.=<<___ if (!$big_endian && $i<16 && $SZ==4); + srl $tmp0,@X[0],24 # byte swap($i) srl $tmp1,@X[0],8 andi $tmp2,@X[0],0xFF00 sll @X[0],@X[0],24 @@ -134,6 +134,26 @@ $code.=<<___ if (!$big_endian && $i<16); # XXX no 64-bit byte swap yet or $tmp1,$tmp2 or @X[0],$tmp1 ___ +$code.=<<___ if (!$big_endian && $i<16 && $SZ==8); + ori $tmp0,$zero,0xFF + dsll $tmp2,$tmp0,32 + or $tmp0,$tmp2 # 0x000000FF000000FF + and $tmp1,@X[0],$tmp0 # byte swap($i) + dsrl $tmp2,@X[0],24 + dsll $tmp1,24 + and $tmp2,$tmp0 + dsll $tmp0,8 # 0x0000FF000000FF00 + or $tmp1,$tmp2 + and $tmp2,@X[0],$tmp0 + dsrl @X[0],8 + dsll $tmp2,8 + and @X[0],$tmp0 + or $tmp1,$tmp2 + or @X[0],$tmp1 + dsrl $tmp1,@X[0],32 + dsll @X[0],32 + or @X[0],$tmp1 +___ $code.=<<___; $ADDU $T1,$X[0],$h # $i $SRL $h,$e,@Sigma1[0] -- 2.25.1