]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Add necessary checks of OPENSSL_NO_DH, OPENSSL_NO_DSA and OPENSSL_NO_EC
authorRichard Levitte <levitte@openssl.org>
Wed, 2 Dec 2020 17:30:55 +0000 (18:30 +0100)
committerRichard Levitte <levitte@openssl.org>
Wed, 16 Dec 2020 10:56:38 +0000 (11:56 +0100)
When OpenSSL is configured with 'no-dh', 'no-dsa' and 'no-ec'
combined, some static functions have no use, which the compiler may
complain about.  We therefore add extra guards to silence it.

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/13589)

providers/implementations/encode_decode/encode_key2any.c
test/endecode_test.c
test/evp_pkey_dparams_test.c

index 30837612cc3fae0ddb83a7f5421101b4843bce19..ee2930852e223497b7a0dce7b6e11895f2a66854 100644 (file)
 #include "prov/der_rsa.h"
 #include "endecoder_local.h"
 
+#if defined(OPENSSL_NO_DH) && defined(OPENSSL_NO_DSA) && defined(OPENSSL_NO_EC)
+# define OPENSSL_NO_KEYPARAMS
+#endif
+
 struct key2any_ctx_st {
     PROV_CTX *provctx;
 
@@ -330,8 +334,7 @@ static int key_to_type_specific_pem_pub_bio(BIO *out, const void *key,
                                            p2s, k2d, ctx, NULL, NULL);
 }
 
-#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_DSA) \
-    || !defined(OPENSSL_NO_EC)
+#ifndef OPENSSL_NO_KEYPARAMS
 static int key_to_type_specific_pem_param_bio(BIO *out, const void *key,
                                               int key_nid, const char *pemname,
                                               key_to_paramstring_fn *p2s,
index 6e67dd1835ca1ad68f745717704009c15e42b9b3..ad76807d4f86539019816e7000d18f8ca17e4eb6 100644 (file)
 #include "helpers/predefined_dhparams.h"
 #include "testutil.h"
 
+#if defined(OPENSSL_NO_DH) && defined(OPENSSL_NO_DSA) && defined(OPENSSL_NO_EC)
+# define OPENSSL_NO_KEYPARAMS
+#endif
+
 #ifndef OPENSSL_NO_EC
 static BN_CTX *bnctx = NULL;
 static OSSL_PARAM_BLD *bld_prime_nc = NULL;
@@ -40,8 +44,7 @@ static OSSL_PARAM *ec_explicit_tri_params_explicit = NULL;
 # endif
 #endif
 
-#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_DSA) \
-    || !defined(OPENSSL_NO_EC)
+#ifndef OPENSSL_NO_KEYPARAMS
 static EVP_PKEY *make_template(const char *type, OSSL_PARAM *genparams)
 {
     EVP_PKEY *pkey = NULL;
@@ -513,8 +516,7 @@ static int test_unprotected_via_PEM(const char *type, EVP_PKEY *key)
                               dump_pem, 0);
 }
 
-#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_DSA) \
-    || !defined(OPENSSL_NO_EC)
+#ifndef OPENSSL_NO_KEYPARAMS
 static int check_params_DER(const char *type, const void *data, size_t data_len)
 {
     const unsigned char *datap = data;
@@ -569,7 +571,7 @@ static int test_params_via_PEM(const char *type, EVP_PKEY *key)
                               test_text, check_params_PEM,
                               dump_pem, 0);
 }
-#endif /* ndef(OPENSSL_NO_DH) || ndef(OPENSSL_NO_DSA) || ndef(OPENSSL_NO_EC) */
+#endif /* !OPENSSL_NO_KEYPARAMS */
 
 static int check_unprotected_legacy_PEM(const char *type,
                                         const void *data, size_t data_len)
index b8e9493dcaedf45edd516fee2114200dc80261db..2b6bd31a66cde12537a9e02a58a6f43e33ee48ce 100644 (file)
 #include <openssl/ec.h>
 #include "testutil.h"
 
