From a8140a42f5ee9e4e1423b5b6b319dc4657659f6f Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Tue, 11 Jun 2019 13:49:43 +0100 Subject: [PATCH] Ensure code is compiled with correct BIGNUM assembler defines Reviewed-by: Richard Levitte Reviewed-by: Shane Lontis (Merged from https://github.com/openssl/openssl/pull/9130) --- Configure | 30 ++++++++++++++++++++++++------ crypto/ppccap.c | 16 ++++++++-------- 2 files changed, 32 insertions(+), 14 deletions(-) diff --git a/Configure b/Configure index 17de50e689..e3c28f98b9 100755 --- a/Configure +++ b/Configure @@ -1407,13 +1407,31 @@ unless ($disabled{asm}) { $target{bn_asm_src} =~ s/\w+-gf2m.c// if (defined($disabled{ec2m})); # bn-586 is the only one implementing bn_*_part_words - push @{$config{lib_defines}}, "OPENSSL_BN_ASM_PART_WORDS" if ($target{bn_asm_src} =~ /bn-586/); - push @{$config{lib_defines}}, "OPENSSL_IA32_SSE2" if (!$disabled{sse2} && $target{bn_asm_src} =~ /86/); + if ($target{bn_asm_src} =~ /bn-586/) { + push @{$config{lib_defines}}, "OPENSSL_BN_ASM_PART_WORDS"; + push @{$config{module_defines}}, "OPENSSL_BN_ASM_PART_WORDS"; + } + if (!$disabled{sse2} && $target{bn_asm_src} =~ /86/) { + push @{$config{lib_defines}}, "OPENSSL_IA32_SSE2"; + push @{$config{module_defines}}, "OPENSSL_IA32_SSE2"; + } - push @{$config{lib_defines}}, "OPENSSL_BN_ASM_MONT" if ($target{bn_asm_src} =~ /-mont/); - push @{$config{lib_defines}}, "OPENSSL_BN_ASM_MONT5" if ($target{bn_asm_src} =~ /-mont5/); - push @{$config{lib_defines}}, "OPENSSL_BN_ASM_GF2m" if ($target{bn_asm_src} =~ /-gf2m/); - push @{$config{lib_defines}}, "BN_DIV3W" if ($target{bn_asm_src} =~ /-div3w/); + if ($target{bn_asm_src} =~ /-mont/) { + push @{$config{lib_defines}}, "OPENSSL_BN_ASM_MONT"; + push @{$config{module_defines}}, "OPENSSL_BN_ASM_MONT"; + } + if ($target{bn_asm_src} =~ /-mont5/) { + push @{$config{lib_defines}}, "OPENSSL_BN_ASM_MONT5"; + push @{$config{module_defines}}, "OPENSSL_BN_ASM_MONT5"; + } + if ($target{bn_asm_src} =~ /-gf2m/) { + push @{$config{lib_defines}}, "OPENSSL_BN_ASM_GF2m"; + push @{$config{module_defines}}, "OPENSSL_BN_ASM_GF2m"; + } + if ($target{bn_asm_src} =~ /-div3w/) { + push @{$config{lib_defines}}, "BN_DIV3W"; + push @{$config{module_defines}}, "BN_DIV3W"; + } if ($target{sha1_asm_src}) { push @{$config{lib_defines}}, "SHA1_ASM" if ($target{sha1_asm_src} =~ /sx86/ || $target{sha1_asm_src} =~ /sha1/); diff --git a/crypto/ppccap.c b/crypto/ppccap.c index 3465864f0a..801a2be391 100644 --- a/crypto/ppccap.c +++ b/crypto/ppccap.c @@ -38,12 +38,8 @@ unsigned int OPENSSL_ppccap_P = 0; static sigset_t all_masked; -/* - * TODO(3.0): Temporarily disabled some assembler that hasn't been brought into - * the FIPS module yet. - */ -#ifndef FIPS_MODE -# ifdef OPENSSL_BN_ASM_MONT + +#ifdef OPENSSL_BN_ASM_MONT int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num) { @@ -68,8 +64,12 @@ int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, return bn_mul_mont_int(rp, ap, bp, np, n0, num); } -# endif - +#endif +/* + * TODO(3.0): Temporarily disabled some assembler that hasn't been brought into + * the FIPS module yet. + */ +#ifndef FIPS_MODE void sha256_block_p8(void *ctx, const void *inp, size_t len); void sha256_block_ppc(void *ctx, const void *inp, size_t len); void sha256_block_data_order(void *ctx, const void *inp, size_t len); -- 2.39.2