diff options
author | Niels Möller <nisse@lysator.liu.se> | 2020-11-24 20:55:51 +0100 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2020-11-24 20:55:51 +0100 |
commit | 87ecdf43c145b76583a3201ccfa1cfa9b93d68d4 (patch) | |
tree | 5ba88546e2b7972392f57c02533a8d999abdbb51 | |
parent | da40585672c6c113d5d9c2eefc73d21828bfe759 (diff) | |
download | nettle-87ecdf43c145b76583a3201ccfa1cfa9b93d68d4.tar.gz |
ppc: Enable _chacha_2core in fat builds.
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | chacha-crypt.c | 8 | ||||
-rw-r--r-- | chacha-internal.h | 14 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | fat-ppc.c | 27 | ||||
-rw-r--r-- | powerpc64/fat/chacha-2core.asm | 36 |
6 files changed, 93 insertions, 4 deletions
@@ -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. diff --git a/chacha-crypt.c b/chacha-crypt.c index 4c3201ff..56181092 100644 --- a/chacha-crypt.c +++ b/chacha-crypt.c @@ -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, diff --git a/chacha-internal.h b/chacha-internal.h index d298ab87..0f790459 100644 --- a/chacha-internal.h +++ b/chacha-internal.h @@ -45,8 +45,10 @@ #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 @@ -72,6 +74,12 @@ _chacha_crypt_1core(struct chacha_ctx *ctx, 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, uint8_t *dst, @@ -84,6 +92,12 @@ _chacha_crypt32_1core(struct chacha_ctx *ctx, 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, uint8_t *dst, diff --git a/configure.ac b/configure.ac index 356d5bc4..09c73a53 100644 --- a/configure.ac +++ b/configure.ac @@ -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 @@ -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 index 00000000..e4d28357 --- /dev/null +++ b/powerpc64/fat/chacha-2core.asm @@ -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') |