diff options
author | Charalampos Mitrodimas <charalampos.mitrodimas@vrull.eu> | 2023-01-26 14:01:42 +0100 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2023-10-26 15:55:49 +0100 |
commit | 204a1c9854193bd7fcc3ea1baaf685c9a67d17bb (patch) | |
tree | 91c13d7a7f510219144d11b3394c886abdc1a9b6 /crypto/sha | |
parent | f6631e38f901e2a439604fac2bd62933f9dbb8ad (diff) |
crypto: sha256: Add mechanism to keep C code as fallback for SHA256_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 SHA256_ASM is defined (but rename it from sha256_block_data_order
to sha256_block_data_order_c). The macro INCLUDE_C_SHA256 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/sha')
-rw-r--r-- | crypto/sha/sha256.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/crypto/sha/sha256.c b/crypto/sha/sha256.c index 4017137c27..6ef218e86e 100644 --- a/crypto/sha/sha256.c +++ b/crypto/sha/sha256.c @@ -116,12 +116,16 @@ int SHA224_Final(unsigned char *md, SHA256_CTX *c) #define HASH_BLOCK_DATA_ORDER sha256_block_data_order #ifndef SHA256_ASM static -#endif +#else +# ifdef INCLUDE_C_SHA256 +void sha256_block_data_order_c(SHA256_CTX *ctx, const void *in, size_t num); +# endif /* INCLUDE_C_SHA256 */ +#endif /* SHA256_ASM */ void sha256_block_data_order(SHA256_CTX *ctx, const void *in, size_t num); #include "crypto/md32_common.h" -#ifndef SHA256_ASM +#if !defined(SHA256_ASM) || defined(INCLUDE_C_SHA256) static const SHA_LONG K256[64] = { 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, @@ -279,8 +283,12 @@ static void sha256_block_data_order(SHA256_CTX *ctx, const void *in, T1 = X[(i)&0x0f] += s0 + s1 + X[(i+9)&0x0f]; \ ROUND_00_15(i,a,b,c,d,e,f,g,h); } while (0) +#ifdef INCLUDE_C_SHA256 +void sha256_block_data_order_c(SHA256_CTX *ctx, const void *in, size_t num) +#else static void sha256_block_data_order(SHA256_CTX *ctx, const void *in, size_t num) +#endif { unsigned MD32_REG_T a, b, c, d, e, f, g, h, s0, s1, T1; SHA_LONG X[16]; |