add autotools bits for cyassl
Signed-off-by: Andy Green <andy.green@linaro.org>
diff --git a/README.build b/README.build
index bb346aa..20d195e 100644
--- a/README.build
+++ b/README.build
@@ -73,6 +73,12 @@
There are several other possible configure options
+--enable-openssl Builds in the SSL support
+
+--with-cyassl Use cyassl instead of OpenSSL... you will need CyaSSL
+ to have been configured with --enable-opensslExtra
+\ when it was built.
+
--enable-libcrypto by default libwebsockets uses its own
built-in md5 and sha-1 implementation for
simplicity. However the libcrypto ones
diff --git a/configure.ac b/configure.ac
index 549b729..1e4ae42 100644
--- a/configure.ac
+++ b/configure.ac
@@ -190,6 +190,18 @@
fi
AM_CONDITIONAL(USE_BUILTIN_GETIFADDRS, test x$builtin_getifaddrs = xyes)
+#
+#
+#
+AC_ARG_WITH(cyassl,
+ [ --with-cyassl Use CyaSSL instead of OpenSSL ],
+ [ use_cyassl=yes
+ ])
+
+if test "x$use_cyassl" = "xyes" ; then
+CFLAGS="$CFLAGS -DUSE_CYASSL -DLWS_OPENSSL_SUPPORT"
+fi
+AM_CONDITIONAL(USE_CYASSL, test x$use_cyassl = xyes)
# Checks for header files.
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 3a51c1a..775d001 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -47,6 +47,10 @@
libwebsockets_la_CFLAGS=-Wall -std=gnu99 -pedantic
libwebsockets_la_LDFLAGS=
+if USE_CYASSL
+libwebsockets_la_LDFLAGS+= -lcyassl
+endif
+
if DISABLE_DEBUG
libwebsockets_la_CFLAGS+= -O4
else
diff --git a/lib/libwebsockets.c b/lib/libwebsockets.c
index 5c30c92..6efebfa 100644
--- a/lib/libwebsockets.c
+++ b/lib/libwebsockets.c
@@ -1691,10 +1691,15 @@
#ifdef LWS_OPENSSL_SUPPORT
context->use_ssl = ssl_cert_filepath != NULL &&
ssl_private_key_filepath != NULL;
+#ifdef USE_CYASSL
+ lwsl_notice(" Compiled with CYASSL support\n");
+#else
+ lwsl_notice(" Compiled with OpenSSL support\n");
+#endif
if (context->use_ssl)
- lwsl_notice(" Compiled with SSL support, using it\n");
+ lwsl_notice(" Using SSL mode\n");
else
- lwsl_notice(" Compiled with SSL support, not using it\n");
+ lwsl_notice(" Using non-SSL mode\n");
#else
if (ssl_cert_filepath != NULL &&
diff --git a/lib/private-libwebsockets.h b/lib/private-libwebsockets.h
index a7f5c27..7f461ef 100644
--- a/lib/private-libwebsockets.h
+++ b/lib/private-libwebsockets.h
@@ -93,11 +93,18 @@
#endif
#ifdef LWS_OPENSSL_SUPPORT
+#ifdef USE_CYASSL
+#include <cyassl/openssl/ssl.h>
+#include <cyassl/error.h>
+unsigned char *
+SHA1(const unsigned char *d, size_t n, unsigned char *md);
+#else
#include <openssl/ssl.h>
#include <openssl/evp.h>
#include <openssl/err.h>
#include <openssl/md5.h>
#include <openssl/sha.h>
+#endif /* not USE_CYASSL */
#endif
#include "libwebsockets.h"
@@ -487,7 +494,4 @@
unsigned char *
SHA1(const unsigned char *d, size_t n, unsigned char *md);
-void
-MD5(const unsigned char *input, int ilen, unsigned char *output);
-
#endif
diff --git a/lib/server.c b/lib/server.c
index 5af1081..c1b6cd8 100644
--- a/lib/server.c
+++ b/lib/server.c
@@ -137,8 +137,10 @@
ssize_t len;
#ifdef LWS_OPENSSL_SUPPORT
int m;
+#ifndef USE_CYASSL
BIO *bio;
#endif
+#endif
switch (wsi->mode) {