xkey_provider: fix building with --disable-management
PATCH 1/1 xkey_provider: fix building with --disable-management
From: Selva Nair <[email protected]...>
--- src/openvpn/xkey_helper.c | 4 ++++ 1 file changed, 4 insertions(+)
src/openvpn/xkey_helper.c +4 -0
@@ -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.
Signature · 1 line
2.30.2
Hi,
Quoted 6 lines · On Tue, Jul 26, 2022 at 07:51:00AM -0400, [email protected]... wrote:
From: Selva Nair <[email protected]...>
Signed-off-by Selva Nair <[email protected]...>--- src/openvpn/xkey_helper.c | 4 ++++ 1 file changed, 4 insertions(+)
Close ;-)
This fixes compilation of xkey_helper.c for --disable-management, but "make check" still fails in test_provider.c
In file included from test_provider.c:38:test_provider.c: In function 'init_test':
test_provider.c:130:36: error: invalid application of 'sizeof' to incomplete type 'struct management'
130 | management = test_calloc(sizeof(*management), 1);
| ^test_provider.c: In function 'xkey_provider_test_mgmt_sign_cb':
test_provider.c:290:19: error: invalid use of undefined type 'struct management'
290 | management->settings.flags = MF_EXTERNAL_KEY|MF_EXTERNAL_KEY_PSSPAD;
| ^~
test_provider.c:290:38: error: 'MF_EXTERNAL_KEY' undeclared (first use in this function)
290 | management->settings.flags = MF_EXTERNAL_KEY|MF_EXTERNAL_KEY_PSSPAD;
| ^~~~~~~~~~~~~~~(and a few more)
... can I have a v2, please?
thanks ;-)
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...PATCH v2 1/1 xkey_provider: fix building with --disable-management
In reply to [email protected]...From: Selva Nair <[email protected]...>
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..
--- src/openvpn/xkey_helper.c | 4 ++++ tests/unit_tests/openvpn/test_provider.c | 7 +++++++ 2 files changed, 11 insertions(+)
src/openvpn/xkey_helper.c +4 -0
@@ -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.
tests/unit_tests/openvpn/test_provider.c +7 -0
@@ -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 /* 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_MANAGEMENTcmocka_unit_test (xkey_provider_test_mgmt_sign_cb), +#endifcmocka_unit_test (xkey_provider_test_generic_sign_cb), };
Signature · 1 line
2.30.2
Quoted 6 lines · On Wed, Jul 27, 2022 at 06:18:30PM -0400, [email protected]... wrote:
From: Selva Nair <[email protected]...>
v2: also fix building
test_provider
- ifdefs intest_provider.c
- includeinteger.hformin_intasmanage.h
may not always pull it in
FTR, buildbot is happy now with these changes. uncrustify is not, see below, but that can probably be fixed on apply.
Quoted 31 lines
tests/unit_tests/openvpn/test_provider.c +4
-0@@ -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.
tests/unit_tests/openvpn/test_provider.c again: · line 317
Quoted 4 lines
tests/unit_tests/openvpn/test_provider.c +1
-0@@ -310,6 +314,7 @@ again: EVP_PKEY_free(privkey); } } +#endif
uncrustify wants this
tests/unit_tests/openvpn/test_provider.c" 2022-07-29 11:34:20.054239000 +0200 renamed from tests/unit_tests/openvpn/test_provider.c" 2022-07-29 11:34:20.067492200 +0200 +1 -1
@@ -314,7 +314,7 @@ EVP_PKEY_free(privkey); } } -#endif +#endif /* ifdef ENABLE_MANAGEMENT */ /* helpers for testing generic key load and sign */ static int xkey_free_called;
Quoted 11 lines
tests/unit_tests/openvpn/test_provider.c +2
-0/* 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_MANAGEMENTcmocka_unit_test (xkey_provider_test_mgmt_sign_cb), +#endifcmocka_unit_test (xkey_provider_test_generic_sign_cb), };
Signature · 1 line
Frank Lichtenheld
Thanks for v2, and "too many #ifdef" indeed. Uncrustify complained that one of the #endif wants a comment, but with the new commit hooks this is easily fixed. (Maybe we want to have a deep look into "do we really want to keep ENABLE_MANAGEMENT?" one day... how much extra code size does that bring to the binaries? It's not *that* much code, is it?)
I have fed the code to buildbot, and it pacified all these modern instances (fedora-36 etc.) ;-)
Your patch has been applied to the master branch.
commit fc75ab33401718fab3a79b19698eefb70a617a83
Author: Selva Nair Date: Wed Jul 27 18:18:30 2022 -0400
xkey_provider: fix building with --disable-management
Signed-off-by: Selva Nair <[email protected]...>
Acked-by: Frank Lichtenheld <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg24749.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering