summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormiod <>2014-04-17 18:16:45 +0000
committermiod <>2014-04-17 18:16:45 +0000
commit6b39fdab5868da712ead9164b4680bd7a7d86773 (patch)
tree90883ba640e038606eee09fb5c784c3df7903a8e /src
parentd2037bc80eb83a1694b3e3458e6df04d0b9b29f1 (diff)
downloadopenbsd-6b39fdab5868da712ead9164b4680bd7a7d86773.tar.gz
openbsd-6b39fdab5868da712ead9164b4680bd7a7d86773.tar.bz2
openbsd-6b39fdab5868da712ead9164b4680bd7a7d86773.zip
Ok, there was a need for OPENSSL_cleanse() instead of bzero() to prevent
supposedly smart compilers from optimizing memory cleanups away. Understood. Ok, in case of an hypothetically super smart compiler, OPENSSL_cleanse() had to be convoluted enough for the compiler not to recognize that this was actually bzero() in disguise. Understood. But then why there had been optimized assembler versions of OPENSSL_cleanse() is beyond me. Did someone not trust the C obfuscation?
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/alphacpuid.pl37
-rw-r--r--src/lib/libcrypto/armv4cpuid.S32
-rw-r--r--src/lib/libcrypto/crypto/Makefile4
-rw-r--r--src/lib/libcrypto/ia64cpuid.S39
-rw-r--r--src/lib/libcrypto/pariscid.pl44
-rwxr-xr-xsrc/lib/libcrypto/ppccpuid.pl32
-rw-r--r--src/lib/libcrypto/s390xcpuid.S35
-rw-r--r--src/lib/libcrypto/sparccpuid.S83
-rw-r--r--src/lib/libcrypto/x86_64cpuid.pl35
-rw-r--r--src/lib/libcrypto/x86cpuid.pl34
-rw-r--r--src/lib/libssl/src/crypto/alphacpuid.pl37
-rw-r--r--src/lib/libssl/src/crypto/armv4cpuid.S32
-rw-r--r--src/lib/libssl/src/crypto/ia64cpuid.S39
-rw-r--r--src/lib/libssl/src/crypto/pariscid.pl44
-rwxr-xr-xsrc/lib/libssl/src/crypto/ppccpuid.pl32
-rw-r--r--src/lib/libssl/src/crypto/s390xcpuid.S35
-rw-r--r--src/lib/libssl/src/crypto/sparccpuid.S83
-rw-r--r--src/lib/libssl/src/crypto/x86_64cpuid.pl35
-rw-r--r--src/lib/libssl/src/crypto/x86cpuid.pl34
19 files changed, 2 insertions, 744 deletions
diff --git a/src/lib/libcrypto/alphacpuid.pl b/src/lib/libcrypto/alphacpuid.pl
index 4b3cbb9827..f6aea6a766 100644
--- a/src/lib/libcrypto/alphacpuid.pl
+++ b/src/lib/libcrypto/alphacpuid.pl
@@ -86,41 +86,4 @@ OPENSSL_rdtsc:
86 rpcc $0 86 rpcc $0
87 ret ($26) 87 ret ($26)
88.end OPENSSL_rdtsc 88.end OPENSSL_rdtsc
89
90.globl OPENSSL_cleanse
91.ent OPENSSL_cleanse
92OPENSSL_cleanse:
93 .frame $30,0,$26
94 .prologue 0
95 beq $17,.Ldone
96 and $16,7,$0
97 bic $17,7,$at
98 beq $at,.Little
99 beq $0,.Laligned
100
101.Little:
102 subq $0,8,$0
103 ldq_u $1,0($16)
104 mov $16,$2
105.Lalign:
106 mskbl $1,$16,$1
107 lda $16,1($16)
108 subq $17,1,$17
109 addq $0,1,$0
110 beq $17,.Lout
111 bne $0,.Lalign
112.Lout: stq_u $1,0($2)
113 beq $17,.Ldone
114 bic $17,7,$at
115 beq $at,.Little
116
117.Laligned:
118 stq $31,0($16)
119 subq $17,8,$17
120 lda $16,8($16)
121 bic $17,7,$at
122 bne $at,.Laligned
123 bne $17,.Little
124.Ldone: ret ($26)
125.end OPENSSL_cleanse
126___ 89___
diff --git a/src/lib/libcrypto/armv4cpuid.S b/src/lib/libcrypto/armv4cpuid.S
index 2d618deaa4..bdfde19c1f 100644
--- a/src/lib/libcrypto/armv4cpuid.S
+++ b/src/lib/libcrypto/armv4cpuid.S
@@ -54,38 +54,6 @@ OPENSSL_atomic_add:
54#endif 54#endif
55.size OPENSSL_atomic_add,.-OPENSSL_atomic_add 55.size OPENSSL_atomic_add,.-OPENSSL_atomic_add
56 56
57.global OPENSSL_cleanse
58.type OPENSSL_cleanse,%function
59OPENSSL_cleanse:
60 eor ip,ip,ip
61 cmp r1,#7
62 subhs r1,r1,#4
63 bhs .Lot
64 cmp r1,#0
65 beq .Lcleanse_done
66.Little:
67 strb ip,[r0],#1
68 subs r1,r1,#1
69 bhi .Little
70 b .Lcleanse_done
71
72.Lot: tst r0,#3
73 beq .Laligned
74 strb ip,[r0],#1
75 sub r1,r1,#1
76 b .Lot
77.Laligned:
78 str ip,[r0],#4
79 subs r1,r1,#4
80 bhs .Laligned
81 adds r1,r1,#4
82 bne .Little
83.Lcleanse_done:
84 tst lr,#1
85 moveq pc,lr
86 .word 0xe12fff1e @ bx lr
87.size OPENSSL_cleanse,.-OPENSSL_cleanse
88
89.global OPENSSL_wipe_cpu 57.global OPENSSL_wipe_cpu
90.type OPENSSL_wipe_cpu,%function 58.type OPENSSL_wipe_cpu,%function
91OPENSSL_wipe_cpu: 59OPENSSL_wipe_cpu:
diff --git a/src/lib/libcrypto/crypto/Makefile b/src/lib/libcrypto/crypto/Makefile
index 449959dc2f..f71fe8e2c1 100644
--- a/src/lib/libcrypto/crypto/Makefile
+++ b/src/lib/libcrypto/crypto/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.19 2014/04/17 18:11:46 miod Exp $ 1# $OpenBSD: Makefile,v 1.20 2014/04/17 18:16:45 miod Exp $
2 2
3LIB= crypto 3LIB= crypto
4 4
@@ -35,6 +35,7 @@ CFLAGS+= -I${LCRYPTO_SRC}/modes -I${LCRYPTO_SRC}/asn1 -I${LCRYPTO_SRC}/evp
35# crypto/ 35# crypto/
36SRCS+= cryptlib.c malloc-wrapper.c mem_dbg.c cversion.c ex_data.c cpt_err.c 36SRCS+= cryptlib.c malloc-wrapper.c mem_dbg.c cversion.c ex_data.c cpt_err.c
37SRCS+= uid.c o_time.c o_str.c o_init.c 37SRCS+= uid.c o_time.c o_str.c o_init.c
38SRCS+= mem_clr.c
38 39
39# aes/ 40# aes/
40SRCS+= aes_misc.c aes_ecb.c aes_cfb.c aes_ofb.c 41SRCS+= aes_misc.c aes_ecb.c aes_cfb.c aes_ofb.c
@@ -432,7 +433,6 @@ obj_dat.h: obj_mac.h
432 433
433.if empty (SSLASM) 434.if empty (SSLASM)
434CFLAGS+=-DOPENSSL_NO_ASM 435CFLAGS+=-DOPENSSL_NO_ASM
435SRCS+= mem_clr.c
436SRCS+= aes_core.c aes_cbc.c 436SRCS+= aes_core.c aes_cbc.c
437SRCS+= bf_enc.c 437SRCS+= bf_enc.c
438SRCS+= bn_asm.c 438SRCS+= bn_asm.c
diff --git a/src/lib/libcrypto/ia64cpuid.S b/src/lib/libcrypto/ia64cpuid.S
index 7832b9b640..517d938888 100644
--- a/src/lib/libcrypto/ia64cpuid.S
+++ b/src/lib/libcrypto/ia64cpuid.S
@@ -126,42 +126,3 @@ OPENSSL_wipe_cpu:
126 mov ar.lc=r3 126 mov ar.lc=r3
127 br.ret.sptk b0 };; 127 br.ret.sptk b0 };;
128.endp OPENSSL_wipe_cpu# 128.endp OPENSSL_wipe_cpu#
129
130.global OPENSSL_cleanse#
131.proc OPENSSL_cleanse#
132OPENSSL_cleanse:
133{ .mib; cmp.eq p6,p0=0,r33 // len==0
134#if defined(_HPUX_SOURCE) && !defined(_LP64)
135 addp4 r32=0,r32
136#endif
137(p6) br.ret.spnt b0 };;
138{ .mib; and r2=7,r32
139 cmp.leu p6,p0=15,r33 // len>=15
140(p6) br.cond.dptk .Lot };;
141
142.Little:
143{ .mib; st1 [r32]=r0,1
144 cmp.ltu p6,p7=1,r33 } // len>1
145{ .mbb; add r33=-1,r33 // len--
146(p6) br.cond.dptk .Little
147(p7) br.ret.sptk.many b0 };;
148
149.Lot:
150{ .mib; cmp.eq p6,p0=0,r2
151(p6) br.cond.dptk .Laligned };;
152{ .mmi; st1 [r32]=r0,1;;
153 and r2=7,r32 }
154{ .mib; add r33=-1,r33
155 br .Lot };;
156
157.Laligned:
158{ .mmi; st8 [r32]=r0,8
159 and r2=-8,r33 // len&~7
160 add r33=-8,r33 };; // len-=8
161{ .mib; cmp.ltu p6,p0=8,r2 // ((len+8)&~7)>8
162(p6) br.cond.dptk .Laligned };;
163
164{ .mbb; cmp.eq p6,p7=r0,r33
165(p7) br.cond.dpnt .Little
166(p6) br.ret.sptk.many b0 };;
167.endp OPENSSL_cleanse#
diff --git a/src/lib/libcrypto/pariscid.pl b/src/lib/libcrypto/pariscid.pl
index bfc56fdc7f..38985afbac 100644
--- a/src/lib/libcrypto/pariscid.pl
+++ b/src/lib/libcrypto/pariscid.pl
@@ -87,50 +87,6 @@ OPENSSL_wipe_cpu
87 .PROCEND 87 .PROCEND
88___ 88___
89{ 89{
90my $inp="%r26";
91my $len="%r25";
92
93$code.=<<___;
94 .EXPORT OPENSSL_cleanse,ENTRY,ARGW0=GR,ARGW1=GR
95 .ALIGN 8
96OPENSSL_cleanse
97 .PROC
98 .CALLINFO NO_CALLS
99 .ENTRY
100 cmpib,*= 0,$len,L\$done
101 nop
102 cmpib,*>>= 15,$len,L\$ittle
103 ldi $SIZE_T-1,%r1
104
105L\$align
106 and,*<> $inp,%r1,%r28
107 b,n L\$aligned
108 stb %r0,0($inp)
109 ldo -1($len),$len
110 b L\$align
111 ldo 1($inp),$inp
112
113L\$aligned
114 andcm $len,%r1,%r28
115L\$ot
116 $ST %r0,0($inp)
117 addib,*<> -$SIZE_T,%r28,L\$ot
118 ldo $SIZE_T($inp),$inp
119
120 and,*<> $len,%r1,$len
121 b,n L\$done
122L\$ittle
123 stb %r0,0($inp)
124 addib,*<> -1,$len,L\$ittle
125 ldo 1($inp),$inp
126L\$done
127 bv ($rp)
128 .EXIT
129 nop
130 .PROCEND
131___
132}
133{
134my ($out,$cnt,$max)=("%r26","%r25","%r24"); 90my ($out,$cnt,$max)=("%r26","%r25","%r24");
135my ($tick,$lasttick)=("%r23","%r22"); 91my ($tick,$lasttick)=("%r23","%r22");
136my ($diff,$lastdiff)=("%r21","%r20"); 92my ($diff,$lastdiff)=("%r21","%r20");
diff --git a/src/lib/libcrypto/ppccpuid.pl b/src/lib/libcrypto/ppccpuid.pl
index 4ba736a1d1..cf48714e33 100755
--- a/src/lib/libcrypto/ppccpuid.pl
+++ b/src/lib/libcrypto/ppccpuid.pl
@@ -93,38 +93,6 @@ Ladd: lwarx r5,0,r3
93 blr 93 blr
94 .long 0 94 .long 0
95 .byte 0,12,0x14,0,0,0,0,0 95 .byte 0,12,0x14,0,0,0,0,0
96
97.globl .OPENSSL_cleanse
98.align 4
99.OPENSSL_cleanse:
100 $CMPLI r4,7
101 li r0,0
102 bge Lot
103 $CMPLI r4,0
104 beqlr-
105Little: mtctr r4
106 stb r0,0(r3)
107 addi r3,r3,1
108 bdnz \$-8
109 blr
110Lot: andi. r5,r3,3
111 beq Laligned
112 stb r0,0(r3)
113 subi r4,r4,1
114 addi r3,r3,1
115 b Lot
116Laligned:
117 $SHRLI r5,r4,2
118 mtctr r5
119 stw r0,0(r3)
120 addi r3,r3,4
121 bdnz \$-8
122 andi. r4,r4,3
123 bne Little
124 blr
125 .long 0
126 .byte 0,12,0x14,0,0,0,2,0
127 .long 0
128___ 96___
129 97
130$code =~ s/\`([^\`]*)\`/eval $1/gem; 98$code =~ s/\`([^\`]*)\`/eval $1/gem;
diff --git a/src/lib/libcrypto/s390xcpuid.S b/src/lib/libcrypto/s390xcpuid.S
index 06815347e6..89bf6be82f 100644
--- a/src/lib/libcrypto/s390xcpuid.S
+++ b/src/lib/libcrypto/s390xcpuid.S
@@ -58,41 +58,6 @@ OPENSSL_wipe_cpu:
58 br %r14 58 br %r14
59.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu 59.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
60 60
61.globl OPENSSL_cleanse
62.type OPENSSL_cleanse,@function
63.align 16
64OPENSSL_cleanse:
65#if !defined(__s390x__) && !defined(__s390x)
66 llgfr %r3,%r3
67#endif
68 lghi %r4,15
69 lghi %r0,0
70 clgr %r3,%r4
71 jh .Lot
72 clgr %r3,%r0
73 bcr 8,%r14
74.Little:
75 stc %r0,0(%r2)
76 la %r2,1(%r2)
77 brctg %r3,.Little
78 br %r14
79.align 4
80.Lot: tmll %r2,7
81 jz .Laligned
82 stc %r0,0(%r2)
83 la %r2,1(%r2)
84 brctg %r3,.Lot
85.Laligned:
86 srlg %r4,%r3,3
87.Loop: stg %r0,0(%r2)
88 la %r2,8(%r2)
89 brctg %r4,.Loop
90 lghi %r4,7
91 ngr %r3,%r4
92 jnz .Little
93 br %r14
94.size OPENSSL_cleanse,.-OPENSSL_cleanse
95
96.section .init 61.section .init
97 brasl %r14,OPENSSL_cpuid_setup 62 brasl %r14,OPENSSL_cpuid_setup
98 63
diff --git a/src/lib/libcrypto/sparccpuid.S b/src/lib/libcrypto/sparccpuid.S
index 0cc247e489..d8b44af2f0 100644
--- a/src/lib/libcrypto/sparccpuid.S
+++ b/src/lib/libcrypto/sparccpuid.S
@@ -314,89 +314,6 @@ _sparcv9_fmadd_probe:
314.type _sparcv9_fmadd_probe,#function 314.type _sparcv9_fmadd_probe,#function
315.size _sparcv9_fmadd_probe,.-_sparcv9_fmadd_probe 315.size _sparcv9_fmadd_probe,.-_sparcv9_fmadd_probe
316 316
317.global OPENSSL_cleanse
318.align 32
319OPENSSL_cleanse:
320 cmp %o1,14
321 nop
322#ifdef ABI64
323 bgu %xcc,.Lot
324#else
325 bgu .Lot
326#endif
327 cmp %o1,0
328 bne .Little
329 nop
330 retl
331 nop
332
333.Little:
334 stb %g0,[%o0]
335 subcc %o1,1,%o1
336 bnz .Little
337 add %o0,1,%o0
338 retl
339 nop
340.align 32
341.Lot:
342#ifndef ABI64
343 subcc %g0,1,%g1
344 ! see above for explanation
345 .word 0x83408000 !rd %ccr,%g1
346 cmp %g1,0x99
347 bne .v8lot
348 nop
349#endif
350
351.v9lot: andcc %o0,7,%g0
352 bz .v9aligned
353 nop
354 stb %g0,[%o0]
355 sub %o1,1,%o1
356 ba .v9lot
357 add %o0,1,%o0
358.align 16,0x01000000
359.v9aligned:
360 .word 0xc0720000 !stx %g0,[%o0]
361 sub %o1,8,%o1
362 andcc %o1,-8,%g0
363#ifdef ABI64
364 .word 0x126ffffd !bnz %xcc,.v9aligned
365#else
366 .word 0x124ffffd !bnz %icc,.v9aligned
367#endif
368 add %o0,8,%o0
369
370 cmp %o1,0
371 bne .Little
372 nop
373 retl
374 nop
375#ifndef ABI64
376.v8lot: andcc %o0,3,%g0
377 bz .v8aligned
378 nop
379 stb %g0,[%o0]
380 sub %o1,1,%o1
381 ba .v8lot
382 add %o0,1,%o0
383 nop
384.v8aligned:
385 st %g0,[%o0]
386 sub %o1,4,%o1
387 andcc %o1,-4,%g0
388 bnz .v8aligned
389 add %o0,4,%o0
390
391 cmp %o1,0
392 bne .Little
393 nop
394 retl
395 nop
396#endif
397.type OPENSSL_cleanse,#function
398.size OPENSSL_cleanse,.-OPENSSL_cleanse
399
400.section ".init",#alloc,#execinstr 317.section ".init",#alloc,#execinstr
401 call OPENSSL_cpuid_setup 318 call OPENSSL_cpuid_setup
402 nop 319 nop
diff --git a/src/lib/libcrypto/x86_64cpuid.pl b/src/lib/libcrypto/x86_64cpuid.pl
index 6ebfd017ea..8422e91342 100644
--- a/src/lib/libcrypto/x86_64cpuid.pl
+++ b/src/lib/libcrypto/x86_64cpuid.pl
@@ -172,41 +172,6 @@ OPENSSL_ia32_cpuid:
172 or %r9,%rax 172 or %r9,%rax
173 ret 173 ret
174.size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid 174.size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid
175
176.globl OPENSSL_cleanse
177.type OPENSSL_cleanse,\@abi-omnipotent
178.align 16
179OPENSSL_cleanse:
180 xor %rax,%rax
181 cmp \$15,$arg2
182 jae .Lot
183 cmp \$0,$arg2
184 je .Lret
185.Little:
186 mov %al,($arg1)
187 sub \$1,$arg2
188 lea 1($arg1),$arg1
189 jnz .Little
190.Lret:
191 ret
192.align 16
193.Lot:
194 test \$7,$arg1
195 jz .Laligned
196 mov %al,($arg1)
197 lea -1($arg2),$arg2
198 lea 1($arg1),$arg1
199 jmp .Lot
200.Laligned:
201 mov %rax,($arg1)
202 lea -8($arg2),$arg2
203 test \$-8,$arg2
204 lea 8($arg1),$arg1
205 jnz .Laligned
206 cmp \$0,$arg2
207 jne .Little
208 ret
209.size OPENSSL_cleanse,.-OPENSSL_cleanse
210___ 175___
211 176
212print<<___ if (!$win64); 177print<<___ if (!$win64);
diff --git a/src/lib/libcrypto/x86cpuid.pl b/src/lib/libcrypto/x86cpuid.pl
index b270b44337..0da613f697 100644
--- a/src/lib/libcrypto/x86cpuid.pl
+++ b/src/lib/libcrypto/x86cpuid.pl
@@ -307,40 +307,6 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
307 } 307 }
308&function_end_B("OPENSSL_indirect_call"); 308&function_end_B("OPENSSL_indirect_call");
309 309
310&function_begin_B("OPENSSL_cleanse");
311 &mov ("edx",&wparam(0));
312 &mov ("ecx",&wparam(1));
313 &xor ("eax","eax");
314 &cmp ("ecx",7);
315 &jae (&label("lot"));
316 &cmp ("ecx",0);
317 &je (&label("ret"));
318&set_label("little");
319 &mov (&BP(0,"edx"),"al");
320 &sub ("ecx",1);
321 &lea ("edx",&DWP(1,"edx"));
322 &jnz (&label("little"));
323&set_label("ret");
324 &ret ();
325
326&set_label("lot",16);
327 &test ("edx",3);
328 &jz (&label("aligned"));
329 &mov (&BP(0,"edx"),"al");
330 &lea ("ecx",&DWP(-1,"ecx"));
331 &lea ("edx",&DWP(1,"edx"));
332 &jmp (&label("lot"));
333&set_label("aligned");
334 &mov (&DWP(0,"edx"),"eax");
335 &lea ("ecx",&DWP(-4,"ecx"));
336 &test ("ecx",-4);
337 &lea ("edx",&DWP(4,"edx"));
338 &jnz (&label("aligned"));
339 &cmp ("ecx",0);
340 &jne (&label("little"));
341 &ret ();
342&function_end_B("OPENSSL_cleanse");
343
344&function_begin_B("OPENSSL_ia32_rdrand"); 310&function_begin_B("OPENSSL_ia32_rdrand");
345 &mov ("ecx",8); 311 &mov ("ecx",8);
346&set_label("loop"); 312&set_label("loop");
diff --git a/src/lib/libssl/src/crypto/alphacpuid.pl b/src/lib/libssl/src/crypto/alphacpuid.pl
index 4b3cbb9827..f6aea6a766 100644
--- a/src/lib/libssl/src/crypto/alphacpuid.pl
+++ b/src/lib/libssl/src/crypto/alphacpuid.pl
@@ -86,41 +86,4 @@ OPENSSL_rdtsc:
86 rpcc $0 86 rpcc $0
87 ret ($26) 87 ret ($26)
88.end OPENSSL_rdtsc 88.end OPENSSL_rdtsc
89
90.globl OPENSSL_cleanse
91.ent OPENSSL_cleanse
92OPENSSL_cleanse:
93 .frame $30,0,$26
94 .prologue 0
95 beq $17,.Ldone
96 and $16,7,$0
97 bic $17,7,$at
98 beq $at,.Little
99 beq $0,.Laligned
100
101.Little:
102 subq $0,8,$0
103 ldq_u $1,0($16)
104 mov $16,$2
105.Lalign:
106 mskbl $1,$16,$1
107 lda $16,1($16)
108 subq $17,1,$17
109 addq $0,1,$0
110 beq $17,.Lout
111 bne $0,.Lalign
112.Lout: stq_u $1,0($2)
113 beq $17,.Ldone
114 bic $17,7,$at
115 beq $at,.Little
116
117.Laligned:
118 stq $31,0($16)
119 subq $17,8,$17
120 lda $16,8($16)
121 bic $17,7,$at
122 bne $at,.Laligned
123 bne $17,.Little
124.Ldone: ret ($26)
125.end OPENSSL_cleanse
126___ 89___
diff --git a/src/lib/libssl/src/crypto/armv4cpuid.S b/src/lib/libssl/src/crypto/armv4cpuid.S
index 2d618deaa4..bdfde19c1f 100644
--- a/src/lib/libssl/src/crypto/armv4cpuid.S
+++ b/src/lib/libssl/src/crypto/armv4cpuid.S
@@ -54,38 +54,6 @@ OPENSSL_atomic_add:
54#endif 54#endif
55.size OPENSSL_atomic_add,.-OPENSSL_atomic_add 55.size OPENSSL_atomic_add,.-OPENSSL_atomic_add
56 56
57.global OPENSSL_cleanse
58.type OPENSSL_cleanse,%function
59OPENSSL_cleanse:
60 eor ip,ip,ip
61 cmp r1,#7
62 subhs r1,r1,#4
63 bhs .Lot
64 cmp r1,#0
65 beq .Lcleanse_done
66.Little:
67 strb ip,[r0],#1
68 subs r1,r1,#1
69 bhi .Little
70 b .Lcleanse_done
71
72.Lot: tst r0,#3
73 beq .Laligned
74 strb ip,[r0],#1
75 sub r1,r1,#1
76 b .Lot
77.Laligned:
78 str ip,[r0],#4
79 subs r1,r1,#4
80 bhs .Laligned
81 adds r1,r1,#4
82 bne .Little
83.Lcleanse_done:
84 tst lr,#1
85 moveq pc,lr
86 .word 0xe12fff1e @ bx lr
87.size OPENSSL_cleanse,.-OPENSSL_cleanse
88
89.global OPENSSL_wipe_cpu 57.global OPENSSL_wipe_cpu
90.type OPENSSL_wipe_cpu,%function 58.type OPENSSL_wipe_cpu,%function
91OPENSSL_wipe_cpu: 59OPENSSL_wipe_cpu:
diff --git a/src/lib/libssl/src/crypto/ia64cpuid.S b/src/lib/libssl/src/crypto/ia64cpuid.S
index 7832b9b640..517d938888 100644
--- a/src/lib/libssl/src/crypto/ia64cpuid.S
+++ b/src/lib/libssl/src/crypto/ia64cpuid.S
@@ -126,42 +126,3 @@ OPENSSL_wipe_cpu:
126 mov ar.lc=r3 126 mov ar.lc=r3
127 br.ret.sptk b0 };; 127 br.ret.sptk b0 };;
128.endp OPENSSL_wipe_cpu# 128.endp OPENSSL_wipe_cpu#
129
130.global OPENSSL_cleanse#
131.proc OPENSSL_cleanse#
132OPENSSL_cleanse:
133{ .mib; cmp.eq p6,p0=0,r33 // len==0
134#if defined(_HPUX_SOURCE) && !defined(_LP64)
135 addp4 r32=0,r32
136#endif
137(p6) br.ret.spnt b0 };;
138{ .mib; and r2=7,r32
139 cmp.leu p6,p0=15,r33 // len>=15
140(p6) br.cond.dptk .Lot };;
141
142.Little:
143{ .mib; st1 [r32]=r0,1
144 cmp.ltu p6,p7=1,r33 } // len>1
145{ .mbb; add r33=-1,r33 // len--
146(p6) br.cond.dptk .Little
147(p7) br.ret.sptk.many b0 };;
148
149.Lot:
150{ .mib; cmp.eq p6,p0=0,r2
151(p6) br.cond.dptk .Laligned };;
152{ .mmi; st1 [r32]=r0,1;;
153 and r2=7,r32 }
154{ .mib; add r33=-1,r33
155 br .Lot };;
156
157.Laligned:
158{ .mmi; st8 [r32]=r0,8
159 and r2=-8,r33 // len&~7
160 add r33=-8,r33 };; // len-=8
161{ .mib; cmp.ltu p6,p0=8,r2 // ((len+8)&~7)>8
162(p6) br.cond.dptk .Laligned };;
163
164{ .mbb; cmp.eq p6,p7=r0,r33
165(p7) br.cond.dpnt .Little
166(p6) br.ret.sptk.many b0 };;
167.endp OPENSSL_cleanse#
diff --git a/src/lib/libssl/src/crypto/pariscid.pl b/src/lib/libssl/src/crypto/pariscid.pl
index bfc56fdc7f..38985afbac 100644
--- a/src/lib/libssl/src/crypto/pariscid.pl
+++ b/src/lib/libssl/src/crypto/pariscid.pl
@@ -87,50 +87,6 @@ OPENSSL_wipe_cpu
87 .PROCEND 87 .PROCEND
88___ 88___
89{ 89{
90my $inp="%r26";
91my $len="%r25";
92
93$code.=<<___;
94 .EXPORT OPENSSL_cleanse,ENTRY,ARGW0=GR,ARGW1=GR
95 .ALIGN 8
96OPENSSL_cleanse
97 .PROC
98 .CALLINFO NO_CALLS
99 .ENTRY
100 cmpib,*= 0,$len,L\$done
101 nop
102 cmpib,*>>= 15,$len,L\$ittle
103 ldi $SIZE_T-1,%r1
104
105L\$align
106 and,*<> $inp,%r1,%r28
107 b,n L\$aligned
108 stb %r0,0($inp)
109 ldo -1($len),$len
110 b L\$align
111 ldo 1($inp),$inp
112
113L\$aligned
114 andcm $len,%r1,%r28
115L\$ot
116 $ST %r0,0($inp)
117 addib,*<> -$SIZE_T,%r28,L\$ot
118 ldo $SIZE_T($inp),$inp
119
120 and,*<> $len,%r1,$len
121 b,n L\$done
122L\$ittle
123 stb %r0,0($inp)
124 addib,*<> -1,$len,L\$ittle
125 ldo 1($inp),$inp
126L\$done
127 bv ($rp)
128 .EXIT
129 nop
130 .PROCEND
131___
132}
133{
134my ($out,$cnt,$max)=("%r26","%r25","%r24"); 90my ($out,$cnt,$max)=("%r26","%r25","%r24");
135my ($tick,$lasttick)=("%r23","%r22"); 91my ($tick,$lasttick)=("%r23","%r22");
136my ($diff,$lastdiff)=("%r21","%r20"); 92my ($diff,$lastdiff)=("%r21","%r20");
diff --git a/src/lib/libssl/src/crypto/ppccpuid.pl b/src/lib/libssl/src/crypto/ppccpuid.pl
index 4ba736a1d1..cf48714e33 100755
--- a/src/lib/libssl/src/crypto/ppccpuid.pl
+++ b/src/lib/libssl/src/crypto/ppccpuid.pl
@@ -93,38 +93,6 @@ Ladd: lwarx r5,0,r3
93 blr 93 blr
94 .long 0 94 .long 0
95 .byte 0,12,0x14,0,0,0,0,0 95 .byte 0,12,0x14,0,0,0,0,0
96
97.globl .OPENSSL_cleanse
98.align 4
99.OPENSSL_cleanse:
100 $CMPLI r4,7
101 li r0,0
102 bge Lot
103 $CMPLI r4,0
104 beqlr-
105Little: mtctr r4
106 stb r0,0(r3)
107 addi r3,r3,1
108 bdnz \$-8
109 blr
110Lot: andi. r5,r3,3
111 beq Laligned
112 stb r0,0(r3)
113 subi r4,r4,1
114 addi r3,r3,1
115 b Lot
116Laligned:
117 $SHRLI r5,r4,2
118 mtctr r5
119 stw r0,0(r3)
120 addi r3,r3,4
121 bdnz \$-8
122 andi. r4,r4,3
123 bne Little
124 blr
125 .long 0
126 .byte 0,12,0x14,0,0,0,2,0
127 .long 0
128___ 96___
129 97
130$code =~ s/\`([^\`]*)\`/eval $1/gem; 98$code =~ s/\`([^\`]*)\`/eval $1/gem;
diff --git a/src/lib/libssl/src/crypto/s390xcpuid.S b/src/lib/libssl/src/crypto/s390xcpuid.S
index 06815347e6..89bf6be82f 100644
--- a/src/lib/libssl/src/crypto/s390xcpuid.S
+++ b/src/lib/libssl/src/crypto/s390xcpuid.S
@@ -58,41 +58,6 @@ OPENSSL_wipe_cpu:
58 br %r14 58 br %r14
59.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu 59.size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu
60 60
61.globl OPENSSL_cleanse
62.type OPENSSL_cleanse,@function
63.align 16
64OPENSSL_cleanse:
65#if !defined(__s390x__) && !defined(__s390x)
66 llgfr %r3,%r3
67#endif
68 lghi %r4,15
69 lghi %r0,0
70 clgr %r3,%r4
71 jh .Lot
72 clgr %r3,%r0
73 bcr 8,%r14
74.Little:
75 stc %r0,0(%r2)
76 la %r2,1(%r2)
77 brctg %r3,.Little
78 br %r14
79.align 4
80.Lot: tmll %r2,7
81 jz .Laligned
82 stc %r0,0(%r2)
83 la %r2,1(%r2)
84 brctg %r3,.Lot
85.Laligned:
86 srlg %r4,%r3,3
87.Loop: stg %r0,0(%r2)
88 la %r2,8(%r2)
89 brctg %r4,.Loop
90 lghi %r4,7
91 ngr %r3,%r4
92 jnz .Little
93 br %r14
94.size OPENSSL_cleanse,.-OPENSSL_cleanse
95
96.section .init 61.section .init
97 brasl %r14,OPENSSL_cpuid_setup 62 brasl %r14,OPENSSL_cpuid_setup
98 63
diff --git a/src/lib/libssl/src/crypto/sparccpuid.S b/src/lib/libssl/src/crypto/sparccpuid.S
index 0cc247e489..d8b44af2f0 100644
--- a/src/lib/libssl/src/crypto/sparccpuid.S
+++ b/src/lib/libssl/src/crypto/sparccpuid.S
@@ -314,89 +314,6 @@ _sparcv9_fmadd_probe:
314.type _sparcv9_fmadd_probe,#function 314.type _sparcv9_fmadd_probe,#function
315.size _sparcv9_fmadd_probe,.-_sparcv9_fmadd_probe 315.size _sparcv9_fmadd_probe,.-_sparcv9_fmadd_probe
316 316
317.global OPENSSL_cleanse
318.align 32
319OPENSSL_cleanse:
320 cmp %o1,14
321 nop
322#ifdef ABI64
323 bgu %xcc,.Lot
324#else
325 bgu .Lot
326#endif
327 cmp %o1,0
328 bne .Little
329 nop
330 retl
331 nop
332
333.Little:
334 stb %g0,[%o0]
335 subcc %o1,1,%o1
336 bnz .Little
337 add %o0,1,%o0
338 retl
339 nop
340.align 32
341.Lot:
342#ifndef ABI64
343 subcc %g0,1,%g1
344 ! see above for explanation
345 .word 0x83408000 !rd %ccr,%g1
346 cmp %g1,0x99
347 bne .v8lot
348 nop
349#endif
350
351.v9lot: andcc %o0,7,%g0
352 bz .v9aligned
353 nop
354 stb %g0,[%o0]
355 sub %o1,1,%o1
356 ba .v9lot
357 add %o0,1,%o0
358.align 16,0x01000000
359.v9aligned:
360 .word 0xc0720000 !stx %g0,[%o0]
361 sub %o1,8,%o1
362 andcc %o1,-8,%g0
363#ifdef ABI64
364 .word 0x126ffffd !bnz %xcc,.v9aligned
365#else
366 .word 0x124ffffd !bnz %icc,.v9aligned
367#endif
368 add %o0,8,%o0
369
370 cmp %o1,0
371 bne .Little
372 nop
373 retl
374 nop
375#ifndef ABI64
376.v8lot: andcc %o0,3,%g0
377 bz .v8aligned
378 nop
379 stb %g0,[%o0]
380 sub %o1,1,%o1
381 ba .v8lot
382 add %o0,1,%o0
383 nop
384.v8aligned:
385 st %g0,[%o0]
386 sub %o1,4,%o1
387 andcc %o1,-4,%g0
388 bnz .v8aligned
389 add %o0,4,%o0
390
391 cmp %o1,0
392 bne .Little
393 nop
394 retl
395 nop
396#endif
397.type OPENSSL_cleanse,#function
398.size OPENSSL_cleanse,.-OPENSSL_cleanse
399
400.section ".init",#alloc,#execinstr 317.section ".init",#alloc,#execinstr
401 call OPENSSL_cpuid_setup 318 call OPENSSL_cpuid_setup
402 nop 319 nop
diff --git a/src/lib/libssl/src/crypto/x86_64cpuid.pl b/src/lib/libssl/src/crypto/x86_64cpuid.pl
index 6ebfd017ea..8422e91342 100644
--- a/src/lib/libssl/src/crypto/x86_64cpuid.pl
+++ b/src/lib/libssl/src/crypto/x86_64cpuid.pl
@@ -172,41 +172,6 @@ OPENSSL_ia32_cpuid:
172 or %r9,%rax 172 or %r9,%rax
173 ret 173 ret
174.size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid 174.size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid
175
176.globl OPENSSL_cleanse
177.type OPENSSL_cleanse,\@abi-omnipotent
178.align 16
179OPENSSL_cleanse:
180 xor %rax,%rax
181 cmp \$15,$arg2
182 jae .Lot
183 cmp \$0,$arg2
184 je .Lret
185.Little:
186 mov %al,($arg1)
187 sub \$1,$arg2
188 lea 1($arg1),$arg1
189 jnz .Little
190.Lret:
191 ret
192.align 16
193.Lot:
194 test \$7,$arg1
195 jz .Laligned
196 mov %al,($arg1)
197 lea -1($arg2),$arg2
198 lea 1($arg1),$arg1
199 jmp .Lot
200.Laligned:
201 mov %rax,($arg1)
202 lea -8($arg2),$arg2
203 test \$-8,$arg2
204 lea 8($arg1),$arg1
205 jnz .Laligned
206 cmp \$0,$arg2
207 jne .Little
208 ret
209.size OPENSSL_cleanse,.-OPENSSL_cleanse
210___ 175___
211 176
212print<<___ if (!$win64); 177print<<___ if (!$win64);
diff --git a/src/lib/libssl/src/crypto/x86cpuid.pl b/src/lib/libssl/src/crypto/x86cpuid.pl
index b270b44337..0da613f697 100644
--- a/src/lib/libssl/src/crypto/x86cpuid.pl
+++ b/src/lib/libssl/src/crypto/x86cpuid.pl
@@ -307,40 +307,6 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
307 } 307 }
308&function_end_B("OPENSSL_indirect_call"); 308&function_end_B("OPENSSL_indirect_call");
309 309
310&function_begin_B("OPENSSL_cleanse");
311 &mov ("edx",&wparam(0));
312 &mov ("ecx",&wparam(1));
313 &xor ("eax","eax");
314 &cmp ("ecx",7);
315 &jae (&label("lot"));
316 &cmp ("ecx",0);
317 &je (&label("ret"));
318&set_label("little");
319 &mov (&BP(0,"edx"),"al");
320 &sub ("ecx",1);
321 &lea ("edx",&DWP(1,"edx"));
322 &jnz (&label("little"));
323&set_label("ret");
324 &ret ();
325
326&set_label("lot",16);
327 &test ("edx",3);
328 &jz (&label("aligned"));
329 &mov (&BP(0,"edx"),"al");
330 &lea ("ecx",&DWP(-1,"ecx"));
331 &lea ("edx",&DWP(1,"edx"));
332 &jmp (&label("lot"));
333&set_label("aligned");
334 &mov (&DWP(0,"edx"),"eax");
335 &lea ("ecx",&DWP(-4,"ecx"));
336 &test ("ecx",-4);
337 &lea ("edx",&DWP(4,"edx"));
338 &jnz (&label("aligned"));
339 &cmp ("ecx",0);
340 &jne (&label("little"));
341 &ret ();
342&function_end_B("OPENSSL_cleanse");
343
344&function_begin_B("OPENSSL_ia32_rdrand"); 310&function_begin_B("OPENSSL_ia32_rdrand");
345 &mov ("ecx",8); 311 &mov ("ecx",8);
346&set_label("loop"); 312&set_label("loop");