diff options
author | Charalampos Mitrodimas <charalampos.mitrodimas@vrull.eu> | 2023-01-26 16:32:47 +0100 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2023-10-26 15:55:49 +0100 |
commit | db44a69aa5ce4bdc3e232ad9d7216af0eda65836 (patch) | |
tree | d2b3fd0492e15965e46cbd88eed88b67dcc3db20 /crypto | |
parent | 17073066520dbbf1ef3ce4856c570d61e9548083 (diff) |
crypto: sha512: Add mechanism to keep C code as fallback for SHA512_ASM
Currently, architectures have to decide if they want the C code or an
arch-specific implementation. Let's add a macro, that allows to keep the C
code even if SHA512_ASM is defined (but rename it from sha512_block_data_order
to sha512_block_data_order_c). The macro INCLUDE_C_SHA512 can be used by
architectures, that want the C code as fallback code.
Signed-off-by: Charalampos Mitrodimas <charalampos.mitrodimas@vrull.eu>
Signed-off-by: Christoph Müllner <christoph.muellner@vrull.eu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21923)
Diffstat (limited to 'crypto')
-rw-r--r-- | crypto/sha/sha512.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/crypto/sha/sha512.c b/crypto/sha/sha512.c index ee00b55de8..bc547d7cdc 100644 --- a/crypto/sha/sha512.c +++ b/crypto/sha/sha512.c @@ -149,6 +149,10 @@ int SHA512_Init(SHA512_CTX *c) #ifndef SHA512_ASM static +#else +# ifdef INCLUDE_C_SHA512 +void sha512_block_data_order_c(SHA512_CTX *ctx, const void *in, size_t num); +# endif #endif void sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num); @@ -338,7 +342,7 @@ void SHA512_Transform(SHA512_CTX *c, const unsigned char *data) sha512_block_data_order(c, data, 1); } -#ifndef SHA512_ASM +#if !defined(SHA512_ASM) || defined(INCLUDE_C_SHA512) static const SHA_LONG64 K512[80] = { U64(0x428a2f98d728ae22), U64(0x7137449123ef65cd), U64(0xb5c0fbcfec4d3b2f), U64(0xe9b5dba58189dbbc), @@ -737,8 +741,12 @@ static void sha512_block_data_order(SHA512_CTX *ctx, const void *in, T1 = X[(j)&0x0f] += s0 + s1 + X[(j+9)&0x0f]; \ ROUND_00_15(i+j,a,b,c,d,e,f,g,h); } while (0) +#ifdef INCLUDE_C_SHA512 +void sha512_block_data_order_c(SHA512_CTX *ctx, const void *in, size_t num) +#else static void sha512_block_data_order(SHA512_CTX *ctx, const void *in, size_t num) +#endif { const SHA_LONG64 *W = in; SHA_LONG64 a, b, c, d, e, f, g, h, s0, s1, T1; |