]> git.ipfire.org Git - thirdparty/nettle.git/commitdiff
Update fat setup for new ghash organization.
authorNiels Möller <nisse@lysator.liu.se>
Sat, 19 Feb 2022 21:25:57 +0000 (22:25 +0100)
committerNiels Möller <nisse@lysator.liu.se>
Sat, 19 Feb 2022 21:25:57 +0000 (22:25 +0100)
ChangeLog
configure.ac
fat-setup.h
fat-x86_64.c
ghash-set-key.c
x86_64/fat/ghash-set-key-2.asm [moved from x86_64/fat/gcm-hash.asm with 88% similarity]
x86_64/fat/ghash-update-2.asm [new file with mode: 0644]
x86_64/fat/ghash-update.asm [new file with mode: 0644]

index b53298e9cc5122c192c6281d689be0782c80d018..4d4921f8c9da988deb79ad16024623d27c300dce 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,19 @@
 2022-02-19  Niels Möller  <nisse@lysator.liu.se>
 
+       * 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.
index 529e6cb5c15b964b1ea871d4c612a84b19740a23..dfd8f4fa1dc26ec4a072e74f4f18b16aca232878 100644 (file)
@@ -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
index 64b272440fde181902a80422f85cd809d1ddc425..e77cce0288a0e5cff1671e17913b2f5b0b06a757 100644 (file)
@@ -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);
index d9f72a03bc6ddcea492634175849f0388dbe09bb..47cf78ae49c06d6349d12ccea0427726cf304daa 100644 (file)
@@ -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))
index e8813a5ef98fbea59c9506b2d4d0f8a58afe83de..0e91afcbda39f921e880b1c7c75c3233a76d0a92 100644 (file)
 #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
similarity index 88%
rename from x86_64/fat/gcm-hash.asm
rename to x86_64/fat/ghash-set-key-2.asm
index 18abc365ac4e94982d4b2116ca32c5da2773a233..717027f5f7bb5d5bb074f2c4bf6bf9956b4d6b09 100644 (file)
@@ -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 (file)
index 0000000..471a31e
--- /dev/null
@@ -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 (file)
index 0000000..e5edb8b
--- /dev/null
@@ -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')