From fc75ab33401718fab3a79b19698eefb70a617a83 Mon Sep 17 00:00:00 2001 From: Selva Nair Date: Wed, 27 Jul 2022 18:18:30 -0400 Subject: [PATCH] xkey_provider: fix building with --disable-management v2: also fix building test_provider - ifdefs in test_provider.c - include integer.h for min_int as manage.h may not always pull it in Too many ifdefs, unfortunately.. Signed-off-by: Selva Nair Acked-by: Frank Lichtenheld Message-Id: <20220727221830.31861-1-selva.nair@gmail.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24749.html Signed-off-by: Gert Doering --- src/openvpn/xkey_helper.c | 4 ++++ tests/unit_tests/openvpn/test_provider.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/src/openvpn/xkey_helper.c b/src/openvpn/xkey_helper.c index 81dd71dc0..27e87d79e 100644 --- a/src/openvpn/xkey_helper.c +++ b/src/openvpn/xkey_helper.c @@ -85,6 +85,7 @@ xkey_digest(const unsigned char *src, size_t srclen, unsigned char *buf, return 1; } +#ifdef ENABLE_MANAGEMENT /** * Load external key for signing via management interface. * The public key must be passed in by the caller as we may not @@ -107,6 +108,7 @@ xkey_load_management_key(OSSL_LIB_CTX *libctx, EVP_PKEY *pubkey) return xkey_load_generic_key(libctx, dummy, pubkey, sign_op, NULL); } +#endif /** * Load a generic key into the xkey provider. @@ -147,6 +149,7 @@ xkey_load_generic_key(OSSL_LIB_CTX *libctx, void *handle, EVP_PKEY *pubkey, return pkey; } +#ifdef ENABLE_MANAGEMENT /** * Signature callback for xkey_provider with management-external-key * @@ -277,6 +280,7 @@ xkey_management_sign(void *unused, unsigned char *sig, size_t *siglen, return (*siglen > 0); } +#endif /* ENABLE MANAGEMENT */ /** * Add PKCS1 DigestInfo to tbs and return the result in *enc. diff --git a/tests/unit_tests/openvpn/test_provider.c b/tests/unit_tests/openvpn/test_provider.c index 47e7e395f..3f9a26e57 100644 --- a/tests/unit_tests/openvpn/test_provider.c +++ b/tests/unit_tests/openvpn/test_provider.c @@ -30,6 +30,7 @@ #include "syshead.h" #include "manage.h" +#include "integer.h" #include "xkey_common.h" #ifdef HAVE_XKEY_PROVIDER @@ -127,7 +128,9 @@ init_test() /* set default propq matching what we use in ssl_openssl.c */ EVP_set_default_properties(NULL, "?provider!=ovpn.xkey"); +#ifdef ENABLE_MANAGEMENT management = test_calloc(sizeof(*management), 1); +#endif } static void @@ -272,6 +275,7 @@ done: return sig; } +#ifdef ENABLE_MANAGEMENT /* Check loading of management external key and have sign callback exercised * for RSA and EC keys with and without digest support in management client. * Sha256 digest used for both cases with pss padding for RSA. @@ -310,6 +314,7 @@ again: EVP_PKEY_free(privkey); } } +#endif /* ifdef ENABLE_MANAGEMENT */ /* helpers for testing generic key load and sign */ static int xkey_free_called; @@ -409,7 +414,9 @@ main(void) const struct CMUnitTest tests[] = { cmocka_unit_test(xkey_provider_test_fetch), +#ifdef ENABLE_MANAGEMENT cmocka_unit_test(xkey_provider_test_mgmt_sign_cb), +#endif cmocka_unit_test(xkey_provider_test_generic_sign_cb), }; -- 2.47.2