Skip to content

Commit a18708c

Browse files
committed
Updates for recent changes to wolfSSL
1. Add optional use of the wc_DhSetNamedKey(). 2. Include check for wc_DhSetNamedKey(). 3. Include the new header kdf.h.
1 parent c070c59 commit a18708c

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

configure.ac

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

71+
AC_CHECK_FUNCS([wc_DhSetNamedKey])
72+
7173
# DEBUG
7274
DEBUG_CFLAGS="-g -O0 -DWOLFENGINE_DEBUG"
7375
AX_DEBUG

include/wolfengine/we_internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
#include <wolfssl/wolfcrypt/ecc.h>
7676
#include <wolfssl/wolfcrypt/random.h>
7777
#include <wolfssl/wolfcrypt/pwdbased.h>
78+
#include <wolfssl/wolfcrypt/kdf.h>
7879

7980
#include <wolfengine/we_openssl_bc.h>
8081
#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;

0 commit comments

Comments
 (0)