Add necessary checks of OPENSSL_NO_DH, OPENSSL_NO_DSA and OPENSSL_NO_EC

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)
This commit is contained in:
Richard Levitte 2020-12-02 18:30:55 +01:00
parent c2403f362e
commit a2e145f8db
3 changed files with 30 additions and 21 deletions

View File

@ -36,6 +36,10 @@
#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,

View File

@ -25,6 +25,10 @@
#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)

View File

@ -21,6 +21,11 @@
#include <openssl/ec.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_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,
@ -89,7 +94,6 @@ static const unsigned char ecparam_bin[] = {
};
# endif
#if !defined(OPENSSL_NO_DH) || !defined(OPENSSL_NO_DSA) || !defined(OPENSSL_NO_EC)
static const struct {
int type;
const unsigned char *param_bin;
@ -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));