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 for Thumb.
14 # The code does not present direct interest to OpenSSL, because of low
15 # performance. Its purpose is to establish _size_ benchmark. Pretty
16 # useless one I must say, because 30% or 88 bytes larger ARMv4 code
17 # [avialable on demand] is almost _twice_ as fast. It should also be
18 # noted that in-lining of .Lcommon and .Lrotate improves performance
19 # by over 40%, while code increases by only 10% or 32 bytes. But once
20 # again, the goal was to establish _size_ benchmark, not performance.
23 #$cheat_on_binutils=1;
33 $K="r8"; # "upper" registers can be used in add/sub and mov insns
43 add $e,$K @ E+=K_xx_xx
47 add $t2,$e @ E+=ROR(A,27)
57 orr $c,$b @ C=ROR(B,2)
59 add $a,$t2,$t1 @ A=E+F_xx_xx(B,C,D)
64 $code.=$inline?&common():"\tbl .Lcommon\n";
69 eor $t1,$d @ F_00_19(B,C,D)
71 $code.=$inline?&rotate():"\tbl .Lrotate\n";
75 $code.=$inline?&common():"\tbl .Lcommon\n";
79 eor $t1,$d @ F_20_39(B,C,D)
81 $code.=$inline?&rotate():"\tbl .Lrotate\n";
85 $code.=$inline?&common():"\tbl .Lcommon\n";
92 orr $t1,$e @ F_40_59(B,C,D)
94 $code.=$inline?&rotate():"\tbl .Lrotate\n";
101 .global sha1_block_data_order
102 .type sha1_block_data_order,%function
105 sha1_block_data_order:
107 if ($cheat_on_binutils) {
111 bx r3 @ switch to Thumb ISA
124 mov $ctx,r0 @ save context
125 mov $inp,r1 @ save inp
126 mov $len,r2 @ save len
127 add $len,$inp @ $len to point at inp end
134 ldrb $a,[$t1,#0] @ $t1 is r1 and holds inp
147 bne .LXload @ [+14*16]
149 mov $inp,$t1 @ update $inp
164 bne .LXupdate @ [+(11+1)*64]
166 ldmia $t0!,{$a,$b,$c,$d,$e} @ $t0 is r0 and holds ctx
179 bne .L_00_19 @ [+(2+9+4+2+8+2)*20]
191 bne .L_20_39_or_60_79 @ [+(2+9+3+2+8+2)*20*2]
205 bne .L_40_59 @ [+(2+9+6+2+8+2)*20]
210 b .L_20_39_or_60_79 @ [+4]
223 stmia $t0!,{$a,$b,$c,$d,$e} @ [+20]
225 add sp,#80*4 @ deallocate stack frame
226 mov $t0,$ctx @ restore ctx
227 mov $t1,$inp @ restore inp
230 b .Lloop @ [+6] total 3212 cycles
243 $code.=".Lcommon:\n".&common()."\tmov pc,lr\n" if (!$inline);
244 $code.=".Lrotate:\n".&rotate()."\tmov pc,lr\n" if (!$inline);
247 .LK_00_19: .word 0x5a827999
248 .LK_20_39: .word 0x6ed9eba1
249 .LK_40_59: .word 0x8f1bbcdc
250 .LK_60_79: .word 0xca62c1d6
251 .size sha1_block_data_order,.-sha1_block_data_order
252 .asciz "SHA1 block transform for Thumb, CRYPTOGAMS by <appro\@openssl.org>"