Fix sm4-xts aarch64 assembly implementation bug

Tested on kunpeng920, to turn on 'VPSM4_EX_CAPABLE'.

Signed-off-by: Liu-Ermeng <liuermeng2@huawei.com>

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23317)
This commit is contained in:
Liu-Ermeng 2024-01-16 18:04:32 -08:00 committed by Tomas Mraz
parent 387b93e149
commit 2a2561709a
3 changed files with 12 additions and 6 deletions

View File

@ -1495,7 +1495,7 @@ $code.=<<___;
mov @tweak[1].16b,@tweak[0].16b mov @tweak[1].16b,@tweak[0].16b
___ ___
&rev32_armeb(@tweak[1],@tweak[1]); &rev32_armeb(@tweak[1],@tweak[1]);
&compute_tweak_vec(@tweak[1],@tweak[2]); &compute_tweak_vec(@tweak[1],@tweak[2],$std);
$code.=<<___; $code.=<<___;
b .check_dec${std} b .check_dec${std}
@ -1505,12 +1505,12 @@ $code.=<<___;
.check_dec${std}: .check_dec${std}:
// encryption:1 decryption:0 // encryption:1 decryption:0
cmp $enc,1 cmp $enc,1
b.eq .prcess_last_2blks${std} b.eq .process_last_2blks${std}
mov @vtmp[0].16B,@tweak[1].16b mov @vtmp[0].16B,@tweak[1].16b
mov @tweak[1].16B,@tweak[2].16b mov @tweak[1].16B,@tweak[2].16b
mov @tweak[2].16B,@vtmp[0].16b mov @tweak[2].16B,@vtmp[0].16b
.prcess_last_2blks${std}: .process_last_2blks${std}:
___ ___
&rev32_armeb(@tweak[1],@tweak[1]); &rev32_armeb(@tweak[1],@tweak[1]);
&rev32_armeb(@tweak[2],@tweak[2]); &rev32_armeb(@tweak[2],@tweak[2]);

View File

@ -1469,7 +1469,7 @@ $code.=<<___;
mov @tweak[1].16b,@tweak[0].16b mov @tweak[1].16b,@tweak[0].16b
___ ___
&rev32_armeb(@tweak[1],@tweak[1]); &rev32_armeb(@tweak[1],@tweak[1]);
&compute_tweak_vec(@tweak[1],@tweak[2]); &compute_tweak_vec(@tweak[1],@tweak[2],$std);
$code.=<<___; $code.=<<___;
b .check_dec${std} b .check_dec${std}
@ -1479,12 +1479,12 @@ $code.=<<___;
.check_dec${std}: .check_dec${std}:
// encryption:1 decryption:0 // encryption:1 decryption:0
cmp $enc,1 cmp $enc,1
b.eq .prcess_last_2blks${std} b.eq .process_last_2blks${std}
mov @vtmp[0].16B,@tweak[1].16b mov @vtmp[0].16B,@tweak[1].16b
mov @tweak[1].16B,@tweak[2].16b mov @tweak[1].16B,@tweak[2].16b
mov @tweak[2].16B,@vtmp[0].16b mov @tweak[2].16B,@vtmp[0].16b
.prcess_last_2blks${std}: .process_last_2blks${std}:
___ ___
&rev32_armeb(@tweak[1],@tweak[1]); &rev32_armeb(@tweak[1],@tweak[1]);
&rev32_armeb(@tweak[2],@tweak[2]); &rev32_armeb(@tweak[2],@tweak[2]);

View File

@ -92,3 +92,9 @@ IV = F0F1F2F3F4F5F6F7F8F9FAFBFCFDFEFF
Plaintext = 6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17 Plaintext = 6BC1BEE22E409F96E93D7E117393172AAE2D8A571E03AC9C9EB76FAC45AF8E5130C81C46A35CE411E5FBC1191A0A52EFF69F2445DF4F9B17
Ciphertext = E9538251C71D7B80BBE4483FEF497BD1B3DB1A3E60408C575D63FF7DB39F83260869F9E2585FEC9F0B863BF8FD784B8627D16C0DB6D2CFC7 Ciphertext = E9538251C71D7B80BBE4483FEF497BD1B3DB1A3E60408C575D63FF7DB39F83260869F9E2585FEC9F0B863BF8FD784B8627D16C0DB6D2CFC7
XTSStandard = IEEE XTSStandard = IEEE
Cipher = SM4-XTS
Key = FFFEFDFCFBFAF9F8F7F6F5F4F3F2F1F0BFBEBDBCBBBAB9B8B7B6B5B4B3B2B1B0
IV = 9A785634120000000000000000000000
Plaintext = 000102030405060708090A0B0C0D0E0F10
Ciphertext = 9E52443A35410CA0BA5637B94C0766F469