Remove user-crypto functionality and Intel IPP support

pull/7097/head
Lealem Amedie 2023-12-27 12:24:19 -07:00
parent b8392ef659
commit 837452b1ca
25 changed files with 139 additions and 3826 deletions

17
.gitignore vendored
View File

@ -286,23 +286,6 @@ mqx/wolfcrypt_benchmark/.settings
mqx/wolfcrypt_benchmark/.cwGeneratedFileSetLog
mqx/wolfcrypt_benchmark/SaAnalysispointsManager.apconfig
# User Crypto example build
wolfcrypt/user-crypto/aclocal.m4
wolfcrypt/user-crypto/config.guess
wolfcrypt/user-crypto/autom4te.cache
wolfcrypt/user-crypto/config.log
wolfcrypt/user-crypto/config.status
wolfcrypt/user-crypto/config.sub
wolfcrypt/user-crypto/depcomp
wolfcrypt/user-crypto/install-sh
wolfcrypt/user-crypto/libtool
wolfcrypt/user-crypto/ltmain.sh
wolfcrypt/user-crypto/m4
wolfcrypt/user-crypto/missing
wolfcrypt/user-crypto/Makefile.in
wolfcrypt/user-crypto/lib/libusercrypto.*
*.hzs
# wolfSSL CSharp wrapper
wrapper/CSharp/x64/

View File

@ -168,7 +168,6 @@ include Docker/include.am
include src/include.am
include support/include.am
include wolfcrypt/user-crypto/include.am
include wolfcrypt/benchmark/include.am
include wolfcrypt/src/include.am
include wolfcrypt/test/include.am

View File

@ -217,8 +217,6 @@ function(generate_build_flags)
set(BUILD_CRL_MONITOR "yes" PARENT_SCOPE)
endif()
set(BUILD_QUIC ${WOLFSSL_QUIC} PARENT_SCOPE)
set(BUILD_USER_RSA ${WOLFSSL_USER_RSA} PARENT_SCOPE)
set(BUILD_USER_CRYPTO ${WOLFSSL_USER_CRYPTO} PARENT_SCOPE)
set(BUILD_WNR ${WOLFSSL_WNR} PARENT_SCOPE)
if(WOLFSSL_SRP OR WOLFSSL_USER_SETTINGS)
set(BUILD_SRP "yes" PARENT_SCOPE)
@ -287,7 +285,6 @@ function(generate_build_flags)
if(WOLFSSL_SP_MATH OR WOLFSSL_SP_MATH_ALL OR WOLFSSL_USER_SETTINGS)
set(BUILD_SP_INT "yes" PARENT_SCOPE)
endif()
set(BUILD_FAST_RSA ${WOLFSSL_FAST_RSA} PARENT_SCOPE)
set(BUILD_MCAPI ${WOLFSSL_MCAPI} PARENT_SCOPE)
set(BUILD_ASYNCCRYPT ${WOLFSSL_ASYNCCRYPT} PARENT_SCOPE)
set(BUILD_WOLFEVENT ${WOLFSSL_ASYNCCRYPT} PARENT_SCOPE)
@ -493,14 +490,10 @@ function(generate_lib_src_list LIB_SOURCES)
list(APPEND LIB_SOURCES wolfcrypt/src/async.c)
endif()
if(NOT BUILD_USER_RSA AND BUILD_RSA)
if(BUILD_FAST_RSA)
list(APPEND LIB_SOURCES wolfcrypt/user-crypto/src/rsa.c)
else()
if(NOT BUILD_FIPS_V2)
list(APPEND LIB_SOURCES wolfcrypt/src/rsa.c)
endif()
endif()
if(BUILD_RSA)
if(NOT BUILD_FIPS_V2)
list(APPEND LIB_SOURCES wolfcrypt/src/rsa.c)
endif()
endif()
if(BUILD_SP)

View File

