From 859ceeeb5174ce50842112c05230cebb59702e83 Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Sun, 18 Jul 2004 17:26:01 +0000 Subject: [PATCH] Anchor AES and SHA-256/-512 assembler from C. --- crypto/aes/aes_core.c | 2 ++ crypto/bn/asm/bn-586.pl | 3 ++- crypto/sha/sha256.c | 4 ++++ crypto/sha/sha512.c | 8 +++++++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/crypto/aes/aes_core.c b/crypto/aes/aes_core.c index 2f41a825f8..29e41edd10 100644 --- a/crypto/aes/aes_core.c +++ b/crypto/aes/aes_core.c @@ -873,6 +873,7 @@ int AES_set_decrypt_key(const unsigned char *userKey, const int bits, return 0; } +#ifndef AES_ASM /* * Encrypt a single block * in and out can overlap @@ -1255,3 +1256,4 @@ void AES_decrypt(const unsigned char *in, unsigned char *out, PUTU32(out + 12, s3); } +#endif /* AES_ASM */ diff --git a/crypto/bn/asm/bn-586.pl b/crypto/bn/asm/bn-586.pl index 9a7c64c464..0415015f65 100644 --- a/crypto/bn/asm/bn-586.pl +++ b/crypto/bn/asm/bn-586.pl @@ -5,7 +5,8 @@ require "x86asm.pl"; &asm_init($ARGV[0],$0); -$sse2=0; # SSE2 is temporarily disabled... +$sse2=0; +for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); } &bn_mul_add_words("bn_mul_add_words"); &bn_mul_words("bn_mul_words"); diff --git a/crypto/sha/sha256.c b/crypto/sha/sha256.c index 2f4078f444..21aa5d7d0d 100644 --- a/crypto/sha/sha256.c +++ b/crypto/sha/sha256.c @@ -117,6 +117,9 @@ void sha256_block_data_order (SHA256_CTX *ctx, const void *in, size_t num); #include "md32_common.h" +#ifdef SHA256_ASM +void sha256_block (SHA256_CTX *ctx, const void *in, size_t num, int host); +#else static const SHA_LONG K256[64] = { 0x428a2f98UL,0x71374491UL,0xb5c0fbcfUL,0xe9b5dba5UL, 0x3956c25bUL,0x59f111f1UL,0x923f82a4UL,0xab1c5ed5UL, @@ -296,6 +299,7 @@ static void sha256_block (SHA256_CTX *ctx, const void *in, size_t num, int host) } #endif +#endif /* SHA256_ASM */ /* * Idea is to trade couple of cycles for some space. On IA-32 we save diff --git a/crypto/sha/sha512.c b/crypto/sha/sha512.c index dc1047d59e..5f7a8dee6d 100644 --- a/crypto/sha/sha512.c +++ b/crypto/sha/sha512.c @@ -83,7 +83,10 @@ int SHA512_Init (SHA512_CTX *c) return 1; } -static void sha512_block (SHA512_CTX *ctx, const void *in, size_t num); +#ifndef SHA512_ASM +static +#endif +void sha512_block (SHA512_CTX *ctx, const void *in, size_t num); int SHA512_Final (unsigned char *md, SHA512_CTX *c) { @@ -241,6 +244,7 @@ unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md) return(md); } +#ifndef SHA512_ASM static const SHA_LONG64 K512[80] = { U64(0x428a2f98d728ae22),U64(0x7137449123ef65cd), U64(0xb5c0fbcfec4d3b2f),U64(0xe9b5dba58189dbbc), @@ -476,3 +480,5 @@ static void sha512_block (SHA512_CTX *ctx, const void *in, size_t num) } #endif + +#endif /* SHA512_ASM */ -- GitLab