Split aes-encrypt.c and aes-decrypt.c into one file per key size.
Move aes128_encrypt and similar functions to their own files. To
make it easier for assembly implementations to override specific
AES variants.
* aes-decrypt.c: Split file, keep only legacy function aes_decrypt here.
* aes-decrypt-table.c (_nettle_aes_decrypt_table): New file, moved
table here.
* aes128-decrypt.c (aes128_decrypt): New file, moved function here.
* aes192-decrypt.c (aes192_decrypt): New file, moved function here.
* aes256-decrypt.c (aes256_decrypt): New file, moved function here.
* aes-encrypt.c: Split file, keep only legacy function aes_encrypt here.
* aes128-encrypt.c (aes128_encrypt): New file, moved function here.
* aes192-encrypt.c (aes192_encrypt): New file, moved function here.
* aes256-encrypt.c (aes256_encrypt): New file, moved function here.
* Makefile.in (nettle_SOURCES): Add new files.
Niels Möller [Sun, 28 Mar 2021 18:43:56 +0000 (20:43 +0200)]
Initial config for s390x, contributed by Mamone Tarsha.
* configure.ac: Add flag --enable-s390x-msa-x1. Add ABI check for
s390x, and setup asm_path.
* Makefile.in (distdir): Add s390x directory.
* s390x/README: New file
nettle-benchmark.c: In function ‘time_umac’:
../umac.h:42:25: warning: ‘key’ may be used uninitialized [-Wmaybe-uninitialized]
42 | #define umac32_set_key nettle_umac32_set_key
nettle-benchmark.c:395:3: note: in expansion of macro ‘umac32_set_key’
395 | umac32_set_key (&ctx32, key);
| ^~~~~~~~~~~~~~
Although this should be harmless as it's in the benchmarking code and
the content of the key doesn't matter, it wouldn't hurt to explicitly
initialize it. This patch also uses predefined constants for key
sizes.
Niels Möller [Sat, 13 Mar 2021 14:19:19 +0000 (15:19 +0100)]
Fix bug in ecc_ecdsa_verify.
* ecc-ecdsa-verify.c (ecc_ecdsa_verify): Use ecc_mod_mul_canonical
to compute the scalars used for ecc multiplication.
* testsuite/ecdsa-verify-test.c (test_main): Add test case that
triggers an assert on 64-bit platforms, without above fix.
* testsuite/ecdsa-sign-test.c (test_main): Test case generating
the same signature.
Michael Weiser [Fri, 25 Dec 2020 16:13:52 +0000 (17:13 +0100)]
arm: Unify neon asm for big- and little-endian modes
Switch arm neon assembler routines to endianness-agnostic loads and
stores where possible to avoid modifications to the rest of the code.
This involves switching to vld1.32 for loading consecutive 32-bit words
in host endianness as well as vst1.8 for storing back to memory in
little-endian order as required by the caller. Where necessary, r3 is
used to store the precalculated offset into the source vector for the
secondary load operations. vstm is kept for little-endian platforms
because it is faster than vst1 on most ARM implementations.
vst1.x (at least on the Allwinner A20 Cortex-A7 implementation) seems to
interfer with itself on subsequent calls, slowing it down further. So we
reschedule some instructions to do stores as soon as results become
available to have some other calculations or loads before the next
vst1.x. This reliably saves two additional cycles per block on salsa20
and chacha which would otherwise be incurred.
vld1.x does not seem to suffer from this or at least not to a level
where two consecutive vld1.x run slower than an equivalent vldm.
Rescheduling them similarly did not improve performance beyond that of
vldm.
Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
Niels Möller [Sun, 10 Jan 2021 19:39:49 +0000 (20:39 +0100)]
ppc: Fix use of __GLIBC_PREREQ in fat-ppc.c.
* fat-ppc.c: Don't use __GLIBC_PREREQ in the same preprocessor
conditional as defined(__GLIBC_PREREQ), but move to a nested #if
conditional. Fixes compile error on OpenBSD/powerpc64, reported by
Jasper Lievisse Adriaanse.
Niels Möller [Mon, 30 Nov 2020 18:54:10 +0000 (19:54 +0100)]
ppc: New assembly for chacha_core4, doing four blocks in parallel.
* chacha-crypt.c: (_nettle_chacha_crypt_4core)
(_nettle_chacha_crypt32_4core): New functions.
* chacha-internal.h: Add prototypes for _nettle_chacha_4core and
related functions.
* configure.ac (asm_nettle_optional_list): Add chacha-4core.asm.
* powerpc64/fat/chacha-4core.asm: New file.
* powerpc64/p7/chacha-4core.asm: New file.
* fat-ppc.c (fat_init): When altivec is available, use
_nettle_chacha_crypt_4core and _nettle_chacha_crypt32_4core
instead of _2core variants.