@ -5420,65 +5420,6 @@ then
esac
fi
# USER CRYPTO
ENABLED_USER_CRYPTO="no"
ENABLED_USER_RSA="no"
AC_DEFINE([BUILD_USER_RSA], [], [User RSA is being defined])
trycryptodir=""
AC_ARG_WITH([user-crypto],
[AS_HELP_STRING([--with-user-crypto=PATH],[Path to USER_CRYPTO install (default /usr/local)])],
[
CPPFLAGS="$CPPFLAGS -DHAVE_USER_CRYPTO"
LIBS="$LIBS -lusercrypto"
if test "x$withval" != "xno" ; then
trycryptodir=$withval
fi
if test "x$withval" = "xyes" ; then
trycryptodir="/usr/local"
fi
LDFLAGS="$LDFLAGS -L$trycryptodir/lib"
CPPFLAGS="$CPPFLAGS -I$trycryptodir/include"
#Look for RSA Init function in usercrypto lib
AC_CHECK_LIB([usercrypto], [wc_InitRsaKey], [user_rsa_linked=yes], [user_rsa_linked=no])
if test "x$user_rsa_linked" = "xyes" ; then
AC_MSG_NOTICE([User user_rsa.h being used])
AM_CFLAGS="$AM_CFLAGS -DHAVE_USER_RSA"
ENABLED_USER_RSA=yes
ENABLED_USER_CRYPTO=yes
fi
#Display check and find result of link attempts
AC_MSG_CHECKING([for USER_CRYPTO])
if test "x$ENABLED_USER_CRYPTO" = "xno" ; then
AC_MSG_RESULT([no])
AC_MSG_ERROR([USER_CRYPTO not found. Either move to /usr/include and /usr/lib or
Specify its path using --with-user-crypto=/dir/])
else
AC_MSG_RESULT([yes])
# Check if .la is available if not then rely on exported path
if test -e $trycryptodir/lib/libusercrypto.la
then
LIB_ADD="$trycryptodir/lib/libusercrypto.la $LIB_ADD"
else
LIB_ADD="-lusercrypto $LIB_ADD"
fi
AM_LDFLAGS="$AM_LDFLAGS -L$trycryptodir/lib"
AM_CFLAGS="$AM_CFLAGS -DHAVE_USER_CRYPTO"
fi
]
)
if test "$ENABLED_USER_CRYPTO" = "yes" && test "$ENABLED_FIPS" = "yes"
then
AC_MSG_ERROR([cannot enable user crypto and fips, user crypto possibility of using code in fips boundary.])
fi
# Whitewood netRandom client library
ENABLED_WNR="no"
trywnrdir=""
@ -7795,171 +7736,6 @@ fi
# End - Single Precision option handling #
################################################################################
# Fast RSA using Intel IPP
ippdir="${srcdir}/IPP"
ipplib="lib" # if autoconf guesses 32bit system changes lib directory
fastRSA_found=no
abs_path=`pwd`
# set up variables used
IPPLIBS=
IPPHEADERS=
IPPLINK=
AC_ARG_ENABLE([fast-rsa],
[AS_HELP_STRING([--enable-fast-rsa],[Enable RSA using Intel IPP (default: disabled)])],
[ ENABLED_FAST_RSA=$enableval ],
[ ENABLED_FAST_RSA=no ],
)
# Fast RSA does not support RSA-PSS
if test "$ENABLED_RSAPSS" = "yes"; then
ENABLED_FAST_RSA=no
fi
if test "$ENABLED_USER_RSA" = "no" && test "$ENABLED_FIPS" = "no"; then
if test "$ac_cv_sizeof_long" = "4" && test "$ac_cv_sizeof_long_long" = "8"; then
ipplib="lib_32" # 32 bit OS detected
fi
# Use static IPP Libraries
if test "$enable_shared" = "no" && test "$ENABLED_FAST_RSA" = "yes"; then
case $host_os in
*darwin*)
ipplib="$ipplib/mac_static"
AC_MSG_ERROR([Issue with static linking to libippcp.a on Mac.
Dynamic IPP libraries supported on Mac])
break;;
*linux*)
ipplib="$ipplib/linux_static"
break;;
*)
ENABLED_FAST_RSA=no
esac
if test -e $srcdir/IPP/$ipplib/libippcore.a && test -e $srcdir/IPP/$ipplib/libippcp.a
then
:
else
ENABLED_FAST_RSA=no
fi
AC_CHECK_HEADERS([IPP/include/ipp.h IPP/include/ippcp.h], [AM_CPPFLAGS="-I$srcdir/IPP/include $AM_CPPFLAGS"], [ENABLED_FAST_RSA=no])
LIB_STATIC_ADD="$srcdir/IPP/$ipplib/libippcp.a $srcdir/IPP/$ipplib/libippcore.a $LIB_STATIC_ADD"
if test "$ENABLED_FAST_RSA" = "no"; then
AC_MSG_ERROR([Could not find fast rsa libraries])
fi
else
# Check for and use bundled IPP libraries
if test "$ENABLED_FAST_RSA" = "yes"; then
AC_MSG_NOTICE([Using local IPP crypto library])
AC_CHECK_HEADER([$abs_path/IPP/include/ippcp.h],
[
# build and default locations on linux and mac
STORE_LDFLAGS=${LDFLAGS}
STORE_CPPFLAGS=${CPPFLAGS}
# using LDFLAGS instead of AM_ temporarily to test link to library
LDFLAGS="-L$ippdir/$ipplib -lippcp -lippcore"
CPPFLAGS="-I$ippdir/include"
AC_CHECK_HEADERS([ippcp.h], [AC_CHECK_LIB([ippcp], [ippsRSAEncrypt_PKCSv15], [fastRSA_found=yes], [fastRSA_found=no])], [fastRSA_found=no])
name="$ippdir/$ipplib/libippcp"
case $host_os in
*darwin*)
# check file existence and conditionally set variables
if test -e $abs_path/IPP/$ipplib/libippcp.dylib
then
IPPLIBS="${name}.dylib ${name}-9.0.dylib ${name}e9-9.0.dylib ${name}g9-9.0.dylib ${name}h9-9.0.dylib ${name}k0-9.0.dylib ${name}l9-9.0.dylib ${name}n8-9.0.dylib ${name}p8-9.0.dylib ${name}s8-9.0.dylib ${name}y8-9.0.dylib IPP/lib/libippcore.dylib IPP/lib/libippcore-9.0.dylib"
IPPLINK="mkdir -p src/.libs && ln -f ${name}.dylib src/.libs/libippcp.dylib && ln -f ${srcdir}/${name}-9.0.dylib src/.libs/libippcp-9.0.dylib && ln -f ${srcdir}/${name}e9-9.0.dylib src/.libs/libippcpe9-9.0.dylib && ln -f ${srcdir}/${name}g9-9.0.dylib src/.libs/libippcpg9-9.0.dylib && ln -f ${srcdir}/${name}h9-9.0.dylib src/.libs/libippcph9-9.0.dylib && ln -f ${srcdir}/${name}k0-9.0.dylib src/.libs/libippcpk0-9.0.dylib && ln -f ${srcdir}/${name}l9-9.0.dylib src/.libs/libippcpl9-9.0.dylib && ln -f ${srcdir}/${name}n8-9.0.dylib src/.libs/libippcpn8-9.0.dylib && ln -f ${srcdir}/${name}p8-9.0.dylib src/.libs/libippcpp8-9.0.dylib && ln -f ${srcdir}/${name}s8-9.0.dylib src/.libs/libippcps8-9.0.dylib && ln -f ${srcdir}/${name}y8-9.0.dylib src/.libs/libippcpy8-9.0.dylib && ln -f ${srcdir}/IPP/lib/libippcore.dylib src/.libs/libippcore.dylib && ln -f ${srcdir}/IPP/lib/libippcore-9.0.dylib src/.libs/libippcore-9.0.dylib"
else
fastRSA_found=no
fi
break;;
*linux*)
# check file existence and conditionally set variables
if test -e $abs_path/IPP/$ipplib/libippcp.so.9.0
then
if test "$ac_cv_sizeof_long" = "4" && test "$ac_cv_sizeof_long_long" = "8"; then
IPPLIBS="${name}.so.9.0 ${name}g9.so.9.0 ${name}h9.so.9.0 ${name}p8.so.9.0 ${name}px.so.9.0 ${name}s8.so.9.0 ${name}.so ${name}w7.so.9.0 IPP/$ipplib/libippcore.so IPP/$ipplib/libippcore.so.9.0"
IPPLINK="mkdir -p src/.libs && ln -f ${name}.so.9.0 src/.libs/libippcp.so.9.0 && ln -f ${name}g9.so.9.0 src/.libs/libippcpg9.so.9.0 && ln -f ${name}h9.so.9.0 src/.libs/libippcph9.so.9.0 && ln -f ${name}p8.so.9.0 src/.libs/libippcpp8.so.9.0 && ln -f ${name}px.so.9.0 src/.libs/libippcppx.so.9.0 && ln -f ${name}s8.so.9.0 src/.libs/libippcps8.so.9.0 && ln -f ${name}.so src/.libs/libippcp.so && ln -f ${name}w7.so.9.0 src/.libs/libippcpw7.so.9.0 && ln -f IPP/$ipplib/libippcore.so src/.libs/libippcore.so && ln -f IPP/$ipplib/libippcore.so.9.0 src/.libs/libippcore.so.9.0"
else
IPPLIBS="${name}.so.9.0 ${name}e9.so.9.0 ${name}k0.so.9.0 ${name}l9.so.9.0 ${name}m7.so.9.0 ${name}mx.so.9.0 ${name}.so ${name}n8.so.9.0 ${name}y8.so.9.0 IPP/lib/libippcore.so IPP/lib/libippcore.so.9.0"
IPPLINK="mkdir -p src/.libs && ln -f ${name}.so.9.0 src/.libs/libippcp.so.9.0 && ln -f ${name}e9.so.9.0 src/.libs/libippcpe9.so.9.0 && ln -f ${name}k0.so.9.0 src/.libs/libippcpk0.so.9.0 && ln -f ${name}l9.so.9.0 src/.libs/libippcpl9.so.9.0 && ln -f ${name}m7.so.9.0 src/.libs/libippcpm7.so.9.0 && ln -f ${name}mx.so.9.0 src/.libs/libippcpmx.so.9.0 && ln -f ${name}.so src/.libs/libippcp.so && ln -f ${name}n8.so.9.0 src/.libs/libippcpn8.so.9.0 && ln -f ${name}y8.so.9.0 src/.libs/libippcpy8.so.9.0 && ln -f IPP/lib/libippcore.so src/.libs/libippcore.so && ln -f IPP/lib/libippcore.so.9.0 src/.libs/libippcore.so.9.0"
fi
else
fastRSA_found=no
fi
break;;
*)
fastRSA_found=no
esac
if test "$fastRSA_found" = "yes"; then
# was successful so add tested LDFLAGS to AM_ flags
AM_LDFLAGS="${AM_LDFLAGS} ${LDFLAGS}"
AM_CPPFLAGS="${AM_CPPFLAGS} ${CPPFLAGS}"
IPPHEADERS="${srcdir}/IPP/include/*.h"
fi
# restore LDFLAGS to user set
LDFLAGS=${STORE_LDFLAGS}
CPPFLAGS=${STORE_CPPFLAGS}
], [fastRSA_found=no])
fi
# Don't cache the result so it can be checked
AS_UNSET([ac_cv_header_ippcp_h])
AS_UNSET([ac_cv_header_ipp_h])
AS_UNSET([ac_cv_lib_ippcp_ippsRSAEncrypt_PKCSv15]);
# Check link and see if user has pre-existing IPP Libraries if not using local
if test "$ENABLED_FAST_RSA" = "yes" && test "$fastRSA_found" = "no"; then
AC_MSG_NOTICE([Checking if IPP crypto library installed])
AC_CHECK_HEADER([ippcp.h], [AC_CHECK_LIB([ippcp], [ippsRSAEncrypt_PKCSv15],
[
fastRSA_found=yes
AM_LDFLAGS="${AM_LDFLAGS} -lippcore -lippcp"
], [ fastRSA_found=no])
], [fastRSA_found=no])
# Error out on not finding libraries
if test "$fastRSA_found" = "no"; then
AC_MSG_ERROR([Could not find fast rsa libraries])
fi
fi
fi # end of if for shared library
else # if user rsa is set than do not use fast rsa option
if test "$ENABLED_FAST_RSA" = "yes"; then
AC_MSG_ERROR([Could not use fast rsa libraries with user crypto or fips])
fi
fi # end of if for user rsa crypto or fips
# End result of checking for IPP Libraries
AC_MSG_CHECKING([for fast RSA])
if test "$ENABLED_FAST_RSA" = "yes"; then
AM_CFLAGS="$AM_CFLAGS -DHAVE_FAST_RSA -DHAVE_USER_RSA"
# add in user crypto header that uses Intel IPP
AM_CPPFLAGS="$AM_CPPFLAGS -I$srcdir/wolfcrypt/user-crypto/include"
if test "$enable_shared" = "yes"; then
LIBS="$LIBS -lippcore -lippcp"
LIB_ADD="-lippcp -lippcore $LIB_ADD"
else
LIB_ADD="$srcdir/IPP/$ipplib/libippcp.a $srcdir/IPP/$ipplib/libippcore.a $LIB_ADD"
fi
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
fi
AC_SUBST([IPPLIBS])
AC_SUBST([IPPHEADERS])
AC_SUBST([IPPLINK])
# static memory use
AC_ARG_ENABLE([staticmemory],
[AS_HELP_STRING([--enable-staticmemory],[Enable static memory use (default: disabled)])],
@ -9123,9 +8899,6 @@ if test "x$ENABLED_LINUXKM" = "xyes"; then
if test "$ENABLED_FASTMATH" = "yes"; then
AC_MSG_ERROR([--enable-fastmath is incompatible with --enable-linuxkm (exceeds stack limit).])
fi
if test "$ENABLED_FAST_RSA" = "yes"; then
AC_MSG_ERROR([--enable-fastrsa is incompatible with --enable-linuxkm.])
fi
if test "$ENABLED_LIBZ_RSA" = "yes"; then
AC_MSG_ERROR([--with-libz is incompatible with --enable-linuxkm.])
fi
@ -9243,8 +9016,6 @@ AM_CONDITIONAL([BUILD_OCSP_STAPLING],[test "x$ENABLED_CERTIFICATE_STATUS_REQUEST
AM_CONDITIONAL([BUILD_OCSP_STAPLING_V2],[test "x$ENABLED_CERTIFICATE_STATUS_REQUEST_V2" = "xyes"])
AM_CONDITIONAL([BUILD_CRL],[test "x$ENABLED_CRL" != "xno" || test "x$ENABLED_USERSETTINGS" = "xyes"])
AM_CONDITIONAL([BUILD_CRL_MONITOR],[test "x$ENABLED_CRL_MONITOR" = "xyes"])
AM_CONDITIONAL([BUILD_USER_RSA],[test "x$ENABLED_USER_RSA" = "xyes"] )
AM_CONDITIONAL([BUILD_USER_CRYPTO],[test "x$ENABLED_USER_CRYPTO" = "xyes"])
AM_CONDITIONAL([BUILD_LIBLMS],[test "x$ENABLED_LIBLMS" = "xyes"])
AM_CONDITIONAL([BUILD_LIBXMSS],[test "x$ENABLED_LIBXMSS" = "xyes"])
AM_CONDITIONAL([BUILD_LIBOQS],[test "x$ENABLED_LIBOQS" = "xyes"])
@ -9290,7 +9061,6 @@ AM_CONDITIONAL([BUILD_SP_INT],[test "x$ENABLED_SP_MATH" = "xyes" || test "x$ENAB
AM_COND_IF([BUILD_SP], [INCLUDE_SP_INT="yes"])
AM_COND_IF([BUILD_SP_INT], [INCLUDE_SP_INT="yes"])
AC_SUBST([INCLUDE_SP_INT])
AM_CONDITIONAL([BUILD_FAST_RSA],[test "x$ENABLED_FAST_RSA" = "xyes"])
AM_CONDITIONAL([BUILD_MCAPI],[test "x$ENABLED_MCAPI" = "xyes"])
AM_CONDITIONAL([BUILD_ASYNCCRYPT],[test "x$ENABLED_ASYNCCRYPT" = "xyes"])
AM_CONDITIONAL([BUILD_WOLFEVENT],[test "x$ENABLED_ASYNCCRYPT" = "xyes"])
@ -9780,8 +9550,6 @@ echo " * Examples: $ENABLED_EXAMPLES"
echo " * Crypt tests: $ENABLED_CRYPT_TESTS"
echo " * Stack sizes in tests: $ENABLED_STACKSIZE"
echo " * Heap stats in tests: $ENABLED_TRACKMEMORY"
echo " * User Crypto: $ENABLED_USER_CRYPTO"
echo " * Fast RSA: $ENABLED_FAST_RSA"
echo " * Asynchronous Crypto: $ENABLED_ASYNCCRYPT"
echo " * Asynchronous Crypto (sim): $ENABLED_ASYNCCRYPT_SW"
echo " * Cavium Nitrox: $ENABLED_CAVIUM"

View File

@ -62,7 +62,6 @@ rm -rf ./swig
rm -rf ./tests
rm -rf ./testsuite
rm -rf ./tirtos
rm -rf ./wolfcrypt/user-crypto
rm -rf ./wrapper
rm -f -- *.rc *.supp *.ac *.am *.conf *.sh *.cproject *.project *.pl
rm -f Vagrantfile SCRIPTS-LIST quit input resource.h

View File

@ -37,20 +37,6 @@ src_libwolfssl@LIBSUFFIX@_la_LIBADD = $(LIBM) $(LIB_ADD) $(LIB_STATIC_ADD)
src_libwolfssl@LIBSUFFIX@_la_CFLAGS = -DBUILDING_WOLFSSL $(AM_CFLAGS) -DLIBWOLFSSL_GLOBAL_EXTRA_CFLAGS="\" $(EXTRA_CFLAGS)\""
src_libwolfssl@LIBSUFFIX@_la_CPPFLAGS = -DBUILDING_WOLFSSL $(AM_CPPFLAGS)
# install the packaged IPP libraries
if BUILD_FAST_RSA
# Link needed IPP libraries
noinst_SCRIPTS+=IPP_links
IPP_links:
@$(IPPLINK)
ippdir = $(libdir)
ipp_DATA = $(IPPLIBS)
include_HEADERS+=$(IPPHEADERS)
endif # BUILD_FAST_RSA
if BUILD_FIPS
if BUILD_FIPS_V2
@ -370,17 +356,11 @@ if BUILD_ASYNCCRYPT
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/async.c
endif
if !BUILD_USER_RSA
if BUILD_RSA
if BUILD_FAST_RSA
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/user-crypto/src/rsa.c
else
if !BUILD_FIPS_CURRENT
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/rsa.c
endif !BUILD_FIPS_CURRENT
endif
endif
endif
if BUILD_RC2
src_libwolfssl@LIBSUFFIX@_la_SOURCES += wolfcrypt/src/rc2.c

View File

@ -50,8 +50,7 @@
#endif
#if defined(OPENSSL_EXTRA) && !defined(NO_BIO) && defined(WOLFSSL_KEY_GEN) && \
(!defined(HAVE_USER_RSA) || defined(HAVE_ECC) || \
(!defined(NO_DSA) && !defined(HAVE_SELFTEST)))
(defined(HAVE_ECC) || (!defined(NO_DSA) && !defined(HAVE_SELFTEST)))
/* Forward declaration for wolfSSL_PEM_write_bio_DSA_PUBKEY.
* Implementation in ssl.c.
*/
@ -220,8 +219,8 @@ static int pem_read_file_key(XFILE fp, wc_pem_password_cb* cb, void* pass,
#endif /* !NO_FILESYSTEM */
#endif
#if defined(OPENSSL_EXTRA) && ((!defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) \
&& !defined(HAVE_USER_RSA)) || !defined(WOLFCRYPT_ONLY))
#if defined(OPENSSL_EXTRA) && ((!defined(NO_RSA) && defined(WOLFSSL_KEY_GEN)) \
|| !defined(WOLFCRYPT_ONLY))
/* Convert DER data to PEM in an allocated buffer.
*
* @param [in] der Buffer containing DER data.
@ -298,8 +297,7 @@ static int der_write_to_bio_as_pem(const unsigned char* der, int derSz,
#endif
#endif
#if (!defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && \
!defined(HAVE_USER_RSA)) || \
#if (!defined(NO_RSA) && defined(WOLFSSL_KEY_GEN)) || \
(!defined(NO_DH) && defined(WOLFSSL_DH_EXTRA)) || \
(defined(HAVE_ECC) && defined(WOLFSSL_KEY_GEN))
#if !defined(NO_FILESYSTEM)
@ -337,7 +335,7 @@ static int der_write_to_file_as_pem(const unsigned char* der, int derSz,
#if defined(WOLFSSL_KEY_GEN) && \
(defined(WOLFSSL_PEM_TO_DER) || defined(WOLFSSL_DER_TO_PEM)) && \
((!defined(NO_RSA) && !defined(HAVE_USER_RSA)) || defined(HAVE_ECC))
(!defined(NO_RSA) || defined(HAVE_ECC))
static int der_to_enc_pem_alloc(unsigned char* der, int derSz,
const EVP_CIPHER *cipher, unsigned char *passwd, int passwdSz, int type,
void* heap, byte** out, int* outSz)
@ -532,8 +530,7 @@ static int pk_bn_field_print_fp(XFILE fp, int indent, const char* field,
#endif /* !NO_CERTS && XFPRINTF && !NO_FILESYSTEM && !NO_STDIO_FILESYSTEM &&
* (!NO_DSA || !NO_RSA || HAVE_ECC) */
#if defined(XSNPRINTF) && !defined(NO_BIO) && !defined(NO_RSA) && \
!defined(HAVE_FAST_RSA)
#if defined(XSNPRINTF) && !defined(NO_BIO) && !defined(NO_RSA)
/* snprintf() must be available */
/* Maximum number of extra indent spaces on each line. */
@ -737,7 +734,7 @@ static int wolfssl_print_number(WOLFSSL_BIO* bio, mp_int* num, const char* name,
return ret;
}
#endif /* XSNPRINTF && !NO_BIO && !NO_RSA && !HAVE_FAST_RSA */
#endif /* XSNPRINTF && !NO_BIO && !NO_RSA */
#if !defined(NO_RSA) || (!defined(NO_DH) && !defined(NO_CERTS) && \
defined(HAVE_FIPS) && !FIPS_VERSION_GT(2,0)) || defined(HAVE_ECC)
@ -922,8 +919,7 @@ void wolfSSL_RSA_free(WOLFSSL_RSA* rsa)
#endif
if (rsa->internal != NULL) {
#if !defined(HAVE_FIPS) && !defined(HAVE_USER_RSA) && \
!defined(HAVE_FAST_RSA) && defined(WC_RSA_BLINDING)
#if !defined(HAVE_FIPS) && defined(WC_RSA_BLINDING)
/* Check if RNG is owned before freeing it. */
if (rsa->ownRng) {
WC_RNG* rng = ((RsaKey*)(rsa->internal))->rng;
@ -1022,8 +1018,7 @@ WOLFSSL_RSA* wolfSSL_RSA_new_ex(void* heap, int devId)
rsaKeyInited = 1;
}
}
#if !defined(HAVE_FIPS) && !defined(HAVE_USER_RSA) && \
!defined(HAVE_FAST_RSA) && defined(WC_RSA_BLINDING)
#if !defined(HAVE_FIPS) && defined(WC_RSA_BLINDING)
if (!err) {
WC_RNG* rng;
@ -1052,8 +1047,7 @@ WOLFSSL_RSA* wolfSSL_RSA_new_ex(void* heap, int devId)
/* Won't fail as key and rng are not NULL. */
}
}
#endif /* !HAVE_FIPS && !HAVE_USER_RSA && !HAVE_FAST_RSA &&
* WC_RSA_BLINDING */
#endif /* !HAVE_FIPS && WC_RSA_BLINDING */
if (!err) {
/* Set wolfCrypt RSA key into RSA key. */
rsa->internal = key;
@ -1105,7 +1099,7 @@ int wolfSSL_RSA_up_ref(WOLFSSL_RSA* rsa)
#ifdef OPENSSL_EXTRA
#if defined(WOLFSSL_KEY_GEN) && !defined(HAVE_USER_RSA)
#if defined(WOLFSSL_KEY_GEN)
/* Allocate a new RSA key and make it a copy.
*
@ -1161,12 +1155,10 @@ WOLFSSL_RSA* wolfSSL_RSAPublicKey_dup(WOLFSSL_RSA *rsa)
/* wolfSSL_RSAPrivateKey_dup not supported */
#endif /* WOLFSSL_KEY_GEN && !HAVE_USER_RSA */
#endif /* WOLFSSL_KEY_GEN */
#ifndef HAVE_USER_RSA
static int wolfSSL_RSA_To_Der_ex(WOLFSSL_RSA* rsa, byte** outBuf, int publicKey,
void* heap);
#endif
/*
* RSA to/from bin APIs
@ -1270,8 +1262,6 @@ WOLFSSL_RSA *wolfSSL_d2i_RSAPrivateKey(WOLFSSL_RSA **out,
return rsa;
}
#if defined(OPENSSL_EXTRA) && !defined(HAVE_USER_RSA) && \
!defined(HAVE_FAST_RSA)
/* Converts an internal RSA structure to DER format for the private key.
*
* If "pp" is null then buffer size only is returned.
@ -1345,8 +1335,6 @@ int wolfSSL_i2d_RSAPublicKey(WOLFSSL_RSA *rsa, unsigned char **pp)
return ret;
}
#endif /* defined(OPENSSL_EXTRA) && !defined(HAVE_USER_RSA) &&
* !defined(HAVE_FAST_RSA) */
#endif /* OPENSSL_EXTRA */
@ -1359,8 +1347,7 @@ int wolfSSL_i2d_RSAPublicKey(WOLFSSL_RSA *rsa, unsigned char **pp)
#if defined(OPENSSL_ALL) || defined(WOLFSSL_ASIO) || defined(WOLFSSL_HAPROXY) \
|| defined(WOLFSSL_NGINX) || defined(WOLFSSL_QT)
#if defined(WOLFSSL_KEY_GEN) && !defined(HAVE_USER_RSA) && \
!defined(HAVE_FAST_RSA) && !defined(NO_BIO)
#if defined(WOLFSSL_KEY_GEN) && !defined(NO_BIO)
/* Read DER data from a BIO.
*
@ -1464,8 +1451,7 @@ WOLFSSL_RSA* wolfSSL_d2i_RSAPrivateKey_bio(WOLFSSL_BIO *bio, WOLFSSL_RSA **out)
XFREE(der, bio ? bio->heap : NULL, DYNAMIC_TYPE_TMP_BUFFER);
return key;
}
#endif /* defined(WOLFSSL_KEY_GEN) && !defined(HAVE_USER_RSA) &&
* !defined(HAVE_FAST_RSA) && !NO_BIO */
#endif /* defined(WOLFSSL_KEY_GEN) && !NO_BIO */
#endif /* OPENSSL_ALL || WOLFSSL_ASIO || WOLFSSL_HAPROXY || WOLFSSL_QT */
@ -1475,7 +1461,6 @@ WOLFSSL_RSA* wolfSSL_d2i_RSAPrivateKey_bio(WOLFSSL_BIO *bio, WOLFSSL_RSA **out)
#ifdef OPENSSL_EXTRA
#ifndef HAVE_USER_RSA
/* Create a DER encoding of key.
*
* Not OpenSSL API.
@ -1612,7 +1597,6 @@ static int wolfSSL_RSA_To_Der_ex(WOLFSSL_RSA* rsa, byte** outBuf, int publicKey,
WOLFSSL_LEAVE("wolfSSL_RSA_To_Der", ret);
return ret;
}
#endif /* !HAVE_USER_RSA */
#endif /* OPENSSL_EXTRA */
@ -1772,7 +1756,7 @@ static WOLFSSL_RSA* wolfssl_rsa_d2i(WOLFSSL_RSA** rsa, const unsigned char* in,
#ifdef OPENSSL_EXTRA
#ifndef NO_BIO
#if defined(WOLFSSL_KEY_GEN) && !defined(HAVE_USER_RSA)
#if defined(WOLFSSL_KEY_GEN)
/* Writes PEM encoding of an RSA public key to a BIO.
*
* @param [in] bio BIO object to write to.
@ -1812,10 +1796,10 @@ int wolfSSL_PEM_write_bio_RSA_PUBKEY(WOLFSSL_BIO* bio, WOLFSSL_RSA* rsa)
return ret;
}
#endif /* WOLFSSL_KEY_GEN && !HAVE_USER_RSA */
#endif /* WOLFSSL_KEY_GEN */
#endif /* !NO_BIO */
#if defined(WOLFSSL_KEY_GEN) && !defined(HAVE_USER_RSA)
#if defined(WOLFSSL_KEY_GEN)
#ifndef NO_FILESYSTEM
/* Writes PEM encoding of an RSA public key to a file pointer.
@ -1886,7 +1870,7 @@ int wolfSSL_PEM_write_RSAPublicKey(XFILE fp, WOLFSSL_RSA* rsa)
return wolfssl_pem_write_rsa_public_key(fp, rsa, RSA_PUBLICKEY_TYPE);
}
#endif /* !NO_FILESYSTEM */
#endif /* WOLFSSL_KEY_GEN && !HAVE_USER_RSA */
#endif /* WOLFSSL_KEY_GEN */
#ifndef NO_BIO
/* Create an RSA public key by reading the PEM encoded data from the BIO.
@ -1983,7 +1967,7 @@ WOLFSSL_RSA* wolfSSL_PEM_read_RSAPublicKey(XFILE fp, WOLFSSL_RSA** rsa,
#endif /* NO_FILESYSTEM */
#if defined(WOLFSSL_KEY_GEN) && !defined(HAVE_USER_RSA) && \
#if defined(WOLFSSL_KEY_GEN) && \
(defined(WOLFSSL_PEM_TO_DER) || defined(WOLFSSL_DER_TO_PEM))
/* Writes PEM encoding of an RSA private key to newly allocated buffer.
@ -2142,7 +2126,7 @@ int wolfSSL_PEM_write_RSAPrivateKey(XFILE fp, WOLFSSL_RSA *rsa,
return ret;
}
#endif /* NO_FILESYSTEM */
#endif /* WOLFSSL_KEY_GEN && !HAVE_USER_RSA && WOLFSSL_PEM_TO_DER */
#endif /* WOLFSSL_KEY_GEN && WOLFSSL_PEM_TO_DER */
#ifndef NO_BIO
/* Create an RSA private key by reading the PEM encoded data from the BIO.
@ -2290,7 +2274,7 @@ int wolfSSL_RSA_print_fp(XFILE fp, WOLFSSL_RSA* rsa, int indent)
}
#endif /* XFPRINTF && !NO_FILESYSTEM && !NO_STDIO_FILESYSTEM */
#if defined(XSNPRINTF) && !defined(NO_BIO) && !defined(HAVE_FAST_RSA)
#if defined(XSNPRINTF) && !defined(NO_BIO)
/* snprintf() must be available */
/* Maximum size of a header line. */
@ -2398,7 +2382,7 @@ int wolfSSL_RSA_print(WOLFSSL_BIO* bio, WOLFSSL_RSA* rsa, int indent)
return ret;
}
#endif /* XSNPRINTF && !NO_BIO && !HAVE_FAST_RSA */
#endif /* XSNPRINTF && !NO_BIO */
#endif /* OPENSSL_EXTRA */
@ -2407,7 +2391,6 @@ int wolfSSL_RSA_print(WOLFSSL_BIO* bio, WOLFSSL_RSA* rsa, int indent)
*/
#if defined(OPENSSL_EXTRA) || defined(OPENSSL_EXTRA_X509_SMALL)
#if !defined(HAVE_USER_RSA) && !defined(HAVE_FAST_RSA)
/* Set RSA key data (external) from wolfCrypt RSA key (internal).
*
* @param [in, out] rsa RSA key.
@ -2500,12 +2483,10 @@ int SetRsaExternal(WOLFSSL_RSA* rsa)
return ret;
}
#endif /* !HAVE_USER_RSA && !HAVE_FAST_RSA */
#endif /* (OPENSSL_EXTRA || OPENSSL_EXTRA_X509_SMALL) */
#ifdef OPENSSL_EXTRA
#if !defined(HAVE_USER_RSA) && !defined(HAVE_FAST_RSA)
/* Set wolfCrypt RSA key data (internal) from RSA key (external).
*
* @param [in, out] rsa RSA key.
@ -2601,8 +2582,6 @@ int SetRsaInternal(WOLFSSL_RSA* rsa)
return ret;
}
#endif /* HAVE_USER_RSA */
/* Set the RSA method into object.
*
* @param [in, out] rsa RSA key.
@ -2679,8 +2658,6 @@ int wolfSSL_RSA_bits(const WOLFSSL_RSA* rsa)
return ret;
}
#ifndef HAVE_USER_RSA
/* Get the BN objects that are the Chinese-Remainder Theorem (CRT) parameters.
*
* Only for those that are not NULL parameters.
@ -2922,8 +2899,6 @@ int wolfSSL_RSA_set0_key(WOLFSSL_RSA *rsa, WOLFSSL_BIGNUM *n, WOLFSSL_BIGNUM *e,
return ret;
}
#endif /* !HAVE_USER_RSA */
/* Get the flags of the RSA key.
*
* @param [in] rsa RSA key.
@ -3088,7 +3063,6 @@ int wolfSSL_RSA_check_key(const WOLFSSL_RSA* rsa)
* RSA generate APIs
*/
#if !defined(HAVE_USER_RSA) && !defined(HAVE_FAST_RSA)
/* Get a random number generator associated with the RSA key.
*
* If not able, then get the global if possible.
@ -3131,7 +3105,6 @@ WC_RNG* WOLFSSL_RSA_GetRNG(WOLFSSL_RSA* rsa, WC_RNG** tmpRng, int* initTmpRng)
return rng;
}
#endif
/* Use the wolfCrypt RSA APIs to generate a new RSA key.
*
@ -3652,8 +3625,6 @@ int wolfSSL_RSA_verify_PKCS1_PSS(WOLFSSL_RSA *rsa, const unsigned char *mHash,
#if defined(OPENSSL_EXTRA)
#if !defined(HAVE_USER_RSA)
/* Encode the message hash.
*
* Used by signing and verification.
@ -4082,8 +4053,6 @@ int wolfSSL_RSA_verify_ex(int hashAlg, const unsigned char* hash,
* RSA public/private encrypt/decrypt APIs
*/
#if !defined(HAVE_USER_RSA) && !defined(HAVE_FAST_RSA)
/* Encrypt with the RSA public key.
*
* Return compliant with OpenSSL.
@ -4481,7 +4450,6 @@ int wolfSSL_RSA_private_encrypt(int len, const unsigned char* from,
WOLFSSL_LEAVE("wolfSSL_RSA_private_encrypt", ret);
return ret;
}
#endif /* !HAVE_USER_RSA && !HAVE_FAST_RSA */
/*
* RSA misc operation APIs
@ -4581,7 +4549,6 @@ int wolfSSL_RSA_GenAdd(WOLFSSL_RSA* rsa)
return ret;
}
#endif /* !HAVE_USER_RSA */
#ifndef NO_WOLFSSL_STUB
/* Enable blinding for RSA key operations.

View File

@ -24176,7 +24176,7 @@ static int pem_write_pubkey(WOLFSSL_EVP_PKEY* key, void* heap, byte** derBuf,
}
switch (key->type) {
#if defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA)
case EVP_PKEY_RSA:
if ((sz = wolfSSL_RSA_To_Der(key->rsa, &buf, 1, heap))
< 0) {
@ -24184,7 +24184,7 @@ static int pem_write_pubkey(WOLFSSL_EVP_PKEY* key, void* heap, byte** derBuf,
break;
}
break;
#endif /* WOLFSSL_KEY_GEN && !NO_RSA && !HAVE_USER_RSA */
#endif /* WOLFSSL_KEY_GEN && !NO_RSA */
#if !defined(NO_DSA) && !defined(HAVE_SELFTEST) && (defined(WOLFSSL_KEY_GEN) || \
defined(WOLFSSL_CERT_GEN))
case EVP_PKEY_DSA:
@ -26839,7 +26839,7 @@ int wolfSSL_CTX_use_PrivateKey(WOLFSSL_CTX *ctx, WOLFSSL_EVP_PKEY *pkey)
}
switch (pkey->type) {
#if defined(WOLFSSL_KEY_GEN) && !defined(HAVE_USER_RSA) && !defined(NO_RSA)
#if defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA)
case EVP_PKEY_RSA:
WOLFSSL_MSG("populating RSA key");
if (PopulateRSAEvpPkeyDer(pkey) != WOLFSSL_SUCCESS)
@ -27494,8 +27494,7 @@ int wolfSSL_CTX_use_certificate_ASN1(WOLFSSL_CTX *ctx, int derSz,
}
#if !defined(HAVE_FAST_RSA) && defined(WOLFSSL_KEY_GEN) && \
!defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA)
/* Adds the rsa private key to the user ctx.
Returns WOLFSSL_SUCCESS if no error, returns WOLFSSL_FAILURE otherwise.*/
int wolfSSL_CTX_use_RSAPrivateKey(WOLFSSL_CTX* ctx, WOLFSSL_RSA* rsa)
@ -27533,7 +27532,7 @@ int wolfSSL_CTX_use_RSAPrivateKey(WOLFSSL_CTX* ctx, WOLFSSL_RSA* rsa)
XFREE(maxDerBuf, NULL, DYNAMIC_TYPE_TMP_BUFFER);
return ret;
}
#endif /* NO_RSA && !HAVE_FAST_RSA */
#endif /* WOLFSSL_KEY_GEN && !NO_RSA */
#ifndef NO_BIO

