Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/crypto/external/bsd/openssl We can only use the SHA3 assembl...



details:   https://anonhg.NetBSD.org/src/rev/23ad2831c278
branches:  trunk
changeset: 1009071:23ad2831c278
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Apr 11 22:41:06 2020 +0000

description:
We can only use the SHA3 assembly routines if we have VSX

diffstat:

 crypto/external/bsd/openssl/dist/crypto/ppccap.c                            |  31 ++++++++++
 crypto/external/bsd/openssl/dist/crypto/sha/asm/keccak1600-ppc64.pl         |  16 ++--
 crypto/external/bsd/openssl/dist/crypto/sha/asm/keccak1600p8-ppc.pl         |  16 ++--
 crypto/external/bsd/openssl/dist/crypto/sha/keccak1600.c                    |   6 +
 crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc/keccak1600p8-ppc.S   |  12 +-
 crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc/sha.inc              |   2 +-
 crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc64/keccak1600-ppc64.S |  20 +++---
 crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc64/keccak1600p8-ppc.S |  20 +++---
 8 files changed, 80 insertions(+), 43 deletions(-)

diffs (288 lines):

diff -r fabfae3b2201 -r 23ad2831c278 crypto/external/bsd/openssl/dist/crypto/ppccap.c
--- a/crypto/external/bsd/openssl/dist/crypto/ppccap.c  Sat Apr 11 20:48:53 2020 +0000
+++ b/crypto/external/bsd/openssl/dist/crypto/ppccap.c  Sat Apr 11 22:41:06 2020 +0000
@@ -160,6 +160,37 @@
 }
 #endif
 
+size_t SHA3_absorb(uint64_t A[5][5], const unsigned char *inp, size_t len,
+    size_t r);
+void SHA3_squeeze(uint64_t A[5][5], unsigned char *out, size_t len, size_t r);
+
+size_t SHA3_absorb_default(uint64_t A[5][5], const unsigned char *inp,
+    size_t len, size_t r);
+void SHA3_squeeze_default(uint64_t A[5][5], unsigned char *out, size_t len,
+    size_t r);
+
+size_t SHA3_absorb_vsx(uint64_t A[5][5], const unsigned char *inp,
+    size_t len, size_t r);
+void SHA3_squeeze_vsx(uint64_t A[5][5], unsigned char *out, size_t len,
+    size_t r);
+
+size_t SHA3_absorb(uint64_t A[5][5], const unsigned char *inp, size_t len,
+    size_t r)
+{
+    return OPENSSL_ppccap_P & PPC_CRYPTO207
+        ? SHA3_absorb_vsx(A, inp, len, r)
+        : SHA3_absorb_default(A, inp, len, r);
+}
+
+void SHA3_squeeze(uint64_t A[5][5], unsigned char *out, size_t len, size_t r)
+{
+    OPENSSL_ppccap_P & PPC_CRYPTO207
+        ? SHA3_absorb_vsx(A, out, len, r)
+        : SHA3_squeeze_default(A, out, len, r);
+}
+
+
+
 static sigjmp_buf ill_jmp;
 static void ill_handler(int sig)
 {
diff -r fabfae3b2201 -r 23ad2831c278 crypto/external/bsd/openssl/dist/crypto/sha/asm/keccak1600-ppc64.pl
--- a/crypto/external/bsd/openssl/dist/crypto/sha/asm/keccak1600-ppc64.pl       Sat Apr 11 20:48:53 2020 +0000
+++ b/crypto/external/bsd/openssl/dist/crypto/sha/asm/keccak1600-ppc64.pl       Sat Apr 11 22:41:06 2020 +0000
@@ -405,10 +405,10 @@
        .long   0
 .size  dword_le_load,.-dword_le_load
 
-.globl SHA3_absorb
-.type  SHA3_absorb,\@function
+.globl SHA3_absorb_vsx
+.type  SHA3_absorb_vsx,\@function
 .align 5
-SHA3_absorb:
+SHA3_absorb_vsx:
        $STU    $sp,-$FRAME($sp)
        mflr    r0
        $PUSH   r14,`$FRAME-$SIZE_T*18`($sp)
@@ -627,15 +627,15 @@
        .long   0
        .byte   0,12,4,1,0x80,18,4,0
        .long   0
-.size  SHA3_absorb,.-SHA3_absorb
+.size  SHA3_absorb_vsx,.-SHA3_absorb_vsx
 ___
 {
 my ($A_flat,$out,$len,$bsz) = map("r$_",(28..31));
 $code.=<<___;
-.globl SHA3_squeeze
-.type  SHA3_squeeze,\@function
+.globl SHA3_squeeze_vsx
+.type  SHA3_squeeze_vsx,\@function
 .align 5
-SHA3_squeeze:
+SHA3_squeeze_vsx:
        $STU    $sp,`-10*$SIZE_T`($sp)
        mflr    r0
        $PUSH   r28,`6*$SIZE_T`($sp)
@@ -705,7 +705,7 @@
        .long   0
        .byte   0,12,4,1,0x80,4,4,0
        .long   0
-.size  SHA3_squeeze,.-SHA3_squeeze
+.size  SHA3_squeeze_vsx,.-SHA3_squeeze_vsx
 ___
 }
 
diff -r fabfae3b2201 -r 23ad2831c278 crypto/external/bsd/openssl/dist/crypto/sha/asm/keccak1600p8-ppc.pl
--- a/crypto/external/bsd/openssl/dist/crypto/sha/asm/keccak1600p8-ppc.pl       Sat Apr 11 20:48:53 2020 +0000
+++ b/crypto/external/bsd/openssl/dist/crypto/sha/asm/keccak1600p8-ppc.pl       Sat Apr 11 22:41:06 2020 +0000
@@ -374,10 +374,10 @@
 my ($A_jagged,$inp,$len,$bsz) = map("r$_",(3..6));
 
 $code.=<<___;
-.globl SHA3_absorb
-.type  SHA3_absorb,\@function
+.globl SHA3_absorb_vsx
+.type  SHA3_absorb_vsx,\@function
 .align 5
-SHA3_absorb:
+SHA3_absorb_vsx:
        $STU    $sp,-$FRAME($sp)
        li      r10,`15+6*$SIZE_T`
        li      r11,`31+6*$SIZE_T`
@@ -674,17 +674,17 @@
        .long   0
        .byte   0,12,0x04,1,0x80,0,4,0
        .long   0
-.size  SHA3_absorb,.-SHA3_absorb
+.size  SHA3_absorb_vsx,.-SHA3_absorb_vsx
 ___
 }
 {
 my ($A_jagged,$out,$len,$bsz) = map("r$_",(3..6));
 
 $code.=<<___;
-.globl SHA3_squeeze
-.type  SHA3_squeeze,\@function
+.globl SHA3_squeeze_vsx
+.type  SHA3_squeeze_vsx,\@function
 .align 5
-SHA3_squeeze:
+SHA3_squeeze_vsx:
        mflr    r9                      ; r9 is not touched by KeccakF1600
        subi    $out,$out,1             ; prepare for stbu
        addi    r8,$A_jagged,4          ; prepare volatiles
@@ -770,7 +770,7 @@
        .long   0
        .byte   0,12,0x14,0,0,0,4,0
        .long   0
-.size  SHA3_squeeze,.-SHA3_squeeze
+.size  SHA3_squeeze_vsx,.-SHA3_squeeze_vsx
 ___
 }
 $code.=<<___;
