3
# ====================================================================
4
# Written by Andy Polyakov <appro@fy.chalmers.se> for the OpenSSL
5
# project. The module is, however, dual licensed under OpenSSL and
6
# CRYPTOGAMS licenses depending on where you obtain it. For further
7
# details see http://www.openssl.org/~appro/cryptogams/.
8
# ====================================================================
10
# SHA1 block procedure for Alpha.
12
# On 21264 performance is 33% better than code generated by vendor
13
# compiler, and 75% better than GCC [3.4], and in absolute terms is
14
# 8.7 cycles per processed byte. Implementation features vectorized
15
# byte swap, but not Xupdate.
17
@X=( "\$0", "\$1", "\$2", "\$3", "\$4", "\$5", "\$6", "\$7",
18
"\$8", "\$9", "\$10", "\$11", "\$12", "\$13", "\$14", "\$15");
26
$E="t9"; @V=($A,$B,$C,$D,$E);
34
my ($i,$a,$b,$c,$d,$e)=@_;
36
$code.=<<___ if ($i==0);
40
$code.=<<___ if (!($i&1) && $i<14);
41
ldq_u @X[$i+2],($i+2)*4+0($inp)
42
ldq_u @X[$i+3],($i+2)*4+7($inp)
44
$code.=<<___ if (!($i&1) && $i<15);
45
extql @X[$i],$inp,@X[$i]
46
extqh @X[$i+1],$inp,@X[$i+1]
48
or @X[$i+1],@X[$i],@X[$i] # pair of 32-bit values are fetched
50
srl @X[$i],24,$t0 # vectorized byte swap
58
zapnot @X[$i],0x88,@X[$i]
73
extll @X[$i],4,@X[$i+1] # extract upper half
79
zapnot @X[$i],0xf,@X[$i]
85
$code.=<<___ if (($i&1) && $i<15);
99
zapnot @X[$i],0xf,@X[$i]
105
$code.=<<___ if ($i>=15); # with forward Xupdate
109
xor @X[($j+2)%16],@X[$j%16],@X[$j%16]
114
xor @X[($j+8)%16],@X[$j%16],@X[$j%16]
119
xor @X[($j+13)%16],@X[$j%16],@X[$j%16]
127
addl @X[$j%16],@X[$j%16],@X[$j%16]
130
zapnot @X[$i%16],0xf,@X[$i%16]
131
or $t1,@X[$j%16],@X[$j%16]
136
my ($i,$a,$b,$c,$d,$e)=@_;
138
$code.=<<___ if ($i<79); # with forward Xupdate
142
xor @X[($j+2)%16],@X[$j%16],@X[$j%16]
147
xor @X[($j+8)%16],@X[$j%16],@X[$j%16]
152
xor @X[($j+13)%16],@X[$j%16],@X[$j%16]
157
addl @X[$j%16],@X[$j%16],@X[$j%16]
161
or $t1,@X[$j%16],@X[$j%16]
163
$code.=<<___ if ($i<77);
164
zapnot @X[$i%16],0xf,@X[$i%16]
166
$code.=<<___ if ($i==79); # with context fetch
193
my ($i,$a,$b,$c,$d,$e)=@_;
195
$code.=<<___; # with forward Xupdate
199
xor @X[($j+2)%16],@X[$j%16],@X[$j%16]
204
xor @X[($j+8)%16],@X[$j%16],@X[$j%16]
208
xor @X[($j+13)%16],@X[$j%16],@X[$j%16]
218
addl @X[$j%16],@X[$j%16],@X[$j%16]
222
or $t1,@X[$j%16],@X[$j%16]
223
zapnot @X[$i%16],0xf,@X[$i%16]
229
#include <asm/regdef.h>
239
.globl sha1_block_data_order
241
.ent sha1_block_data_order
242
sha1_block_data_order:
268
lda $K,31129($K) # K_00_19
270
for ($i=0;$i<20;$i++) { &BODY_00_19($i,@V); unshift(@V,pop(@V)); }
274
lda $K,-5215($K) # K_20_39
276
for (;$i<40;$i++) { &BODY_20_39($i,@V); unshift(@V,pop(@V)); }
280
lda $K,-17188($K) # K_40_59
282
for (;$i<60;$i++) { &BODY_40_59($i,@V); unshift(@V,pop(@V)); }
286
lda $K,-15914($K) # K_60_79
288
for (;$i<80;$i++) { &BODY_20_39($i,@V); unshift(@V,pop(@V)); }
316
.end sha1_block_data_order
317
.ascii "SHA1 block transform for Alpha, CRYPTOGAMS by <appro\@openssl.org>"
320
$output=shift and open STDOUT,">$output";