Adding support for wolfSSL backend
PATCH 1/1 Adding support for wolfSSL backend
This patch adds the option to use wolfSSL as the ssl backend. To build this patch:
1. wolfSSL needs to be built with the --enable-all configure option.
2. OpenVPN must be built with the --with-crypto-library=wolfssl configure option.
Documentation regarding the wolfSSL SSL library may be found here: https://www.wolfssl.com/
Sincerely
Juliusz
.gitignore +5 -0
@@ -72,3 +72,8 @@ nbproject test-driver compile stamp-h2 + +\.settings/ +\.project +\.cproject +\.autotools
configure.ac +27 -2
@@ -276,10 +276,10 @@ AC_ARG_WITH( AC_ARG_WITH( [crypto-library], - [AS_HELP_STRING([--with-crypto-library=library], [build with the given crypto library, TYPE=openssl|mbedtls @<:@default=openssl@:>@])], + [AS_HELP_STRING([--with-crypto-library=library], [build with the given crypto library, TYPE=openssl|mbedtls|wolfssl @<:@default=openssl@:>@])], [ case "${withval}" in - openssl|mbedtls) ;; + openssl|mbedtls|wolfssl) ;; *) AC_MSG_ERROR([bad value ${withval} for --with-crypto-library]) ;; esac ],
@@ -1011,6 +1011,31 @@ elif test "${with_crypto_library}" = "mbedtls"; then AC_DEFINE([ENABLE_CRYPTO_MBEDTLS], [1], [Use mbed TLS library]) CRYPTO_CFLAGS="${MBEDTLS_CFLAGS}" CRYPTO_LIBS="${MBEDTLS_LIBS}" +elif test "${with_crypto_library}" = "wolfssl"; then + AC_ARG_VAR([WOLFSSL_CFLAGS], [C compiler flags for wolfssl]) + AC_ARG_VAR([WOLFSSL_LIBS], [linker flags for wolfssl]) + + saved_CFLAGS="${CFLAGS}" + saved_LIBS="${LIBS}" + + if test -z "${WOLFSSL_CFLAGS}" -a -z "${WOLFSSL_LIBS}"; then + # if the user did not explicitly specify flags, try to autodetect + LIBS="${LIBS} -lwolfssl -lm -pthread" + AC_CHECK_LIB( + [wolfssl], + [wolfSSL_get_ciphers], + [], + [AC_MSG_ERROR([Could not link wolfSSL library.])] + ) + fi + + have_crypto_aead_modes="yes" + + CFLAGS="${WOLFSSL_CFLAGS} ${CFLAGS}" + LIBS="${WOLFSSL_LIBS} ${LIBS}" + AC_DEFINE([ENABLE_CRYPTO_WOLFSSL], [1], [Use wolfSSL crypto library]) + CRYPTO_CFLAGS="${WOLFSSL_CFLAGS}" + CRYPTO_LIBS="${WOLFSSL_LIBS}" else AC_MSG_ERROR([Invalid crypto library: ${with_crypto_library}]) fi
include/openvpn-plugin.h.in +8 -1
@@ -32,6 +32,12 @@ #define __OPENVPN_X509_CERT_T_DECLARED typedef mbedtls_x509_crt openvpn_x509_cert_t; #endif +#elif defined(ENABLE_CRYPTO_WOLFSSL) /* ifdef ENABLE_CRYPTO_WOLFSSL */ +#include <wolfssl/ssl.h> +#ifndef __OPENVPN_X509_CERT_T_DECLARED +#define __OPENVPN_X509_CERT_T_DECLARED +typedef WOLFSSL_X509 openvpn_x509_cert_t; +#endif #else /* ifdef ENABLE_CRYPTO_MBEDTLS */ #include <openssl/x509.h> #ifndef __OPENVPN_X509_CERT_T_DECLARED
@@ -332,7 +338,8 @@ struct openvpn_plugin_callbacks typedef enum { SSLAPI_NONE, SSLAPI_OPENSSL, - SSLAPI_MBEDTLS + SSLAPI_MBEDTLS, + SSLAPI_WOLFSSL } ovpnSSLAPI; /**
src/openvpn/Makefile.am +3 -0
@@ -50,6 +50,7 @@ openvpn_SOURCES = \ crypto.c crypto.h crypto_backend.h \ crypto_openssl.c crypto_openssl.h \ crypto_mbedtls.c crypto_mbedtls.h \ + crypto_wolfssl.c crypto_wolfssl.h \ dhcp.c dhcp.h \ env_set.c env_set.h \ errlevel.h \
@@ -115,10 +116,12 @@ openvpn_SOURCES = \ ssl.c ssl.h ssl_backend.h \ ssl_openssl.c ssl_openssl.h \ ssl_mbedtls.c ssl_mbedtls.h \ + ssl_wolfssl.c ssl_wolfssl.h \ ssl_common.h \ ssl_verify.c ssl_verify.h ssl_verify_backend.h \ ssl_verify_openssl.c ssl_verify_openssl.h \ ssl_verify_mbedtls.c ssl_verify_mbedtls.h \ + ssl_verify_wolfssl.c ssl_verify_wolfssl.h \ status.c status.h \ syshead.h \ tls_crypt.c tls_crypt.h \
src/openvpn/crypto_backend.h +7 -4
@@ -29,18 +29,21 @@#ifndef CRYPTO_BACKEND_H_ #define CRYPTO_BACKEND_H_ +/* TLS uses a tag of 128 bytes, let's do the same for OpenVPN */ +#define OPENVPN_AEAD_TAG_LENGTH 16 +#ifdef ENABLE_CRYPTO_OPENSSL #include "crypto_openssl.h" #endif #ifdef ENABLE_CRYPTO_MBEDTLS #include "crypto_mbedtls.h" #endif +#ifdef ENABLE_CRYPTO_WOLFSSL +#include "crypto_wolfssl.h" +#endif #include "basic.h" #include "buffer.h" -/* TLS uses a tag of 128 bytes, let's do the same for OpenVPN */ -#define OPENVPN_AEAD_TAG_LENGTH 16 -/* Maximum cipher block size (bytes) */ #define OPENVPN_MAX_CIPHER_BLOCK_SIZE 32
@@ -355,7 +358,7 @@ void cipher_ctx_free(cipher_ctx_t *ctx);* @param key_len Length of the key, in bytes * @param kt Static cipher parameters to use * @param enc Whether to encrypt or decrypt (either -* \c MBEDTLS_OP_ENCRYPT or \c MBEDTLS_OP_DECRYPT). +* \c OPENVPN_OP_ENCRYPT or \c OPENVPN_OP_DECRYPT). */ void cipher_ctx_init (cipher_ctx_t *ctx,const uint8_t *key,int key_len,const cipher_kt_t *kt,int enc);
src/openvpn/crypto_wolfssl.c new file +1977 -0
1,977 lines not on this page · raw message
src/openvpn/crypto_wolfssl.h new file +522 -0
522 lines not on this page · raw message
src/openvpn/options.c +4 -0
@@ -862,7 +862,11 @@ init_options(struct options *o, const bool init_gc)#if P2MP o->scheduled_exit_interval =5 ;#endif +#ifdef ENABLE_CRYPTO_WOLFSSL + o->ciphername ="AES-256-CBC" ; +#else o->ciphername ="BF-CBC" ; +#endif #ifdef HAVE_AEAD_CIPHER_MODES /* IV_NCP=2 requires GCM support */ o->ncp_enabled = true;#else
src/openvpn/options.h +2 -2
@@ -79,8 +79,8 @@ struct options_pre_pull };#endif -#if !defined(ENABLE_CRYPTO_OPENSSL ) && !defined(ENABLE_CRYPTO_MBEDTLS ) -#error "At least one of OpenSSL or mbed TLS needs to be defined." +#if !defined(ENABLE_CRYPTO_OPENSSL ) && !defined(ENABLE_CRYPTO_MBEDTLS ) && !defined(ENABLE_CRYPTO_WOLFSSL ) +#error "At least one of OpenSSL or mbed TLS or wolfSSL needs to be defined."#endif struct connection_entry
src/openvpn/ssl_backend.h +5 -0
@@ -42,6 +42,11 @@#include "ssl_verify_mbedtls.h" #define SSLAPI SSLAPI_MBEDTLS#endif +#ifdef ENABLE_CRYPTO_WOLFSSL +#include "ssl_wolfssl.h" +#include "ssl_verify_wolfssl.h" +#define SSLAPI SSLAPI_WOLFSSL +#endif /* Ensure that SSLAPI got a sane value if SSL is disabled or unknown */ #ifndef SSLAPI
src/openvpn/ssl_verify.h +3 -0
@@ -40,6 +40,9 @@#ifdef ENABLE_CRYPTO_MBEDTLS #include "ssl_verify_mbedtls.h" #endif +#ifdef ENABLE_CRYPTO_WOLFSSL +#include "ssl_verify_wolfssl.h" +#endif #include "ssl_verify_backend.h"
src/openvpn/ssl_verify_wolfssl.c new file +654 -0
337 lines not on this page · raw message
src/openvpn/ssl_verify_wolfssl.h new file +76 -0
76 lines not on this page · raw message
src/openvpn/ssl_wolfssl.c new file +1194 -0
1,194 lines not on this page · raw message
src/openvpn/ssl_wolfssl.h new file +93 -0
93 lines not on this page · raw message
tests/unit_tests/openvpn/test_crypto.c +17 -0
Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Hi Juliusz,
Quoted 7 lines · Juliusz Sosinowicz
This patch adds the option to use wolfSSL as the ssl backend. To build this patch:
1. wolfSSL needs to be built with the
--enable-allconfigure option.
2. OpenVPN must be built with the--with-crypto-library=wolfsslconfigure option.
first of all thanks a lot for your contribution!
I have looked at wolfSSL more than a year ago and back then it was implementing an OpenSSL compatibility layer, so that it could be used as drop-in replacement in all those programs using OpenSSL as main TLS library.
Is this layer still in place?
If so, why not using it to link OpenVPN against wolfSSL rather than adding yet another backend?
The reason why I ask is that adding a new crypto backend drastically increases the maintenance cost for us. Therefore, reducing the change required in OpenVPN would be extremely beneficial.
Thanks a lot.
Best Regards,
Signature · 1 line
Antonio Quartulli
Hi,
Quoted 2 lines · Antonio Quartulli
The reason why I ask is that adding a new crypto backend drastically increases the maintenance cost for us.
... and since we're already struggling with providing proper maintenance and getting new stuff integrated in a timely fashion, every new burden due to extra testing, extra backends to consider when adding crypto- related patches, etc., is a fairly big no-go today.
Now, if we had 30 contributors that are all sitting idle waiting for patches to review, test and ACK, I might view this slightly differently...
Quoted 2 lines
Therefore, reducing the change
required in OpenVPN would be extremely beneficial.
This.
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...Am 16.08.19 um 16:14 schrieb Juliusz Sosinowicz:
Quoted 3 lines
This patch adds the option to use wolfSSL as the ssl backend. To build this patch:
That is great and it is also a very big patch. I skimmed only through the patch.
+#ifdef ENABLE_CRYPTO_WOLFSSL
+ o->ciphername = "AES-256-CBC";
+#else
o->ciphername = "BF-CBC";
+#endif
Such silent changes that OpenVPN behaves different, is something we would like to avoid. Better to error out in this case than to behave diffently.
Overall the WolfSSL feels to be a bit similar to OpenSSL. Is there any compatibility you are aiming at?
Also it would be nice to have a summary for people on the OpenVPN perspective
- Why WolfSSL in OpenVPN instead of mbed or OpenSSL
- What features does WolfSSL offer in OpenVPN that mbed/OpenSSL don't have
- What is missing with WolfSSL?
That should also good to have in the patch like README.mbedtls.
And one of the important question is:
What are your future plans in terms of involvement in OpenVPN development and maintaince? I think since you are first time contributer and this a big patch, that is something resonable to ask.
Arne
Hi,
thank you for the feedback. To answer your questions:
- Why WolfSSL in OpenVPN instead of mbed or OpenSSL
wolfSSL can be compiled to use very few resources in a wide array of embedded environments.
wolfSSL is FIPS ready - that is it has all the code available to be FIPS 140 validated on a platform.
- What features does WolfSSL offer in OpenVPN that mbed/OpenSSL don't have
wolfSSL has a large customer base and some of them would like to use OpenVPN with wolfSSL.
- What is missing with WolfSSL?
wolfSSL doesn’t support some older, weaker algorithms like Blowfish.
wolfSSL also lacks support for CryptoAPI and exporting of keying material.
- What are your future plans in terms of involvement in OpenVPN
development and maintaince?
Our plans are to help support and maintain the wolfSSL component of any project, including OpenVPN, that decides to incorporate our technology.
Regarding our OpenSSL compatibility layer: we do have a compatibility layer for OpenSSL but it still lacks many features. In addition, using wolfSSL directly without an additional layer allows for better efficiency and performance.
Sincerely
Juliusz
Quoted 37 lines · Arne Schwabe
Am 16.08.19 um 16:14 schrieb Juliusz Sosinowicz:
Quoted 3 lines
This patch adds the option to use wolfSSL as the ssl backend. To build this patch:
That is great and it is also a very big patch. I skimmed only through the patch.
src/openvpn/options.c +4
-0+#ifdef ENABLE_CRYPTO_WOLFSSL + o->ciphername ="AES-256-CBC" ; +#else o->ciphername ="BF-CBC" ; +#endif Such silent changes that OpenVPN behaves different, is something we would like to avoid. Better to error out in this case than to behave diffently.
Overall the WolfSSL feels to be a bit similar to OpenSSL. Is there any compatibility you are aiming at?
Also it would be nice to have a summary for people on the OpenVPN perspective
- Why WolfSSL in OpenVPN instead of mbed or OpenSSL
- What features does WolfSSL offer in OpenVPN that mbed/OpenSSL don't have
- What is missing with WolfSSL?That should also good to have in the patch like README.mbedtls.
And one of the important question is:
What are your future plans in terms of involvement in OpenVPN development and maintaince? I think since you are first time contributer and this a big patch, that is something resonable to ask.
Arne
Hey,
thanks for taking your time to answer.
I want to give you an honest opionion of mine to merging WolfSSL in OpenVPN. Please note, that this is my personal opinion and not to be confused to be an official OpenVPN community project or OpenVPN Inc position.
For every patch we have to decide if it worth accepting it and if the maintainance of the code is worthless and if the code itself is acceptable. Adding a third crypto library duplicates an already existing feature. So there needs to a very compelling reason for us to add this large feature.
We have not seen any involvement from your companay in the OpenVPN project so far. So accepting this patch and then later finding out that we have high maintainance cost for it, is something I really would like to avoid.
OpenVPN runs on small deployment but nothing that is really embedded. And almost all these already have mbed TLS or OpenSSL in place. In the main system that OpenVPN targets which are typical Unix systems or Windows, I have not really seen much use of WolfSSL either or seen a single email/issue/ticket requesting support for it, so from my personal impression there seem to be not much need for WolfSSL.
In summary, I personally cannot really find a good reason to incoperate WolfSSL currently into OpenVPN.
For the future of the patch. I would recommend that you keep maintaining that patch out of tree. We incorporate the fixes changes in the rest of OpenVPN to make this a more viable option. If your involvement in OpenVPN is high enough that I and others do feel that accepting the patch is a burden anymore, it can be merged in the future.
Quoted 6 lines
thank you for the feedback. To answer your questions:
- Why WolfSSL in OpenVPN instead of mbed or OpenSSL wolfSSL can be compiled to use very few resources in a wide array of embedded environments.
That seem to be also the stated goal for mbed TLS.
Quoted 5 lines
wolfSSL is FIPS ready - that is it has all the code available to be FIPS 140 validated on a platform.
- What features does WolfSSL offer in OpenVPN that mbed/OpenSSL don't have wolfSSL has a large customer base and some of them would like to use OpenVPN with wolfSSL.
I personally do not care for FIPS. Also that feel more like marketing for WolfSSL rather to what actually is an improvement to OepnVPN.
Quoted 3 lines
- What is missing with WolfSSL?
wolfSSL doesn’t support some older, weaker algorithms like Blowfish. wolfSSL also lacks support for CryptoAPI and exporting of keying material.
Otherwise it is a complete drop in replacement for OpenSSL?
Quoted 4 lines
- What are your future plans in terms of involvement in OpenVPN development and maintaince?
Our plans are to help support and maintain the wolfSSL component of any project, including OpenVPN, that decides to incorporate our technology.
When I asked here I meant more involvement in the OpenVPN project. I.e. helping reviewing patches that are cyrpto related. Looking into bug fixing etc. Fox It that did the mbed TLS port of OpenVPN did and is still involved in these kind of things.
Furthermore the commitment here is bit too vague for me even for the maintaince of the WolfSSL support. It sounds like a PR phrase. "WolfSSL component" for all that I know could just mean WolfSSL itself.
Quoted 4 lines
Regarding our OpenSSL compatibility layer: we do have a compatibility layer for OpenSSL but it still lacks many features. In addition, using wolfSSL directly without an additional layer allows for better efficiency and performance.
This very vague.
Arne
Hi,
Quoted 4 lines · Arne Schwabe
I want to give you an honest opionion of mine to merging WolfSSL in OpenVPN. Please note, that this is my personal opinion and not to be confused to be an official OpenVPN community project or OpenVPN Inc position.
Arne summarized things quite well. New and large additions need to balance "what *our* users want/need", "what the core team finds interesting enough to spend time on" and "how expensive in terms of maintainer lifetime will it be to maintain that stuff".
Since we're currently short on contributors that can review crypto related code changes, and we do not have anyone in the team today that can review WolfSSL interface code at all, this isn't likely going to happen in the near future.
gert,
herder of cats, aka "trying to keep development somewhat on track"
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...Hi,
Quoted 11 lines · Gert Doering
Quoted 4 lines · Arne Schwabe
I want to give you an honest opionion of mine to merging WolfSSL in OpenVPN. Please note, that this is my personal opinion and not to be confused to be an official OpenVPN community project or OpenVPN Inc position.
Arne summarized things quite well. New and large additions need to balance "what *our* users want/need", "what the core team finds interesting enough to spend time on" and "how expensive in terms of maintainer lifetime will it be to maintain that stuff".
Quoted 4 lines
Since we're currently short on contributors that can review crypto related code changes, and we do not have anyone in the team today that can review WolfSSL interface code at all, this isn't likely going to happen in the near future.
Just like Arne and Gert, I believe we're currently not in the position to take on the maintenance burden of adding another crypto backend. I'd rather spend our time on fixing bugs and improving openvpn performance (the crypto libs are not the bottleneck).
-Steffan
Quoted 13 lines · Gert Doering
Hi,
Quoted 4 lines · Arne Schwabe
I want to give you an honest opionion of mine to merging WolfSSL in OpenVPN. Please note, that this is my personal opinion and not to be confused to be an official OpenVPN community project or OpenVPN Inc position.
Arne summarized things quite well. New and large additions need to balance "what *our* users want/need", "what the core team finds interesting enough to spend time on" and "how expensive in terms of maintainer lifetime will it be to maintain that stuff".
Quoted 4 lines
Since we're currently short on contributors that can review crypto related code changes, and we do not have anyone in the team today that can review WolfSSL interface code at all, this isn't likely going to happen in the near future.
I have to say both Arne and Gert do have some really valid points.
But there is a lot to learn from Fox-ITs involvement. We *are* open to new contributors, who can be resources on various segments of OpenVPN. And we have few resources who really understands the depths of cryptology; we lean a lot on Steffan and Arne currently. But the initial PolarSSL support got acceptance because they more or less promised to help OpenVPN in the future on the crypto side.
What I'm saying, if you in WolfSSL are willing to help out, be available and help out responding to crypto related questions and patches on this -devel mailing list, be present in the community IRC channels, etc ... this would make it far easier to accept another crypto backend. And this is basically what Fox-IT has done via Steffan (and earlier Adrian).
This is also how we got IPv6 support in OpenVPN too; Gert had patches several years ago he maintained, he grew trust and with that he got more challenges and is now a co-maintainer of the OpenVPN community project. Lev got involved as well in a similar way, with features F-Secure Freedome needed at that time.
And you can find that a lot of the active people here get their changes
included, because they're active on a regular bases.
It doesn't mean they need to be active every day, but that they keep in touch at least every now and then on mailing lists or IRC and join the hackathons from time to time.
So getting a trust that you're going to be available also after WolfSSL support is added is kind of the key point; to help maintaining both the WolfSSL implementation but also helping out on a regular basis, especially on the crypto side.
Signature · 4 lines
kind regards, David Sommerseth OpenVPN Inc