Skip to content

Conversation

siddharth-narayan
Copy link
Contributor

This pull request adds post quantum functionality in SoftEtherVPN by default for all users. My previous pull request previously added post quantum functionality, but in order for that to work, OpenSSL had to be dynamically installed, and so did oqsprovider, which depends on liboqs. What this meant for Windows users is that they would have had to install OpenSSL, and then build not just oqsprovider, but liboqs as well. All of these would have to be built from source BEFORE any post quantum functionality was available. Even on Linux, almost no distributions package liboqs or oqsprovider, so both of those would still have to be built from source. This is too much to expect a user to do.

So, to solve this problem, I integrated oqsprovider statically, so that it is built in by default by adding new git submodules for oqsprovider and liboqs. However, oqsprovider uses cmake's find_package to depend on liboqs. Because liboqs will not be installed on the user's system, this will fail, so Findliboqs.cmake had to be added to src/Mayaqua/3rdparty/, following this CMake workaround. I'm pretty new to writing CMake, so I'm not sure my code there is the most optimal way to build oqsprovider and make it depend on liboqs, but I've checked that it builds and runs properly on both Linux and Windows.

@chipitsine
Copy link
Member

we have several way of linking against openssl.
for example, we can link against openssl shipped with distro.

we do not rebuild openssl always (but it is one of alternatives)

@chipitsine
Copy link
Member

in theory we can even link against libressl (but it's not a common case)

@siddharth-narayan
Copy link
Contributor Author

siddharth-narayan commented Jun 28, 2024

Yes, I understand. My changes are only to do with building in oqsprovider functionality, and they don't change anything about how OpenSSL is linked. On Windows, to the best of my knowledge, OpenSSL is linked statically, while on Linux, OpenSSL is dynamic. My changes don't affect how OpenSSL is linked at all, but only make sure that oqsprovider and liboqs are built in statically. For the LibreSSL edge case, I can disable oqsprovider and liboqs building, if that's not already accomplished by the most recent commit 1f9ce6f

@chipitsine chipitsine self-assigned this Jul 3, 2024
@chipitsine
Copy link
Member

@chipitsine
Copy link
Member

well, what am I afraid of is keeping an eye on updating git submodules (to keep them in sync with openssl).
@siddharth-narayan , do you have an appetite for that :) ?

@chipitsine
Copy link
Member

I overlooked trigger definition in Fedora pipeline.

here's fix: #2025

@siddharth-narayan
Copy link
Contributor Author

Is the Fedora build working now, or do I need to push another commit to see it fail? For updating the git submodules, I don't think OpenSSL would break backwards compatibility that quickly, but if it's necessary, then of course I will come back and update them.

@chipitsine
Copy link
Member

chipitsine commented Jul 3, 2024

in Fedora openssl is built without provider support (but openssl >= 3)
it should be handled somehow.

I can prepare fix tomorrow.
if you have an appetite for that, I'd appreciate

Fedora pipeline was not enabled for pull requests, thus we missed that regression

@siddharth-narayan
Copy link
Contributor Author

After doing a bit of searching, I can't find any option to build OpenSSL without providers. It's doesn't seem to be in OpenSSL's ./Configure. Is the problem something related to engine support instead?

@siddharth-narayan
Copy link
Contributor Author

I did some digging, and I found the problem. I found your test commit to add

#ifndef OPENSSL_NO_ENGINE
#include <openssl/engine.h>
#endif

This seems to be completely correct, and should work properly. The only problem is that OPENSSL_NO_ENGINE isn't defined by the OpenSSL package on Fedora Rawhide. If you check the package, a very recent commit from two days ago removes engine*.h from the include directory without defining OPENSSL_NO_ENGINE. I think this is probably the issue.

I think the simplest solution is this:
For fixing the test, add openssl-devel-engine to the dependencies, and keep the #ifndef OPENSSL_NO_ENGINE guard for anyone else who builds with an OpenSSL that doesn't support engines.

@chipitsine
Copy link
Member

I did some digging, and I found the problem. I found your test commit to add

#ifndef OPENSSL_NO_ENGINE
#include <openssl/engine.h>
#endif

This seems to be completely correct, and should work properly. The only problem is that OPENSSL_NO_ENGINE isn't defined by the OpenSSL package on Fedora Rawhide. If you check the package, a very recent commit from two days ago removes engine*.h from the include directory without defining OPENSSL_NO_ENGINE. I think this is probably the issue.

I think the simplest solution is this: For fixing the test, add openssl-devel-engine to the dependencies, and keep the #ifndef OPENSSL_NO_ENGINE guard for anyone else who builds with an OpenSSL that doesn't support engines.

we can mimic OPENSSL_NO_ENGINE in cmake,

@chipitsine
Copy link
Member

I'll try installing openssl-devel-engine as well

@siddharth-narayan
Copy link
Contributor Author

siddharth-narayan commented Jul 4, 2024

The fix isn't very related to this pull request, but it might as well go here.

What did you mean by

we can mimic OPENSSL_NO_ENGINE in cmake,

@chipitsine
Copy link
Member

The fix isn't very related to this pull request, but it might as well go here.

What did you mean by

we can mimic OPENSSL_NO_ENGINE in cmake,

I thought it was not a bug but intended behaviour.
in such case we can invoke check_symbol_exists(...) from CMake

in case it is a bug, let's stay with your approach by installing package on Fedora

@chipitsine
Copy link
Member

I can accept Fedora pipeline fix immediately.

as for rest, it looks good, but I would have more look at it (well, I do not like an idea to add more submodules, but it seems to be the way those libs are served nowdays)

@siddharth-narayan
Copy link
Contributor Author

Ok, I can revert the commit here and make a separate pull request, which is probably best practice anyway.

@siddharth-narayan
Copy link
Contributor Author

About the git submodules, would CMake's FetchContent be an alternative? As far as I understand the library could be downloaded already compiled and then used that way. Would this work as an alternative?

@chipitsine
Copy link
Member

since most people serve it as submodules, let's stick with submodules

@siddharth-narayan
Copy link
Contributor Author

Sorry, made a bad commit and accidentally pushed

@chipitsine
Copy link
Member

if you still work on this PR, you can convert it to draft to avoid accidental merge

image

@siddharth-narayan
Copy link
Contributor Author

No, I'm not doing any active work, I was working on my master branch and accidentally pushed to this one.

@chipitsine
Copy link
Member

I'll try to merge today

@chipitsine chipitsine merged commit a836b3b into SoftEtherVPN:master Jul 19, 2024
13 checks passed
@chipitsine
Copy link
Member

thank you for contribution!

@siddharth-narayan siddharth-narayan deleted the built-in-post-quantum branch July 19, 2024 23:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants