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

fix build with libressl >= 3.5.0 #249

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

ffontaine
Copy link

Fix the following build failure with libressl >= 3.5.0:

crypto-openssl-10.cpp:78:18: error: field 'ctx' has incomplete type 'HMAC_CTX' {aka 'hmac_ctx_st'}
   78 |         HMAC_CTX ctx;
      |                  ^~~

Fixes:

Signed-off-by: Fabrice Fontaine [email protected]

@loqs
Copy link

loqs commented May 15, 2022

What if instead you tested for OPENSSL_VERSION_NUMBER < 0x10100000L?
I believe for libressl >= 3.5.0 that would be 0x20000000L and guaranteed not to change so would accommodate that case as well as OpenSSL 1.1 and 3.0 in a single test.

@ffontaine
Copy link
Author

As OPENSSL_VERSION_NUMBER is hardcoded to 0x20000000L in libressl, this would mean that the build will fail for all versions before 3.5.0. If you want to be compatible with all libressl versions, LIBRESSL_VERSION_NUMBER must be checked.

@loqs
Copy link

loqs commented May 16, 2022

What if instead you use a feature test?

diff --git a/crypto-openssl-10.cpp b/crypto-openssl-10.cpp
index f0f2c53..1623690 100644
--- a/crypto-openssl-10.cpp
+++ b/crypto-openssl-10.cpp
@@ -28,16 +28,15 @@
  * as that of the covered work.
  */
 
-#include <openssl/opensslconf.h>
+#include <openssl/hmac.h>
 
-#if !defined(OPENSSL_API_COMPAT)
+#if defined(HMAC_cleanup)
 
 #include "crypto.hpp"
 #include "key.hpp"
 #include "util.hpp"
 #include <openssl/aes.h>
 #include <openssl/sha.h>
-#include <openssl/hmac.h>
 #include <openssl/evp.h>
 #include <openssl/rand.h>
 #include <openssl/err.h>
diff --git a/crypto-openssl-11.cpp b/crypto-openssl-11.cpp
index adf03bb..518b90c 100644
--- a/crypto-openssl-11.cpp
+++ b/crypto-openssl-11.cpp
@@ -28,16 +28,15 @@
  * as that of the covered work.
  */
 
-#include <openssl/opensslconf.h>
+#include <openssl/hmac.h>
 
-#if defined(OPENSSL_API_COMPAT)
+#if !defined(HMAC_cleanup)
 
 #include "crypto.hpp"
 #include "key.hpp"
 #include "util.hpp"
 #include <openssl/aes.h>
 #include <openssl/sha.h>
-#include <openssl/hmac.h>
 #include <openssl/evp.h>
 #include <openssl/rand.h>
 #include <openssl/err.h>

Fix the following build failure with libressl >= 3.5.0:

crypto-openssl-10.cpp:78:18: error: field 'ctx' has incomplete type 'HMAC_CTX' {aka 'hmac_ctx_st'}
   78 |         HMAC_CTX ctx;
      |                  ^~~

Fixes:
 - http://autobuild.buildroot.org/results/98747d470c2ad59280934e160d24bd3fdad1503c

Signed-off-by: Fabrice Fontaine <[email protected]>
@ffontaine
Copy link
Author

I updated the PR as requested

loqs added a commit to loqs/PACKAGES-OSSL3 that referenced this pull request Aug 29, 2022
kLiHz added a commit to kLiHz/git-crypt that referenced this pull request Apr 13, 2023
Copy link

@xendarboh xendarboh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This enables one to build, install, and use git-crypt on Ubuntu LTS.
When otherwise, it fails to build. So +1 👍
Thanx!

@ffontaine
Copy link
Author

Do you plan on merging this PR?

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.

4 participants