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.
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 \
#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
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);
#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"
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
{
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)
(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))
#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
-C powerpc64/fat/gcm-hash.asm
-
+C x86_64/fat/ghash-set-key-2.asm
ifelse(`
Copyright (C) 2022 Niels Möller
')
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')
--- /dev/null
+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')
--- /dev/null
+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')