From c06fb6d4607646bd36d1234a302a49994e976c24 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Niels=20M=C3=B6ller?= Date: Sun, 25 Jan 2015 21:12:24 +0100 Subject: [PATCH] Prepare for additional fat functions. --- ChangeLog | 10 ++++++++++ configure.ac | 5 ++++- fat-setup.h | 3 +++ sha1-compress.c | 7 +++++++ sha256-compress.c | 7 +++++++ 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index ad386a68..f56bd56a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,15 @@ 2015-01-25 Niels Möller + * sha1-compress.c: Prepare for fat build with C and assembly + implementations. + * sha256-compress.c: Likewise. + + * fat-setup.h (sha1_compress_func, sha256_compress_func): New typedefs. + + * configure.ac (asm_nettle_optional_list): Added + sha1-compress-2.asm and sha256-compress-2.asm, and corresponding + HAVE_NATIVE_*. + From Martin Storsjö: * arm: Add .arch directives for armv6. This allows building these files as part of a fat build, even if the assembler by default diff --git a/configure.ac b/configure.ac index ad6dfca8..5e7384d7 100644 --- a/configure.ac +++ b/configure.ac @@ -307,7 +307,8 @@ asm_replace_list="aes-encrypt-internal.asm aes-decrypt-internal.asm \ # Assembler files which generate additional object files if they are used. asm_nettle_optional_list="gcm-hash8.asm cpuid.asm \ aes-encrypt-internal-2.asm aes-decrypt-internal-2.asm memxor-2.asm \ - salsa20-core-internal-2.asm sha3-permute-2.asm sha512-compress-2.asm \ + salsa20-core-internal-2.asm sha1-compress-2.asm sha256-compress-2.asm \ + sha3-permute-2.asm sha512-compress-2.asm \ umac-nh-n-2.asm umac-nh-2.asm" asm_hogweed_optional_list="" @@ -413,6 +414,8 @@ AH_VERBATIM([HAVE_NATIVE], #undef HAVE_NATIVE_ecc_521_redc #undef HAVE_NATIVE_gcm_hash8 #undef HAVE_NATIVE_salsa20_core +#undef HAVE_NATIVE_sha1_compress +#undef HAVE_NATIVE_sha256_compress #undef HAVE_NATIVE_sha512_compress #undef HAVE_NATIVE_sha3_permute #undef HAVE_NATIVE_umac_nh diff --git a/fat-setup.h b/fat-setup.h index 7c0bbf66..09e8c371 100644 --- a/fat-setup.h +++ b/fat-setup.h @@ -154,6 +154,9 @@ typedef void *(memxor_func)(void *dst, const void *src, size_t n); typedef void salsa20_core_func (uint32_t *dst, const uint32_t *src, unsigned rounds); +typedef void sha1_compress_func(uint32_t *state, const uint8_t *input); +typedef void sha256_compress_func(uint32_t *state, const uint8_t *input, const uint32_t *k); + struct sha3_state; typedef void sha3_permute_func (struct sha3_state *state); diff --git a/sha1-compress.c b/sha1-compress.c index 769a4cfb..377b9c1e 100644 --- a/sha1-compress.c +++ b/sha1-compress.c @@ -129,6 +129,13 @@ #define subRound(a, b, c, d, e, f, k, data) \ ( e += ROTL32( 5, a ) + f( b, c, d ) + k + data, b = ROTL32( 30, b ) ) +/* For fat builds */ +#if HAVE_NATIVE_sha1_compress +void +_nettle_sha1_compress_c(uint32_t *state, const uint8_t *input); +#define _nettle_sha1_compress _nettle_sha1_compress_c +#endif + /* Perform the SHA transformation. Note that this code, like MD5, seems to break some optimizing compilers due to the complexity of the expressions and the size of the basic block. It may be necessary to split it into diff --git a/sha256-compress.c b/sha256-compress.c index 5c32f931..156c8cf9 100644 --- a/sha256-compress.c +++ b/sha256-compress.c @@ -116,6 +116,13 @@ h += S0(a) + Majority(a,b,c); \ } while (0) +/* For fat builds */ +#if HAVE_NATIVE_sha256_compress +void +_nettle_sha256_compress_c(uint32_t *state, const uint8_t *input, const uint32_t *k); +#define _nettle_sha256_compress _nettle_sha256_compress_c +#endif + void _nettle_sha256_compress(uint32_t *state, const uint8_t *input, const uint32_t *k) { -- 2.47.2