]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
ppc: Enable _chacha_2core in fat builds.
authorNiels Möller <nisse@lysator.liu.se>
Tue, 24 Nov 2020 19:55:51 +0000 (20:55 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Tue, 24 Nov 2020 19:55:51 +0000 (20:55 +0100)
ChangeLog
chacha-crypt.c
chacha-internal.h
configure.ac
fat-ppc.c
powerpc64/fat/chacha-2core.asm [new file with mode: 0644]

index 0c2f45e2e521277ff41b145951d1675555201d0e..4c91ccbced36959290f959b3f2c4b921f08745a6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2020-11-24  Niels Möller  <nisse@lysator.liu.se>
+
+       Enable ppc chacha_2core in fat builds.
+       * configure.ac: Add HAVE_NATIVE_fat_chacha_2core.
+       * chacha-crypt.c: Check HAVE_NATIVE_fat_chacha_2core.
+       * chacha-internal.h (_chacha_crypt_2core, _chacha_crypt32_2core):
+       Add declarations.
+       * fat-ppc.c (fat_init): Use _nettle_chacha_crypt_2core and
+       _nettle_chacha_crypt32_2core when altivec is available.
+       * powerpc64/fat/chacha-2core.asm: New file, including p7 version.
+
 2020-11-23  Niels Möller  <nisse@lysator.liu.se>
 
        * powerpc64/p7/chacha-2core.asm: New file.
index 4c3201ffac8b5e417115b2334b5cfd2b81f36164..5618109248a4280425dfd06e739e0bbb81164db7 100644 (file)
@@ -62,7 +62,7 @@
 #elif HAVE_NATIVE_chacha_2core
 #define _chacha_crypt_2core chacha_crypt
 #define _chacha_crypt32_2core chacha_crypt32
-#elif !HAVE_NATIVE_fat_chacha_3core
+#elif !(HAVE_NATIVE_fat_chacha_3core || HAVE_NATIVE_fat_chacha_2core)
 #undef _chacha_crypt_1core
 #undef _chacha_crypt32_1core
 #define _chacha_crypt_1core chacha_crypt
@@ -112,7 +112,7 @@ _chacha_crypt_3core(struct chacha_ctx *ctx,
 }
 #endif
 
-#if HAVE_NATIVE_chacha_2core
+#if HAVE_NATIVE_chacha_2core || HAVE_NATIVE_fat_chacha_2core
 void
 _chacha_crypt_2core(struct chacha_ctx *ctx,
                    size_t length,
@@ -224,7 +224,7 @@ _chacha_crypt32_3core(struct chacha_ctx *ctx,
 }
 #endif
 
-#if HAVE_NATIVE_chacha_2core
+#if HAVE_NATIVE_chacha_2core || HAVE_NATIVE_fat_chacha_2core
 void
 _chacha_crypt32_2core(struct chacha_ctx *ctx,
                    size_t length,
@@ -258,7 +258,7 @@ _chacha_crypt32_2core(struct chacha_ctx *ctx,
 }
 #endif
 
-#if !HAVE_NATIVE_chacha_3core
+#if !(HAVE_NATIVE_chacha_3core || HAVE_NATIVE_chacha_2core)
 void
 _chacha_crypt32_1core(struct chacha_ctx *ctx,
                      size_t length,
index d298ab875f6a6a8aa8446914f4cead8a32fc64ec..0f790459f6b5472c100e742dc8b1d655e91f4e5e 100644 (file)
 #define _chacha_3core _nettle_chacha_3core
 #define _chacha_3core32 _nettle_chacha_3core32
 #define _chacha_crypt_1core _nettle_chacha_crypt_1core
+#define _chacha_crypt_2core _nettle_chacha_crypt_2core
 #define _chacha_crypt_3core _nettle_chacha_crypt_3core
 #define _chacha_crypt32_1core _nettle_chacha_crypt32_1core
+#define _chacha_crypt32_2core _nettle_chacha_crypt32_2core
 #define _chacha_crypt32_3core _nettle_chacha_crypt32_3core
 
 void
@@ -71,6 +73,12 @@ _chacha_crypt_1core(struct chacha_ctx *ctx,
                    uint8_t *dst,
                    const uint8_t *src);
 
+void
+_chacha_crypt_2core(struct chacha_ctx *ctx,
+                   size_t length,
+                   uint8_t *dst,
+                   const uint8_t *src);
+
 void
 _chacha_crypt_3core(struct chacha_ctx *ctx,
                    size_t length,
@@ -83,6 +91,12 @@ _chacha_crypt32_1core(struct chacha_ctx *ctx,
                      uint8_t *dst,
                      const uint8_t *src);
 
+void
+_chacha_crypt32_2core(struct chacha_ctx *ctx,
+                     size_t length,
+                     uint8_t *dst,
+                     const uint8_t *src);
+
 void
 _chacha_crypt32_3core(struct chacha_ctx *ctx,
                      size_t length,
index 356d5bc4f7ca440e0c362f36372e0ae0e102c3e4..09c73a53c35de89e9b9617bc019b218f9caa5436 100644 (file)
@@ -609,6 +609,7 @@ AH_VERBATIM([HAVE_NATIVE],
 #undef HAVE_NATIVE_chacha_core
 #undef HAVE_NATIVE_chacha_2core
 #undef HAVE_NATIVE_chacha_3core
+#undef HAVE_NATIVE_fat_chacha_2core
 #undef HAVE_NATIVE_fat_chacha_3core
 #undef HAVE_NATIVE_ecc_curve25519_modp
 #undef HAVE_NATIVE_ecc_curve448_modp
index 7b12e54a28de0495b4ede3ebc7279e4fe23a1ae1..2839747330e3e57e61166c17bc59e4ca13850d80 100644 (file)
--- a/fat-ppc.c
+++ b/fat-ppc.c
@@ -60,6 +60,7 @@
 #include "nettle-types.h"
 
 #include "aes-internal.h"
+#include "chacha-internal.h"
 #include "gcm.h"
 #include "fat-setup.h"
 
@@ -152,6 +153,14 @@ DECLARE_FAT_FUNC(_nettle_chacha_core, chacha_core_func)
 DECLARE_FAT_FUNC_VAR(chacha_core, chacha_core_func, c);
 DECLARE_FAT_FUNC_VAR(chacha_core, chacha_core_func, altivec);
 
+DECLARE_FAT_FUNC(nettle_chacha_crypt, chacha_crypt_func)
+DECLARE_FAT_FUNC_VAR(chacha_crypt, chacha_crypt_func, 1core)
+DECLARE_FAT_FUNC_VAR(chacha_crypt, chacha_crypt_func, 3core)
+
+DECLARE_FAT_FUNC(nettle_chacha_crypt32, chacha_crypt_func)
+DECLARE_FAT_FUNC_VAR(chacha_crypt32, chacha_crypt_func, 1core)
+DECLARE_FAT_FUNC_VAR(chacha_crypt32, chacha_crypt_func, 3core)
+
 static void CONSTRUCTOR
 fat_init (void)
 {
@@ -182,10 +191,14 @@ fat_init (void)
       if (verbose)
        fprintf (stderr, "libnettle: enabling altivec code.\n");
       _nettle_chacha_core_vec = _nettle_chacha_core_altivec;
+      nettle_chacha_crypt_vec = _nettle_chacha_crypt_2core;
+      nettle_chacha_crypt32_vec = _nettle_chacha_crypt32_2core;
     }
   else
     {
       _nettle_chacha_core_vec = _nettle_chacha_core_c;
+      nettle_chacha_crypt_vec = _nettle_chacha_crypt_1core;
+      nettle_chacha_crypt32_vec = _nettle_chacha_crypt32_1core;
     }
 }
 
@@ -206,3 +219,17 @@ DEFINE_FAT_FUNC(_nettle_aes_decrypt, void,
 DEFINE_FAT_FUNC(_nettle_chacha_core, void,
                (uint32_t *dst, const uint32_t *src, unsigned rounds),
                (dst, src, rounds))
+
+DEFINE_FAT_FUNC(nettle_chacha_crypt, void,
+               (struct chacha_ctx *ctx,
+                size_t length,
+                uint8_t *dst,
+                const uint8_t *src),
+               (ctx, length, dst, src))
+
+DEFINE_FAT_FUNC(nettle_chacha_crypt32, void,
+               (struct chacha_ctx *ctx,
+                size_t length,
+                uint8_t *dst,
+                const uint8_t *src),
+               (ctx, length, dst, src))
diff --git a/powerpc64/fat/chacha-2core.asm b/powerpc64/fat/chacha-2core.asm
new file mode 100644 (file)
index 0000000..e4d2835
--- /dev/null
@@ -0,0 +1,36 @@
+C powerpc64/fat/chacha-2core.asm
+
+
+ifelse(`
+   Copyright (C) 2020 Niels Möller
+
+   This file is part of GNU Nettle.
+
+   GNU Nettle is free software: you can redistribute it and/or
+   modify it under the terms of either:
+
+     * the GNU Lesser General Public License as published by the Free
+       Software Foundation; either version 3 of the License, or (at your
+       option) any later version.
+
+   or
+
+     * the GNU General Public License as published by the Free
+       Software Foundation; either version 2 of the License, or (at your
+       option) any later version.
+
+   or both in parallel, as here.
+
+   GNU Nettle is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received copies of the GNU General Public License and
+   the GNU Lesser General Public License along with this program.  If
+   not, see http://www.gnu.org/licenses/.
+')
+
+dnl PROLOGUE(_nettle_fat_chacha_2core) picked up by configure
+
+include_src(`powerpc64/p7/chacha-2core.asm')