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

20230711-linuxkm-fixes #6604

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 20 additions & 16 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,9 @@ AC_SUBST([ENABLED_LINUXKM_BENCHMARKS])
if test "$ENABLED_LINUXKM_DEFAULTS" = "yes"
then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_DH_CONST -DWOLFSSL_SP_MOD_WORD_RP -DWOLFSSL_SP_DIV_64 -DWOLFSSL_SP_DIV_WORD_HALF -DWOLFSSL_SMALL_STACK_STATIC -DWOLFSSL_TEST_SUBROUTINE=static"
if test "$ENABLED_LINUXKM_PIE" = "yes"; then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_NO_OCSP_ISSUER_CHECK"
fi
if test "$ENABLED_FIPS" = "no"; then
AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_OLD_PRIME_CHECK"
fi
Expand Down Expand Up @@ -4391,6 +4394,14 @@ then
fi


# MD4
AC_ARG_ENABLE([md4],
[AS_HELP_STRING([--enable-md4],[Enable MD4 (default: disabled)])],
[ ENABLED_MD4=$enableval ],
[ ENABLED_MD4=no ]
)


# DES3
AC_ARG_ENABLE([des3],
[AS_HELP_STRING([--enable-des3],[Enable DES3 (default: disabled)])],
Expand Down Expand Up @@ -4701,7 +4712,7 @@ AS_CASE([$FIPS_VERSION],
AS_IF([test "x$ENABLED_DES3" = "xno"],[ENABLED_DES3="yes"])
])

