diff options
author | Andy Polyakov <appro@openssl.org> | 2014-06-25 22:10:45 +0200 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2014-06-25 22:12:08 +0200 |
commit | 1536bcfd567d6e369abac1fcaafd56bf7d16d7bb (patch) | |
tree | f551fa9e1693e6c9624d16f319fa5fe017852691 /crypto/aes | |
parent | 3fc0b1edad0c75d7beb51fa77f63ffe817295e2c (diff) |
aesv8-armx.pl: rigid input verification in key setup.
(cherry picked from commit 7b8c8c4d7973f17bbbee45d4718224c5853d9dc7)
Diffstat (limited to 'crypto/aes')
-rwxr-xr-x | crypto/aes/asm/aesv8-armx.pl | 21 |
1 files changed, 20 insertions, 1 deletions
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} |