From: Niels Möller Date: Sat, 19 Feb 2022 21:25:57 +0000 (+0100) Subject: Update fat setup for new ghash organization. X-Git-Tag: nettle_3.8_release_20220602~20 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b80b8894049731f78163ca38fc6625230d054d0;p=thirdparty%2Fnettle.git Update fat setup for new ghash organization. --- diff --git a/ChangeLog b/ChangeLog index b53298e9..4d4921f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,19 @@ 2022-02-19 Niels Möller + * fat-x86_64.c (fat_init): Update fat init for new _ghash_set_key + and _ghash_update functions, delete setup for old gcm functions. + * fat-setup.h (ghash_set_key_func, ghash_update_func): New + typedefs. + (gcm_init_key_func, gcm_hash_func): Deleted typedefs. + * x86_64/fat/ghash-update.asm: New file. + * x86_64/fat/ghash-update-2.asm: New file. + * x86_64/fat/ghash-set-key-2.asm: New file. + * x86_64/fat/gcm-hash.asm: Deleted. + * ghash-set-key.c (_nettle_ghash_set_key_c): New name, for fat + builds. + * configure.ac (asm_nettle_optional_list): Add ghash-set-key-2.asm + ghash-update-2.asm. + * ghash-set-key.c (_ghash_digest): Deleted, and also deleted assembly implementations. * gcm.c (gcm_digest): Replace call to _ghash_digest with block16_xor. diff --git a/configure.ac b/configure.ac index 529e6cb5..dfd8f4fa 100644 --- a/configure.ac +++ b/configure.ac @@ -605,6 +605,7 @@ asm_nettle_optional_list="cpuid.asm cpu-facility.asm \ aes256-encrypt-2.asm aes256-decrypt-2.asm \ cbc-aes128-encrypt-2.asm cbc-aes192-encrypt-2.asm cbc-aes256-encrypt-2.asm \ chacha-2core.asm chacha-3core.asm chacha-4core.asm chacha-core-internal-2.asm \ + ghash-set-key-2.asm ghash-update-2.asm \ salsa20-2core.asm salsa20-core-internal-2.asm \ sha1-compress-2.asm sha256-compress-2.asm \ sha3-permute-2.asm sha512-compress-2.asm \ @@ -750,11 +751,7 @@ AH_VERBATIM([HAVE_NATIVE], #undef HAVE_NATIVE_ecc_secp384r1_redc #undef HAVE_NATIVE_ecc_secp521r1_modp #undef HAVE_NATIVE_ecc_secp521r1_redc -#undef HAVE_NATIVE_gcm_init_key -#undef HAVE_NATIVE_fat_gcm_init_key -#undef HAVE_NATIVE_gcm_hash -#undef HAVE_NATIVE_fat_gcm_hash -#undef HAVE_NATIVE_gcm_hash8 +#undef HAVE_NATIVE_ghash_set_key #undef HAVE_NATIVE_salsa20_core #undef HAVE_NATIVE_salsa20_2core #undef HAVE_NATIVE_fat_salsa20_2core diff --git a/fat-setup.h b/fat-setup.h index 64b27244..e77cce02 100644 --- a/fat-setup.h +++ b/fat-setup.h @@ -164,10 +164,10 @@ typedef void aes_crypt_internal_func (unsigned rounds, const uint32_t *keys, const uint8_t *src); struct gcm_key; -typedef void gcm_init_key_func (union nettle_block16 *table); - -typedef void gcm_hash_func (const struct gcm_key *key, union nettle_block16 *x, - size_t length, const uint8_t *data); +typedef void ghash_set_key_func (struct gcm_key *ctx, const union nettle_block16 *key); +typedef const uint8_t * +ghash_update_func (const struct gcm_key *ctx, union nettle_block16 *state, + size_t blocks, const uint8_t *data); typedef void *(memxor_func)(void *dst, const void *src, size_t n); typedef void *(memxor3_func)(void *dst_in, const void *a_in, const void *b_in, size_t n); diff --git a/fat-x86_64.c b/fat-x86_64.c index d9f72a03..47cf78ae 100644 --- a/fat-x86_64.c +++ b/fat-x86_64.c @@ -43,8 +43,7 @@ #include "nettle-types.h" #include "aes-internal.h" -#include "gcm.h" -#include "gcm-internal.h" +#include "ghash-internal.h" #include "memxor.h" #include "fat-setup.h" @@ -160,13 +159,13 @@ DECLARE_FAT_FUNC(_nettle_sha256_compress, sha256_compress_func) DECLARE_FAT_FUNC_VAR(sha256_compress, sha256_compress_func, x86_64) DECLARE_FAT_FUNC_VAR(sha256_compress, sha256_compress_func, sha_ni) -DECLARE_FAT_FUNC(_nettle_gcm_init_key, gcm_init_key_func) -DECLARE_FAT_FUNC_VAR(gcm_init_key, gcm_init_key_func, c) -DECLARE_FAT_FUNC_VAR(gcm_init_key, gcm_init_key_func, pclmul) +DECLARE_FAT_FUNC(_nettle_ghash_set_key, ghash_set_key_func) +DECLARE_FAT_FUNC_VAR(ghash_set_key, ghash_set_key_func, c) +DECLARE_FAT_FUNC_VAR(ghash_set_key, ghash_set_key_func, pclmul) -DECLARE_FAT_FUNC(_nettle_gcm_hash, gcm_hash_func) -DECLARE_FAT_FUNC_VAR(gcm_hash, gcm_hash_func, c) -DECLARE_FAT_FUNC_VAR(gcm_hash, gcm_hash_func, pclmul) +DECLARE_FAT_FUNC(_nettle_ghash_update, ghash_update_func) +DECLARE_FAT_FUNC_VAR(ghash_update, ghash_update_func, table) +DECLARE_FAT_FUNC_VAR(ghash_update, ghash_update_func, pclmul) /* This function should usually be called only once, at startup. But @@ -243,15 +242,15 @@ fat_init (void) { if (verbose) fprintf (stderr, "libnettle: using pclmulqdq instructions.\n"); - _nettle_gcm_init_key_vec = _nettle_gcm_init_key_pclmul; - _nettle_gcm_hash_vec = _nettle_gcm_hash_pclmul; + _nettle_ghash_set_key_vec = _nettle_ghash_set_key_pclmul; + _nettle_ghash_update_vec = _nettle_ghash_update_pclmul; } else { if (verbose) fprintf (stderr, "libnettle: not using pclmulqdq instructions.\n"); - _nettle_gcm_init_key_vec = _nettle_gcm_init_key_c; - _nettle_gcm_hash_vec = _nettle_gcm_hash8; + _nettle_ghash_set_key_vec = _nettle_ghash_set_key_c; + _nettle_ghash_update_vec = _nettle_ghash_update_table; } if (features.vendor == X86_INTEL) @@ -320,11 +319,10 @@ DEFINE_FAT_FUNC(_nettle_sha256_compress, void, (uint32_t *state, const uint8_t *input, const uint32_t *k), (state, input, k)) -DEFINE_FAT_FUNC(_nettle_gcm_init_key, void, - (union nettle_block16 *table), - (table)) - -DEFINE_FAT_FUNC(_nettle_gcm_hash, void, - (const struct gcm_key *key, union nettle_block16 *x, - size_t length, const uint8_t *data), - (key, x, length, data)) +DEFINE_FAT_FUNC(_nettle_ghash_set_key, void, + (struct gcm_key *ctx, const union nettle_block16 *key), + (ctx, key)) +DEFINE_FAT_FUNC(_nettle_ghash_update, const uint8_t *, + (const struct gcm_key *ctx, union nettle_block16 *state, + size_t blocks, const uint8_t *data), + (ctx, state, blocks, data)) diff --git a/ghash-set-key.c b/ghash-set-key.c index e8813a5e..0e91afcb 100644 --- a/ghash-set-key.c +++ b/ghash-set-key.c @@ -44,6 +44,13 @@ #include "ghash-internal.h" #include "block-internal.h" +/* For fat builds */ +#if HAVE_NATIVE_ghash_set_key +void +_nettle_ghash_set_key_c (struct gcm_key *ctx, const union nettle_block16 *key); +#define _nettle_ghash_set_key _nettle_ghash_set_key_c +#endif + /* Implements a lookup table for processors without carryless-mul instruction. */ void diff --git a/x86_64/fat/gcm-hash.asm b/x86_64/fat/ghash-set-key-2.asm similarity index 88% rename from x86_64/fat/gcm-hash.asm rename to x86_64/fat/ghash-set-key-2.asm index 18abc365..717027f5 100644 --- a/x86_64/fat/gcm-hash.asm +++ b/x86_64/fat/ghash-set-key-2.asm @@ -1,5 +1,4 @@ -C powerpc64/fat/gcm-hash.asm - +C x86_64/fat/ghash-set-key-2.asm ifelse(` Copyright (C) 2022 Niels Möller @@ -32,8 +31,7 @@ ifelse(` ') dnl picked up by configure -dnl PROLOGUE(_nettle_fat_gcm_init_key) -dnl PROLOGUE(_nettle_fat_gcm_hash) +dnl PROLOGUE(_nettle_ghash_set_key) define(`fat_transform', `$1_pclmul') -include_src(`x86_64/pclmul/gcm-hash.asm') +include_src(`x86_64/pclmul/ghash-set-key.asm') diff --git a/x86_64/fat/ghash-update-2.asm b/x86_64/fat/ghash-update-2.asm new file mode 100644 index 00000000..471a31ed --- /dev/null +++ b/x86_64/fat/ghash-update-2.asm @@ -0,0 +1,37 @@ +C x86_64/fat/ghash-update-2.asm + +ifelse(` + Copyright (C) 2022 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 picked up by configure +dnl PROLOGUE(_nettle_ghash_update) + +define(`fat_transform', `$1_pclmul') +include_src(`x86_64/pclmul/ghash-update.asm') diff --git a/x86_64/fat/ghash-update.asm b/x86_64/fat/ghash-update.asm new file mode 100644 index 00000000..e5edb8bf --- /dev/null +++ b/x86_64/fat/ghash-update.asm @@ -0,0 +1,37 @@ +C x86_64/fat/ghash-update.asm + +ifelse(` + Copyright (C) 2022 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 picked up by configure +dnl PROLOGUE(_nettle_ghash_update) + +define(`fat_transform', `$1_table') +include_src(`x86_64/ghash-update.asm')