summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorjsing <>2024-03-27 12:59:12 +0000
committerjsing <>2024-03-27 12:59:12 +0000
commitfeced734cd9525f3d3e8b5db422209833f23147a (patch)
treec4f83da25bb30acf2b4284b357429e2e289147f2 /src
parent01082574366fe7c583c2135e66ad113c289114bc (diff)
downloadopenbsd-feced734cd9525f3d3e8b5db422209833f23147a.tar.gz
openbsd-feced734cd9525f3d3e8b5db422209833f23147a.tar.bz2
openbsd-feced734cd9525f3d3e8b5db422209833f23147a.zip
Remove unused rc4 parisc assembly.
This is already disabled since it is "about 35% slower than C code".
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/arch/hppa/Makefile.inc6
-rw-r--r--src/lib/libcrypto/rc4/asm/rc4-parisc.pl294
2 files changed, 1 insertions, 299 deletions
diff --git a/src/lib/libcrypto/arch/hppa/Makefile.inc b/src/lib/libcrypto/arch/hppa/Makefile.inc
index 75bb288c91..92f18cc6b8 100644
--- a/src/lib/libcrypto/arch/hppa/Makefile.inc
+++ b/src/lib/libcrypto/arch/hppa/Makefile.inc
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile.inc,v 1.16 2024/03/27 12:54:42 jsing Exp $ 1# $OpenBSD: Makefile.inc,v 1.17 2024/03/27 12:59:12 jsing Exp $
2 2
3# hppa-specific libcrypto build rules 3# hppa-specific libcrypto build rules
4 4
@@ -17,11 +17,7 @@ SRCS+= des_enc.c fcrypt_b.c
17CFLAGS+= -DGHASH_ASM 17CFLAGS+= -DGHASH_ASM
18SSLASM+= modes ghash-parisc ghash-parisc 18SSLASM+= modes ghash-parisc ghash-parisc
19# rc4 19# rc4
20.if 0 # about 35% slower than C code
21SSLASM+= rc4 rc4-parisc rc4-parisc
22.else
23SRCS+= rc4.c 20SRCS+= rc4.c
24.endif
25# sha 21# sha
26CFLAGS+= -DSHA1_ASM 22CFLAGS+= -DSHA1_ASM
27SSLASM+= sha sha1-parisc sha1-parisc 23SSLASM+= sha sha1-parisc sha1-parisc
diff --git a/src/lib/libcrypto/rc4/asm/rc4-parisc.pl b/src/lib/libcrypto/rc4/asm/rc4-parisc.pl
deleted file mode 100644
index 6a1a2aad77..0000000000
--- a/src/lib/libcrypto/rc4/asm/rc4-parisc.pl
+++ /dev/null
@@ -1,294 +0,0 @@
1#!/usr/bin/env perl
2
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# ====================================================================
9
10# RC4 for PA-RISC.
11
12# June 2009.
13#
14# Performance is 33% better than gcc 3.2 generated code on PA-7100LC.
15# For reference, [4x] unrolled loop is >40% faster than folded one.
16# It's possible to unroll loop 8 times on PA-RISC 2.0, but improvement
17# is believed to be not sufficient to justify the effort...
18#
19# Special thanks to polarhome.com for providing HP-UX account.
20
21$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
22
23$flavour = shift;
24$output = shift;
25open STDOUT,">$output";
26
27if ($flavour =~ /64/) {
28 $LEVEL ="2.0W";
29 $SIZE_T =8;
30 $FRAME_MARKER =80;
31 $SAVED_RP =16;
32 $PUSH ="std";
33 $PUSHMA ="std,ma";
34 $POP ="ldd";
35 $POPMB ="ldd,mb";
36} else {
37 $LEVEL ="1.0";
38 $SIZE_T =4;
39 $FRAME_MARKER =48;
40 $SAVED_RP =20;
41 $PUSH ="stw";
42 $PUSHMA ="stwm";
43 $POP ="ldw";
44 $POPMB ="ldwm";
45}
46
47$FRAME=4*$SIZE_T+$FRAME_MARKER; # 4 saved regs + frame marker
48 # [+ argument transfer]
49$SZ=1; # defaults to RC4_CHAR
50if (open CONF,"<${dir}../../opensslconf.h") {
51 while(<CONF>) {
52 if (m/#\s*define\s+RC4_INT\s+(.*)/) {
53 $SZ = ($1=~/char$/) ? 1 : 4;
54 last;
55 }
56 }
57 close CONF;
58}
59
60if ($SZ==1) { # RC4_CHAR
61 $LD="ldb";
62 $LDX="ldbx";
63 $MKX="addl";
64 $ST="stb";
65} else { # RC4_INT (~5% faster than RC4_CHAR on PA-7100LC)
66 $LD="ldw";
67 $LDX="ldwx,s";
68 $MKX="sh2addl";
69 $ST="stw";
70}
71
72$key="%r26";
73$len="%r25";
74$inp="%r24";
75$out="%r23";
76
77@XX=("%r19","%r20");
78@TX=("%r21","%r22");
79$YY="%r28";
80$TY="%r29";
81
82$acc="%r1";
83$ix="%r2";
84$iy="%r3";
85$dat0="%r4";
86$dat1="%r5";
87$rem="%r6";
88$mask="%r31";
89
90sub unrolledloopbody {
91for ($i=0;$i<4;$i++) {
92$code.=<<___;
93 ldo 1($XX[0]),$XX[1]
94 `sprintf("$LDX %$TY(%$key),%$dat1") if ($i>0)`
95 and $mask,$XX[1],$XX[1]
96 $LDX $YY($key),$TY
97 $MKX $YY,$key,$ix
98 $LDX $XX[1]($key),$TX[1]
99 $MKX $XX[0],$key,$iy
100 $ST $TX[0],0($ix)
101 comclr,<> $XX[1],$YY,%r0 ; conditional
102 copy $TX[0],$TX[1] ; move
103 `sprintf("%sdep %$dat1,%d,8,%$acc",$i==1?"z":"",8*($i-1)+7) if ($i>0)`
104 $ST $TY,0($iy)
105 addl $TX[0],$TY,$TY
106 addl $TX[1],$YY,$YY
107 and $mask,$TY,$TY
108 and $mask,$YY,$YY
109___
110push(@TX,shift(@TX)); push(@XX,shift(@XX)); # "rotate" registers
111} }
112
113sub foldedloop {
114my ($label,$count)=@_;
115$code.=<<___;
116$label
117 $MKX $YY,$key,$iy
118 $LDX $YY($key),$TY
119 $MKX $XX[0],$key,$ix
120 $ST $TX[0],0($iy)
121 ldo 1($XX[0]),$XX[0]
122 $ST $TY,0($ix)
123 addl $TX[0],$TY,$TY
124 ldbx $inp($out),$dat1
125 and $mask,$TY,$TY
126 and $mask,$XX[0],$XX[0]
127 $LDX $TY($key),$acc
128 $LDX $XX[0]($key),$TX[0]
129 ldo 1($out),$out
130 xor $dat1,$acc,$acc
131 addl $TX[0],$YY,$YY
132 stb $acc,-1($out)
133 addib,<> -1,$count,$label ; $count is always small
134 and $mask,$YY,$YY
135___
136}
137
138$code=<<___;
139 .LEVEL $LEVEL
140 .text
141
142 .EXPORT RC4,ENTRY,ARGW0=GR,ARGW1=GR,ARGW2=GR,ARGW3=GR
143RC4
144 .PROC
145 .CALLINFO FRAME=`$FRAME-4*$SIZE_T`,NO_CALLS,SAVE_RP,ENTRY_GR=6
146 .ENTRY
147 $PUSH %r2,-$SAVED_RP(%sp) ; standard prologue
148 $PUSHMA %r3,$FRAME(%sp)
149 $PUSH %r4,`-$FRAME+1*$SIZE_T`(%sp)
150 $PUSH %r5,`-$FRAME+2*$SIZE_T`(%sp)
151 $PUSH %r6,`-$FRAME+3*$SIZE_T`(%sp)
152
153 cmpib,*= 0,$len,L\$abort
154 sub $inp,$out,$inp ; distance between $inp and $out
155
156 $LD `0*$SZ`($key),$XX[0]
157 $LD `1*$SZ`($key),$YY
158 ldo `2*$SZ`($key),$key
159
160 ldi 0xff,$mask
161 ldi 3,$dat0
162
163 ldo 1($XX[0]),$XX[0] ; warm up loop
164 and $mask,$XX[0],$XX[0]
165 $LDX $XX[0]($key),$TX[0]
166 addl $TX[0],$YY,$YY
167 cmpib,*>>= 6,$len,L\$oop1 ; is $len large enough to bother?
168 and $mask,$YY,$YY
169
170 and,<> $out,$dat0,$rem ; is $out aligned?
171 b L\$alignedout
172 subi 4,$rem,$rem
173 sub $len,$rem,$len
174___
175&foldedloop("L\$alignout",$rem); # process till $out is aligned
176
177$code.=<<___;
178L\$alignedout ; $len is at least 4 here
179 and,<> $inp,$dat0,$acc ; is $inp aligned?
180 b L\$oop4
181 sub $inp,$acc,$rem ; align $inp
182
183 sh3addl $acc,%r0,$acc
184 subi 32,$acc,$acc
185 mtctl $acc,%cr11 ; load %sar with vshd align factor
186 ldwx $rem($out),$dat0
187 ldo 4($rem),$rem
188L\$oop4misalignedinp
189___
190&unrolledloopbody();
191$code.=<<___;
192 $LDX $TY($key),$ix
193 ldwx $rem($out),$dat1
194 ldo -4($len),$len
195 or $ix,$acc,$acc ; last piece, no need to dep
196 vshd $dat0,$dat1,$iy ; align data
197 copy $dat1,$dat0
198 xor $iy,$acc,$acc
199 stw $acc,0($out)
200 cmpib,*<< 3,$len,L\$oop4misalignedinp
201 ldo 4($out),$out
202 cmpib,*= 0,$len,L\$done
203 nop
204 b L\$oop1
205 nop
206
207 .ALIGN 8
208L\$oop4
209___
210&unrolledloopbody();
211$code.=<<___;
212 $LDX $TY($key),$ix
213 ldwx $inp($out),$dat0
214 ldo -4($len),$len
215 or $ix,$acc,$acc ; last piece, no need to dep
216 xor $dat0,$acc,$acc
217 stw $acc,0($out)
218 cmpib,*<< 3,$len,L\$oop4
219 ldo 4($out),$out
220 cmpib,*= 0,$len,L\$done
221 nop
222___
223&foldedloop("L\$oop1",$len);
224$code.=<<___;
225L\$done
226 $POP `-$FRAME-$SAVED_RP`(%sp),%r2
227 ldo -1($XX[0]),$XX[0] ; chill out loop
228 sub $YY,$TX[0],$YY
229 and $mask,$XX[0],$XX[0]
230 and $mask,$YY,$YY
231 $ST $XX[0],`-2*$SZ`($key)
232 $ST $YY,`-1*$SZ`($key)
233 $POP `-$FRAME+1*$SIZE_T`(%sp),%r4
234 $POP `-$FRAME+2*$SIZE_T`(%sp),%r5
235 $POP `-$FRAME+3*$SIZE_T`(%sp),%r6
236L\$abort
237 bv (%r2)
238 .EXIT
239 $POPMB -$FRAME(%sp),%r3
240 .PROCEND
241___
242
243$code.=<<___;
244
245 .EXPORT RC4_set_key,ENTRY,ARGW0=GR,ARGW1=GR,ARGW2=GR
246 .ALIGN 8
247RC4_set_key
248 .PROC
249 .CALLINFO NO_CALLS
250 .ENTRY
251 $ST %r0,`0*$SZ`($key)
252 $ST %r0,`1*$SZ`($key)
253 ldo `2*$SZ`($key),$key
254 copy %r0,@XX[0]
255L\$1st
256 $ST @XX[0],0($key)
257 ldo 1(@XX[0]),@XX[0]
258 bb,>= @XX[0],`31-8`,L\$1st ; @XX[0]<256
259 ldo $SZ($key),$key
260
261 ldo `-256*$SZ`($key),$key ; rewind $key
262 addl $len,$inp,$inp ; $inp to point at the end
263 sub %r0,$len,%r23 ; inverse index
264 copy %r0,@XX[0]
265 copy %r0,@XX[1]
266 ldi 0xff,$mask
267
268L\$2nd
269 $LDX @XX[0]($key),@TX[0]
270 ldbx %r23($inp),@TX[1]
271 addi,nuv 1,%r23,%r23 ; increment and conditional
272 sub %r0,$len,%r23 ; inverse index
273 addl @TX[0],@XX[1],@XX[1]
274 addl @TX[1],@XX[1],@XX[1]
275 and $mask,@XX[1],@XX[1]
276 $MKX @XX[0],$key,$TY
277 $LDX @XX[1]($key),@TX[1]
278 $MKX @XX[1],$key,$YY
279 ldo 1(@XX[0]),@XX[0]
280 $ST @TX[0],0($YY)
281 bb,>= @XX[0],`31-8`,L\$2nd ; @XX[0]<256
282 $ST @TX[1],0($TY)
283
284 bv,n (%r2)
285 .EXIT
286 nop
287 .PROCEND
288___
289$code =~ s/\`([^\`]*)\`/eval $1/gem;
290$code =~ s/cmpib,\*/comib,/gm if ($SIZE_T==4);
291$code =~ s/\bbv\b/bve/gm if ($SIZE_T==8);
292
293print $code;
294close STDOUT;