2 # Copyright 2009-2016 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the OpenSSL license (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
10 # ====================================================================
11 # Written by Andy Polyakov <appro@openssl.org> for the OpenSSL
12 # project. The module is, however, dual licensed under OpenSSL and
13 # CRYPTOGAMS licenses depending on where you obtain it. For further
14 # details see http://www.openssl.org/~appro/cryptogams/.
15 # ====================================================================
17 # SHA1 block procedure for Alpha.
19 # On 21264 performance is 33% better than code generated by vendor
20 # compiler, and 75% better than GCC [3.4], and in absolute terms is
21 # 8.7 cycles per processed byte. Implementation features vectorized
22 # byte swap, but not Xupdate.
24 @X=( "\$0", "\$1", "\$2", "\$3", "\$4", "\$5", "\$6", "\$7",
25 "\$8", "\$9", "\$10", "\$11", "\$12", "\$13", "\$14", "\$15");
33 $E="t9"; @V=($A,$B,$C,$D,$E);
41 my ($i,$a,$b,$c,$d,$e)=@_;
43 $code.=<<___ if ($i==0);
47 $code.=<<___ if (!($i&1) && $i<14);
48 ldq_u @X[$i+2],($i+2)*4+0($inp)
49 ldq_u @X[$i+3],($i+2)*4+7($inp)
51 $code.=<<___ if (!($i&1) && $i<15);
52 extql @X[$i],$inp,@X[$i]
53 extqh @X[$i+1],$inp,@X[$i+1]
55 or @X[$i+1],@X[$i],@X[$i] # pair of 32-bit values are fetched
57 srl @X[$i],24,$t0 # vectorized byte swap
65 zapnot @X[$i],0x88,@X[$i]
80 extll @X[$i],4,@X[$i+1] # extract upper half
86 zapnot @X[$i],0xf,@X[$i]
92 $code.=<<___ if (($i&1) && $i<15);
106 zapnot @X[$i],0xf,@X[$i]
112 $code.=<<___ if ($i>=15); # with forward Xupdate
116 xor @X[($j+2)%16],@X[$j%16],@X[$j%16]
121 xor @X[($j+8)%16],@X[$j%16],@X[$j%16]
126 xor @X[($j+13)%16],@X[$j%16],@X[$j%16]
134 addl @X[$j%16],@X[$j%16],@X[$j%16]
137 zapnot @X[$i%16],0xf,@X[$i%16]
138 or $t1,@X[$j%16],@X[$j%16]
143 my ($i,$a,$b,$c,$d,$e)=@_;
145 $code.=<<___ if ($i<79); # with forward Xupdate
149 xor @X[($j+2)%16],@X[$j%16],@X[$j%16]
154 xor @X[($j+8)%16],@X[$j%16],@X[$j%16]
159 xor @X[($j+13)%16],@X[$j%16],@X[$j%16]
164 addl @X[$j%16],@X[$j%16],@X[$j%16]
168 or $t1,@X[$j%16],@X[$j%16]
170 $code.=<<___ if ($i<77);
171 zapnot @X[$i%16],0xf,@X[$i%16]
173 $code.=<<___ if ($i==79); # with context fetch
200 my ($i,$a,$b,$c,$d,$e)=@_;
202 $code.=<<___; # with forward Xupdate
206 xor @X[($j+2)%16],@X[$j%16],@X[$j%16]
211 xor @X[($j+8)%16],@X[$j%16],@X[$j%16]
215 xor @X[($j+13)%16],@X[$j%16],@X[$j%16]
225 addl @X[$j%16],@X[$j%16],@X[$j%16]
229 or $t1,@X[$j%16],@X[$j%16]
230 zapnot @X[$i%16],0xf,@X[$i%16]
236 #include <asm/regdef.h>
246 .globl sha1_block_data_order
248 .ent sha1_block_data_order
249 sha1_block_data_order:
275 lda $K,31129($K) # K_00_19
277 for ($i=0;$i<20;$i++) { &BODY_00_19($i,@V); unshift(@V,pop(@V)); }
281 lda $K,-5215($K) # K_20_39
283 for (;$i<40;$i++) { &BODY_20_39($i,@V); unshift(@V,pop(@V)); }
287 lda $K,-17188($K) # K_40_59
289 for (;$i<60;$i++) { &BODY_40_59($i,@V); unshift(@V,pop(@V)); }
293 lda $K,-15914($K) # K_60_79
295 for (;$i<80;$i++) { &BODY_20_39($i,@V); unshift(@V,pop(@V)); }
323 .end sha1_block_data_order
324 .ascii "SHA1 block transform for Alpha, CRYPTOGAMS by <appro\@openssl.org>"
327 $output=pop and open STDOUT,">$output";