Skip to content

Commit 6161ec9

Browse files
authored
Merge pull request #154 from ejohnstown/update
Updates for wolfSSL v5.0
2 parents 0a54fd4 + 123384f commit 6161ec9

File tree

8 files changed

+39
-7
lines changed

8 files changed

+39
-7
lines changed

configure.ac

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ if test "x$have_wolfssl" = "xyes"; then
6868
LDFLAGS="$LDFLAGS $WOLFSSL_LDFLAGS"
6969
fi
7070

71+
AC_CHECK_HEADERS([wolfssl/wolfcrypt/kdf.h])
72+
AC_CHECK_FUNCS([wc_DhSetNamedKey])
73+
7174
# DEBUG
7275
DEBUG_CFLAGS="-g -O0 -DWOLFENGINE_DEBUG"
7376
AX_DEBUG

include/wolfengine/we_internal.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@
2222
#ifndef INTERNAL_H
2323
#define INTERNAL_H
2424

25+
#ifdef HAVE_CONFIG_H
26+
#include <config.h>
27+
#endif
28+
2529
/* OpenSSL 3.0.0 has deprecated the ENGINE API. */
2630
#define OPENSSL_API_COMPAT 10101
2731

@@ -75,6 +79,9 @@
7579
#include <wolfssl/wolfcrypt/ecc.h>
7680
#include <wolfssl/wolfcrypt/random.h>
7781
#include <wolfssl/wolfcrypt/pwdbased.h>
82+
#ifdef HAVE_WOLFSSL_WOLFCRYPT_KDF_H
83+
#include <wolfssl/wolfcrypt/kdf.h>
84+
#endif
7885

7986
#include <wolfengine/we_openssl_bc.h>
8087
#include <wolfengine/we_logging.h>

src/we_dh.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,25 +1080,41 @@ static int we_dh_pkey_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
10801080
if (ret == 1) {
10811081
/* Set named DH parameters. */
10821082
if (XSTRNCMP(type, "dh_param", 9) == 0) {
1083+
#ifndef HAVE_WC_DHSETNAMEDKEY
10831084
const DhParams *params;
1085+
#else
1086+
int params;
1087+
#endif
10841088

10851089
if (XSTRNCMP(value, "ffdhe2048", 10) == 0) {
10861090
WOLFENGINE_MSG(WE_LOG_KE,
10871091
"Setting named parameters: ffdhe2048");
1092+
#ifndef HAVE_WC_DHSETNAMEDKEY
10881093
params = wc_Dh_ffdhe2048_Get();
1094+
#else
1095+
params = WC_FFDHE_2048;
1096+
#endif
10891097
}
10901098
#ifdef HAVE_FFDHE_3072
10911099
else if (XSTRNCMP(value, "ffdhe3072", 10) == 0) {
10921100
WOLFENGINE_MSG(WE_LOG_KE,
10931101
"Setting named parameters: ffdhe3072");
1102+
#ifndef HAVE_WC_DHSETNAMEDKEY
10941103
params = wc_Dh_ffdhe3072_Get();
1104+
#else
1105+
params = WC_FFDHE_3072;
1106+
#endif
10951107
}
10961108
#endif
10971109
#ifdef HAVE_FFDHE_4096
10981110
else if (XSTRNCMP(value, "ffdhe4096", 10) == 0) {
10991111
WOLFENGINE_MSG(WE_LOG_KE,
11001112
"Setting named parameters: ffdhe4096");
1113+
#ifndef HAVE_WC_DHSETNAMEDKEY
11011114
params = wc_Dh_ffdhe4096_Get();
1115+
#else
1116+
params = WC_FFDHE_4096;
1117+
#endif
11021118
}
11031119
#endif
11041120
else {
@@ -1110,14 +1126,18 @@ static int we_dh_pkey_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
11101126
}
11111127

11121128
if (ret == 1) {
1129+
#ifndef HAVE_WC_DHSETNAMEDKEY
11131130
rc = wc_DhSetKey_ex(&dh->key, params->p, params->p_len,
11141131
params->g, params->g_len,
1115-
#ifdef HAVE_FFDHE_Q
1132+
#ifdef HAVE_FFDHE_Q
11161133
params->q, params->q_len
1117-
#else
1134+
#else
11181135
NULL, 0
1119-
#endif
1136+
#endif
11201137
);
1138+
#else
1139+
rc = wc_DhSetNamedKey(&dh->key, params);
1140+
#endif
11211141
if (rc != 0) {
11221142
WOLFENGINE_ERROR_MSG(WE_LOG_KE, "Failed set parameters");
11231143
ret = 0;

src/we_ecc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
2020
*/
2121

22-
#include <wolfengine/we_wolfengine.h>
2322
#include <wolfengine/we_internal.h>
23+
#include <wolfengine/we_wolfengine.h>
2424

2525
#ifdef WE_HAVE_ECC
2626

src/we_fips.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
2020
*/
2121

22+
#include <wolfengine/we_internal.h>
2223
#include <wolfengine/we_fips.h>
2324

2425
/* Bitmask of FIPS checks in wolfEngine_FipsCheck. Can be set by application
@@ -46,4 +47,4 @@ void wolfEngine_SetFipsChecks(long checksMask)
4647
long wolfEngine_GetFipsChecks()
4748
{
4849
return fipsChecks;
49-
}
50+
}

src/we_internal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
2020
*/
2121

22-
#include <wolfengine/we_wolfengine.h>
2322
#include <wolfengine/we_internal.h>
23+
#include <wolfengine/we_wolfengine.h>
2424

2525
#ifdef WE_NO_OPENSSL_MALLOC
2626
#if OPENSSL_VERSION_NUMBER >= 0x10100000L

src/we_openssl_bc.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
2020
*/
2121

22+
#include <wolfengine/we_internal.h>
2223
#include <wolfengine/we_openssl_bc.h>
2324

2425
/* These were all added in OpenSSL 1.1.0 */

src/we_wolfengine.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
2020
*/
2121

22-
#include <wolfengine/we_wolfengine.h>
2322
#include <wolfengine/we_internal.h>
23+
#include <wolfengine/we_wolfengine.h>
2424

2525
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
2626
/* Engine id - implementation uses wolfSSL */

0 commit comments

Comments
 (0)