-#ifndef OPENSSL_NO_DH
+#if defined(OPENSSL_NO_DH) && defined(OPENSSL_NO_DSA) && defined(OPENSSL_NO_EC)
+# define OPENSSL_NO_KEYPARAMS
+#endif
+
+#ifndef OPENSSL_NO_KEYPARAMS
+# ifndef OPENSSL_NO_DH
 static const unsigned char dhparam_bin[] = {
 0x30,0x82,0x01,0x08,0x02,0x82,0x01,0x01,0x00,0xc0,0xd1,0x2e,0x14,0x18,0xbd,0x03,
 0xfd,0x39,0xe1,0x99,0xf4,0x93,0x06,0x2d,0x49,0xc6,0xb5,0xb9,0xf0,0x91,0xcb,0x2f,
@@ -41,9 +46,9 @@ static const unsigned char dhparam_bin[] = {
 0x06,0x7f,0x7f,0xd7,0x7b,0x42,0x5b,0xba,0x93,0x7a,0xeb,0x43,0x5f,0xce,0x59,0x26,
 0xe8,0x76,0xdc,0xee,0xe2,0xbe,0x36,0x7a,0x83,0x02,0x01,0x02
 };
-#endif
+# endif
 
-#ifndef OPENSSL_NO_DSA
+# ifndef OPENSSL_NO_DSA
 static const unsigned char dsaparam_bin[] = {
 0x30,0x82,0x02,0x28,0x02,0x82,0x01,0x01,0x00,0xf2,0x85,0x01,0xa5,0xb9,0x56,0x65,
 0x19,0xff,0x9a,0x7d,0xf9,0x90,0xd6,0xaa,0x73,0xac,0xf7,0x94,0xfa,0x8a,0x64,0x6d,
@@ -81,29 +86,28 @@ static const unsigned char dsaparam_bin[] = {
 0x22,0x15,0xc1,0x8b,0x04,0xb9,0x8a,0xa8,0xb7,0x1b,0x62,0x44,0xc6,0xef,0x4b,0x74,
 0xd0,0xfd,0xa9,0xb4,0x4e,0xdd,0x7d,0x38,0x60,0xd1,0x40,0xcd
 };
-#endif
+# endif
 
-#ifndef OPENSSL_NO_EC
+# ifndef OPENSSL_NO_EC
 static const unsigned char ecparam_bin[] = {
 0x06,0x08,0x2a,0x86,0x48,0xce,0x3d,0x03,0x01,0x07
 };
-#endif
+# endif
 
-#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_EC)
 static const struct {
     int type;
     const unsigned char *param_bin;
     size_t param_bin_len;
 } pkey_params [] = {
-#ifndef OPENSSL_NO_DH
+# ifndef OPENSSL_NO_DH
     { EVP_PKEY_DH, dhparam_bin, sizeof(dhparam_bin) },
-#endif
-#ifndef OPENSSL_NO_DSA
+# endif
+# ifndef OPENSSL_NO_DSA
     { EVP_PKEY_DSA, dsaparam_bin, sizeof(dsaparam_bin) },
-#endif
-#ifndef OPENSSL_NO_EC
+# endif
+# ifndef OPENSSL_NO_EC
     { EVP_PKEY_EC, ecparam_bin, sizeof(ecparam_bin) }
-#endif
+# endif
 };
 
 static int params_bio_test(int id)
@@ -140,7 +144,7 @@ static int params_bio_test(int id)
 
 int setup_tests(void)
 {
-#if defined(OPENSSL_NO_DH) && defined(OPENSSL_NO_DSA) && defined(OPENSSL_NO_EC)
+#ifdef OPENSSL_NO_KEYPARAMS
     TEST_note("No DH/DSA/EC support");
 #else
     ADD_ALL_TESTS(params_bio_test, OSSL_NELEM(pkey_params));