2 # Copyright 2007-2020 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the Apache License 2.0 (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 for Thumb.
21 # The code does not present direct interest to OpenSSL, because of low
22 # performance. Its purpose is to establish _size_ benchmark. Pretty
23 # useless one I must say, because 30% or 88 bytes larger ARMv4 code
24 # [available on demand] is almost _twice_ as fast. It should also be
25 # noted that in-lining of .Lcommon and .Lrotate improves performance
26 # by over 40%, while code increases by only 10% or 32 bytes. But once
27 # again, the goal was to establish _size_ benchmark, not performance.
29 $output=pop and open STDOUT
,">$output";
32 #$cheat_on_binutils=1;
42 $K="r8"; # "upper" registers can be used in add/sub and mov insns
52 add
$e,$K @ E
+=K_xx_xx
56 add
$t2,$e @ E
+=ROR
(A
,27)
66 orr
$c,$b @ C
=ROR
(B
,2)
68 add
$a,$t2,$t1 @ A
=E
+F_xx_xx
(B
,C
,D
)
73 $code.=$inline?
&common
():"\tbl .Lcommon\n";
78 eor
$t1,$d @ F_00_19
(B
,C
,D
)
80 $code.=$inline?
&rotate
():"\tbl .Lrotate\n";
84 $code.=$inline?
&common
():"\tbl .Lcommon\n";
88 eor
$t1,$d @ F_20_39
(B
,C
,D
)
90 $code.=$inline?
&rotate
():"\tbl .Lrotate\n";
94 $code.=$inline?
&common
():"\tbl .Lcommon\n";
101 orr
$t1,$e @ F_40_59
(B
,C
,D
)
103 $code.=$inline?
&rotate
():"\tbl .Lrotate\n";
110 .global sha1_block_data_order
111 .type sha1_block_data_order
,%function
114 sha1_block_data_order
:
116 if ($cheat_on_binutils) {
120 bx r3 @ switch to Thumb ISA
133 mov
$ctx,r0 @ save context
134 mov
$inp,r1 @ save inp
135 mov
$len,r2 @ save len
136 add
$len,$inp @
$len to point at inp end
143 ldrb
$a,[$t1,#0] @ $t1 is r1 and holds inp
156 bne
.LXload @
[+14*16]
158 mov
$inp,$t1 @ update
$inp
173 bne
.LXupdate @
[+(11+1)*64]
175 ldmia
$t0!,{$a,$b,$c,$d,$e} @
$t0 is r0
and holds ctx
188 bne
.L_00_19 @
[+(2+9+4+2+8+2)*20]
200 bne
.L_20_39_or_60_79 @
[+(2+9+3+2+8+2)*20*2]
214 bne
.L_40_59 @
[+(2+9+6+2+8+2)*20]
219 b
.L_20_39_or_60_79 @
[+4]
232 stmia
$t0!,{$a,$b,$c,$d,$e} @
[+20]
234 add sp
,#80*4 @ deallocate stack frame
235 mov
$t0,$ctx @ restore ctx
236 mov
$t1,$inp @ restore inp
239 b
.Lloop @
[+6] total
3212 cycles
252 $code.=".Lcommon:\n".&common
()."\tmov pc,lr\n" if (!$inline);
253 $code.=".Lrotate:\n".&rotate
()."\tmov pc,lr\n" if (!$inline);
256 .LK_00_19
: .word
0x5a827999
257 .LK_20_39
: .word
0x6ed9eba1
258 .LK_40_59
: .word
0x8f1bbcdc
259 .LK_60_79
: .word
0xca62c1d6
260 .size sha1_block_data_order
,.-sha1_block_data_order
261 .asciz
"SHA1 block transform for Thumb, CRYPTOGAMS by <appro\@openssl.org>"
265 close STDOUT
or die "error closing STDOUT: $!"; # enforce flush