vpaes-x86[_64].pl: handle zero length in vpaes_cbc_encrypt [from HEAD].
PR: 2775
This commit is contained in:
parent
67d216801b
commit
6296729fae
@ -843,6 +843,8 @@ $k_dsbo=0x2c0; # decryption sbox final output
|
|||||||
&mov ($out,&wparam(1)); # out
|
&mov ($out,&wparam(1)); # out
|
||||||
&mov ($round,&wparam(2)); # len
|
&mov ($round,&wparam(2)); # len
|
||||||
&mov ($key,&wparam(3)); # key
|
&mov ($key,&wparam(3)); # key
|
||||||
|
&sub ($round,16);
|
||||||
|
&jc (&label("cbc_abort"));
|
||||||
&lea ($base,&DWP(-56,"esp"));
|
&lea ($base,&DWP(-56,"esp"));
|
||||||
&mov ($const,&wparam(4)); # ivp
|
&mov ($const,&wparam(4)); # ivp
|
||||||
&and ($base,-16);
|
&and ($base,-16);
|
||||||
@ -853,7 +855,6 @@ $k_dsbo=0x2c0; # decryption sbox final output
|
|||||||
&mov (&DWP(48,"esp"),$base);
|
&mov (&DWP(48,"esp"),$base);
|
||||||
|
|
||||||
&mov (&DWP(0,"esp"),$out); # save out
|
&mov (&DWP(0,"esp"),$out); # save out
|
||||||
&sub ($round,16);
|
|
||||||
&mov (&DWP(4,"esp"),$key) # save key
|
&mov (&DWP(4,"esp"),$key) # save key
|
||||||
&mov (&DWP(8,"esp"),$const); # save ivp
|
&mov (&DWP(8,"esp"),$const); # save ivp
|
||||||
&mov ($out,$round); # $out works as $len
|
&mov ($out,$round); # $out works as $len
|
||||||
@ -896,6 +897,7 @@ $k_dsbo=0x2c0; # decryption sbox final output
|
|||||||
&mov ($base,&DWP(8,"esp")); # restore ivp
|
&mov ($base,&DWP(8,"esp")); # restore ivp
|
||||||
&mov ("esp",&DWP(48,"esp"));
|
&mov ("esp",&DWP(48,"esp"));
|
||||||
&movdqu (&QWP(0,$base),"xmm1"); # write IV
|
&movdqu (&QWP(0,$base),"xmm1"); # write IV
|
||||||
|
&set_label("cbc_abort");
|
||||||
&function_end("${PREFIX}_cbc_encrypt");
|
&function_end("${PREFIX}_cbc_encrypt");
|
||||||
|
|
||||||
&asm_finish();
|
&asm_finish();
|
||||||
|
@ -263,7 +263,7 @@ _vpaes_decrypt_core:
|
|||||||
pshufb %xmm2, %xmm4 # 4 = sbou
|
pshufb %xmm2, %xmm4 # 4 = sbou
|
||||||
pxor %xmm0, %xmm4 # 4 = sb1u + k
|
pxor %xmm0, %xmm4 # 4 = sb1u + k
|
||||||
movdqa 0x70(%r10), %xmm0 # 0 : sbot
|
movdqa 0x70(%r10), %xmm0 # 0 : sbot
|
||||||
movdqa .Lk_sr-.Lk_dsbd(%r11), %xmm2
|
movdqa -0x160(%r11), %xmm2 # .Lk_sr-.Lk_dsbd=-0x160
|
||||||
pshufb %xmm3, %xmm0 # 0 = sb1t
|
pshufb %xmm3, %xmm0 # 0 = sb1t
|
||||||
pxor %xmm4, %xmm0 # 0 = A
|
pxor %xmm4, %xmm0 # 0 = A
|
||||||
pshufb %xmm2, %xmm0
|
pshufb %xmm2, %xmm0
|
||||||
@ -869,6 +869,8 @@ ${PREFIX}_cbc_encrypt:
|
|||||||
___
|
___
|
||||||
($len,$key)=($key,$len);
|
($len,$key)=($key,$len);
|
||||||
$code.=<<___;
|
$code.=<<___;
|
||||||
|
sub \$16,$len
|
||||||
|
jc .Lcbc_abort
|
||||||
___
|
___
|
||||||
$code.=<<___ if ($win64);
|
$code.=<<___ if ($win64);
|
||||||
lea -0xb8(%rsp),%rsp
|
lea -0xb8(%rsp),%rsp
|
||||||
@ -887,7 +889,6 @@ ___
|
|||||||
$code.=<<___;
|
$code.=<<___;
|
||||||
movdqu ($ivp),%xmm6 # load IV
|
movdqu ($ivp),%xmm6 # load IV
|
||||||
sub $inp,$out
|
sub $inp,$out
|
||||||
sub \$16,$len
|
|
||||||
call _vpaes_preheat
|
call _vpaes_preheat
|
||||||
cmp \$0,${enc}d
|
cmp \$0,${enc}d
|
||||||
je .Lcbc_dec_loop
|
je .Lcbc_dec_loop
|
||||||
@ -932,6 +933,7 @@ $code.=<<___ if ($win64);
|
|||||||
.Lcbc_epilogue:
|
.Lcbc_epilogue:
|
||||||
___
|
___
|
||||||
$code.=<<___;
|
$code.=<<___;
|
||||||
|
.Lcbc_abort:
|
||||||
ret
|
ret
|
||||||
.size ${PREFIX}_cbc_encrypt,.-${PREFIX}_cbc_encrypt
|
.size ${PREFIX}_cbc_encrypt,.-${PREFIX}_cbc_encrypt
|
||||||
___
|
___
|
||||||
|
Loading…
Reference in New Issue
Block a user