Fix SM4-XTS build failure on Mac mini M1 master
authorXu Yizhou <xuyizhou1@huawei.com>
Fri, 3 Feb 2023 07:59:59 +0000 (15:59 +0800)
committerRichard Levitte <levitte@openssl.org>
Mon, 6 Feb 2023 11:36:07 +0000 (12:36 +0100)
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20202)

crypto/sm4/asm/vpsm4-armv8.pl
crypto/sm4/asm/vpsm4_ex-armv8.pl

index cb1be122e4e08490872ea0694c64f79ad309a7bb..79219c3ab111b24fe01277d465b8eb063bd5f5bd 100755 (executable)
@@ -524,7 +524,7 @@ sub compute_tweak_vec() {
        my $std = shift;
        &rbit(@vtmp[2],$src,$std);
 $code.=<<___;
-       ldr  @qtmp[0], =0x01010101010101010101010101010187
+       ldr  @qtmp[0], .Lxts_magic
        shl  $des.16b, @vtmp[2].16b, #1
        ext  @vtmp[1].16b, @vtmp[2].16b, @vtmp[2].16b,#15
        ushr @vtmp[1].16b, @vtmp[1].16b, #7
@@ -572,6 +572,8 @@ _vpsm4_consts:
        .dword 0x56aa3350a3b1bac6,0xb27022dc677d9197
 .Lshuffles:
        .dword 0x0B0A090807060504,0x030201000F0E0D0C
+.Lxts_magic:
+       .dword 0x0101010101010187,0x0101010101010101
 
 .size  _vpsm4_consts,.-_vpsm4_consts
 ___
index 3d094aa535ee485d9de036d5f3e7b5d089f4ef1a..f2d5b6debf6102c5b5e1e5f4431b26dfc7bf84f4 100644 (file)
@@ -475,12 +475,12 @@ sub load_sbox () {
        my $data = shift;
 
 $code.=<<___;
-       ldr $MaskQ,        =0x0306090c0f0205080b0e0104070a0d00
-       ldr $TAHMatQ,   =0x22581a6002783a4062185a2042387a00
-       ldr $TALMatQ,   =0xc10bb67c4a803df715df62a89e54e923
-       ldr $ATAHMatQ,   =0x1407c6d56c7fbeadb9aa6b78c1d21300
-       ldr $ATALMatQ,   =0xe383c1a1fe9edcbc6404462679195b3b
-       ldr $ANDMaskQ,  =0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f
+       ldr $MaskQ, .Lsbox_magic
+       ldr $TAHMatQ, .Lsbox_magic+16
+       ldr $TALMatQ, .Lsbox_magic+32
+       ldr $ATAHMatQ, .Lsbox_magic+48
+       ldr $ATALMatQ, .Lsbox_magic+64
+       ldr $ANDMaskQ, .Lsbox_magic+80
 ___
 }
 
@@ -525,7 +525,7 @@ sub compute_tweak_vec() {
        my $std = shift;
        &rbit(@vtmp[2],$src,$std);
 $code.=<<___;
-       ldr  @qtmp[0], =0x01010101010101010101010101010187
+       ldr  @qtmp[0], .Lxts_magic
        shl  $des.16b, @vtmp[2].16b, #1
        ext  @vtmp[1].16b, @vtmp[2].16b, @vtmp[2].16b,#15
        ushr @vtmp[1].16b, @vtmp[1].16b, #7
@@ -556,6 +556,15 @@ _${prefix}_consts:
        .dword 0x56aa3350a3b1bac6,0xb27022dc677d9197
 .Lshuffles:
        .dword 0x0B0A090807060504,0x030201000F0E0D0C
+.Lxts_magic:
+       .dword 0x0101010101010187,0x0101010101010101
+.Lsbox_magic:
+       .dword 0x0b0e0104070a0d00,0x0306090c0f020508
+       .dword 0x62185a2042387a00,0x22581a6002783a40
+       .dword 0x15df62a89e54e923,0xc10bb67c4a803df7
+       .dword 0xb9aa6b78c1d21300,0x1407c6d56c7fbead
+       .dword 0x6404462679195b3b,0xe383c1a1fe9edcbc
+       .dword 0x0f0f0f0f0f0f0f0f,0x0f0f0f0f0f0f0f0f
 
 .size  _${prefix}_consts,.-_${prefix}_consts
 ___