Ensure code is compiled with correct BIGNUM assembler defines
authorMatt Caswell <matt@openssl.org>
Tue, 11 Jun 2019 12:49:43 +0000 (13:49 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 12 Jun 2019 08:16:43 +0000 (09:16 +0100)
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/9130)

Configure
crypto/ppccap.c

index 17de50e6897b5464ece653cec09b5737a26659e3..e3c28f98b99ad8dd630cfa23c63a6d2f735948c4 100755 (executable)
--- 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/);
index 3465864f0ab9cc1e9a08ebb65e557089c021dfa2..801a2be391c035dbe50ac32b78f5476e90c590c9 100644 (file)
@@ -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);