View File

@ -234,10 +234,6 @@
#define FOURK_BUF 4096
#define GEN_BUF 294
#ifndef USER_CRYPTO_ERROR
#define USER_CRYPTO_ERROR (-101) /* error returned by IPP lib. */
#endif
#endif
#ifndef NO_SIG_WRAPPER
@ -18685,11 +18681,7 @@ static int test_wc_InitRsaKey(void)
ExpectIntEQ(wc_InitRsaKey(&key, HEAP_HINT), 0);
/* Test bad args. */
#ifndef HAVE_USER_RSA
ExpectIntEQ(wc_InitRsaKey(NULL, HEAP_HINT), BAD_FUNC_ARG);
#else
ExpectIntEQ(wc_InitRsaKey(NULL, HEAP_HINT), USER_CRYPTO_ERROR);
#endif
DoExpectIntEQ(wc_FreeRsaKey(&key), 0);
#endif
@ -18726,7 +18718,7 @@ static int test_wc_RsaPrivateKeyDecode(void)
}
ExpectIntEQ(wc_RsaPrivateKeyDecode(tmp, &idx, &key, (word32)bytes), 0);
#ifndef HAVE_USER_RSA
/* Test bad args. */
ExpectIntEQ(wc_RsaPrivateKeyDecode(NULL, &idx, &key, (word32)bytes),
BAD_FUNC_ARG);
@ -18734,15 +18726,6 @@ static int test_wc_RsaPrivateKeyDecode(void)
BAD_FUNC_ARG);
ExpectIntEQ(wc_RsaPrivateKeyDecode(tmp, &idx, NULL, (word32)bytes),
BAD_FUNC_ARG);
#else
/* Test bad args. User RSA. */
ExpectIntEQ(wc_RsaPrivateKeyDecode(NULL, &idx, &key, (word32)bytes),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaPrivateKeyDecode(tmp, NULL, &key, (word32)bytes),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaPrivateKeyDecode(tmp, &idx, NULL, (word32)bytes),
USER_CRYPTO_ERROR);
#endif
XFREE(tmp, NULL, DYNAMIC_TYPE_TMP_BUFFER);
DoExpectIntEQ(wc_FreeRsaKey(&key), 0);
@ -18789,7 +18772,7 @@ static int test_wc_RsaPublicKeyDecode(void)
}
ExpectIntEQ(wc_RsaPublicKeyDecode(tmp, &idx, &keyPub, (word32)bytes), 0);
#ifndef HAVE_USER_RSA
/* Pass in bad args. */
ExpectIntEQ(wc_RsaPublicKeyDecode(NULL, &idx, &keyPub, (word32)bytes),
BAD_FUNC_ARG);
@ -18797,15 +18780,6 @@ static int test_wc_RsaPublicKeyDecode(void)
BAD_FUNC_ARG);
ExpectIntEQ(wc_RsaPublicKeyDecode(tmp, &idx, NULL, (word32)bytes),
BAD_FUNC_ARG);
#else
/* Pass in bad args. */
ExpectIntEQ(wc_RsaPublicKeyDecode(NULL, &idx, &keyPub, (word32)bytes),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaPublicKeyDecode(tmp, NULL, &keyPub, (word32)bytes),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaPublicKeyDecode(tmp, &idx, NULL, (word32)bytes),
USER_CRYPTO_ERROR);
#endif
DoExpectIntEQ(wc_FreeRsaKey(&keyPub), 0);
@ -18854,7 +18828,7 @@ static int test_wc_RsaPublicKeyDecodeRaw(void)
ExpectIntEQ(wc_InitRsaKey(&key, HEAP_HINT), 0);
ExpectIntEQ(wc_RsaPublicKeyDecodeRaw(&n, nSz, &e, eSz, &key), 0);
#ifndef HAVE_USER_RSA
/* Pass in bad args. */
ExpectIntEQ(wc_RsaPublicKeyDecodeRaw(NULL, nSz, &e, eSz, &key),
BAD_FUNC_ARG);
@ -18862,15 +18836,7 @@ static int test_wc_RsaPublicKeyDecodeRaw(void)
BAD_FUNC_ARG);
ExpectIntEQ(wc_RsaPublicKeyDecodeRaw(&n, nSz, &e, eSz, NULL),
BAD_FUNC_ARG);
#else
/* Pass in bad args. User RSA. */
ExpectIntEQ(wc_RsaPublicKeyDecodeRaw(NULL, nSz, &e, eSz, &key),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaPublicKeyDecodeRaw(&n, nSz, NULL, eSz, &key),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaPublicKeyDecodeRaw(&n, nSz, &e, eSz, NULL),
USER_CRYPTO_ERROR);
#endif
DoExpectIntEQ(wc_FreeRsaKey(&key), 0);
#endif
@ -18879,7 +18845,7 @@ static int test_wc_RsaPublicKeyDecodeRaw(void)
} /* END test_wc_RsaPublicKeyDecodeRaw */
#if (!defined(NO_RSA) || !defined(HAVE_FAST_RSA)) && defined(WOLFSSL_KEY_GEN)
#if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN)
/* In FIPS builds, wc_MakeRsaKey() will return an error if it cannot find
* a probable prime in 5*(modLen/2) attempts. In non-FIPS builds, it keeps
* trying until it gets a probable prime. */
@ -18929,7 +18895,6 @@ static int test_wc_MakeRsaKey(void)
ExpectIntEQ(MAKE_RSA_KEY(&genKey, bits, WC_RSA_EXPONENT, &rng), 0);
DoExpectIntEQ(wc_FreeRsaKey(&genKey), 0);
#ifndef HAVE_USER_RSA
/* Test bad args. */
ExpectIntEQ(MAKE_RSA_KEY(NULL, bits, WC_RSA_EXPONENT, &rng), BAD_FUNC_ARG);
ExpectIntEQ(MAKE_RSA_KEY(&genKey, bits, WC_RSA_EXPONENT, NULL),
@ -18938,17 +18903,6 @@ static int test_wc_MakeRsaKey(void)
ExpectIntEQ(MAKE_RSA_KEY(&genKey, bits, 2, &rng), BAD_FUNC_ARG);
/* e & 1 == 0 */
ExpectIntEQ(MAKE_RSA_KEY(&genKey, bits, 6, &rng), BAD_FUNC_ARG);
#else
/* Test bad args. */
ExpectIntEQ(MAKE_RSA_KEY(NULL, bits, WC_RSA_EXPONENT, &rng),
USER_CRYPTO_ERROR);
ExpectIntEQ(MAKE_RSA_KEY(&genKey, bits, WC_RSA_EXPONENT, NULL),
USER_CRYPTO_ERROR);
/* e < 3 */
ExpectIntEQ(MAKE_RSA_KEY(&genKey, bits, 2, &rng), USER_CRYPTO_ERROR);
/* e & 1 == 0 */
ExpectIntEQ(MAKE_RSA_KEY(&genKey, bits, 6, &rng), USER_CRYPTO_ERROR);
#endif /* HAVE_USER_RSA */
DoExpectIntEQ(wc_FreeRng(&rng), 0);
#endif
@ -19351,7 +19305,7 @@ static int test_wc_RsaKeyToDer(void)
ExpectIntEQ(MAKE_RSA_KEY(&genKey, bits, WC_RSA_EXPONENT, &rng), 0);
ExpectIntGT(wc_RsaKeyToDer(&genKey, der, derSz), 0);
#ifndef HAVE_USER_RSA
/* Pass good/bad args. */
ExpectIntEQ(wc_RsaKeyToDer(NULL, der, FOURK_BUF), BAD_FUNC_ARG);
/* Get just the output length */
@ -19363,19 +19317,6 @@ static int test_wc_RsaKeyToDer(void)
/* Put back to Private Key */
genKey.type = 1;
#endif
#else
/* Pass good/bad args. */
ExpectIntEQ(wc_RsaKeyToDer(NULL, der, FOURK_BUF), USER_CRYPTO_ERROR);
/* Get just the output length */
ExpectIntGT(wc_RsaKeyToDer(&genKey, NULL, 0), 0);
/* Try Public Key. */
genKey.type = 0;
ExpectIntEQ(wc_RsaKeyToDer(&genKey, der, FOURK_BUF), USER_CRYPTO_ERROR);
#ifdef WOLFSSL_CHECK_MEM_ZERO
/* Put back to Private Key */
genKey.type = 1;
#endif
#endif
XFREE(der, NULL, DYNAMIC_TYPE_TMP_BUFFER);
DoExpectIntEQ(wc_FreeRsaKey(&genKey), 0);
@ -19402,9 +19343,7 @@ static int test_wc_RsaKeyToPublicDer(void)
int bits = 2048;
word32 derLen = 294;
#endif
#ifndef HAVE_USER_RSA
int ret;
#endif
XMEMSET(&rng, 0, sizeof(rng));
XMEMSET(&key, 0, sizeof(key));
@ -19422,16 +19361,10 @@ static int test_wc_RsaKeyToPublicDer(void)
ExpectIntGT(wc_RsaKeyToPublicDer_ex(&key, NULL, derLen, 0), 0);
ExpectIntGT(wc_RsaKeyToPublicDer_ex(&key, der, derLen, 0), 0);
#ifndef HAVE_USER_RSA
/* Pass in bad args. */
ExpectIntEQ(wc_RsaKeyToPublicDer(NULL, der, derLen), BAD_FUNC_ARG);
ExpectIntLT(ret = wc_RsaKeyToPublicDer(&key, der, -1), 0);
ExpectTrue((ret == BUFFER_E) || (ret == BAD_FUNC_ARG));
#else
/* Pass in bad args. */
ExpectIntEQ(wc_RsaKeyToPublicDer(NULL, der, derLen), USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaKeyToPublicDer(&key, der, -1), USER_CRYPTO_ERROR);
#endif
XFREE(der, NULL, DYNAMIC_TYPE_TMP_BUFFER);
DoExpectIntEQ(wc_FreeRsaKey(&key), 0);
@ -19507,8 +19440,7 @@ static int test_wc_RsaPublicEncryptDecrypt_ex(void)
{
EXPECT_DECLS;
#if !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && !defined(HAVE_FIPS)\
&& !defined(WC_NO_RSA_OAEP) && !defined(HAVE_USER_RSA)\
&& !defined(NO_SHA256)
&& !defined(WC_NO_RSA_OAEP) && !defined(NO_SHA256)
RsaKey key;
WC_RNG rng;
const char inStr[] = TEST_STRING;
@ -19605,7 +19537,7 @@ static int test_wc_RsaSSL_SignVerify(void)
/* Sign. */
ExpectIntEQ(wc_RsaSSL_Sign(in, inLen, out, outSz, &key, &rng), (int)outSz);
idx = (int)outSz;
#ifndef HAVE_USER_RSA
/* Test bad args. */
ExpectIntEQ(wc_RsaSSL_Sign(NULL, inLen, out, outSz, &key, &rng),
BAD_FUNC_ARG);
@ -19615,21 +19547,10 @@ static int test_wc_RsaSSL_SignVerify(void)
BAD_FUNC_ARG);
ExpectIntEQ(wc_RsaSSL_Sign(in, inLen, out, outSz, NULL, &rng),
BAD_FUNC_ARG);
#else
/* Test bad args. */
ExpectIntEQ(wc_RsaSSL_Sign(NULL, inLen, out, outSz, &key, &rng),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaSSL_Sign(in, 0, out, outSz, &key, &rng),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaSSL_Sign(in, inLen, NULL, outSz, &key, &rng),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaSSL_Sign(in, inLen, out, outSz, NULL, &rng),
USER_CRYPTO_ERROR);
#endif
/* Verify. */
ExpectIntEQ(wc_RsaSSL_Verify(out, idx, plain, plainSz, &key), (int)inLen);
#ifndef HAVE_USER_RSA
/* Pass bad args. */
ExpectIntEQ(wc_RsaSSL_Verify(NULL, idx, plain, plainSz, &key),
BAD_FUNC_ARG);
@ -19639,17 +19560,6 @@ static int test_wc_RsaSSL_SignVerify(void)
BAD_FUNC_ARG);
ExpectIntEQ(wc_RsaSSL_Verify(out, idx, plain, plainSz, NULL),
BAD_FUNC_ARG);
#else
/* Pass bad args. */
ExpectIntEQ(wc_RsaSSL_Verify(NULL, idx, plain, plainSz, &key),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaSSL_Verify(out, 0, plain, plainSz, &key),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaSSL_Verify(out, idx, NULL, plainSz, &key),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaSSL_Verify(out, idx, plain, plainSz, NULL),
USER_CRYPTO_ERROR);
#endif
WC_FREE_VAR(in, NULL);
WC_FREE_VAR(out, NULL);
@ -19689,11 +19599,7 @@ static int test_wc_RsaEncryptSize(void)
ExpectIntEQ(wc_RsaEncryptSize(&key), 256);
/* Pass in bad arg. */
#ifndef HAVE_USER_RSA
ExpectIntEQ(wc_RsaEncryptSize(NULL), BAD_FUNC_ARG);
#else
ExpectIntEQ(wc_RsaEncryptSize(NULL), 0);
#endif
DoExpectIntEQ(wc_FreeRsaKey(&key), 0);
DoExpectIntEQ(wc_FreeRng(&rng), 0);
@ -19730,7 +19636,7 @@ static int test_wc_RsaFlattenPublicKey(void)
ExpectIntEQ(MAKE_RSA_KEY(&key, bits, WC_RSA_EXPONENT, &rng), 0);
ExpectIntEQ(wc_RsaFlattenPublicKey(&key, e, &eSz, n, &nSz), 0);
#ifndef HAVE_USER_RSA
/* Pass bad args. */
ExpectIntEQ(wc_RsaFlattenPublicKey(NULL, e, &eSz, n, &nSz),
BAD_FUNC_ARG);
@ -19742,19 +19648,6 @@ static int test_wc_RsaFlattenPublicKey(void)
BAD_FUNC_ARG);
ExpectIntEQ(wc_RsaFlattenPublicKey(&key, e, &eSz, n, NULL),
BAD_FUNC_ARG);
#else
/* Pass bad args. */
ExpectIntEQ(wc_RsaFlattenPublicKey(NULL, e, &eSz, n, &nSz),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaFlattenPublicKey(&key, NULL, &eSz, n, &nSz),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaFlattenPublicKey(&key, e, NULL, n, &nSz),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaFlattenPublicKey(&key, e, &eSz, NULL, &nSz),
USER_CRYPTO_ERROR);
ExpectIntEQ(wc_RsaFlattenPublicKey(&key, e, &eSz, n, NULL),
USER_CRYPTO_ERROR);
#endif
DoExpectIntEQ(wc_FreeRsaKey(&key), 0);
DoExpectIntEQ(wc_FreeRng(&rng), 0);
@ -29135,11 +29028,7 @@ static int test_wc_SignatureGetSize_rsa(void)
/* // NOLINTEND(clang-analyzer-optin.core.EnumCastOutOfRange) */
ExpectIntEQ(wc_SignatureGetSize(sig_type, &rsa_key, key_len), BAD_FUNC_ARG);
sig_type = WC_SIGNATURE_TYPE_RSA;
#ifndef HAVE_USER_RSA
ExpectIntEQ(wc_SignatureGetSize(sig_type, NULL, key_len), BAD_FUNC_ARG);
#else
ExpectIntEQ(wc_SignatureGetSize(sig_type, NULL, key_len), 0);
#endif
ExpectIntEQ(wc_SignatureGetSize(sig_type, NULL, key_len), BAD_FUNC_ARG);
key_len = (word32)0;
ExpectIntEQ(wc_SignatureGetSize(sig_type, &rsa_key, key_len), BAD_FUNC_ARG);
@ -32840,16 +32729,16 @@ static int test_wolfSSL_certs(void)
ExpectTrue(SSL_CTX_use_certificate_file(ctx, svrCertFile, SSL_FILETYPE_PEM));
ExpectTrue(SSL_CTX_use_PrivateKey_file(ctx, svrKeyFile, SSL_FILETYPE_PEM));
ExpectTrue(SSL_CTX_use_PrivateKey_file(ctx, cliKeyFile, SSL_FILETYPE_PEM));
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
ExpectIntEQ(SSL_CTX_check_private_key(ctx), SSL_FAILURE);
#endif
ExpectTrue(SSL_CTX_use_PrivateKey_file(ctx, svrKeyFile, SSL_FILETYPE_PEM));
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
ExpectIntEQ(SSL_CTX_check_private_key(ctx), SSL_SUCCESS);
#endif
ExpectNotNull(ssl = SSL_new(ctx));
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
ExpectIntEQ(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS);
#endif
@ -32866,7 +32755,7 @@ static int test_wolfSSL_certs(void)
WOLFSSL_FILETYPE_PEM));
ExpectIntEQ(SSL_use_certificate(ssl, x509ext), WOLFSSL_SUCCESS);
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
/* with loading in a new cert the check on private key should now fail */
ExpectIntNE(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS);
#endif
@ -33127,16 +33016,16 @@ static int test_wolfSSL_private_keys(void)
ExpectTrue(SSL_CTX_use_PrivateKey_file(ctx, svrKeyFile, WOLFSSL_FILETYPE_PEM));
/* Have to load a cert before you can check the private key against that
* certificates public key! */
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
ExpectIntEQ(wolfSSL_CTX_check_private_key(ctx), WOLFSSL_FAILURE);
#endif
ExpectTrue(SSL_CTX_use_certificate_file(ctx, svrCertFile, WOLFSSL_FILETYPE_PEM));
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
ExpectIntEQ(wolfSSL_CTX_check_private_key(ctx), WOLFSSL_SUCCESS);
#endif
ExpectNotNull(ssl = SSL_new(ctx));
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
ExpectIntEQ(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS);
#endif
@ -33149,7 +33038,7 @@ static int test_wolfSSL_private_keys(void)
ExpectIntEQ(SSL_use_RSAPrivateKey_ASN1(ssl,
(unsigned char*)client_key_der_2048,
sizeof_client_key_der_2048), WOLFSSL_SUCCESS);
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
/* Should mismatch now that a different private key loaded */
ExpectIntNE(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS);
#endif
@ -33157,7 +33046,7 @@ static int test_wolfSSL_private_keys(void)
ExpectIntEQ(SSL_use_PrivateKey_ASN1(0, ssl,
(unsigned char*)server_key,
sizeof_server_key_der_2048), WOLFSSL_SUCCESS);
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
/* After loading back in DER format of original key, should match */
ExpectIntEQ(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS);
#endif
@ -33167,7 +33056,7 @@ static int test_wolfSSL_private_keys(void)
(unsigned char*)client_key_der_2048,
sizeof_client_key_der_2048), WOLFSSL_SUCCESS);
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
/* Should mismatch now that a different private key loaded */
ExpectIntNE(wolfSSL_CTX_check_private_key(ctx), WOLFSSL_SUCCESS);
#endif
@ -33175,7 +33064,7 @@ static int test_wolfSSL_private_keys(void)
ExpectIntEQ(SSL_CTX_use_PrivateKey_ASN1(0, ctx,
(unsigned char*)server_key,
sizeof_server_key_der_2048), WOLFSSL_SUCCESS);
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
/* After loading back in DER format of original key, should match */
ExpectIntEQ(wolfSSL_CTX_check_private_key(ctx), WOLFSSL_SUCCESS);
#endif
@ -33229,7 +33118,7 @@ static int test_wolfSSL_private_keys(void)
WOLFSSL_FILETYPE_PEM));
ExpectNotNull(ssl = SSL_new(ctx));
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
ExpectIntEQ(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS);
#endif
SSL_free(ssl);
@ -33262,7 +33151,7 @@ static int test_wolfSSL_private_keys(void)
WOLFSSL_FILETYPE_PEM));
ExpectNotNull(ssl = SSL_new(ctx));
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
ExpectIntEQ(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS);
#endif
SSL_free(ssl);
@ -33273,7 +33162,7 @@ static int test_wolfSSL_private_keys(void)
WOLFSSL_FILETYPE_PEM));
ExpectNotNull(ssl = SSL_new(ctx));
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
ExpectIntNE(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS);
#endif
@ -33295,7 +33184,7 @@ static int test_wolfSSL_private_keys(void)
WOLFSSL_FILETYPE_PEM));
ExpectNotNull(ssl = SSL_new(ctx));
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
ExpectIntEQ(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS);
#endif
SSL_free(ssl);
@ -33306,7 +33195,7 @@ static int test_wolfSSL_private_keys(void)
WOLFSSL_FILETYPE_PEM));
ExpectNotNull(ssl = SSL_new(ctx));
#if !defined(HAVE_USER_RSA) && !defined(NO_CHECK_PRIVATE_KEY)
#if !defined(NO_CHECK_PRIVATE_KEY)
ExpectIntNE(wolfSSL_check_private_key(ssl), WOLFSSL_SUCCESS);
#endif
@ -33666,8 +33555,7 @@ static int test_wolfSSL_PEM_PrivateKey(void)
/* key is DES encrypted */
#if !defined(NO_DES3) && defined(WOLFSSL_ENCRYPTED_KEYS) && \
!defined(NO_RSA) && !defined(NO_BIO) && !defined(NO_FILESYSTEM) && \
!defined(NO_MD5) && defined(WOLFSSL_KEY_GEN) && \
!defined(HAVE_USER_RSA) && !defined(NO_RSA)
!defined(NO_MD5) && defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA)
{
XFILE f = XBADFILE;
wc_pem_password_cb* passwd_cb = NULL;
@ -33780,7 +33668,7 @@ static int test_wolfSSL_PEM_file_RSAKey(void)
EXPECT_DECLS;
#if (defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)) && \
defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA) && \
!defined(HAVE_USER_RSA) && !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
!defined(NO_FILESYSTEM) && !defined(NO_CERTS)
RSA* rsa = NULL;
XFILE fp = XBADFILE;
@ -33809,7 +33697,7 @@ static int test_wolfSSL_PEM_file_RSAPrivateKey(void)
{
EXPECT_DECLS;
#if !defined(NO_RSA) && defined(OPENSSL_EXTRA) && defined(WOLFSSL_KEY_GEN) && \
!defined(HAVE_USER_RSA) && !defined(NO_FILESYSTEM) && \
!defined(NO_FILESYSTEM) && \
(defined(WOLFSSL_PEM_TO_DER) || defined(WOLFSSL_DER_TO_PEM))
RSA* rsa = NULL;
XFILE f = NULL;
@ -33868,7 +33756,7 @@ static int test_wolfSSL_PEM_bio_RSAKey(void)
EXPECT_DECLS;
#if (defined(OPENSSL_EXTRA) || defined(OPENSSL_ALL)) && \
defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA) && \
!defined(HAVE_USER_RSA) && !defined(NO_FILESYSTEM) && !defined(NO_CERTS)
!defined(NO_FILESYSTEM) && !defined(NO_CERTS)
RSA* rsa = NULL;
BIO* bio = NULL;
@ -33943,7 +33831,7 @@ static int test_wolfSSL_PEM_bio_RSAPrivateKey(void)
ExpectNotNull((rsa = PEM_read_bio_RSAPrivateKey(bio, NULL, NULL, NULL)));
ExpectIntEQ(RSA_size(rsa), 256);
#if defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA)
ExpectNull(rsa_dup = RSAPublicKey_dup(NULL));
/* Test duplicating empty key. */
ExpectNotNull(rsa_dup = RSA_new());
@ -34924,8 +34812,7 @@ static int test_wolfSSL_EVP_MD_hmac_signing(void)
static int test_wolfSSL_EVP_MD_rsa_signing(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_USER_RSA) && \
defined(USE_CERT_BUFFERS_2048)
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && defined(USE_CERT_BUFFERS_2048)
WOLFSSL_EVP_PKEY* privKey = NULL;
WOLFSSL_EVP_PKEY* pubKey = NULL;
WOLFSSL_EVP_PKEY_CTX* keyCtx = NULL;
@ -35142,7 +35029,6 @@ static int test_wolfSSL_CTX_add_extra_chain_cert(void)
ExpectNotNull(x509 = wolfSSL_X509_load_certificate_file(clientFile,
WOLFSSL_FILETYPE_PEM));
#if !defined(HAVE_USER_RSA) && !defined(HAVE_FAST_RSA)
/* additional test of getting EVP_PKEY key size from X509
* Do not run with user RSA because wolfSSL_RSA_size is not currently
* allowed with user RSA */
@ -35179,7 +35065,6 @@ static int test_wolfSSL_CTX_add_extra_chain_cert(void)
pkey = NULL;
#endif /* HAVE_ECC */
}
#endif /* !defined(HAVE_USER_RSA) && !defined(HAVE_FAST_RSA) */
ExpectIntEQ((int)SSL_CTX_add_extra_chain_cert(ctx, x509), SSL_SUCCESS);
if (EXPECT_SUCCESS()) {
@ -46072,8 +45957,7 @@ static int test_wolfSSL_d2i_PrivateKeys_bio(void)
ExpectNotNull(ctx = SSL_CTX_new(wolfSSLv23_client_method()));
#endif
#if !defined(HAVE_FAST_RSA) && defined(WOLFSSL_KEY_GEN) && \
!defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA)
{
RSA* rsa = NULL;
/* Tests bad parameters */
@ -46113,7 +45997,7 @@ static int test_wolfSSL_d2i_PrivateKeys_bio(void)
#endif /* USE_CERT_BUFFERS_2048 WOLFSSL_KEY_GEN */
RSA_free(rsa);
}
#endif /* !HAVE_FAST_RSA && WOLFSSL_KEY_GEN && !NO_RSA && !HAVE_USER_RSA*/
#endif /* WOLFSSL_KEY_GEN && !NO_RSA */
SSL_CTX_free(ctx);
ctx = NULL;
BIO_free(bio);
@ -47751,7 +47635,6 @@ static int test_wolfSSL_CTX_ctrl(void)
ExpectIntEQ(wolfSSL_EC_KEY_generate_key(ecKey), 1);
#endif
#if !defined(HAVE_USER_RSA) && !defined(HAVE_FAST_RSA)
/* additional test of getting EVP_PKEY key size from X509
* Do not run with user RSA because wolfSSL_RSA_size is not currently
* allowed with user RSA */
@ -47785,7 +47668,6 @@ static int test_wolfSSL_CTX_ctrl(void)
EVP_PKEY_free(pkey);
#endif /* HAVE_ECC */
}
#endif /* !defined(HAVE_USER_RSA) && !defined(HAVE_FAST_RSA) */
/* Tests should fail with passed in NULL pointer */
ExpectIntEQ((int)wolfSSL_CTX_ctrl(ctx, SSL_CTRL_EXTRA_CHAIN_CERT, 0, NULL),
@ -51425,8 +51307,7 @@ static int test_wc_ecc_get_curve_id_from_params(void)
static int test_wolfSSL_EVP_PKEY_encrypt(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && \
!defined(HAVE_FAST_RSA)
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN)
WOLFSSL_RSA* rsa = NULL;
WOLFSSL_EVP_PKEY* pkey = NULL;
WOLFSSL_EVP_PKEY_CTX* ctx = NULL;
@ -51534,7 +51415,7 @@ static int test_wolfSSL_EVP_PKEY_encrypt(void)
}
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && \
!defined(HAVE_FAST_RSA) && !defined(HAVE_SELFTEST)
!defined(HAVE_SELFTEST)
#if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2))
#ifndef TEST_WOLFSSL_EVP_PKEY_SIGN_VERIFY
#define TEST_WOLFSSL_EVP_PKEY_SIGN_VERIFY
@ -51562,7 +51443,7 @@ static int test_wolfSSL_EVP_PKEY_sign_verify(int keyType)
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA)
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && \
!defined(HAVE_FAST_RSA) && !defined(HAVE_SELFTEST)
!defined(HAVE_SELFTEST)
#if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2))
WOLFSSL_RSA* rsa = NULL;
#endif
@ -51612,7 +51493,7 @@ static int test_wolfSSL_EVP_PKEY_sign_verify(int keyType)
switch (keyType) {
case EVP_PKEY_RSA:
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && \
!defined(HAVE_FAST_RSA) && !defined(HAVE_SELFTEST)
!defined(HAVE_SELFTEST)
#if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2))
{
ExpectNotNull(rsa = RSA_generate_key(2048, 3, NULL, NULL));
@ -51649,7 +51530,7 @@ static int test_wolfSSL_EVP_PKEY_sign_verify(int keyType)
ExpectNotNull(ctx = EVP_PKEY_CTX_new(pkey, NULL));
ExpectIntEQ(EVP_PKEY_sign_init(ctx), WOLFSSL_SUCCESS);
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && \
!defined(HAVE_FAST_RSA) && !defined(HAVE_SELFTEST)
!defined(HAVE_SELFTEST)
#if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2))
if (keyType == EVP_PKEY_RSA)
ExpectIntEQ(EVP_PKEY_CTX_set_rsa_padding(ctx, RSA_PKCS1_PADDING),
@ -51670,7 +51551,7 @@ static int test_wolfSSL_EVP_PKEY_sign_verify(int keyType)
ExpectNotNull(ctx_verify = EVP_PKEY_CTX_new(pkey, NULL));
ExpectIntEQ(EVP_PKEY_verify_init(ctx_verify), WOLFSSL_SUCCESS);
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && \
!defined(HAVE_FAST_RSA) && !defined(HAVE_SELFTEST)
!defined(HAVE_SELFTEST)
#if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2))
if (keyType == EVP_PKEY_RSA)
ExpectIntEQ(
@ -51686,7 +51567,7 @@ static int test_wolfSSL_EVP_PKEY_sign_verify(int keyType)
WOLFSSL_FAILURE);
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && \
!defined(HAVE_FAST_RSA) && !defined(HAVE_SELFTEST)
!defined(HAVE_SELFTEST)
#if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2))
if (keyType == EVP_PKEY_RSA) {
#if defined(WC_RSA_NO_PADDING) || defined(WC_RSA_DIRECT)
@ -51755,7 +51636,7 @@ static int test_wolfSSL_EVP_PKEY_sign_verify_rsa(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && \
!defined(HAVE_FAST_RSA) && !defined(HAVE_SELFTEST)
!defined(HAVE_SELFTEST)
#if !defined(HAVE_FIPS) || (defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION>2))
ExpectIntEQ(test_wolfSSL_EVP_PKEY_sign_verify(EVP_PKEY_RSA), TEST_SUCCESS);
#endif
@ -56541,7 +56422,7 @@ static int test_wolfSSL_X509_print(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) && \
!defined(NO_RSA) && !defined(HAVE_FAST_RSA) && defined(XSNPRINTF)
!defined(NO_RSA) && defined(XSNPRINTF)
X509 *x509 = NULL;
BIO *bio = NULL;
#if defined(OPENSSL_ALL) && !defined(NO_WOLFSSL_DIR)
@ -56648,8 +56529,7 @@ static int test_wolfSSL_BIO_get_len(void)
static int test_wolfSSL_RSA(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_USER_RSA) && \
defined(WOLFSSL_KEY_GEN)
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && defined(WOLFSSL_KEY_GEN)
RSA* rsa = NULL;
const BIGNUM *n;
const BIGNUM *e;
@ -56814,8 +56694,7 @@ static int test_wolfSSL_RSA(void)
static int test_wolfSSL_RSA_DER(void)
{
EXPECT_DECLS;
#if !defined(HAVE_FAST_RSA) && defined(WOLFSSL_KEY_GEN) && \
!defined(NO_RSA) && !defined(HAVE_USER_RSA) && defined(OPENSSL_EXTRA)
#if defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA) && defined(OPENSSL_EXTRA)
RSA *rsa = NULL;
int i;
const unsigned char *buff = NULL;
@ -56903,8 +56782,8 @@ static int test_wolfSSL_RSA_print(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) && \
!defined(NO_RSA) && !defined(HAVE_FAST_RSA) && defined(WOLFSSL_KEY_GEN) && \
!defined(HAVE_FAST_RSA) && !defined(NO_BIO) && defined(XFPRINTF)
!defined(NO_RSA) && defined(WOLFSSL_KEY_GEN) && \
!defined(NO_BIO) && defined(XFPRINTF)
BIO *bio = NULL;
WOLFSSL_RSA* rsa = NULL;
@ -57031,7 +56910,7 @@ static int test_wolfSSL_RSA_sign_sha3(void)
static int test_wolfSSL_RSA_get0_key(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA)
RSA *rsa = NULL;
const BIGNUM* n = NULL;
const BIGNUM* e = NULL;
@ -57083,7 +56962,7 @@ static int test_wolfSSL_RSA_get0_key(void)
static int test_wolfSSL_RSA_meth(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA)
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA)
RSA *rsa = NULL;
RSA_METHOD *rsa_meth = NULL;
@ -57151,8 +57030,7 @@ static int test_wolfSSL_RSA_meth(void)
static int test_wolfSSL_RSA_verify(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA) && \
!defined(NO_FILESYSTEM)
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(NO_FILESYSTEM)
#ifndef NO_BIO
XFILE fp = XBADFILE;
RSA *pKey = NULL;
@ -57232,7 +57110,7 @@ static int test_wolfSSL_RSA_verify(void)
static int test_wolfSSL_RSA_sign(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA)
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA)
RSA *rsa;
unsigned char hash[SHA256_DIGEST_LENGTH];
#ifdef USE_CERT_BUFFERS_1024
@ -57289,7 +57167,7 @@ static int test_wolfSSL_RSA_sign(void)
static int test_wolfSSL_RSA_sign_ex(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA)
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA)
RSA *rsa = NULL;
unsigned char hash[SHA256_DIGEST_LENGTH];
#ifdef USE_CERT_BUFFERS_1024
@ -57377,7 +57255,7 @@ static int test_wolfSSL_RSA_sign_ex(void)
static int test_wolfSSL_RSA_public_decrypt(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA)
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA)
RSA *rsa;
unsigned char msg[SHA256_DIGEST_LENGTH];
#ifdef USE_CERT_BUFFERS_1024
@ -57552,7 +57430,7 @@ static int test_wolfSSL_RSA_public_decrypt(void)
static int test_wolfSSL_RSA_private_encrypt(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA)
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA)
RSA *rsa;
unsigned char msg[SHA256_DIGEST_LENGTH];
#ifdef USE_CERT_BUFFERS_1024
@ -57712,7 +57590,7 @@ static int test_wolfSSL_RSA_private_encrypt(void)
static int test_wolfSSL_RSA_public_encrypt(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA)
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA)
RSA* rsa = NULL;
const unsigned char msg[2048/8] = { 0 };
unsigned char encMsg[2048/8];
@ -57741,7 +57619,7 @@ static int test_wolfSSL_RSA_public_encrypt(void)
static int test_wolfSSL_RSA_private_decrypt(void)
{
EXPECT_DECLS;
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA) && !defined(HAVE_FAST_RSA)
#if defined(OPENSSL_EXTRA) && !defined(NO_RSA)
RSA* rsa = NULL;
unsigned char msg[2048/8];
const unsigned char encMsg[2048/8] = { 0 };
@ -57906,8 +57784,7 @@ static int test_wolfSSL_RSA_To_Der(void)
{
EXPECT_DECLS;
#ifdef WOLFSSL_TEST_STATIC_BUILD
#if defined(WOLFSSL_KEY_GEN) && !defined(HAVE_USER_RSA) && \
defined(OPENSSL_EXTRA) && !defined(NO_RSA)
#if defined(WOLFSSL_KEY_GEN) && defined(OPENSSL_EXTRA) && !defined(NO_RSA)
RSA* rsa;
#ifdef USE_CERT_BUFFERS_1024
const unsigned char* privDer = client_key_der_1024;
@ -57990,7 +57867,7 @@ static int test_wolfSSL_PEM_write_RSA_PUBKEY(void)
{
EXPECT_DECLS;
#if !defined(NO_RSA) && defined(OPENSSL_EXTRA) && !defined(NO_FILESYSTEM) && \
defined(WOLFSSL_KEY_GEN) && !defined(HAVE_USER_RSA)
defined(WOLFSSL_KEY_GEN)
RSA* rsa = NULL;
ExpectIntEQ(wolfSSL_PEM_write_RSA_PUBKEY(XBADFILE, NULL), 0);
@ -58005,7 +57882,7 @@ static int test_wolfSSL_PEM_write_RSAPrivateKey(void)
{
EXPECT_DECLS;
#if !defined(NO_RSA) && defined(OPENSSL_EXTRA) && defined(WOLFSSL_KEY_GEN) && \
!defined(HAVE_USER_RSA) && (defined(WOLFSSL_PEM_TO_DER) || \
(defined(WOLFSSL_PEM_TO_DER) || \
defined(WOLFSSL_DER_TO_PEM)) && !defined(NO_FILESYSTEM)
RSA* rsa = NULL;
#ifdef USE_CERT_BUFFERS_1024
@ -58051,8 +57928,7 @@ static int test_wolfSSL_PEM_write_mem_RSAPrivateKey(void)
{
EXPECT_DECLS;
#if !defined(NO_RSA) && defined(OPENSSL_EXTRA) && defined(WOLFSSL_KEY_GEN) && \
!defined(HAVE_USER_RSA) && (defined(WOLFSSL_PEM_TO_DER) || \
defined(WOLFSSL_DER_TO_PEM))
(defined(WOLFSSL_PEM_TO_DER) || defined(WOLFSSL_DER_TO_PEM))
RSA* rsa = NULL;
#ifdef USE_CERT_BUFFERS_1024
const unsigned char* privDer = client_key_der_1024;

View File

@ -2875,7 +2875,7 @@ const char* GetSigName(int oid) {
#if !defined(NO_DSA) || defined(HAVE_ECC) || !defined(NO_CERTS) || \
(!defined(NO_RSA) && \
(defined(WOLFSSL_CERT_GEN) || \
((defined(WOLFSSL_KEY_GEN) || defined(OPENSSL_EXTRA)) && !defined(HAVE_USER_RSA))))
((defined(WOLFSSL_KEY_GEN) || defined(OPENSSL_EXTRA)))))
/* Set the DER/BER encoding of the ASN.1 INTEGER header.
*
* When output is NULL, calculate the header length only.
@ -2924,7 +2924,7 @@ int SetASNInt(int len, byte firstByte, byte* output)
#if !defined(NO_DSA) || defined(HAVE_ECC) || (defined(WOLFSSL_CERT_GEN) && \
!defined(NO_RSA)) || ((defined(WOLFSSL_KEY_GEN) || \
(!defined(NO_DH) && defined(WOLFSSL_DH_EXTRA)) || \
defined(OPENSSL_EXTRA)) && !defined(NO_RSA) && !defined(HAVE_USER_RSA))
defined(OPENSSL_EXTRA)) && !defined(NO_RSA))
/* Set the DER/BER encoding of the ASN.1 INTEGER element with an mp_int.
* The number is assumed to be positive.
*
@ -2960,41 +2960,6 @@ static int SetASNIntMP(mp_int* n, int maxSz, byte* output)
return idx;
}
#endif
#if !defined(NO_RSA) && defined(HAVE_USER_RSA) && \
(defined(WOLFSSL_CERT_GEN) || defined(OPENSSL_EXTRA))
/* Set the DER/BER encoding of the ASN.1 INTEGER element with an mp_int from
* an RSA key.
* The number is assumed to be positive.
*
* n Multi-precision integer to encode.
* output Buffer to write into.
* returns BUFFER_E when the data is too long for the buffer.
* MP_TO_E when encoding the integer fails.
* Otherwise, the number of bytes added to the buffer.
*/
static int SetASNIntRSA(void* n, byte* output)
{
int idx = 0;
int leadingBit;
int length;
leadingBit = wc_Rsa_leading_bit(n);
length = wc_Rsa_unsigned_bin_size(n);
idx = SetASNInt(length, leadingBit ? 0x80 : 0x00, output);
if ((idx + length) > MAX_RSA_INT_SZ)
return BUFFER_E;
if (output) {
int err = wc_Rsa_to_unsigned_bin(n, output + idx, length);
if (err != MP_OKAY)
return MP_TO_E;
}
idx += length;
return idx;
}
#endif /* !NO_RSA && HAVE_USER_RSA && WOLFSSL_CERT_GEN */
#endif /* !WOLFSSL_ASN_TEMPLATE */
#ifdef WOLFSSL_ASN_TEMPLATE
@ -3316,7 +3281,7 @@ static int GetIntPositive(mp_int* mpi, const byte* input, word32* inOutIdx,
#endif /* (ECC || !NO_DSA) && !WOLFSSL_ASN_TEMPLATE */
#ifndef WOLFSSL_ASN_TEMPLATE
#if (!defined(NO_RSA) && !defined(HAVE_USER_RSA)) || !defined(NO_DSA)
#if !defined(NO_RSA) || !defined(NO_DSA)
static int SkipInt(const byte* input, word32* inOutIdx, word32 maxIdx)
{
word32 idx = *inOutIdx;
@ -3445,7 +3410,7 @@ int CheckBitString(const byte* input, word32* inOutIdx, int* len,
/* RSA (with CertGen or KeyGen) OR ECC OR ED25519 OR ED448 (with CertGen or
* KeyGen) */
#if (!defined(NO_RSA) && !defined(HAVE_USER_RSA) && \
#if (!defined(NO_RSA) && \
(defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN) || \
defined(OPENSSL_EXTRA))) || \
(defined(HAVE_ECC) && defined(HAVE_ECC_KEY_EXPORT)) || \
@ -6336,7 +6301,6 @@ static int DecodeRsaPssParams(const byte* params, word32 sz,
}
#endif /* WC_RSA_PSS */
#ifndef HAVE_USER_RSA
#if defined(WOLFSSL_ASN_TEMPLATE) || (!defined(NO_CERTS) && \
(defined(WOLFSSL_KEY_GEN) || defined(OPENSSL_EXTRA) || \
defined(WOLFSSL_KCAPI_RSA) || defined(WOLFSSL_SE050)))
@ -6674,8 +6638,6 @@ int wc_RsaPrivateKeyValidate(const byte* input, word32* inOutIdx, int* keySz,
{
return _RsaPrivateKeyDecode(input, inOutIdx, NULL, keySz, inSz);
}
#endif /* HAVE_USER_RSA */
#endif /* NO_RSA */
#ifdef WOLFSSL_ASN_TEMPLATE
@ -7221,12 +7183,6 @@ int wc_CheckPrivateKey(const byte* privKey, word32 privKeySz,
if ((ret = wc_RsaPublicKeyDecode(pubKey, &keyIdx, b,
pubKeySz)) == 0) {
/* limit for user RSA crypto because of RsaKey
* dereference. */
#if defined(HAVE_USER_RSA)
WOLFSSL_MSG("Cannot verify RSA pair with user RSA");
ret = 1; /* return first RSA cert as match */
#else
/* both keys extracted successfully now check n and e
* values are the same. This is dereferencing RsaKey */
if (mp_cmp(&(a->n), &(b->n)) != MP_EQ ||
@ -7236,7 +7192,6 @@ int wc_CheckPrivateKey(const byte* privKey, word32 privKeySz,
}
else
ret = 1;
#endif
}
else {
WOLFSSL_ERROR_VERBOSE(ret);
@ -9231,7 +9186,6 @@ int EncryptContent(byte* input, word32 inputSz, byte* out, word32* outSz,
#ifndef NO_RSA
#ifndef HAVE_USER_RSA
#if defined(WOLFSSL_RENESAS_TSIP_TLS) || defined(WOLFSSL_RENESAS_FSPSM_TLS)
/* This function is to retrieve key position information in a cert.*
* The information will be used to call TSIP TLS-linked API for *
@ -9583,7 +9537,6 @@ int wc_RsaPublicKeyDecode(const byte* input, word32* inOutIdx, RsaKey* key,
return ret;
}
#endif /* HAVE_USER_RSA */
#endif /* !NO_RSA */
#ifndef NO_DH
@ -25136,7 +25089,7 @@ int wc_GetFASCNFromCert(struct DecodedCert* cert, byte* fascn, word32* fascnSz)
#if !defined(NO_RSA) && (defined(WOLFSSL_CERT_GEN) || \
defined(WOLFSSL_KCAPI_RSA) || \
((defined(WOLFSSL_KEY_GEN) || defined(OPENSSL_EXTRA)) && !defined(HAVE_USER_RSA)))
((defined(WOLFSSL_KEY_GEN) || defined(OPENSSL_EXTRA))))
/* USER RSA ifdef portions used instead of refactor in consideration for
possible fips build */
/* Encode a public RSA key to output.
@ -25171,19 +25124,13 @@ static int SetRsaPublicKey(byte* output, RsaKey* key, int outLen,
return BAD_FUNC_ARG;
}
#ifdef HAVE_USER_RSA
nSz = SetASNIntRSA(key->n, NULL);
#else
nSz = SetASNIntMP(&key->n, MAX_RSA_INT_SZ, NULL);
#endif
if (nSz < 0)
return nSz;
#ifdef HAVE_USER_RSA
eSz = SetASNIntRSA(key->e, NULL);
#else
eSz = SetASNIntMP(&key->e, MAX_RSA_INT_SZ, NULL);
#endif
if (eSz < 0)
return eSz;
seqSz = SetSequence((word32)(nSz + eSz), seq);
@ -25224,18 +25171,10 @@ static int SetRsaPublicKey(byte* output, RsaKey* key, int outLen,
XMEMCPY(output + idx, seq, seqSz);
idx += seqSz;
/* n */
#ifdef HAVE_USER_RSA
nSz = SetASNIntRSA(key->n, output + idx);
#else
nSz = SetASNIntMP(&key->n, nSz, output + idx);
#endif
idx += (word32)nSz;
/* e */
#ifdef HAVE_USER_RSA
eSz = SetASNIntRSA(key->e, output + idx);
#else
eSz = SetASNIntMP(&key->e, eSz, output + idx);
#endif
idx += (word32)eSz;
return (int)idx;
@ -25263,13 +25202,8 @@ static int SetRsaPublicKey(byte* output, RsaKey* key, int outLen,
dataASN[RSAPUBLICKEYASN_IDX_ALGOID_P_SEQ].noOut = 1;
#endif
/* Set public key mp_ints. */
#ifdef HAVE_USER_RSA
SetASN_MP(&dataASN[RSAPUBLICKEYASN_IDX_PUBKEY_RSA_N], key->n);
SetASN_MP(&dataASN[RSAPUBLICKEYASN_IDX_PUBKEY_RSA_E], key->e);
#else
SetASN_MP(&dataASN[RSAPUBLICKEYASN_IDX_PUBKEY_RSA_N], &key->n);
SetASN_MP(&dataASN[RSAPUBLICKEYASN_IDX_PUBKEY_RSA_E], &key->e);
#endif
/* Calculate size of RSA public key. */
ret = SizeASN_Items(rsaPublicKeyASN + o, dataASN + o,
(int)rsaPublicKeyASN_Length - o, &sz);
@ -25338,11 +25272,11 @@ int wc_RsaKeyToPublicDer_ex(RsaKey* key, byte* output, word32 inLen,
}
#endif /* !NO_RSA && (WOLFSSL_CERT_GEN || WOLFSSL_KCAPI_RSA ||
((OPENSSL_EXTRA || WOLFSSL_KEY_GEN) && !HAVE_USER_RSA))) */
((OPENSSL_EXTRA || WOLFSSL_KEY_GEN))) */
#if (defined(WOLFSSL_KEY_GEN) || defined(OPENSSL_EXTRA) || \
defined(WOLFSSL_KCAPI_RSA) || defined(WOLFSSL_SE050)) && \
!defined(NO_RSA) && !defined(HAVE_USER_RSA)
!defined(NO_RSA)
/* Encode private RSA key in DER format.
*
@ -25481,7 +25415,7 @@ int wc_RsaKeyToDer(RsaKey* key, byte* output, word32 inLen)
#endif
}
#endif /* (WOLFSSL_KEY_GEN || OPENSSL_EXTRA) && !NO_RSA && !HAVE_USER_RSA */
#endif /* (WOLFSSL_KEY_GEN || OPENSSL_EXTRA) && !NO_RSA */
#ifdef WOLFSSL_CERT_GEN
@ -38640,8 +38574,7 @@ int wc_Asn1_PrintAll(Asn1* asn1, Asn1PrintOptions* opts, unsigned char* data,
#endif /* !NO_ASN */
/* Functions that parse, but are not using ASN.1 */
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA) && \
(!defined(NO_BIG_INT) || defined(WOLFSSL_SP_MATH))
#if !defined(NO_RSA) && (!defined(NO_BIG_INT) || defined(WOLFSSL_SP_MATH))
/* import RSA public key elements (n, e) into RsaKey structure (key) */
/* this function does not use any ASN.1 parsing */
int wc_RsaPublicKeyDecodeRaw(const byte* n, word32 nSz, const byte* e,
@ -38692,7 +38625,7 @@ int wc_RsaPublicKeyDecodeRaw(const byte* n, word32 nSz, const byte* e,
return 0;
}
#endif /* !NO_RSA && !HAVE_USER_RSA && (!NO_BIG_INT || WOLFSSL_SP_MATH) */
#endif /* !NO_RSA && (!NO_BIG_INT || WOLFSSL_SP_MATH) */
#ifdef WOLFSSL_SEP

View File

@ -2273,7 +2273,7 @@ WOLFSSL_EVP_PKEY_CTX *wolfSSL_EVP_PKEY_CTX_new(WOLFSSL_EVP_PKEY *pkey, WOLFSSL_E
if (ctx == NULL) return NULL;
XMEMSET(ctx, 0, sizeof(WOLFSSL_EVP_PKEY_CTX));
ctx->pkey = pkey;
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if !defined(NO_RSA)
ctx->padding = RSA_PKCS1_PADDING;
ctx->md = NULL;
#endif
@ -2774,7 +2774,7 @@ int wolfSSL_EVP_PKEY_decrypt(WOLFSSL_EVP_PKEY_CTX *ctx,
(void)len;
switch (ctx->pkey->type) {
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if !defined(NO_RSA)
case EVP_PKEY_RSA:
if (out == NULL) {
if (ctx->pkey->rsa == NULL) {
@ -2877,7 +2877,7 @@ int wolfSSL_EVP_PKEY_encrypt(WOLFSSL_EVP_PKEY_CTX *ctx,
(void)len;
switch (ctx->pkey->type) {
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if !defined(NO_RSA)
case EVP_PKEY_RSA:
if (out == NULL) {
if (ctx->pkey->rsa == NULL) {
@ -2958,7 +2958,7 @@ int wolfSSL_EVP_PKEY_sign_init(WOLFSSL_EVP_PKEY_CTX *ctx)
return ret;
switch (ctx->pkey->type) {
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if !defined(NO_RSA)
case EVP_PKEY_RSA:
ctx->op = EVP_PKEY_OP_SIGN;
ret = WOLFSSL_SUCCESS;
@ -3006,7 +3006,7 @@ int wolfSSL_EVP_PKEY_sign(WOLFSSL_EVP_PKEY_CTX *ctx, unsigned char *sig,
(void)tbslen;
switch (ctx->pkey->type) {
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if !defined(NO_RSA)
case EVP_PKEY_RSA: {
unsigned int usiglen = (unsigned int)*siglen;
if (!sig) {
@ -3120,7 +3120,7 @@ int wolfSSL_EVP_PKEY_verify_init(WOLFSSL_EVP_PKEY_CTX *ctx)
return WOLFSSL_FAILURE;
switch (ctx->pkey->type) {
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if !defined(NO_RSA)
case EVP_PKEY_RSA:
ctx->op = EVP_PKEY_OP_VERIFY;
return WOLFSSL_SUCCESS;
@ -3162,7 +3162,7 @@ int wolfSSL_EVP_PKEY_verify(WOLFSSL_EVP_PKEY_CTX *ctx, const unsigned char *sig,
return WOLFSSL_FAILURE;
switch (ctx->pkey->type) {
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if !defined(NO_RSA)
case EVP_PKEY_RSA:
return wolfSSL_RSA_verify_ex(WC_HASH_TYPE_NONE, tbs,
(unsigned int)tbslen, sig, (unsigned int)siglen, ctx->pkey->rsa,
@ -3358,8 +3358,7 @@ int wolfSSL_EVP_PKEY_keygen(WOLFSSL_EVP_PKEY_CTX *ctx,
}
switch (pkey->type) {
#if !defined(HAVE_FAST_RSA) && defined(WOLFSSL_KEY_GEN) && \
!defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if defined(WOLFSSL_KEY_GEN) && !defined(NO_RSA)
case EVP_PKEY_RSA:
pkey->rsa = wolfSSL_RSA_generate_key(ctx->nbits, WC_RSA_EXPONENT,
NULL, NULL);
@ -3892,7 +3891,7 @@ int wolfSSL_EVP_SignFinal(WOLFSSL_EVP_MD_CTX *ctx, unsigned char *sigret,
return ret;
switch (pkey->type) {
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if !defined(NO_RSA)
case EVP_PKEY_RSA: {
int nid;
const WOLFSSL_EVP_MD *ctxmd;
@ -3988,7 +3987,7 @@ int wolfSSL_EVP_VerifyFinal(WOLFSSL_EVP_MD_CTX *ctx,
(void)siglen;
switch (pkey->type) {
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if !defined(NO_RSA)
case EVP_PKEY_RSA: {
int nid;
const WOLFSSL_EVP_MD *ctxmd = wolfSSL_EVP_MD_CTX_md(ctx);
@ -4461,7 +4460,7 @@ int wolfSSL_EVP_DigestSignFinal(WOLFSSL_EVP_MD_CTX *ctx, unsigned char *sig,
else {
/* Sign the digest. */
switch (ctx->pctx->pkey->type) {
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if !defined(NO_RSA)
case EVP_PKEY_RSA: {
unsigned int sigSz = (unsigned int)*siglen;
int nid;
@ -4564,7 +4563,7 @@ int wolfSSL_EVP_DigestVerifyFinal(WOLFSSL_EVP_MD_CTX *ctx,
else {
/* Verify the signature with the digest. */
switch (ctx->pctx->pkey->type) {
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if !defined(NO_RSA)
case EVP_PKEY_RSA: {
int nid;
const WOLFSSL_EVP_MD *md = wolfSSL_EVP_MD_CTX_md(ctx);
@ -8510,7 +8509,7 @@ static void clearEVPPkeyKeys(WOLFSSL_EVP_PKEY *pkey)
}
#ifndef NO_RSA
#if defined(WOLFSSL_KEY_GEN) && !defined(HAVE_USER_RSA)
#if defined(WOLFSSL_KEY_GEN)
static int PopulateRSAEvpPkeyDer(WOLFSSL_EVP_PKEY *pkey)
{
int ret = 0;
@ -8668,12 +8667,12 @@ int wolfSSL_EVP_PKEY_set1_RSA(WOLFSSL_EVP_PKEY *pkey, WOLFSSL_RSA *key)
}
}
#if defined(WOLFSSL_KEY_GEN) && !defined(HAVE_USER_RSA)
#if defined(WOLFSSL_KEY_GEN)
if (PopulateRSAEvpPkeyDer(pkey) != WOLFSSL_SUCCESS) {
WOLFSSL_MSG("PopulateRSAEvpPkeyDer failed");
return WOLFSSL_FAILURE;
}
#endif /* WOLFSSL_KEY_GEN && !HAVE_USER_RSA */
#endif /* WOLFSSL_KEY_GEN */
#ifdef WC_RSA_BLINDING
if (key->ownRng == 0) {

View File

@ -36,12 +36,6 @@
#include <wolfssl/wolfcrypt/async.h>
#endif
/* IPP header files for library initialization */
#ifdef HAVE_FAST_RSA
#include <ipp.h>
#include <ippcp.h>
#endif
#ifdef FREESCALE_LTC_TFM
#include <wolfssl/wolfcrypt/port/nxp/ksdk_port.h>
#endif
@ -234,20 +228,6 @@ int wolfCrypt_Init(void)
}
#endif
/* if defined have fast RSA then initialize Intel IPP */
#ifdef HAVE_FAST_RSA
WOLFSSL_MSG("Attempting to use optimized IPP Library");
if ((ret = ippInit()) != ippStsNoErr) {
/* possible to get a CPU feature support status on optimized IPP
library but still use default library and see competitive speeds */
WOLFSSL_MSG("Warning when trying to set up optimization");
WOLFSSL_MSG(ippGetStatusString(ret));
WOLFSSL_MSG("Using default fast IPP library");
ret = 0;
(void)ret; /* suppress not read warning */
}
#endif
#if defined(FREESCALE_LTC_TFM) || defined(FREESCALE_LTC_ECC)
ret = ksdk_port_init();
if (ret != 0) {

View File

@ -16405,87 +16405,45 @@ static wc_test_ret_t rsa_flatten_test(RsaKey* key)
/* Parameter Validation testing. */
ret = wc_RsaFlattenPublicKey(NULL, e, &eSz, n, &nSz);
#ifdef HAVE_USER_RSA
/* Implementation using IPP Libraries returns:
* -101 = USER_CRYPTO_ERROR
*/
if (ret == 0)
#else
if (ret != BAD_FUNC_ARG)
#endif
return WC_TEST_RET_ENC_EC(ret);
ret = wc_RsaFlattenPublicKey(key, NULL, &eSz, n, &nSz);
#ifdef HAVE_USER_RSA
/* Implementation using IPP Libraries returns:
* -101 = USER_CRYPTO_ERROR
*/
if (ret == 0)
#else
if (ret != BAD_FUNC_ARG)
#endif
return WC_TEST_RET_ENC_EC(ret);
ret = wc_RsaFlattenPublicKey(key, e, NULL, n, &nSz);
#ifdef HAVE_USER_RSA
/* Implementation using IPP Libraries returns:
* -101 = USER_CRYPTO_ERROR
*/
if (ret == 0)
#else
if (ret != BAD_FUNC_ARG)
#endif
return WC_TEST_RET_ENC_EC(ret);
ret = wc_RsaFlattenPublicKey(key, e, &eSz, NULL, &nSz);
#ifdef HAVE_USER_RSA
/* Implementation using IPP Libraries returns:
* -101 = USER_CRYPTO_ERROR
*/
if (ret == 0)
#else
if (ret != BAD_FUNC_ARG)
#endif
return WC_TEST_RET_ENC_EC(ret);
ret = wc_RsaFlattenPublicKey(key, e, &eSz, n, NULL);
#ifdef HAVE_USER_RSA
/* Implementation using IPP Libraries returns:
* -101 = USER_CRYPTO_ERROR
*/
if (ret == 0)
#else
if (ret != BAD_FUNC_ARG)
#endif
return WC_TEST_RET_ENC_EC(ret);
ret = wc_RsaFlattenPublicKey(key, e, &eSz, n, &nSz);
if (ret != 0)
return WC_TEST_RET_ENC_EC(ret);
eSz = 0;
ret = wc_RsaFlattenPublicKey(key, e, &eSz, n, &nSz);
#ifdef HAVE_USER_RSA
/* Implementation using IPP Libraries returns:
* -101 = USER_CRYPTO_ERROR
*/
if (ret == 0)
#else
if (ret != RSA_BUFFER_E)
#endif
return WC_TEST_RET_ENC_EC(ret);
eSz = sizeof(e);
nSz = 0;
ret = wc_RsaFlattenPublicKey(key, e, &eSz, n, &nSz);
#ifdef HAVE_USER_RSA
/* Implementation using IPP Libraries returns:
* -101 = USER_CRYPTO_ERROR
*/
if (ret == 0)
#else
if (ret != RSA_BUFFER_E)
#endif
return WC_TEST_RET_ENC_EC(ret);
return 0;
}
#endif /* NO_ASN */
#if !defined(HAVE_FIPS) && !defined(HAVE_USER_RSA) && !defined(NO_ASN) \
#if !defined(HAVE_FIPS) && !defined(NO_ASN) \
&& !defined(WOLFSSL_RSA_VERIFY_ONLY)
static wc_test_ret_t rsa_export_key_test(RsaKey* key)
{
@ -16560,7 +16518,7 @@ static wc_test_ret_t rsa_export_key_test(RsaKey* key)
return 0;
}
#endif /* !HAVE_FIPS && !USER_RSA && !NO_ASN */
#endif /* !HAVE_FIPS && !NO_ASN && !WOLFSSL_RSA_VERIFY_ONLY */
#ifndef NO_SIG_WRAPPER
static wc_test_ret_t rsa_sig_test(RsaKey* key, word32 keyLen, int modLen, WC_RNG* rng)
@ -16622,12 +16580,7 @@ static wc_test_ret_t rsa_sig_test(RsaKey* key, word32 keyLen, int modLen, WC_RNG
return WC_TEST_RET_ENC_EC(ret);
ret = wc_SignatureGenerate(WC_HASH_TYPE_SHA256, WC_SIGNATURE_TYPE_RSA, in,
inLen, out, &sigSz, key, keyLen, NULL);
#ifdef HAVE_USER_RSA
/* Implementation using IPP Libraries returns:
* -101 = USER_CRYPTO_ERROR
*/
if (ret == 0)
#elif defined(WOLFSSL_AFALG_XILINX_RSA) || defined(WOLFSSL_XILINX_CRYPT)
#if defined(WOLFSSL_AFALG_XILINX_RSA) || defined(WOLFSSL_XILINX_CRYPT)
/* blinding / rng handled with hardware acceleration */
if (ret != 0)
#elif defined(WOLFSSL_ASYNC_CRYPT) || defined(WOLF_CRYPTO_CB)
@ -16845,7 +16798,7 @@ static wc_test_ret_t rsa_nb_test(RsaKey* key, const byte* in, word32 inLen, byte
}
#endif
#if !defined(HAVE_USER_RSA) && !defined(NO_ASN)
#if !defined(NO_ASN)
static wc_test_ret_t rsa_decode_test(RsaKey* keyPub)
{
wc_test_ret_t ret;
@ -18537,8 +18490,7 @@ exit_rsa:
#ifndef WOLFSSL_RSA_VERIFY_ONLY
#if !defined(WC_NO_RSA_OAEP) && !defined(WC_NO_RNG) && \
!defined(HAVE_FAST_RSA) && !defined(HAVE_USER_RSA) && \
(!defined(HAVE_FIPS) || \
(!defined(HAVE_FIPS) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))) \
&& !defined(WOLF_CRYPTO_CB_ONLY_RSA)
static wc_test_ret_t rsa_oaep_padding_test(RsaKey* key, WC_RNG* rng)
@ -18942,7 +18894,7 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t rsa_test(void)
XMEMSET(keypub, 0, sizeof *keypub);
#endif
#if !defined(HAVE_USER_RSA) && !defined(NO_ASN)
#if !defined(NO_ASN)
ret = rsa_decode_test(key);
if (ret != 0)
ERROR_OUT(ret, exit_rsa);
@ -19206,19 +19158,18 @@ WOLFSSL_TEST_SUBROUTINE wc_test_ret_t rsa_test(void)
#ifndef WOLFSSL_RSA_VERIFY_ONLY
#if !defined(WC_NO_RSA_OAEP) && !defined(WC_NO_RNG)
#if !defined(HAVE_FAST_RSA) && !defined(HAVE_USER_RSA) && \
(!defined(HAVE_FIPS) || \
#if (!defined(HAVE_FIPS) || \
(defined(HAVE_FIPS_VERSION) && (HAVE_FIPS_VERSION >= 2))) \
&& !defined(WOLF_CRYPTO_CB_ONLY_RSA)
ret = rsa_oaep_padding_test(key, &rng);
if (ret != 0)
return ret;
#endif /* !HAVE_FAST_RSA && !HAVE_FIPS */
#endif /* !HAVE_FIPS */
#endif /* WC_NO_RSA_OAEP && !WC_NO_RNG */
#endif /* WOLFSSL_RSA_VERIFY_ONLY */
#if !defined(HAVE_FIPS) && !defined(HAVE_USER_RSA) && !defined(NO_ASN) \
#if !defined(HAVE_FIPS) && !defined(NO_ASN) \
&& !defined(WOLFSSL_RSA_VERIFY_ONLY)
ret = rsa_export_key_test(key);
if (ret != 0)
@ -23225,7 +23176,7 @@ static void show(const char *title, const char *p, unsigned int s) {
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t openssl_pkey0_test(void)
{
wc_test_ret_t ret = 0;
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA) && !defined(NO_SHA)
#if !defined(NO_RSA) && !defined(NO_SHA)
byte* prvTmp;
byte* pubTmp;
int prvBytes;
@ -23453,8 +23404,7 @@ openssl_pkey0_test_done:
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t openssl_pkey1_test(void)
{
wc_test_ret_t ret = 0;
#if !defined(NO_FILESYSTEM) && !defined(NO_RSA) && !defined(HAVE_USER_RSA) && \
!defined(NO_SHA)
#if !defined(NO_FILESYSTEM) && !defined(NO_RSA) && !defined(NO_SHA)
EVP_PKEY_CTX* dec = NULL;
EVP_PKEY_CTX* enc = NULL;
EVP_PKEY* pubKey = NULL;
@ -23649,7 +23599,7 @@ openssl_pkey1_test_done:
WOLFSSL_TEST_SUBROUTINE wc_test_ret_t openssl_evpSig_test(void)
{
#if !defined(NO_RSA) && !defined(NO_SHA) && !defined(HAVE_USER_RSA)
#if !defined(NO_RSA) && !defined(NO_SHA)
byte* prvTmp;
byte* pubTmp;
int prvBytes;

View File

@ -1,9 +0,0 @@
AM_CFLAGS=-I m4
#add in wolfssl directory
AM_CPPFLAGS+=-I$(abs_srcdir)/../../ -I$(srcdir)/include/
lib_LTLIBRARIES = lib/libusercrypto.la
lib_libusercrypto_la_CPPFLAGS = $(AM_CPPFLAGS)
lib_libusercrypto_la_LDFLAGS = $(AM_LDFLAGS)
lib_libusercrypto_la_SOURCES = src/rsa.c
include_HEADERS = include/user_rsa.h

View File

@ -1,78 +0,0 @@
/*
* Copyright (C) 2006-2023 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
/*
Created to use intel's IPP see their license for linking to intel's IPP library
*/
##BUILDING ON 64BIT MAC OSX
Tested and developed on MAC OSX linking to IPP v9.0
for me exporting the IPP library was needed. As an example it was
export DYLD_LIBRARY_PATH="/opt/intel/ipp/lib"
first go to the root wolfssl dir and run ./autogen.sh && ./configure it with desired settings then make. This is to set up the define options and wolfssl library for the user crypto to link to.
Then go to the wolfssl/user-crypto directory and run ./autogen.sh && ./configure then make make install this creates a usercrypto library to use
Finally go back to the root wolfssl directory and follow these build instructions
building wolfSSL add CPPFLAGS=-I/opt/intel/ipp/include for finding the IPP include files
An example build would be
./configure --with-user-crypto CPPFLAGS=-I/opt/intel/ipp/include --enable-lighty
##BUILDING IN 32BIT UBUNTU
Tested on UBUNTU 32 bit linking to IPP v9.0
for me exporting the IPP library. As an example it was
export LD_LIBRARY_PATH="/opt/intel/ipp/lib/ia32_lin/:$LD_LIBRARY_PATH"
first go to the root wolfssl dir and configure it with desired settings and make install. This is to set up the define options and wolfssl library for the user crypto to link to.
For me on Ubuntu the IPP libraries had been installed into /opt/intel/ipp/lib/ia32_lin/ so the ./configure LDFLAGS=-L/opt/intel/ipp/lib/ia32_lin was needed to be looking at that directory.
Run make && make install from the directory wolfssl_root/wolfssl/user-crypto/ this creates a usercrypto library to use
Finally go back to the root wolfssl directory and follow these build instructions
building wolfSSL add CPPFLAGS=-I/opt/intel/ipp/include for finding the IPP include files
./configure --with-user-crypto=root_wolfssl/wolfssl/user-crypto CPPFLAGS=-I/opt/intel/ipp/include (plus any desired additional flags)
##THINGS TO CHECK FOR IF NOT ABLE TO LINK WITH USERCRYPTO LIB
Check that the path has been exported for the IPP library. If usercrypto is unable to use the function to init an RSA key then the link to it will fail in configure. Check for this by $DYLD_LIBRARY_PATH on mac or $LD_LIBRARY_PATH on ubuntu. If the directory for the Intel IPP libraries are not displayed than use "export DYLD_LIBRARY_PATH=path_to_ipp_libraries:$DYLD_LIBRARY_PATH".
##CREATING OWN RSA CRYPTO PLUGIN
It is required to have a header file named user_rsa.h. This is what is looked for by wolfssl/wolfcrypt/rsa.h and should contain the user defined rsa key struct.
It is required to have a library called usercrypto. This is linked to when configuring wolfSSL with the option --with-user-crypto
It is required when compiled with RSA cert generation to have key struct elements named n and e containing the corresponding big numbers. And the three helper functions to work with the big numbers. These functions are called by wolfcrypt/src/asn.c when working with certificates.
To view the needed functions look at wolfssl/wolfcrypt/rsa.h they will be extern functions surrounded by HAVE_USER_RSA define.
Cert Generation for other sign and verify such as ECC are not yet supported.
When building with openssl compatibility layer extra developent needs to be done, having the two functions SetRsaExernal and SetRsaInternal
wolfSSL does not take responsibility for the strength of security of third party cryptography libraries plugged in by the user.

View File

@ -1,23 +0,0 @@
#!/bin/sh
#
# Create configure and makefile stuff...
#
# Git hooks should come before autoreconf.
if test -d .git; then
if ! test -d .git/hooks; then
mkdir .git/hooks
fi
ln -s -f ../../pre-commit.sh .git/hooks/pre-commit
ln -s -f ../../pre-push.sh .git/hooks/pre-push
fi
# If this is a source checkout then call autoreconf with error as well
if test -d .git; then
WARNINGS="all,error"
else
WARNINGS="all"
fi
autoreconf --install --force --verbose

View File

@ -1,44 +0,0 @@
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.63])
AC_INIT([usercypto], [0.1], [])
AC_CONFIG_SRCDIR([src/rsa.c])
AM_INIT_AUTOMAKE([1.11 -Wall -Werror -Wno-portability foreign tar-ustar subdir-objects no-define color-tests])
LT_PREREQ([2.2])
LT_INIT([disable-static])
LT_LANG([C++])
LT_LANG([C])
# Checks for programs.
AC_PROG_CC
AC_CONFIG_MACRO_DIR([m4])
# Checks for libraries.
AM_LDFLAGS=$LDFLAGS
LDFLAGS="$LDFLAGS -L/opt/intel/ipp/lib -lippcp -lippcore"
# Path to find wolfssl/options and other includes
AM_CPPFLAGS=$CPPFLAGS
CPPFLAGS="$CPPFLAGS -I../../ -I/opt/intel/ipp/include"
AC_CHECK_LIB([ippcore], [ippGetStatusString], [], [AC_MSG_ERROR([ippcore library needed ./configure LDFLAGS=/path/to/ipp/lib])])
AC_CHECK_LIB([ippcp], [ippsRSA_InitPublicKey], [], [AC_MSG_ERROR([ippcp library needed ./configure LDFLAGS=/path/to/ipp/lib])])
# check headers
AC_CHECK_HEADER([ippcp.h], [], [AC_MSG_ERROR([ippcp.h not found ./configure CPPFLAGS=-I/ipp/headers])])
AC_CHECK_HEADER([ipp.h], [], [AC_MSG_ERROR([ipp.h not found ./configure CPPFLAGS=-I/ipp/headers])])
LDFLAGS=$AM_LDFLAGS
CPPFLAGS=$AM_CPPFLAGS
AM_LDFLAGS="-L/opt/intel/ipp/lib -lippcp -lippcore"
AM_CPPFLAGS="-I/opt/intel/ipp/include"
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_LDFLAGS])
AC_C_INLINE
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

View File

@ -1,13 +0,0 @@
if BUILD_FAST_RSA
include_HEADERS += wolfcrypt/user-crypto/include/user_rsa.h
endif
# user crypto plug in example
EXTRA_DIST+= wolfcrypt/user-crypto/configure.ac
EXTRA_DIST+= wolfcrypt/user-crypto/autogen.sh
EXTRA_DIST+= wolfcrypt/user-crypto/include/user_rsa.h
EXTRA_DIST+= wolfcrypt/user-crypto/src/rsa.c
EXTRA_DIST+= wolfcrypt/user-crypto/lib/.gitkeep
EXTRA_DIST+= wolfcrypt/user-crypto/README.txt
EXTRA_DIST+= wolfcrypt/user-crypto/Makefile.am

View File

@ -1,137 +0,0 @@
/* user_rsa.h
*
* Copyright (C) 2006-2023 wolfSSL Inc.
*
* This file is part of wolfSSL.
*
* wolfSSL is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* wolfSSL is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
*/
/*
Created to use intel's IPP see their license for linking to intel's IPP library
*/
#ifndef USER_WOLF_CRYPT_RSA_H
#define USER_WOLF_CRYPT_RSA_H
#include <wolfssl/wolfcrypt/settings.h>
#ifndef NO_RSA
#include <wolfssl/wolfcrypt/types.h>
#include <wolfssl/wolfcrypt/random.h>
/* intels crypto */
#include <ipp.h>
#include <ippcp.h>
#ifdef __cplusplus
extern "C" {
#endif
/* needed for WOLFSSL_RSA type but use macro guard against redefine */
#if defined(OPENSSL_EXTRA) && !defined(WOLFSSL_TYPES_DEFINED) \
&& !defined(WOLFSSL_RSA_TYPE_DEFINED)
struct WOLFSSL_RSA;
typedef struct WOLFSSL_RSA WOLFSSL_RSA;
#define WOLFSSL_RSA_TYPE_DEFINED
#endif
enum {
RSA_PUBLIC = 0,
RSA_PRIVATE = 1,
};
/* RSA */
struct RsaKey {
IppsBigNumState* n;
IppsBigNumState* e;
IppsBigNumState* dipp;
IppsBigNumState* pipp;
IppsBigNumState* qipp;
IppsBigNumState* dPipp;
IppsBigNumState* dQipp;
IppsBigNumState* uipp;
int nSz, eSz, dSz;
IppsRSAPublicKeyState* pPub;
IppsRSAPrivateKeyState* pPrv;
word32 prvSz; /* size of private key */
word32 sz; /* size of signature */
int type; /* public or private */
void* heap; /* for user memory overrides */
};
#ifndef WC_RSAKEY_TYPE_DEFINED
typedef struct RsaKey RsaKey;
#define WC_RSAKEY_TYPE_DEFINED
#endif
WOLFSSL_API int wc_InitRsaKey(RsaKey* key, void*);
WOLFSSL_API int wc_InitRsaKey_ex(RsaKey* key, void* heap, int devId);
WOLFSSL_API int wc_FreeRsaKey(RsaKey* key);
WOLFSSL_API int wc_RsaPublicEncrypt(const byte* in, word32 inLen, byte* out,
word32 outLen, RsaKey* key, WC_RNG* rng);
WOLFSSL_API int wc_RsaPrivateDecryptInline(byte* in, word32 inLen, byte** out,
RsaKey* key);
WOLFSSL_API int wc_RsaPrivateDecrypt(const byte* in, word32 inLen, byte* out,
word32 outLen, RsaKey* key);
WOLFSSL_API int wc_RsaSSL_Sign(const byte* in, word32 inLen, byte* out,
word32 outLen, RsaKey* key, WC_RNG* rng);
WOLFSSL_API int wc_RsaSSL_VerifyInline(byte* in, word32 inLen, byte** out,
RsaKey* key);
WOLFSSL_API int wc_RsaSSL_Verify(const byte* in, word32 inLen, byte* out,
word32 outLen, RsaKey* key);
WOLFSSL_API int wc_RsaEncryptSize(RsaKey* key);
WOLFSSL_API int wc_RsaPrivateKeyDecode(const byte* input, word32* inOutIdx,
RsaKey*, word32);
WOLFSSL_API int wc_RsaPublicKeyDecode_ex(const byte* input, word32* inOutIdx,
word32 inSz, const byte** n, word32* nSz, const byte** e, word32* eSz);
WOLFSSL_API int wc_RsaPublicKeyDecode(const byte* input, word32* inOutIdx,
RsaKey*, word32);
WOLFSSL_API int wc_RsaPublicKeyDecodeRaw(const byte* n, word32 nSz,
const byte* e, word32 eSz, RsaKey* key);
WOLFSSL_API int wc_RsaKeyToDer(RsaKey*, byte* output, word32 inLen);
WOLFSSL_API int wc_RsaKeyToPublicDer(RsaKey*, byte* output, word32 inLen);
#ifdef WOLFSSL_KEY_GEN
WOLFSSL_API int wc_MakeRsaKey(RsaKey* key, int size, long e, WC_RNG* rng);
#endif
WOLFSSL_API int wc_RsaFlattenPublicKey(RsaKey*, byte*, word32*, byte*,
word32*);
WOLFSSL_API int wc_RsaSetRNG(RsaKey* key, WC_RNG* rng);
#if defined(WOLFSSL_CERT_GEN) || defined(WOLFSSL_KEY_GEN) || defined(OPENSSL_EXTRA)
/* abstracted BN operations with RSA key */
WOLFSSL_API int wc_Rsa_leading_bit(void* BN);
WOLFSSL_API int wc_Rsa_unsigned_bin_size(void* BN);
/* return MP_OKAY on success */
WOLFSSL_API int wc_Rsa_to_unsigned_bin(void* BN, byte* in, int inLen);
#endif
#ifdef OPENSSL_EXTRA /* abstracted functions to deal with rsa key */
WOLFSSL_API int SetRsaExternal(WOLFSSL_RSA* rsa);
WOLFSSL_API int SetRsaInternal(WOLFSSL_RSA* rsa);
#endif
#ifdef __cplusplus
} /* extern "C" */
#endif
#endif /* NO_RSA */
#endif /* USER_WOLF_CRYPT_RSA_H */

File diff suppressed because it is too large Load Diff

View File

@ -6415,10 +6415,8 @@ WOLFSSL_LOCAL int SetKeysSide(WOLFSSL* ssl, enum encrypt_side side);
/* Set*Internal and Set*External functions */
WOLFSSL_LOCAL int SetDsaInternal(WOLFSSL_DSA* dsa);
WOLFSSL_LOCAL int SetDsaExternal(WOLFSSL_DSA* dsa);
#ifndef HAVE_USER_RSA
WOLFSSL_LOCAL int SetRsaExternal(WOLFSSL_RSA* rsa);
WOLFSSL_LOCAL int SetRsaInternal(WOLFSSL_RSA* rsa);
#endif
typedef enum elem_set {
ELEMENT_P = 0x01,
@ -6645,7 +6643,7 @@ WOLFSSL_LOCAL int EncryptDerKey(byte *der, int *derSz, const EVP_CIPHER* cipher,
#endif
#endif
#if !defined(NO_RSA) && !defined(HAVE_USER_RSA)
#if !defined(NO_RSA)
WOLFSSL_LOCAL int wolfSSL_RSA_To_Der(WOLFSSL_RSA* rsa, byte** outBuf,
int publicKey, void* heap);
#endif

View File

@ -704,7 +704,6 @@ WOLFSSL_API void wc_FreeDer(DerBuffer** pDer);
#endif
#ifndef NO_RSA
#if !defined(HAVE_USER_RSA)
WOLFSSL_API int wc_RsaPublicKeyDecode_ex(const byte* input, word32* inOutIdx,
word32 inSz, const byte** n, word32* nSz, const byte** e, word32* eSz);
/* For FIPS v1/v2 and selftest this is in rsa.h */
@ -717,7 +716,6 @@ WOLFSSL_API void wc_FreeDer(DerBuffer** pDer);
(! ((HAVE_FIPS_VERSION == 5) && (HAVE_FIPS_VERSION_MINOR == 0)))))
WOLFSSL_API int wc_RsaKeyToPublicDer(RsaKey* key, byte* output, word32 inLen);
#endif
#endif /* !HAVE_USER_RSA */
WOLFSSL_API int wc_RsaPublicKeyDerSize(RsaKey* key, int with_header);
WOLFSSL_API int wc_RsaKeyToPublicDer_ex(RsaKey* key, byte* output, word32 inLen,
int with_header);

View File

@ -58,11 +58,6 @@ RSA keys can be used to encrypt, decrypt, sign and verify data.
#define NO_RSA_BOUNDS_CHECK
#endif
/* allow for user to plug in own crypto */
#if !defined(HAVE_FIPS) && (defined(HAVE_USER_RSA) || defined(HAVE_FAST_RSA))
#include "user_rsa.h"
#else
#include <wolfssl/wolfcrypt/wolfmath.h>
#include <wolfssl/wolfcrypt/random.h>
@ -450,8 +445,6 @@ WOLFSSL_LOCAL int wc_RsaUnPad_ex(byte* pkcsBlock, word32 pkcsBlockLen, byte** ou
WOLFSSL_LOCAL int wc_hash2mgf(enum wc_HashType hType);
#endif /* HAVE_USER_RSA */
#ifdef __cplusplus
} /* extern "C" */
#endif

View File

@ -3177,7 +3177,6 @@ extern void uITRON4_free(void *p) ;
* RSA public only, CAVP selftest, fast RSA, user RSA, QAT or CryptoCell */
#if (defined(WOLFSSL_RSA_KEY_CHECK) || (defined(HAVE_FIPS) && FIPS_VERSION_GE(2,0))) && \
!defined(WOLFSSL_NO_RSA_KEY_CHECK) && !defined(WOLFSSL_RSA_PUBLIC_ONLY) && \
!defined(HAVE_USER_RSA) && !defined(HAVE_FAST_RSA) && \
!defined(HAVE_INTEL_QA) && !defined(WOLFSSL_CRYPTOCELL) && \
!defined(HAVE_SELFTEST)