2 # Copyright 2007-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 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.
30 open STDOUT,">$output";
33 #$cheat_on_binutils=1;
43 $K="r8"; # "upper" registers can be used in add/sub and mov insns
53 add $e,$K @ E+=K_xx_xx
57 add $t2,$e @ E+=ROR(A,27)
67 orr $c,$b @ C=ROR(B,2)
69 add $a,$t2,$t1 @ A=E+F_xx_xx(B,C,D)
74 $code.=$inline?&common():"\tbl .Lcommon\n";
79 eor $t1,$d @ F_00_19(B,C,D)
81 $code.=$inline?&rotate():"\tbl .Lrotate\n";
85 $code.=$inline?&common():"\tbl .Lcommon\n";
89 eor $t1,$d @ F_20_39(B,C,D)
91 $code.=$inline?&rotate():"\tbl .Lrotate\n";
95 $code.=$inline?&common():"\tbl .Lcommon\n";
102 orr $t1,$e @ F_40_59(B,C,D)
104 $code.=$inline?&rotate():"\tbl .Lrotate\n";
111 .global sha1_block_data_order
112 .type sha1_block_data_order,%function
115 sha1_block_data_order:
117 if ($cheat_on_binutils) {
121 bx r3 @ switch to Thumb ISA
134 mov $ctx,r0 @ save context
135 mov $inp,r1 @ save inp
136 mov $len,r2 @ save len
137 add $len,$inp @ $len to point at inp end
144 ldrb $a,[$t1,#0] @ $t1 is r1 and holds inp
157 bne .LXload @ [+14*16]
159 mov $inp,$t1 @ update $inp
174 bne .LXupdate @ [+(11+1)*64]
176 ldmia $t0!,{$a,$b,$c,$d,$e} @ $t0 is r0 and holds ctx
189 bne .L_00_19 @ [+(2+9+4+2+8+2)*20]
201 bne .L_20_39_or_60_79 @ [+(2+9+3+2+8+2)*20*2]
215 bne .L_40_59 @ [+(2+9+6+2+8+2)*20]
220 b .L_20_39_or_60_79 @ [+4]
233 stmia $t0!,{$a,$b,$c,$d,$e} @ [+20]
235 add sp,#80*4 @ deallocate stack frame
236 mov $t0,$ctx @ restore ctx
237 mov $t1,$inp @ restore inp
240 b .Lloop @ [+6] total 3212 cycles
253 $code.=".Lcommon:\n".&common()."\tmov pc,lr\n" if (!$inline);
254 $code.=".Lrotate:\n".&rotate()."\tmov pc,lr\n" if (!$inline);
257 .LK_00_19: .word 0x5a827999
258 .LK_20_39: .word 0x6ed9eba1
259 .LK_40_59: .word 0x8f1bbcdc
260 .LK_60_79: .word 0xca62c1d6
261 .size sha1_block_data_order,.-sha1_block_data_order
262 .asciz "SHA1 block transform for Thumb, CRYPTOGAMS by <appro\@openssl.org>"
266 close STDOUT; # enforce flush