From: Andy Polyakov Date: Wed, 25 Jun 2014 20:10:45 +0000 (+0200) Subject: aesv8-armx.pl: rigid input verification in key setup. X-Git-Tag: OpenSSL_1_0_2-beta2~97 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=1536bcfd567d6e369abac1fcaafd56bf7d16d7bb;p=oweals%2Fopenssl.git aesv8-armx.pl: rigid input verification in key setup. (cherry picked from commit 7b8c8c4d7973f17bbbee45d4718224c5853d9dc7) --- diff --git a/crypto/aes/asm/aesv8-armx.pl b/crypto/aes/asm/aesv8-armx.pl index 87fe446b30..923c7f62d5 100755 --- a/crypto/aes/asm/aesv8-armx.pl +++ b/crypto/aes/asm/aesv8-armx.pl @@ -70,6 +70,19 @@ $code.=<<___ if ($flavour =~ /64/); add x29,sp,#0 ___ $code.=<<___; + mov $ptr,#-1 + cmp $inp,#0 + b.eq .Lenc_key_abort + cmp $out,#0 + b.eq .Lenc_key_abort + mov $ptr,#-2 + cmp $bits,#128 + b.lt .Lenc_key_abort + cmp $bits,#256 + b.gt .Lenc_key_abort + tst $bits,#0x3f + b.ne .Lenc_key_abort + adr $ptr,rcon cmp $bits,#192 @@ -209,8 +222,10 @@ $code.=<<___; .Ldone: str $rounds,[$out] + mov $ptr,#0 - eor x0,x0,x0 // return value +.Lenc_key_abort: + mov x0,$ptr // return value `"ldr x29,[sp],#16" if ($flavour =~ /64/)` ret .size ${prefix}_set_encrypt_key,.-${prefix}_set_encrypt_key @@ -230,6 +245,9 @@ ___ $code.=<<___; bl .Lenc_key + cmp x0,#0 + b.ne .Ldec_key_abort + sub $out,$out,#240 // restore original $out mov x4,#-16 add $inp,$out,x12,lsl#4 // end of key schedule @@ -254,6 +272,7 @@ $code.=<<___; vst1.32 {v0.16b},[$inp] eor x0,x0,x0 // return value +.Ldec_key_abort: ___ $code.=<<___ if ($flavour !~ /64/); ldmia sp!,{r4,pc}