diff --git a/Makefile.am b/Makefile.am index 761733e7..f7451e81 100644 --- a/Makefile.am +++ b/Makefile.am @@ -88,8 +88,8 @@ coverage: init-coverage build-coverage gen-coverage # DSP/VCPROJ generation adapted from libcurl # only OpenSSL and WinCNG are supported with this build system -CRYPTO_CSOURCES = openssl.c wincng.c -CRYPTO_HHEADERS = openssl.h wincng.h +CRYPTO_CSOURCES = openssl.c wincng.c mbedtls.c +CRYPTO_HHEADERS = openssl.h wincng.h mbedtls.h # Makefile.inc provides the CSOURCES and HHEADERS defines include Makefile.inc diff --git a/Makefile.mbedTLS.inc b/Makefile.mbedTLS.inc new file mode 100644 index 00000000..7e978642 --- /dev/null +++ b/Makefile.mbedTLS.inc @@ -0,0 +1,2 @@ +CRYPTO_CSOURCES = mbedtls.c +CRYPTO_HHEADERS = mbedtls.h diff --git a/configure.ac b/configure.ac index d6bdab4a..e13cfbf0 100644 --- a/configure.ac +++ b/configure.ac @@ -93,6 +93,9 @@ AC_ARG_WITH(libgcrypt, AC_ARG_WITH(wincng, AC_HELP_STRING([--with-wincng],[Use Windows CNG for crypto]), use_wincng=$withval,use_wincng=auto) +AC_ARG_WITH(mbedtls, + AC_HELP_STRING([--with-mbedtls],[Use mbedTLS for crypto]), + use_mbedtls=$withval,use_mbedtls=auto) AC_ARG_WITH(libz, AC_HELP_STRING([--with-libz],[Use zlib for compression]), use_libz=$withval,use_libz=auto) @@ -163,11 +166,25 @@ AM_CONDITIONAL(WINCNG, test "$ac_cv_libbcrypt" = "yes") AM_CONDITIONAL(OS400QC3, false) +# Look for libmbedtls +if test "$found_crypto" = "none" && test "$use_mbedtls" != "no"; then + AC_LIB_HAVE_LINKFLAGS([mbedtls], [], [#include ]) +fi +if test "$ac_cv_libmbedtls" = "yes"; then + AC_DEFINE(LIBSSH2_MBEDTLS, 1, [Use mbedtls]) + LIBSREQUIRED= # mbedtls doesn't provide a .pc file + LIBS="$LIBS -lmbedtls -lmbedcrypto" + found_crypto=libmbedtls + support_clear_memory=yes +fi +AM_CONDITIONAL(MBEDTLS, test "$ac_cv_libmbedtls" = "yes") + # Check if crypto library was found if test "$found_crypto" = "none"; then AC_MSG_ERROR([No crypto library found! Try --with-libssl-prefix=PATH or --with-libgcrypt-prefix=PATH + or --with-libmbedtls-prefix=PATH or --with-wincng on Windows\ ]) fi diff --git a/src/Makefile.am b/src/Makefile.am index 1334c552..c14dc7cb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -14,6 +14,9 @@ endif if OS400QC3 include ../Makefile.os400qc3.inc endif +if MBEDTLS +include ../Makefile.mbedTLS.inc +endif # Makefile.inc provides the CSOURCES and HHEADERS defines include ../Makefile.inc