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

WolfSSL and SHA256_DIGEST_LENGTH in vtls.h #1865

Closed
gvanem opened this issue Sep 5, 2017 · 4 comments
Closed

WolfSSL and SHA256_DIGEST_LENGTH in vtls.h #1865

gvanem opened this issue Sep 5, 2017 · 4 comments

Comments

@gvanem
Copy link
Contributor

@gvanem gvanem commented Sep 5, 2017

When building with USE_CYASSL and a recent WolfSSL, I get a compile error in vtls/cyassl.c (from MSVC):

F:\MingW32\src\inet\Crypto\WolfSSL\wolfssl/openssl/sha.h(92): 
  error C2059: syntax error: 'constant'

due to the enum in WolfSSL's openssl/sha.h:

enum {
    SHA256_DIGEST_LENGTH = 32
};

and the fact vtls/vtls.h precedes openssl/sha.h.

Looking at the history of openssl/sha.h. it's not clear to me at which version this change was done.
But maybe libcurl could just do:

--- a/lib/vtls/vtls.h 2017-08-29 08:46:39
+++ b/lib/vtls/vtls.h 2017-09-05 16:05:09
@@ -116,7 +116,14 @@
 #define MD5_DIGEST_LENGTH 16 /* fixed size */
 #endif

-#ifndef SHA256_DIGEST_LENGTH
+#if !defined(SHA256_DIGEST_LENGTH) && !(defined(USE_CYASSL) && (LIBCYASSL_VERSION_HEX >= 0x03012000))
+/*
+ * in WolfSSL's <openssl/sha.h> 3.12+, an enum is used:
+ *  enum {
+ *    SHA256_DIGEST_LENGTH = 32
+ * };
+ *
+ */
 #define SHA256_DIGEST_LENGTH 32 /* fixed size */
 #endif
@bagder
Copy link
Member

@bagder bagder commented Sep 6, 2017

It seems they did this change in this commit.

@jay
Copy link
Member

@jay jay commented Sep 6, 2017

hm that's a while ago. I have built more recent versions (but not yet the latest version) and haven't had this problem, I wonder why. How exactly are you building?

@bagder
Copy link
Member

@bagder bagder commented Sep 6, 2017

I too get a build error with wolfssl 3.12, but with @gvanem's fix I get this:


vtls/vtls.h:119:65: error: "LIBCYASSL_VERSION_HEX" is not defined, evaluates to 0 [-Werror=undef]
 #if !defined(SHA256_DIGEST_LENGTH) && !(defined(USE_CYASSL) && (LIBCYASSL_VERSION_HEX >= 0x03012000))
                                                                 ^~~~~~~~~~~~~~~~~~~~~

bagder added a commit that referenced this issue Sep 6, 2017
... instead of the prefix-less version since WolfSSL 3.12 now uses an
enum with that name that causes build failures for us.

Fixes #1865
Reported-by: Gisle Vanem
@bagder
Copy link
Member

@bagder bagder commented Sep 6, 2017

My suggestion is probably to instead switch to use another define, provided in #1867. It avoids having to add wolfssl-specific checks to the generic vtls source files.

@bagder bagder closed this in 4bb80d5 Sep 7, 2017
@lock lock bot locked as resolved and limited conversation to collaborators May 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

3 participants
You can’t perform that action at this time.