diff --git a/configure.ac b/configure.ac index 7bf8e1922..9a597f989 100644 --- a/configure.ac +++ b/configure.ac @@ -1931,6 +1931,20 @@ fi AM_CONDITIONAL([BUILD_PWDBASED], [test "x$ENABLED_PWDBASED" = "xyes"]) +# wolfCrypt Only Build +AC_ARG_ENABLE([cryptonly], + [AS_HELP_STRING([--enable-cryptonly],[Enable wolfCrypt Only build (default: disabled)])], + [ENABLED_CRYPTONLY=$enableval], + [ENABLED_CRYPTONLY=no]) + +if test "$ENABLED_CRYPTONLY" = "yes" +then + AM_CFLAGS="$AM_CFLAGS -DWOLFCRYPT_ONLY" +fi + +AM_CONDITIONAL([BUILD_CRYPTONLY], [test "x$ENABLED_CRYPTONLY" = "xyes"]) + + # set fastmath default FASTMATH_DEFAULT=no @@ -2002,6 +2016,7 @@ AC_ARG_ENABLE([examples], AS_IF([test "x$ENABLED_FILESYSTEM" = "xno"], [ENABLED_EXAMPLES="no"]) AS_IF([test "x$ENABLED_INLINE" = "xno"], [ENABLED_EXAMPLES="no"]) +AS_IF([test "x$ENABLED_CRYPTONLY" = "xyes"], [ENABLED_EXAMPLES="no"]) AM_CONDITIONAL([BUILD_EXAMPLES], [test "x$ENABLED_EXAMPLES" = "xyes"]) @@ -2402,6 +2417,7 @@ echo " * RABBIT: $ENABLED_RABBIT" echo " * CHACHA: $ENABLED_CHACHA" echo " * Hash DRBG: $ENABLED_HASHDRBG" echo " * PWDBASED: $ENABLED_PWDBASED" +echo " * wolfCrypt Only: $ENABLED_CRYPTONLY" echo " * HKDF: $ENABLED_HKDF" echo " * MD4: $ENABLED_MD4" echo " * PSK: $ENABLED_PSK" diff --git a/src/crl.c b/src/crl.c index 6cd26cdd2..51bff821a 100644 --- a/src/crl.c +++ b/src/crl.c @@ -27,6 +27,7 @@ #include +#ifndef WOLFCRYPT_ONLY #ifdef HAVE_CRL #include @@ -806,3 +807,4 @@ int LoadCRL(WOLFSSL_CRL* crl, const char* path, int type, int monitor) #endif /* NO_FILESYSTEM */ #endif /* HAVE_CRL */ +#endif /* !WOLFCRYPT_ONLY */ diff --git a/src/include.am b/src/include.am index 6c2629bc0..f594b1cf9 100644 --- a/src/include.am +++ b/src/include.am @@ -205,6 +205,7 @@ if BUILD_SRP src_libwolfssl_la_SOURCES += wolfcrypt/src/srp.c endif +if !BUILD_CRYPTONLY # ssl files src_libwolfssl_la_SOURCES += \ src/internal.c \ @@ -224,3 +225,5 @@ endif if BUILD_SNIFFER src_libwolfssl_la_SOURCES += src/sniffer.c endif + +endif # !BUILD_CRYPTONLY diff --git a/src/internal.c b/src/internal.c index cb3399cf8..9a8383fdd 100644 --- a/src/internal.c +++ b/src/internal.c @@ -26,6 +26,8 @@ #include +#ifndef WOLFCRYPT_ONLY + #include #include #include @@ -15596,3 +15598,4 @@ int DoSessionTicket(WOLFSSL* ssl, } #endif /* HAVE_STUNNEL */ #endif /* NO_WOLFSSL_SERVER */ +#endif /* WOLFCRYPT_ONLY */ diff --git a/src/io.c b/src/io.c index 5bd24273f..e296a2ed9 100644 --- a/src/io.c +++ b/src/io.c @@ -26,6 +26,8 @@ #include +#ifndef WOLFCRYPT_ONLY + #ifdef _WIN32_WCE /* On WinCE winsock2.h must be included before windows.h for socket stuff */ #include @@ -1161,4 +1163,5 @@ void wolfSSL_SetIO_NetX(WOLFSSL* ssl, NX_TCP_SOCKET* nxSocket, ULONG waitOption) } #endif /* HAVE_NETX */ +#endif /* WOLFCRYPT_ONLY */ diff --git a/src/keys.c b/src/keys.c index 2c232a762..41b5a941f 100644 --- a/src/keys.c +++ b/src/keys.c @@ -27,6 +27,8 @@ #include +#ifndef WOLFCRYPT_ONLY + #include #include #if defined(SHOW_SECRETS) || defined(CHACHA_AEAD_TEST) @@ -2779,3 +2781,5 @@ int MakeMasterSecret(WOLFSSL* ssl) #endif } +#endif /* WOLFCRYPT_ONLY */ + diff --git a/src/ocsp.c b/src/ocsp.c index 1794d6317..2b355d988 100644 --- a/src/ocsp.c +++ b/src/ocsp.c @@ -27,6 +27,7 @@ #include +#ifndef WOLFCRYPT_ONLY #ifdef HAVE_OCSP #include @@ -300,4 +301,5 @@ int CheckCertOCSP(WOLFSSL_OCSP* ocsp, DecodedCert* cert) #endif /* HAVE_OCSP */ +#endif /* WOLFCRYPT_ONLY */ diff --git a/src/sniffer.c b/src/sniffer.c index d28b91599..fa371ca2b 100644 --- a/src/sniffer.c +++ b/src/sniffer.c @@ -25,6 +25,7 @@ #include +#ifndef WOLFCRYPT_ONLY #ifdef WOLFSSL_SNIFFER #include @@ -3038,3 +3039,4 @@ int ssl_GetSessionStats(unsigned int* active, unsigned int* total, #endif /* WOLFSSL_SNIFFER */ +#endif /* WOLFCRYPT_ONLY */ diff --git a/src/ssl.c b/src/ssl.c index 64b27f7de..eae5f6003 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -25,6 +25,8 @@ #include +#ifndef WOLFCRYPT_ONLY + #ifdef HAVE_ERRNO_H #include #endif @@ -16861,4 +16863,5 @@ int wolfSSL_ED25519_verify(const unsigned char *msg, unsigned int msgSz, } #endif /* OPENSSL_EXTRA && HAVE_ED25519 */ +#endif /* WOLFCRYPT_ONLY */ diff --git a/src/tls.c b/src/tls.c index c0bdcd305..5d4657941 100644 --- a/src/tls.c +++ b/src/tls.c @@ -26,6 +26,8 @@ #include +#ifndef WOLFCRYPT_ONLY + #include #include #include @@ -3507,3 +3509,4 @@ int TLSX_Parse(WOLFSSL* ssl, byte* input, word16 length, byte isRequest, #endif /* NO_WOLFSSL_SERVER */ #endif /* NO_TLS */ +#endif /* WOLFCRYPT_ONLY */ diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index b7e7031c4..9daf55b9d 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -4587,6 +4587,28 @@ int ParseCert(DecodedCert* cert, int type, int verify, void* cm) #endif +#ifdef WOLFCRYPT_ONLY + +/* dummy functions, not using wolfSSL so don't need actual ones */ +Signer* GetCA(void* signers, byte* hash) +{ + (void)hash; + + return (Signer*)signers; +} + +#ifndef NO_SKID +Signer* GetCAByName(void* signers, byte* hash) +{ + (void)hash; + + return (Signer*)signers; +} +#endif /* NO_SKID */ + +#endif /* WOLFCRYPT_ONLY */ + + int ParseCertRelative(DecodedCert* cert, int type, int verify, void* cm) { word32 confirmOID; diff --git a/wolfcrypt/test/include.am b/wolfcrypt/test/include.am index 950d7c601..fcb07979f 100644 --- a/wolfcrypt/test/include.am +++ b/wolfcrypt/test/include.am @@ -1,6 +1,10 @@ # vim:ft=automake # All paths should be given relative to the root +noinst_PROGRAMS+= wolfcrypt/test/testwolfcrypt +if BUILD_CRYPTONLY +check_PROGRAMS+= wolfcrypt/test/testwolfcrypt +endif noinst_PROGRAMS+= wolfcrypt/test/testwolfcrypt wolfcrypt_test_testwolfcrypt_SOURCES = wolfcrypt/test/test.c wolfcrypt_test_testwolfcrypt_LDADD = src/libwolfssl.la