AS_IF([test "x$ENABLED_FIPS" = "xyes" && test "x$thread_ls_on" = "xno"],
AS_IF([test "x$ENABLED_FIPS" = "xyes" && test "x$thread_ls_on" = "xno" && test "$ENABLE_LINUXKM" = "no"],
[AC_MSG_ERROR([FIPS requires Thread Local Storage])])


Expand Down Expand Up @@ -6299,6 +6310,11 @@ AC_ARG_ENABLE([curl],
# curl support requires all the features enabled within this conditional.
if test "$ENABLED_CURL" = "yes"
then
if test "$ENABLED_MD4" = "no"
then
ENABLED_MD4="yes"
fi

if test "x$ENABLED_DES3" = "xno"
then
ENABLED_DES3="yes"
Expand Down Expand Up @@ -6513,14 +6529,6 @@ then
fi
fi

# MD4
AC_ARG_ENABLE([md4],
[AS_HELP_STRING([--enable-md4],[Enable MD4 (default: disabled)])],
[ ENABLED_MD4=$enableval ],
[ ENABLED_MD4=no ]
)


if test "$ENABLED_MD4" = "no"
then
#turn on MD4 if using stunnel
Expand Down Expand Up @@ -8933,14 +8941,10 @@ fi

if test "$ENABLED_REPRODUCIBLE_BUILD" != "yes"
then
ESCAPED_ARGS="$ac_configure_args"
ESCAPED_ARGS=$(echo "$ESCAPED_ARGS" | sed 's/\\/\\\\/g')
ESCAPED_ARGS=$(echo "$ESCAPED_ARGS" | sed 's/\"/\\\"/g')
ESCAPED_GLOBAL_ARGS="$CPPFLAGS $AM_CPPFLAGS $CFLAGS $AM_CFLAGS"
ESCAPED_GLOBAL_ARGS=$(echo "$ESCAPED_GLOBAL_ARGS" | sed 's/\\/\\\\/g')
ESCAPED_GLOBAL_ARGS=$(echo "$ESCAPED_GLOBAL_ARGS" | sed 's/\"/\\\"/g')
ESCAPED_ARGS=$(echo "$ac_configure_args" | sed 's/\\/\\\\/g;s/\"/\\\"/g')
ESCAPED_GLOBAL_CFLAGS=$(echo "$CPPFLAGS $AM_CPPFLAGS $CFLAGS $AM_CFLAGS" | sed 's/\\/\\\\/g;s/\"/\\\"/g')
echo "#define LIBWOLFSSL_CONFIGURE_ARGS \"$ESCAPED_ARGS\"" > "${output_objdir}/.build_params" &&
echo "#define LIBWOLFSSL_GLOBAL_CFLAGS \"$ESCAPED_GLOBAL_ARGS\" LIBWOLFSSL_GLOBAL_EXTRA_CFLAGS" >> "${output_objdir}/.build_params" ||
echo "#define LIBWOLFSSL_GLOBAL_CFLAGS \"$ESCAPED_GLOBAL_CFLAGS\" LIBWOLFSSL_GLOBAL_EXTRA_CFLAGS" >> "${output_objdir}/.build_params" ||
AC_MSG_ERROR([Couldn't create ${output_objdir}/.build_params.])
else
rm -f "${output_objdir}/.build_params"
Expand Down
2 changes: 1 addition & 1 deletion scripts/sniffer-gen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ run_sequence() {
run_test "" "-v 4 -g" "-v 4 -J"
else
echo "Invalid test"
exit -1
exit 1
fi
}

Expand Down
5 changes: 5 additions & 0 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -35791,6 +35791,11 @@ static int DoSessionTicket(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
#endif

if (!ssl->options.tls1_3) {
if (ssl->arrays == NULL) {
WOLFSSL_MSG("CreateTicket called with null arrays");
ret = BAD_FUNC_ARG;
goto error;
}
XMEMCPY(it->msecret, ssl->arrays->masterSecret, SECRET_LEN);
#ifndef NO_ASN_TIME
c32toa(LowResTimer(), it->timestamp);
Expand Down
3 changes: 0 additions & 3 deletions src/ocsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,8 +549,6 @@ int CheckOcspRequest(WOLFSSL_OCSP* ocsp, OcspRequest* ocspRequest,
return ret;
}

#ifdef HAVE_OCSP

#ifndef WOLFSSL_NO_OCSP_ISSUER_CHAIN_CHECK
static int CheckOcspResponderChain(OcspEntry* single, DecodedCert *cert,
void* vp) {
Expand Down Expand Up @@ -646,7 +644,6 @@ int CheckOcspResponder(OcspResponse *bs, DecodedCert *cert, void* vp)
}
return ret;
}
#endif /* HAVE_OCSP */

#if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) || \
defined(WOLFSSL_APACHE_HTTPD) || defined(HAVE_LIGHTY)
Expand Down
5 changes: 3 additions & 2 deletions src/tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -1693,7 +1693,6 @@ int ALPN_Select(WOLFSSL *ssl)
SendAlert(ssl, alert_fatal, no_application_protocol);
WOLFSSL_ERROR_VERBOSE(UNKNOWN_ALPN_PROTOCOL_NAME_E);
return UNKNOWN_ALPN_PROTOCOL_NAME_E;
break;
}
}
else
Expand Down Expand Up @@ -10290,8 +10289,10 @@ static int TLSX_PskKeModes_Parse(WOLFSSL* ssl, const byte* input, word16 length,
if (ret == 0)
ret = TLSX_PskKeyModes_Use(ssl, modes);

if (ret != 0)
if (ret != 0) {
WOLFSSL_ERROR_VERBOSE(ret);
}

return ret;
}

Expand Down
17 changes: 11 additions & 6 deletions tests/api.c
Original file line number Diff line number Diff line change
Expand Up @@ -40233,12 +40233,15 @@ static int test_wolfSSL_BIO_gets(void)
ExpectNotNull(emp_bm = BUF_MEM_new());
ExpectNotNull(msg_bm = BUF_MEM_new());
ExpectIntEQ(BUF_MEM_grow(msg_bm, sizeof(msg)), sizeof(msg));
XFREE(msg_bm->data, NULL, DYNAMIC_TYPE_OPENSSL);
if (EXPECT_SUCCESS())
XFREE(msg_bm->data, NULL, DYNAMIC_TYPE_OPENSSL);
/* emp size is 1 for terminator */
ExpectIntEQ(BUF_MEM_grow(emp_bm, sizeof(emp)), sizeof(emp));
XFREE(emp_bm->data, NULL, DYNAMIC_TYPE_OPENSSL);
emp_bm->data = emp;
msg_bm->data = msg;
if (EXPECT_SUCCESS()) {
XFREE(emp_bm->data, NULL, DYNAMIC_TYPE_OPENSSL);
emp_bm->data = emp;
msg_bm->data = msg;
}
ExpectIntEQ(BIO_set_mem_buf(bio, emp_bm, BIO_CLOSE), WOLFSSL_SUCCESS);

/* check reading an empty string */
Expand All @@ -40256,9 +40259,11 @@ static int test_wolfSSL_BIO_gets(void)
ExpectIntEQ(BIO_gets(bio, bio_buffer, bufferSz), 8);
ExpectIntEQ(BIO_gets(bio, bio_buffer, -1), 0);

emp_bm->data = NULL;
if (EXPECT_SUCCESS())
emp_bm->data = NULL;
BUF_MEM_free(emp_bm);
msg_bm->data = NULL;
if (EXPECT_SUCCESS())
msg_bm->data = NULL;
BUF_MEM_free(msg_bm);
#endif

Expand Down
3 changes: 3 additions & 0 deletions tests/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ char* create_tmp_dir(char *tmpDir, int len)
#ifdef _MSC_VER
if (_mkdir(tmpDir) != 0)
return NULL;
#elif defined(__CYGWIN__) || defined(__MINGW32__)
if (mkdir(tmpDir) != 0)
return NULL;
#else
if (mkdir(tmpDir, 0700) != 0)
return NULL;
Expand Down
35 changes: 11 additions & 24 deletions wolfcrypt/src/asn.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ ASN Options:
#include <wolfssl/wolfcrypt/cryptocb.h>
#endif

#include <wolfssl/internal.h>
#ifndef WOLFCRYPT_ONLY
#include <wolfssl/internal.h>
#endif

#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
#include <wolfssl/openssl/objects.h>
#endif
Expand Down Expand Up @@ -18867,7 +18870,7 @@ static int DecodeAuthKeyId(const byte* input, word32 sz, DecodedCert* cert)
/* Get the hash or hash of the hash if wrong size. */
ret = GetHashId(dataASN[AUTHKEYIDASN_IDX_KEYID].data.ref.data,
(int)dataASN[AUTHKEYIDASN_IDX_KEYID].data.ref.length,
cert->extAuthKeyId, HashIdAlg(cert->signatureOID));
cert->extAuthKeyId, HashIdAlg((int)cert->signatureOID));
}
#ifdef WOLFSSL_AKID_NAME
if (ret == 0 && dataASN[AUTHKEYIDASN_IDX_ISSUER].data.ref.data != NULL) {
Expand Down Expand Up @@ -21448,29 +21451,10 @@ int wc_ParseCert(DecodedCert* cert, int type, int verify, void* cm)
return ParseCert(cert, type, verify, cm);
}

#if !defined(OPENSSL_EXTRA) && !defined(OPENSSL_EXTRA_X509_SMALL) && \
!defined(GetCA)
/* from SSL proper, for locking can't do find here anymore.
* brought in from internal.h if built with compat layer.
* if defined(GetCA), it's a predefined macro and these prototypes
* would conflict.
*/
#ifdef __cplusplus
extern "C" {
#endif
Signer* GetCA(void* signers, byte* hash);
#ifndef NO_SKID
Signer* GetCAByName(void* signers, byte* hash);
#endif
#ifdef __cplusplus
}
#endif

#endif /* !OPENSSL_EXTRA && !OPENSSL_EXTRA_X509_SMALL && !GetCA */

#if defined(WOLFCRYPT_ONLY)
#ifdef WOLFCRYPT_ONLY

/* dummy functions, not using wolfSSL so don't need actual ones */
Signer* GetCA(void* signers, byte* hash);
Signer* GetCA(void* signers, byte* hash)
{
(void)hash;
Expand All @@ -21479,6 +21463,7 @@ Signer* GetCA(void* signers, byte* hash)
}

#ifndef NO_SKID
Signer* GetCAByName(void* signers, byte* hash);
Signer* GetCAByName(void* signers, byte* hash)
{
(void)hash;
Expand All @@ -21488,6 +21473,8 @@ Signer* GetCAByName(void* signers, byte* hash)
#endif /* NO_SKID */

#ifdef WOLFSSL_AKID_NAME
Signer* GetCAByAKID(void* vp, const byte* issuer, word32 issuerSz,
const byte* serial, word32 serialSz);
Signer* GetCAByAKID(void* vp, const byte* issuer, word32 issuerSz,
const byte* serial, word32 serialSz)
{
Expand Down Expand Up @@ -22701,7 +22688,7 @@ int ParseCertRelative(DecodedCert* cert, int type, int verify, void* cm)
}
}
else {
cert->maxPathLen = min(cert->ca->maxPathLen - 1,
cert->maxPathLen = (byte)min(cert->ca->maxPathLen - 1,
cert->maxPathLen);
}
}
Expand Down
6 changes: 4 additions & 2 deletions wolfssl/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -6128,12 +6128,14 @@ WOLFSSL_LOCAL WC_RNG* WOLFSSL_RSA_GetRNG(WOLFSSL_RSA *rsa, WC_RNG **tmpRNG,
DecodedCert* cert);
#endif

WOLFSSL_LOCAL Signer* GetCA(void* vp, byte* hash);
#ifndef GetCA
WOLFSSL_LOCAL Signer* GetCA(void* vp, byte* hash);
#endif
#ifdef WOLFSSL_AKID_NAME
WOLFSSL_LOCAL Signer* GetCAByAKID(void* vp, const byte* issuer,
word32 issuerSz, const byte* serial, word32 serialSz);
#endif
#ifndef NO_SKID
#if !defined(NO_SKID) && !defined(GetCAByName)
WOLFSSL_LOCAL Signer* GetCAByName(void* cm, byte* hash);
#endif
#endif /* !NO_CERTS */
Expand Down