Topic: [SOLVED] Getting Started WolfCrypt on Arduino

Hi, maybe this query sounds rather silly, but I'm desperate.
I'm trying to deploy an Arduino project to encrypt and decrypt using AES, but I get nothing since only get many import errors from libraries.

I followed the instructions to build the library "/IDE/ARDUINO/" and then I copied in the libraries directory at Arduino.

As I get some fault, I modified some ".h" files to convert relative paths, but I keep getting errors.

Is there any tutorial for getting started showing how to use wolfcrypt library from scratch in an Arduino project?
Thank you very much for taking time and giving me tips!


2 (edited by Kaleb J. Himes 2016-10-13 10:03:47)

Re: [SOLVED] Getting Started WolfCrypt on Arduino

Hi jesussotofan,

There are a couple of steps needed when building for Arduino. Most notably I will point out we have only ever tested the following on Intel Galileo board. We have not ported to any other platforms using Arduino.

You stated you only desire to use AES encrypt and decrypt, is this the only functionality you need? Are you not doing any TLS?
If this is the case you should be able to compile a select subset of our libraries which means you would only place the following four files in the <wolfssl-root> directory and then copy the root directory into the search path for Arduino.


If that is not the case and you intend to do a full build then the steps are just about as simple as the README implies. I will try to simplify more:

In arduino IDE hit File->open
By default you should be looking at a directory containing a folder named "libraries"
Note where that folder is located.
Now take wolfssl download.
If your download has "wolfssl-x.x.x" as the name, rename it to simply "wolfssl". I will refer to this directory as <wolfssl-root>, it just means the top-level wolfssl directory as we also have a directory inside the root directory named "wolfssl".
copy/paste the entire <wolfssl-root> directory into the "libraries" directory, not at the same level.
You should now have:

now follow the steps in the README for moving all the .c source files to the root directory of wolfssl and building the libraries.

Make sure you have the correct settings
In the Arduino IDE check Tools -> Board
by default this is set to something like "Arduino/Genuino Uno" if that is not the board you're building for then select the correct board. If you do not see the board you are looking for then select the "Board Manager" option and find the correct board support and install it. Then restart the IDE and again go Tools -> Board and find your board.

If you have any further trouble let us know.

Kind Regards,


Re: [SOLVED] Getting Started WolfCrypt on Arduino

Hi, thanks for your reply Kaleb.
I just need to use AES algorithm, forgetting the use of TLS / SSL. I copied the four files that told me except "wc_aes.c" because there was not, instead I copied "aes.c".

All these files were in <wolfssl-root> / wolfcrypt / src.
Now that they have been copied to <wolfssl-root>, I copied this folder in <path-to-arduino> / libraries.

I open a new Arduino project and go to "Sketch> Include Library> Contributed libraries" but I can not choose wolfssl libraries because they do not appear.

I do not know what I did wrong this time, but I can not get this to work.
I was wrong about something?

Thank you very much for any help or advice you can give me!


Re: [SOLVED] Getting Started WolfCrypt on Arduino

Hi jesussotofan,

You're correct, wc_aes.c was a typo, should have been just aes.c.

Now that you have <path-to-arduino>/libraries/wolfssl/(bunch of stuff + aes.c, wc_port.c, coding.c, and error.c) you need to take the last step performed by the script which is to simply create a new file and call it "wolfssl.h" and put this line in it:

/* stub header file for Arduino compatibility */

arduino won't recognize it as a library without a header file with the same name as the directory (that's why I noted to rename wolfssl-x.x.x to simply wolfssl).



Re: [SOLVED] Getting Started WolfCrypt on Arduino

Thanks very much for take your time and for your reply, Kaleb.

It works!


Re: [SOLVED] Getting Started WolfCrypt on Arduino

Hi, I want to use wolfCrypt in a project on an ESP8266 module, but I can't get it to work after following these instructions. I have copied the four mentioned c files into the root directory of wolfssl and put the wolfssl directory into the libraries folder. I included <wolfssl.h> into the sketch file, but I get the following compile error:

Arduino: 1.6.8 (Windows 10), Board: "Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 921600, 512K (64K SPIFFS), ck, Disabled, None"

In file included from C:\Program Files (x86)\Arduino\libraries\wolfssl/wolfssl/wolfcrypt/types.h:28:0,

                 from C:\Program Files (x86)\Arduino\libraries\wolfssl/wolfssl/wolfcrypt/aes.h:26,

                 from C:\Program Files (x86)\Arduino\libraries\wolfssl\aes.c:31:

C:\Program Files (x86)\Arduino\libraries\wolfssl/wolfssl/wolfcrypt/wc_port.h:107:9: error: unknown type name 'pthread_mutex_t'

         typedef pthread_mutex_t wolfSSL_Mutex;


exit status 1
Error compiling for board Generic ESP8266 Module.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Do I have to copy other c files as well? Or is it not compatible with the ESP8266 board?


Re: [SOLVED] Getting Started WolfCrypt on Arduino

Hi jellefresen,

pthreads is not something provided by wolfSSL. Pthreads stands for POSIX threads and is typically only supported in a POSIX environment.

Please see instructions on building for ARDUINO here: … /

One crucial step is to uncomment the define for WOLFSSL_ARDUINO in <wolfssl-root>/wolfssl/wolfcrypt/settings.h. This will in turn define SINGLE_THREADED which prevents our libraries from including the pthreads header file.



Re: [SOLVED] Getting Started WolfCrypt on Arduino

I have installed the wolfssl library in Arduino and it appears me in the examples. Until here everything is ok but when I want to compile it, it says me the following errors.

In file included from C:\Program Files (x86)\Arduino\libraries\wolfssl/wolfssl/ssl.h:95:0,

                 from C:\Users\LabSE\AppData\Local\Temp\arduino_modified_sketch_350713\wolfssl_client.ino:24:

C:\Program Files (x86)\Arduino\libraries\wolfssl/wolfssl/io.h:120:36: fatal error: sys/socket.h: No such file or directory

             #include <sys/socket.h>


compilation terminated.

exit status 1
Error compilando para la tarjeta Arduino/Genuino Uno.

Anyone knows why?
Can this library help me to enable ssl to communicate with an smtp server using the wifly shield?


Re: [SOLVED] Getting Started WolfCrypt on Arduino

Hi Ornelas,

wolfSSL falls back to including <sys/socket.h> when no other port layers have been enabled.  Last time we worked with wolfSSL on an Arduino, we created a define called WOLFSSL_ARDUINO.  Are you defining this when compiling wolfSSL?

Further instructions can be found in the following README: … /

Best Regards,