From 71a94becd57c2fb84d531dc50aa1f1a4031889cf Mon Sep 17 00:00:00 2001 From: miod Date: Thu, 17 Apr 2014 18:16:45 +0000 Subject: [PATCH] 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? --- lib/libcrypto/alphacpuid.pl | 37 ------------- lib/libcrypto/armv4cpuid.S | 32 ----------- lib/libcrypto/crypto/Makefile | 4 +- lib/libcrypto/ia64cpuid.S | 39 ------------- lib/libcrypto/pariscid.pl | 44 --------------- lib/libcrypto/ppccpuid.pl | 32 ----------- lib/libcrypto/s390xcpuid.S | 35 ------------ lib/libcrypto/sparccpuid.S | 83 ---------------------------- lib/libcrypto/x86_64cpuid.pl | 35 ------------ lib/libcrypto/x86cpuid.pl | 34 ------------ lib/libssl/src/crypto/alphacpuid.pl | 37 ------------- lib/libssl/src/crypto/armv4cpuid.S | 32 ----------- lib/libssl/src/crypto/ia64cpuid.S | 39 ------------- lib/libssl/src/crypto/pariscid.pl | 44 --------------- lib/libssl/src/crypto/ppccpuid.pl | 32 ----------- lib/libssl/src/crypto/s390xcpuid.S | 35 ------------ lib/libssl/src/crypto/sparccpuid.S | 83 ---------------------------- lib/libssl/src/crypto/x86_64cpuid.pl | 35 ------------ lib/libssl/src/crypto/x86cpuid.pl | 34 ------------ 19 files changed, 2 insertions(+), 744 deletions(-) diff --git a/lib/libcrypto/alphacpuid.pl b/lib/libcrypto/alphacpuid.pl index 4b3cbb9827d..f6aea6a7663 100644 --- a/lib/libcrypto/alphacpuid.pl +++ b/lib/libcrypto/alphacpuid.pl @@ -86,41 +86,4 @@ OPENSSL_rdtsc: rpcc $0 ret ($26) .end OPENSSL_rdtsc - -.globl OPENSSL_cleanse -.ent OPENSSL_cleanse -OPENSSL_cleanse: - .frame $30,0,$26 - .prologue 0 - beq $17,.Ldone - and $16,7,$0 - bic $17,7,$at - beq $at,.Little - beq $0,.Laligned - -.Little: - subq $0,8,$0 - ldq_u $1,0($16) - mov $16,$2 -.Lalign: - mskbl $1,$16,$1 - lda $16,1($16) - subq $17,1,$17 - addq $0,1,$0 - beq $17,.Lout - bne $0,.Lalign -.Lout: stq_u $1,0($2) - beq $17,.Ldone - bic $17,7,$at - beq $at,.Little - -.Laligned: - stq $31,0($16) - subq $17,8,$17 - lda $16,8($16) - bic $17,7,$at - bne $at,.Laligned - bne $17,.Little -.Ldone: ret ($26) -.end OPENSSL_cleanse ___ diff --git a/lib/libcrypto/armv4cpuid.S b/lib/libcrypto/armv4cpuid.S index 2d618deaa43..bdfde19c1fc 100644 --- a/lib/libcrypto/armv4cpuid.S +++ b/lib/libcrypto/armv4cpuid.S @@ -54,38 +54,6 @@ OPENSSL_atomic_add: #endif .size OPENSSL_atomic_add,.-OPENSSL_atomic_add -.global OPENSSL_cleanse -.type OPENSSL_cleanse,%function -OPENSSL_cleanse: - eor ip,ip,ip - cmp r1,#7 - subhs r1,r1,#4 - bhs .Lot - cmp r1,#0 - beq .Lcleanse_done -.Little: - strb ip,[r0],#1 - subs r1,r1,#1 - bhi .Little - b .Lcleanse_done - -.Lot: tst r0,#3 - beq .Laligned - strb ip,[r0],#1 - sub r1,r1,#1 - b .Lot -.Laligned: - str ip,[r0],#4 - subs r1,r1,#4 - bhs .Laligned - adds r1,r1,#4 - bne .Little -.Lcleanse_done: - tst lr,#1 - moveq pc,lr - .word 0xe12fff1e @ bx lr -.size OPENSSL_cleanse,.-OPENSSL_cleanse - .global OPENSSL_wipe_cpu .type OPENSSL_wipe_cpu,%function OPENSSL_wipe_cpu: diff --git a/lib/libcrypto/crypto/Makefile b/lib/libcrypto/crypto/Makefile index 449959dc2fa..f71fe8e2c19 100644 --- a/lib/libcrypto/crypto/Makefile +++ b/lib/libcrypto/crypto/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.19 2014/04/17 18:11:46 miod Exp $ +# $OpenBSD: Makefile,v 1.20 2014/04/17 18:16:45 miod Exp $ LIB= crypto @@ -35,6 +35,7 @@ CFLAGS+= -I${LCRYPTO_SRC}/modes -I${LCRYPTO_SRC}/asn1 -I${LCRYPTO_SRC}/evp # crypto/ SRCS+= cryptlib.c malloc-wrapper.c mem_dbg.c cversion.c ex_data.c cpt_err.c SRCS+= uid.c o_time.c o_str.c o_init.c +SRCS+= mem_clr.c # aes/ SRCS+= aes_misc.c aes_ecb.c aes_cfb.c aes_ofb.c @@ -432,7 +433,6 @@ obj_dat.h: obj_mac.h .if empty (SSLASM) CFLAGS+=-DOPENSSL_NO_ASM -SRCS+= mem_clr.c SRCS+= aes_core.c aes_cbc.c SRCS+= bf_enc.c SRCS+= bn_asm.c diff --git a/lib/libcrypto/ia64cpuid.S b/lib/libcrypto/ia64cpuid.S index 7832b9b640b..517d9388881 100644 --- a/lib/libcrypto/ia64cpuid.S +++ b/lib/libcrypto/ia64cpuid.S @@ -126,42 +126,3 @@ OPENSSL_wipe_cpu: mov ar.lc=r3 br.ret.sptk b0 };; .endp OPENSSL_wipe_cpu# - -.global OPENSSL_cleanse# -.proc OPENSSL_cleanse# -OPENSSL_cleanse: -{ .mib; cmp.eq p6,p0=0,r33 // len==0 -#if defined(_HPUX_SOURCE) && !defined(_LP64) - addp4 r32=0,r32 -#endif -(p6) br.ret.spnt b0 };; -{ .mib; and r2=7,r32 - cmp.leu p6,p0=15,r33 // len>=15 -(p6) br.cond.dptk .Lot };; - -.Little: -{ .mib; st1 [r32]=r0,1 - cmp.ltu p6,p7=1,r33 } // len>1 -{ .mbb; add r33=-1,r33 // len-- -(p6) br.cond.dptk .Little -(p7) br.ret.sptk.many b0 };; - -.Lot: -{ .mib; cmp.eq p6,p0=0,r2 -(p6) br.cond.dptk .Laligned };; -{ .mmi; st1 [r32]=r0,1;; - and r2=7,r32 } -{ .mib; add r33=-1,r33 - br .Lot };; - -.Laligned: -{ .mmi; st8 [r32]=r0,8 - and r2=-8,r33 // len&~7 - add r33=-8,r33 };; // len-=8 -{ .mib; cmp.ltu p6,p0=8,r2 // ((len+8)&~7)>8 -(p6) br.cond.dptk .Laligned };; - -{ .mbb; cmp.eq p6,p7=r0,r33 -(p7) br.cond.dpnt .Little -(p6) br.ret.sptk.many b0 };; -.endp OPENSSL_cleanse# diff --git a/lib/libcrypto/pariscid.pl b/lib/libcrypto/pariscid.pl index bfc56fdc7fc..38985afbacb 100644 --- a/lib/libcrypto/pariscid.pl +++ b/lib/libcrypto/pariscid.pl @@ -87,50 +87,6 @@ OPENSSL_wipe_cpu .PROCEND ___ { -my $inp="%r26"; -my $len="%r25"; - -$code.=<<___; - .EXPORT OPENSSL_cleanse,ENTRY,ARGW0=GR,ARGW1=GR - .ALIGN 8 -OPENSSL_cleanse - .PROC - .CALLINFO NO_CALLS - .ENTRY - cmpib,*= 0,$len,L\$done - nop - cmpib,*>>= 15,$len,L\$ittle - ldi $SIZE_T-1,%r1 - -L\$align - and,*<> $inp,%r1,%r28 - b,n L\$aligned - stb %r0,0($inp) - ldo -1($len),$len - b L\$align - ldo 1($inp),$inp - -L\$aligned - andcm $len,%r1,%r28 -L\$ot - $ST %r0,0($inp) - addib,*<> -$SIZE_T,%r28,L\$ot - ldo $SIZE_T($inp),$inp - - and,*<> $len,%r1,$len - b,n L\$done -L\$ittle - stb %r0,0($inp) - addib,*<> -1,$len,L\$ittle - ldo 1($inp),$inp -L\$done - bv ($rp) - .EXIT - nop - .PROCEND -___ -} -{ my ($out,$cnt,$max)=("%r26","%r25","%r24"); my ($tick,$lasttick)=("%r23","%r22"); my ($diff,$lastdiff)=("%r21","%r20"); diff --git a/lib/libcrypto/ppccpuid.pl b/lib/libcrypto/ppccpuid.pl index 4ba736a1d1b..cf48714e338 100755 --- a/lib/libcrypto/ppccpuid.pl +++ b/lib/libcrypto/ppccpuid.pl @@ -93,38 +93,6 @@ Ladd: lwarx r5,0,r3 blr .long 0 .byte 0,12,0x14,0,0,0,0,0 - -.globl .OPENSSL_cleanse -.align 4 -.OPENSSL_cleanse: - $CMPLI r4,7 - li r0,0 - bge Lot - $CMPLI r4,0 - beqlr- -Little: mtctr r4 - stb r0,0(r3) - addi r3,r3,1 - bdnz \$-8 - blr -Lot: andi. r5,r3,3 - beq Laligned - stb r0,0(r3) - subi r4,r4,1 - addi r3,r3,1 - b Lot -Laligned: - $SHRLI r5,r4,2 - mtctr r5 - stw r0,0(r3) - addi r3,r3,4 - bdnz \$-8 - andi. r4,r4,3 - bne Little - blr - .long 0 - .byte 0,12,0x14,0,0,0,2,0 - .long 0 ___ $code =~ s/\`([^\`]*)\`/eval $1/gem; diff --git a/lib/libcrypto/s390xcpuid.S b/lib/libcrypto/s390xcpuid.S index 06815347e6a..89bf6be82f5 100644 --- a/lib/libcrypto/s390xcpuid.S +++ b/lib/libcrypto/s390xcpuid.S @@ -58,41 +58,6 @@ OPENSSL_wipe_cpu: br %r14 .size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu -.globl OPENSSL_cleanse -.type OPENSSL_cleanse,@function -.align 16 -OPENSSL_cleanse: -#if !defined(__s390x__) && !defined(__s390x) - llgfr %r3,%r3 -#endif - lghi %r4,15 - lghi %r0,0 - clgr %r3,%r4 - jh .Lot - clgr %r3,%r0 - bcr 8,%r14 -.Little: - stc %r0,0(%r2) - la %r2,1(%r2) - brctg %r3,.Little - br %r14 -.align 4 -.Lot: tmll %r2,7 - jz .Laligned - stc %r0,0(%r2) - la %r2,1(%r2) - brctg %r3,.Lot -.Laligned: - srlg %r4,%r3,3 -.Loop: stg %r0,0(%r2) - la %r2,8(%r2) - brctg %r4,.Loop - lghi %r4,7 - ngr %r3,%r4 - jnz .Little - br %r14 -.size OPENSSL_cleanse,.-OPENSSL_cleanse - .section .init brasl %r14,OPENSSL_cpuid_setup diff --git a/lib/libcrypto/sparccpuid.S b/lib/libcrypto/sparccpuid.S index 0cc247e4897..d8b44af2f0a 100644 --- a/lib/libcrypto/sparccpuid.S +++ b/lib/libcrypto/sparccpuid.S @@ -314,89 +314,6 @@ _sparcv9_fmadd_probe: .type _sparcv9_fmadd_probe,#function .size _sparcv9_fmadd_probe,.-_sparcv9_fmadd_probe -.global OPENSSL_cleanse -.align 32 -OPENSSL_cleanse: - cmp %o1,14 - nop -#ifdef ABI64 - bgu %xcc,.Lot -#else - bgu .Lot -#endif - cmp %o1,0 - bne .Little - nop - retl - nop - -.Little: - stb %g0,[%o0] - subcc %o1,1,%o1 - bnz .Little - add %o0,1,%o0 - retl - nop -.align 32 -.Lot: -#ifndef ABI64 - subcc %g0,1,%g1 - ! see above for explanation - .word 0x83408000 !rd %ccr,%g1 - cmp %g1,0x99 - bne .v8lot - nop -#endif - -.v9lot: andcc %o0,7,%g0 - bz .v9aligned - nop - stb %g0,[%o0] - sub %o1,1,%o1 - ba .v9lot - add %o0,1,%o0 -.align 16,0x01000000 -.v9aligned: - .word 0xc0720000 !stx %g0,[%o0] - sub %o1,8,%o1 - andcc %o1,-8,%g0 -#ifdef ABI64 - .word 0x126ffffd !bnz %xcc,.v9aligned -#else - .word 0x124ffffd !bnz %icc,.v9aligned -#endif - add %o0,8,%o0 - - cmp %o1,0 - bne .Little - nop - retl - nop -#ifndef ABI64 -.v8lot: andcc %o0,3,%g0 - bz .v8aligned - nop - stb %g0,[%o0] - sub %o1,1,%o1 - ba .v8lot - add %o0,1,%o0 - nop -.v8aligned: - st %g0,[%o0] - sub %o1,4,%o1 - andcc %o1,-4,%g0 - bnz .v8aligned - add %o0,4,%o0 - - cmp %o1,0 - bne .Little - nop - retl - nop -#endif -.type OPENSSL_cleanse,#function -.size OPENSSL_cleanse,.-OPENSSL_cleanse - .section ".init",#alloc,#execinstr call OPENSSL_cpuid_setup nop diff --git a/lib/libcrypto/x86_64cpuid.pl b/lib/libcrypto/x86_64cpuid.pl index 6ebfd017ea5..8422e913426 100644 --- a/lib/libcrypto/x86_64cpuid.pl +++ b/lib/libcrypto/x86_64cpuid.pl @@ -172,41 +172,6 @@ OPENSSL_ia32_cpuid: or %r9,%rax ret .size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid - -.globl OPENSSL_cleanse -.type OPENSSL_cleanse,\@abi-omnipotent -.align 16 -OPENSSL_cleanse: - xor %rax,%rax - cmp \$15,$arg2 - jae .Lot - cmp \$0,$arg2 - je .Lret -.Little: - mov %al,($arg1) - sub \$1,$arg2 - lea 1($arg1),$arg1 - jnz .Little -.Lret: - ret -.align 16 -.Lot: - test \$7,$arg1 - jz .Laligned - mov %al,($arg1) - lea -1($arg2),$arg2 - lea 1($arg1),$arg1 - jmp .Lot -.Laligned: - mov %rax,($arg1) - lea -8($arg2),$arg2 - test \$-8,$arg2 - lea 8($arg1),$arg1 - jnz .Laligned - cmp \$0,$arg2 - jne .Little - ret -.size OPENSSL_cleanse,.-OPENSSL_cleanse ___ print<<___ if (!$win64); diff --git a/lib/libcrypto/x86cpuid.pl b/lib/libcrypto/x86cpuid.pl index b270b44337d..0da613f6971 100644 --- a/lib/libcrypto/x86cpuid.pl +++ b/lib/libcrypto/x86cpuid.pl @@ -307,40 +307,6 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); } } &function_end_B("OPENSSL_indirect_call"); -&function_begin_B("OPENSSL_cleanse"); - &mov ("edx",&wparam(0)); - &mov ("ecx",&wparam(1)); - &xor ("eax","eax"); - &cmp ("ecx",7); - &jae (&label("lot")); - &cmp ("ecx",0); - &je (&label("ret")); -&set_label("little"); - &mov (&BP(0,"edx"),"al"); - &sub ("ecx",1); - &lea ("edx",&DWP(1,"edx")); - &jnz (&label("little")); -&set_label("ret"); - &ret (); - -&set_label("lot",16); - &test ("edx",3); - &jz (&label("aligned")); - &mov (&BP(0,"edx"),"al"); - &lea ("ecx",&DWP(-1,"ecx")); - &lea ("edx",&DWP(1,"edx")); - &jmp (&label("lot")); -&set_label("aligned"); - &mov (&DWP(0,"edx"),"eax"); - &lea ("ecx",&DWP(-4,"ecx")); - &test ("ecx",-4); - &lea ("edx",&DWP(4,"edx")); - &jnz (&label("aligned")); - &cmp ("ecx",0); - &jne (&label("little")); - &ret (); -&function_end_B("OPENSSL_cleanse"); - &function_begin_B("OPENSSL_ia32_rdrand"); &mov ("ecx",8); &set_label("loop"); diff --git a/lib/libssl/src/crypto/alphacpuid.pl b/lib/libssl/src/crypto/alphacpuid.pl index 4b3cbb9827d..f6aea6a7663 100644 --- a/lib/libssl/src/crypto/alphacpuid.pl +++ b/lib/libssl/src/crypto/alphacpuid.pl @@ -86,41 +86,4 @@ OPENSSL_rdtsc: rpcc $0 ret ($26) .end OPENSSL_rdtsc - -.globl OPENSSL_cleanse -.ent OPENSSL_cleanse -OPENSSL_cleanse: - .frame $30,0,$26 - .prologue 0 - beq $17,.Ldone - and $16,7,$0 - bic $17,7,$at - beq $at,.Little - beq $0,.Laligned - -.Little: - subq $0,8,$0 - ldq_u $1,0($16) - mov $16,$2 -.Lalign: - mskbl $1,$16,$1 - lda $16,1($16) - subq $17,1,$17 - addq $0,1,$0 - beq $17,.Lout - bne $0,.Lalign -.Lout: stq_u $1,0($2) - beq $17,.Ldone - bic $17,7,$at - beq $at,.Little - -.Laligned: - stq $31,0($16) - subq $17,8,$17 - lda $16,8($16) - bic $17,7,$at - bne $at,.Laligned - bne $17,.Little -.Ldone: ret ($26) -.end OPENSSL_cleanse ___ diff --git a/lib/libssl/src/crypto/armv4cpuid.S b/lib/libssl/src/crypto/armv4cpuid.S index 2d618deaa43..bdfde19c1fc 100644 --- a/lib/libssl/src/crypto/armv4cpuid.S +++ b/lib/libssl/src/crypto/armv4cpuid.S @@ -54,38 +54,6 @@ OPENSSL_atomic_add: #endif .size OPENSSL_atomic_add,.-OPENSSL_atomic_add -.global OPENSSL_cleanse -.type OPENSSL_cleanse,%function -OPENSSL_cleanse: - eor ip,ip,ip - cmp r1,#7 - subhs r1,r1,#4 - bhs .Lot - cmp r1,#0 - beq .Lcleanse_done -.Little: - strb ip,[r0],#1 - subs r1,r1,#1 - bhi .Little - b .Lcleanse_done - -.Lot: tst r0,#3 - beq .Laligned - strb ip,[r0],#1 - sub r1,r1,#1 - b .Lot -.Laligned: - str ip,[r0],#4 - subs r1,r1,#4 - bhs .Laligned - adds r1,r1,#4 - bne .Little -.Lcleanse_done: - tst lr,#1 - moveq pc,lr - .word 0xe12fff1e @ bx lr -.size OPENSSL_cleanse,.-OPENSSL_cleanse - .global OPENSSL_wipe_cpu .type OPENSSL_wipe_cpu,%function OPENSSL_wipe_cpu: diff --git a/lib/libssl/src/crypto/ia64cpuid.S b/lib/libssl/src/crypto/ia64cpuid.S index 7832b9b640b..517d9388881 100644 --- a/lib/libssl/src/crypto/ia64cpuid.S +++ b/lib/libssl/src/crypto/ia64cpuid.S @@ -126,42 +126,3 @@ OPENSSL_wipe_cpu: mov ar.lc=r3 br.ret.sptk b0 };; .endp OPENSSL_wipe_cpu# - -.global OPENSSL_cleanse# -.proc OPENSSL_cleanse# -OPENSSL_cleanse: -{ .mib; cmp.eq p6,p0=0,r33 // len==0 -#if defined(_HPUX_SOURCE) && !defined(_LP64) - addp4 r32=0,r32 -#endif -(p6) br.ret.spnt b0 };; -{ .mib; and r2=7,r32 - cmp.leu p6,p0=15,r33 // len>=15 -(p6) br.cond.dptk .Lot };; - -.Little: -{ .mib; st1 [r32]=r0,1 - cmp.ltu p6,p7=1,r33 } // len>1 -{ .mbb; add r33=-1,r33 // len-- -(p6) br.cond.dptk .Little -(p7) br.ret.sptk.many b0 };; - -.Lot: -{ .mib; cmp.eq p6,p0=0,r2 -(p6) br.cond.dptk .Laligned };; -{ .mmi; st1 [r32]=r0,1;; - and r2=7,r32 } -{ .mib; add r33=-1,r33 - br .Lot };; - -.Laligned: -{ .mmi; st8 [r32]=r0,8 - and r2=-8,r33 // len&~7 - add r33=-8,r33 };; // len-=8 -{ .mib; cmp.ltu p6,p0=8,r2 // ((len+8)&~7)>8 -(p6) br.cond.dptk .Laligned };; - -{ .mbb; cmp.eq p6,p7=r0,r33 -(p7) br.cond.dpnt .Little -(p6) br.ret.sptk.many b0 };; -.endp OPENSSL_cleanse# diff --git a/lib/libssl/src/crypto/pariscid.pl b/lib/libssl/src/crypto/pariscid.pl index bfc56fdc7fc..38985afbacb 100644 --- a/lib/libssl/src/crypto/pariscid.pl +++ b/lib/libssl/src/crypto/pariscid.pl @@ -87,50 +87,6 @@ OPENSSL_wipe_cpu .PROCEND ___ { -my $inp="%r26"; -my $len="%r25"; - -$code.=<<___; - .EXPORT OPENSSL_cleanse,ENTRY,ARGW0=GR,ARGW1=GR - .ALIGN 8 -OPENSSL_cleanse - .PROC - .CALLINFO NO_CALLS - .ENTRY - cmpib,*= 0,$len,L\$done - nop - cmpib,*>>= 15,$len,L\$ittle - ldi $SIZE_T-1,%r1 - -L\$align - and,*<> $inp,%r1,%r28 - b,n L\$aligned - stb %r0,0($inp) - ldo -1($len),$len - b L\$align - ldo 1($inp),$inp - -L\$aligned - andcm $len,%r1,%r28 -L\$ot - $ST %r0,0($inp) - addib,*<> -$SIZE_T,%r28,L\$ot - ldo $SIZE_T($inp),$inp - - and,*<> $len,%r1,$len - b,n L\$done -L\$ittle - stb %r0,0($inp) - addib,*<> -1,$len,L\$ittle - ldo 1($inp),$inp -L\$done - bv ($rp) - .EXIT - nop - .PROCEND -___ -} -{ my ($out,$cnt,$max)=("%r26","%r25","%r24"); my ($tick,$lasttick)=("%r23","%r22"); my ($diff,$lastdiff)=("%r21","%r20"); diff --git a/lib/libssl/src/crypto/ppccpuid.pl b/lib/libssl/src/crypto/ppccpuid.pl index 4ba736a1d1b..cf48714e338 100755 --- a/lib/libssl/src/crypto/ppccpuid.pl +++ b/lib/libssl/src/crypto/ppccpuid.pl @@ -93,38 +93,6 @@ Ladd: lwarx r5,0,r3 blr .long 0 .byte 0,12,0x14,0,0,0,0,0 - -.globl .OPENSSL_cleanse -.align 4 -.OPENSSL_cleanse: - $CMPLI r4,7 - li r0,0 - bge Lot - $CMPLI r4,0 - beqlr- -Little: mtctr r4 - stb r0,0(r3) - addi r3,r3,1 - bdnz \$-8 - blr -Lot: andi. r5,r3,3 - beq Laligned - stb r0,0(r3) - subi r4,r4,1 - addi r3,r3,1 - b Lot -Laligned: - $SHRLI r5,r4,2 - mtctr r5 - stw r0,0(r3) - addi r3,r3,4 - bdnz \$-8 - andi. r4,r4,3 - bne Little - blr - .long 0 - .byte 0,12,0x14,0,0,0,2,0 - .long 0 ___ $code =~ s/\`([^\`]*)\`/eval $1/gem; diff --git a/lib/libssl/src/crypto/s390xcpuid.S b/lib/libssl/src/crypto/s390xcpuid.S index 06815347e6a..89bf6be82f5 100644 --- a/lib/libssl/src/crypto/s390xcpuid.S +++ b/lib/libssl/src/crypto/s390xcpuid.S @@ -58,41 +58,6 @@ OPENSSL_wipe_cpu: br %r14 .size OPENSSL_wipe_cpu,.-OPENSSL_wipe_cpu -.globl OPENSSL_cleanse -.type OPENSSL_cleanse,@function -.align 16 -OPENSSL_cleanse: -#if !defined(__s390x__) && !defined(__s390x) - llgfr %r3,%r3 -#endif - lghi %r4,15 - lghi %r0,0 - clgr %r3,%r4 - jh .Lot - clgr %r3,%r0 - bcr 8,%r14 -.Little: - stc %r0,0(%r2) - la %r2,1(%r2) - brctg %r3,.Little - br %r14 -.align 4 -.Lot: tmll %r2,7 - jz .Laligned - stc %r0,0(%r2) - la %r2,1(%r2) - brctg %r3,.Lot -.Laligned: - srlg %r4,%r3,3 -.Loop: stg %r0,0(%r2) - la %r2,8(%r2) - brctg %r4,.Loop - lghi %r4,7 - ngr %r3,%r4 - jnz .Little - br %r14 -.size OPENSSL_cleanse,.-OPENSSL_cleanse - .section .init brasl %r14,OPENSSL_cpuid_setup diff --git a/lib/libssl/src/crypto/sparccpuid.S b/lib/libssl/src/crypto/sparccpuid.S index 0cc247e4897..d8b44af2f0a 100644 --- a/lib/libssl/src/crypto/sparccpuid.S +++ b/lib/libssl/src/crypto/sparccpuid.S @@ -314,89 +314,6 @@ _sparcv9_fmadd_probe: .type _sparcv9_fmadd_probe,#function .size _sparcv9_fmadd_probe,.-_sparcv9_fmadd_probe -.global OPENSSL_cleanse -.align 32 -OPENSSL_cleanse: - cmp %o1,14 - nop -#ifdef ABI64 - bgu %xcc,.Lot -#else - bgu .Lot -#endif - cmp %o1,0 - bne .Little - nop - retl - nop - -.Little: - stb %g0,[%o0] - subcc %o1,1,%o1 - bnz .Little - add %o0,1,%o0 - retl - nop -.align 32 -.Lot: -#ifndef ABI64 - subcc %g0,1,%g1 - ! see above for explanation - .word 0x83408000 !rd %ccr,%g1 - cmp %g1,0x99 - bne .v8lot - nop -#endif - -.v9lot: andcc %o0,7,%g0 - bz .v9aligned - nop - stb %g0,[%o0] - sub %o1,1,%o1 - ba .v9lot - add %o0,1,%o0 -.align 16,0x01000000 -.v9aligned: - .word 0xc0720000 !stx %g0,[%o0] - sub %o1,8,%o1 - andcc %o1,-8,%g0 -#ifdef ABI64 - .word 0x126ffffd !bnz %xcc,.v9aligned -#else - .word 0x124ffffd !bnz %icc,.v9aligned -#endif - add %o0,8,%o0 - - cmp %o1,0 - bne .Little - nop - retl - nop -#ifndef ABI64 -.v8lot: andcc %o0,3,%g0 - bz .v8aligned - nop - stb %g0,[%o0] - sub %o1,1,%o1 - ba .v8lot - add %o0,1,%o0 - nop -.v8aligned: - st %g0,[%o0] - sub %o1,4,%o1 - andcc %o1,-4,%g0 - bnz .v8aligned - add %o0,4,%o0 - - cmp %o1,0 - bne .Little - nop - retl - nop -#endif -.type OPENSSL_cleanse,#function -.size OPENSSL_cleanse,.-OPENSSL_cleanse - .section ".init",#alloc,#execinstr call OPENSSL_cpuid_setup nop diff --git a/lib/libssl/src/crypto/x86_64cpuid.pl b/lib/libssl/src/crypto/x86_64cpuid.pl index 6ebfd017ea5..8422e913426 100644 --- a/lib/libssl/src/crypto/x86_64cpuid.pl +++ b/lib/libssl/src/crypto/x86_64cpuid.pl @@ -172,41 +172,6 @@ OPENSSL_ia32_cpuid: or %r9,%rax ret .size OPENSSL_ia32_cpuid,.-OPENSSL_ia32_cpuid - -.globl OPENSSL_cleanse -.type OPENSSL_cleanse,\@abi-omnipotent -.align 16 -OPENSSL_cleanse: - xor %rax,%rax - cmp \$15,$arg2 - jae .Lot - cmp \$0,$arg2 - je .Lret -.Little: - mov %al,($arg1) - sub \$1,$arg2 - lea 1($arg1),$arg1 - jnz .Little -.Lret: - ret -.align 16 -.Lot: - test \$7,$arg1 - jz .Laligned - mov %al,($arg1) - lea -1($arg2),$arg2 - lea 1($arg1),$arg1 - jmp .Lot -.Laligned: - mov %rax,($arg1) - lea -8($arg2),$arg2 - test \$-8,$arg2 - lea 8($arg1),$arg1 - jnz .Laligned - cmp \$0,$arg2 - jne .Little - ret -.size OPENSSL_cleanse,.-OPENSSL_cleanse ___ print<<___ if (!$win64); diff --git a/lib/libssl/src/crypto/x86cpuid.pl b/lib/libssl/src/crypto/x86cpuid.pl index b270b44337d..0da613f6971 100644 --- a/lib/libssl/src/crypto/x86cpuid.pl +++ b/lib/libssl/src/crypto/x86cpuid.pl @@ -307,40 +307,6 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); } } &function_end_B("OPENSSL_indirect_call"); -&function_begin_B("OPENSSL_cleanse"); - &mov ("edx",&wparam(0)); - &mov ("ecx",&wparam(1)); - &xor ("eax","eax"); - &cmp ("ecx",7); - &jae (&label("lot")); - &cmp ("ecx",0); - &je (&label("ret")); -&set_label("little"); - &mov (&BP(0,"edx"),"al"); - &sub ("ecx",1); - &lea ("edx",&DWP(1,"edx")); - &jnz (&label("little")); -&set_label("ret"); - &ret (); - -&set_label("lot",16); - &test ("edx",3); - &jz (&label("aligned")); - &mov (&BP(0,"edx"),"al"); - &lea ("ecx",&DWP(-1,"ecx")); - &lea ("edx",&DWP(1,"edx")); - &jmp (&label("lot")); -&set_label("aligned"); - &mov (&DWP(0,"edx"),"eax"); - &lea ("ecx",&DWP(-4,"ecx")); - &test ("ecx",-4); - &lea ("edx",&DWP(4,"edx")); - &jnz (&label("aligned")); - &cmp ("ecx",0); - &jne (&label("little")); - &ret (); -&function_end_B("OPENSSL_cleanse"); - &function_begin_B("OPENSSL_ia32_rdrand"); &mov ("ecx",8); &set_label("loop"); -- 2.20.1