summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHayden Roche <haydenroche5@gmail.com>2021-10-01 16:06:55 -0700
committerDaniel Stenberg <daniel@haxx.se>2021-10-02 13:55:31 +0200
commite12dc2dd977c1e5f8d05e681d8d31f4fc124f6f9 (patch)
tree13fd124a333b03208069065f1e15625cb162bb46
parent8bb5f4ddf3c7d023196ad70d6af265424edebfee (diff)
downloadcurl-e12dc2dd977c1e5f8d05e681d8d31f4fc124f6f9.tar.gz
wolfssl: use for SHA256, MD4, MD5, and setting DES odd parity
Prior to this commit, OpenSSL could be used for all these functions, but not wolfSSL. This commit makes it so wolfSSL will be used if USE_WOLFSSL is defined. Closes #7806
-rw-r--r--lib/curl_des.c4
-rw-r--r--lib/curl_sha256.h9
-rw-r--r--lib/md4.c13
-rw-r--r--lib/md5.c11
-rw-r--r--lib/sha256.c7
5 files changed, 37 insertions, 7 deletions
diff --git a/lib/curl_des.c b/lib/curl_des.c
index 8c5af19cd..76185cbf2 100644
--- a/lib/curl_des.c
+++ b/lib/curl_des.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 2015 - 2020, Steve Holme, <steve_holme@hotmail.com>.
+ * Copyright (C) 2015 - 2021, Steve Holme, <steve_holme@hotmail.com>.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -22,7 +22,7 @@
#include "curl_setup.h"
-#if defined(USE_NTLM) && !defined(USE_OPENSSL)
+#if defined(USE_NTLM) && !defined(USE_OPENSSL) && !defined(USE_WOLFSSL)
#include "curl_des.h"
diff --git a/lib/curl_sha256.h b/lib/curl_sha256.h
index b4579d769..b14c475ef 100644
--- a/lib/curl_sha256.h
+++ b/lib/curl_sha256.h
@@ -8,7 +8,7 @@
* \___|\___/|_| \_\_____|
*
* Copyright (C) 2017, Florin Petriuc, <petriuc.florin@gmail.com>
- * Copyright (C) 2018 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2018 - 2021, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -28,7 +28,14 @@
extern const struct HMAC_params Curl_HMAC_SHA256[1];
+#ifdef USE_WOLFSSL
+/* SHA256_DIGEST_LENGTH is an enum value in wolfSSL. Need to import it from
+ * sha.h*/
+#include <wolfssl/options.h>
+#include <openssl/sha.h>
+#else
#define SHA256_DIGEST_LENGTH 32
+#endif
void Curl_sha256it(unsigned char *outbuffer, const unsigned char *input,
const size_t len);
diff --git a/lib/md4.c b/lib/md4.c
index e7a428fc2..d90e45475 100644
--- a/lib/md4.c
+++ b/lib/md4.c
@@ -27,6 +27,7 @@
#include "curl_md4.h"
#include "warnless.h"
+
#ifdef USE_OPENSSL
#include <openssl/opensslconf.h>
#if defined(OPENSSL_VERSION_MAJOR) && (OPENSSL_VERSION_MAJOR >= 3)
@@ -35,6 +36,13 @@
#endif
#endif /* USE_OPENSSL */
+#ifdef USE_WOLFSSL
+#include <wolfssl/options.h>
+#ifdef NO_MD4
+#define OPENSSL_NO_MD4
+#endif
+#endif
+
#ifdef USE_MBEDTLS
#include <mbedtls/version.h>
#if MBEDTLS_VERSION_NUMBER >= 0x03000000
@@ -74,8 +82,9 @@ static void MD4_Final(unsigned char *result, MD4_CTX *ctx)
md4_digest(ctx, MD4_DIGEST_SIZE, result);
}
-#elif defined(USE_OPENSSL) && !defined(OPENSSL_NO_MD4)
-/* When OpenSSL is available we use the MD4-functions from OpenSSL */
+#elif (defined(USE_OPENSSL) || defined(USE_WOLFSSL)) && \
+ !defined(OPENSSL_NO_MD4)
+/* When OpenSSL or wolfSSL is available, we use their MD4 functions. */
#include <openssl/md4.h>
#elif (defined(__MAC_OS_X_VERSION_MAX_ALLOWED) && \
diff --git a/lib/md5.c b/lib/md5.c
index 983ed9746..00b40af4d 100644
--- a/lib/md5.c
+++ b/lib/md5.c
@@ -65,12 +65,19 @@ static void MD5_Final(unsigned char *digest, MD5_CTX *ctx)
md5_digest(ctx, 16, digest);
}
-#elif defined(USE_OPENSSL) && !defined(USE_AMISSL)
-/* When OpenSSL is available we use the MD5-function from OpenSSL */
+#elif (defined(USE_OPENSSL) && !defined(USE_AMISSL)) || defined(USE_WOLFSSL)
+
+#ifdef USE_WOLFSSL
+#include <wolfssl/options.h>
+#endif
+
+#if defined(USE_OPENSSL) || (defined(USE_WOLFSSL) && !defined(NO_MD5))
+/* When OpenSSL or wolfSSL is available, we use their MD5 functions. */
#include <openssl/md5.h>
#include "curl_memory.h"
/* The last #include file should be: */
#include "memdebug.h"
+#endif
#elif defined(USE_MBEDTLS)
diff --git a/lib/sha256.c b/lib/sha256.c
index a2e7e4131..270be1c67 100644
--- a/lib/sha256.c
+++ b/lib/sha256.c
@@ -29,6 +29,13 @@
#include "curl_sha256.h"
#include "curl_hmac.h"
+#ifdef USE_WOLFSSL
+#include <wolfssl/options.h>
+#ifndef NO_SHA256
+#define USE_OPENSSL_SHA256
+#endif
+#endif
+
#if defined(USE_OPENSSL)
#include <openssl/opensslv.h>