Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dlfcn required for windows build #1768

Open
andybrucenet opened this issue Apr 25, 2024 · 2 comments
Open

dlfcn required for windows build #1768

andybrucenet opened this issue Apr 25, 2024 · 2 comments

Comments

@andybrucenet
Copy link

andybrucenet commented Apr 25, 2024

Describe the bug
When building on windows receive a compile error from src/common/ossl_helpers.c - dlfcn.h is not available on windows

To Reproduce
Try to build on windows :)

Expected behavior
One of four things:

  1. Provide cross-platform code to load shared libraries (alternative to dlopen / dlclose)
  2. #ifdef around #include <dlfcn.h> / dlfcn functions (simply ignore on windows and assume that required libraries are loaded).
  3. Require dlfcn-win32 package with basic instructions on the liboqs github page on how to install (prerequisite).
  4. Auto-install dlfcn-win32 from dlfcn-win32 github page as part of standard build.

Screenshots
I even put on a screenshot for you :)
liboqs-build-error

Environment (please complete the following information):

  • OS: Windows 11 with Visual Studio 2022 latest patches
  • OpenSSL version: 3.3.0
  • Compiler version used: MSVC (CL) 19.39.33523
  • Build variables used: no overrides
  • liboqs version: main branch

Additional context
I added logs collected from my run which shows all the configuration occurring.
buildliboqs.log''

I worked around the problem as follows:

// ABr: avoid dlfcn on windows
#if !defined(_MSC_VER)
#include <dlfcn.h>
#endif
[...]
static void ensure_symbol(const char *name, void **symp) {
#if !defined(_MSC_VER)
	if (!*symp) {
		void *sym = dlsym(libcrypto_dlhandle, name);
		if (!sym) {
			exit(EXIT_FAILURE);
		}
		*symp = sym;
	}
#endif
}
static void ensure_library(void) {
#if !defined(_MSC_VER)
	if (!libcrypto_dlhandle) {
		libcrypto_dlhandle = dlopen(OQS_OPENSSL_CRYPTO_SONAME,
		                            RTLD_LAZY | RTLD_LOCAL);
		if (!libcrypto_dlhandle) {
			exit(EXIT_FAILURE);
		}
	}

#define ENSURE_SYMBOL(name) \
    ensure_symbol(#name, (void **)&_oqs_ossl_sym_##name)
#define FUNC(ret, name, args, cargs)        \
    ENSURE_SYMBOL(name);
#define VOID_FUNC FUNC
#include "ossl_functions.h"
#undef VOID_FUNC
#undef FUNC
#undef ENSURE_SYMBOL
#endif
}
@baentsch
Copy link
Member

Please check PLATFORMS.md: You'll notice limited Windows support for liboqs (we don't have people knowledgeable/interested in that platform for the project). Any contributions via PR welcome!

@andybrucenet
Copy link
Author

Just saw this. I'll be happy to put in some code as soon as I get to a stopping point.

On the good news - I have integrated all the defined NIST algos for DSA / KEM on Windows (with my local hacks for now), macOS, iOS, Android, and Linux (glibc 2.34 since a "static" openssl build...still requires a glibc unless yet-more-work is done with musl).

All my tests pass on every platform. I still need to prove interoperability such that when keys are exchanged between different platforms via PEM files that everything works. But so far things is looking good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Todo
Development

No branches or pull requests

2 participants