diff -r fabfae3b2201 -r 23ad2831c278 crypto/external/bsd/openssl/dist/crypto/sha/keccak1600.c
--- a/crypto/external/bsd/openssl/dist/crypto/sha/keccak1600.c  Sat Apr 11 20:48:53 2020 +0000
+++ b/crypto/external/bsd/openssl/dist/crypto/sha/keccak1600.c  Sat Apr 11 22:41:06 2020 +0000
@@ -11,6 +11,12 @@
 #include <string.h>
 #include <assert.h>
 
+#ifdef __powerpc__
+#define SHA3_absorb SHA3_absorb_default
+#define SHA3_squeeze SHA3_squeeze_default
+#undef KECCAK1600_ASM
+#endif
+
 size_t SHA3_absorb(uint64_t A[5][5], const unsigned char *inp, size_t len,
                    size_t r);
 void SHA3_squeeze(uint64_t A[5][5], unsigned char *out, size_t len, size_t r);
diff -r fabfae3b2201 -r 23ad2831c278 crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc/keccak1600p8-ppc.S
--- a/crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc/keccak1600p8-ppc.S Sat Apr 11 20:48:53 2020 +0000
+++ b/crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc/keccak1600p8-ppc.S Sat Apr 11 22:41:06 2020 +0000
@@ -288,11 +288,11 @@
 .byte  0,12,0x04,1,0x80,0,1,0
 .long  0
 
-.globl SHA3_absorb
-.type  SHA3_absorb,@function
+.globl SHA3_absorb_vsx
+.type  SHA3_absorb_vsx,@function
 
 .align 5
-SHA3_absorb:
+SHA3_absorb_vsx:
        stwu    1,-232(1)
        li      10,39
        li      11,55
@@ -590,11 +590,11 @@
 .byte  0,12,0x04,1,0x80,0,4,0
 .long  0
 
-.globl SHA3_squeeze
-.type  SHA3_squeeze,@function
+.globl SHA3_squeeze_vsx
+.type  SHA3_squeeze_vsx,@function
 
 .align 5
-SHA3_squeeze:
+SHA3_squeeze_vsx:
        mflr    9
        subi    4,4,1
        addi    8,3,4
diff -r fabfae3b2201 -r 23ad2831c278 crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc/sha.inc
--- a/crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc/sha.inc    Sat Apr 11 20:48:53 2020 +0000
+++ b/crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc/sha.inc    Sat Apr 11 22:41:06 2020 +0000
@@ -1,5 +1,5 @@
 .PATH.S: ${.PARSEDIR}
-SHA_SRCS = sha1-ppc.S keccak1600p8-ppc.S
+SHA_SRCS = sha1-ppc.S keccak1600p8-ppc.S keccak1600.c
 SHACPPFLAGS = -DSHA1_ASM -DKECCAK1600_ASM
 KECCAKNI = yes
 .if NOT_USING_SHAXXX_FROM_LIBC
diff -r fabfae3b2201 -r 23ad2831c278 crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc64/keccak1600-ppc64.S
--- a/crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc64/keccak1600-ppc64.S       Sat Apr 11 20:48:53 2020 +0000
+++ b/crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc64/keccak1600-ppc64.S       Sat Apr 11 22:41:06 2020 +0000
@@ -317,16 +317,16 @@
 .long  0
 
 
-.globl SHA3_absorb
-.type  SHA3_absorb,@function
+.globl SHA3_absorb_vsx
+.type  SHA3_absorb_vsx,@function
 .section       ".opd","aw"
 .align 3
-SHA3_absorb:
-.quad  .SHA3_absorb,.TOC.@tocbase,0
+SHA3_absorb_vsx:
+.quad  .SHA3_absorb_vsx,.TOC.@tocbase,0
 .previous
 
 .align 5
-.SHA3_absorb:
+.SHA3_absorb_vsx:
        stdu    1,-272(1)
        mflr    0
        std     14,128(1)
@@ -546,16 +546,16 @@
 .byte  0,12,4,1,0x80,18,4,0
 .long  0
 
-.globl SHA3_squeeze
-.type  SHA3_squeeze,@function
+.globl SHA3_squeeze_vsx
+.type  SHA3_squeeze_vsx,@function
 .section       ".opd","aw"
 .align 3
-SHA3_squeeze:
-.quad  .SHA3_squeeze,.TOC.@tocbase,0
+SHA3_squeeze_vsx:
+.quad  .SHA3_squeeze_vsx,.TOC.@tocbase,0
 .previous
 
 .align 5
-.SHA3_squeeze:
+.SHA3_squeeze_vsx:
        stdu    1,-80(1)
        mflr    0
        std     28,48(1)
diff -r fabfae3b2201 -r 23ad2831c278 crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc64/keccak1600p8-ppc.S
--- a/crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc64/keccak1600p8-ppc.S       Sat Apr 11 20:48:53 2020 +0000
+++ b/crypto/external/bsd/openssl/lib/libcrypto/arch/powerpc64/keccak1600p8-ppc.S       Sat Apr 11 22:41:06 2020 +0000
@@ -288,16 +288,16 @@
 .byte  0,12,0x04,1,0x80,0,1,0
 .long  0
 
-.globl SHA3_absorb
-.type  SHA3_absorb,@function
+.globl SHA3_absorb_vsx
+.type  SHA3_absorb_vsx,@function
 .section       ".opd","aw"
 .align 3
-SHA3_absorb:
-.quad  .SHA3_absorb,.TOC.@tocbase,0
+SHA3_absorb_vsx:
+.quad  .SHA3_absorb_vsx,.TOC.@tocbase,0
 .previous
 
 .align 5
-.SHA3_absorb:
+.SHA3_absorb_vsx:
        stdu    1,-256(1)
        li      10,63
        li      11,79
@@ -595,16 +595,16 @@
 .byte  0,12,0x04,1,0x80,0,4,0
 .long  0
 
-.globl SHA3_squeeze
-.type  SHA3_squeeze,@function
+.globl SHA3_squeeze_vsx
+.type  SHA3_squeeze_vsx,@function
 .section       ".opd","aw"
 .align 3
-SHA3_squeeze:
-.quad  .SHA3_squeeze,.TOC.@tocbase,0
+SHA3_squeeze_vsx:
+.quad  .SHA3_squeeze_vsx,.TOC.@tocbase,0
 .previous
 
 .align 5
-.SHA3_squeeze:
+.SHA3_squeeze_vsx:
        mflr    9
        subi    4,4,1
        addi    8,3,4



Home | Main Index | Thread Index | Old Index