]> granicus.if.org Git - openssl/commitdiff
Make assembly language versions of OPENSSL_cleanse() accept zero length
authorDr. Stephen Henson <steve@openssl.org>
Fri, 12 Feb 2010 17:02:13 +0000 (17:02 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Fri, 12 Feb 2010 17:02:13 +0000 (17:02 +0000)
parameter. Backport from HEAD, orginal by appro.

crypto/alphacpuid.s
crypto/ia64cpuid.S
crypto/perlasm/ppc-xlate.pl
crypto/ppccpuid.pl
crypto/s390xcpuid.S
crypto/sparccpuid.S
crypto/x86_64cpuid.pl
crypto/x86cpuid.pl

index b13b3cdb3c058c9126bbc82b7e563455c1a6585d..3fa77a0ade5b1415080cbe95e8468d51e88a4471 100644 (file)
@@ -90,6 +90,7 @@ OPENSSL_rdtsc:
 OPENSSL_cleanse:
        .frame  $30,0,$26
        .prologue 0
+       beq     $17,.Ldone
        and     $16,7,$0
        bic     $17,7,$at
        beq     $at,.Little
index 1a03b028fcee8ab90fca61acd174d1e038311095..d705fff7ee7cfee9a4e901a2696627ed107f91a9 100644 (file)
@@ -130,9 +130,11 @@ 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)
-{ .mmi;        addp4           r32=0,r32       };;
+       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            };;
index 755524c9cff6b46bcc6ab327199f4e03f6d0acd9..4579671c9701107d0bf04c59a81fc3fde010d01b 100755 (executable)
@@ -101,6 +101,13 @@ my $bnelr = sub {
        "       .long   ".sprintf "0x%x",19<<26|$bo<<21|2<<16|16<<1 :
        "       bclr    $bo,2";
 };
+my $beqlr = sub {
+    my $f = shift;
+    my $bo = $f=~/-/ ? 12+2 : 12;      # optional "not to be taken" hint
+    ($flavour =~ /linux/) ?            # GNU as doesn't allow most recent hints
+       "       .long   ".sprintf "0x%X",19<<26|$bo<<21|2<<16|16<<1 :
+       "       bclr    $bo,2";
+};
 # GNU assembler can't handle extrdi rA,rS,16,48, or when sum of last two
 # arguments is 64, with "operand out of range" error.
 my $extrdi = sub {
index fe44ff07bc6040c9841c7837e9a2f3312082508e..369e1d0df932c66022b970db3f61d117385e2574 100755 (executable)
@@ -67,6 +67,8 @@ Loop: lwarx   r5,0,r3
        $CMPLI  r4,7
        li      r0,0
        bge     Lot
+       $CMPLI  r4,0
+       beqlr-
 Little:        mtctr   r4
        stb     r0,0(r3)
        addi    r3,r3,1
index aa704c033a426021ce4a0b75bc70d476a6c36341..b053c6a28190ca4d4c83b74b6b4b603efb184d6d 100644 (file)
@@ -62,6 +62,8 @@ OPENSSL_cleanse:
        lghi    %r0,0
        clgr    %r3,%r4
        jh      .Lot
+       clgr    %r3,%r0
+       bcr     8,%r14
 .Little:
        stc     %r0,0(%r2)
        la      %r2,1(%r2)
index 4691bd72bb3a6b32ca164cf7694b85d391e0f9ef..bcf46f209d43f89b5769a7ddb4e79c1e6d0cfa91 100644 (file)
@@ -242,6 +242,10 @@ OPENSSL_cleanse:
 #else
        bgu     .Lot
 #endif
+       cmp     %o1,0
+       bne     .Little
+       nop
+       retl
        nop
 
 .Little:
index 862118f285858439384cbed181c056bd6b58501d..a7f98b3fd361c60bd0e2657fa054d9badd52b304 100644 (file)
@@ -145,12 +145,14 @@ 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
-       ret
+.Lret: ret
 .align 16
 .Lot:
        test    \$7,$arg1
index e5dcc5812485d407b0b28059bc18c8874e6c082e..a7464af19b771d48aca8b3669e827ff843d29c82 100644 (file)
@@ -279,11 +279,14 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); }
        &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);