2024-02-07 13:52:18 -08:00
# wolfSSL with Arduino
2016-01-08 11:54:46 -07:00
2024-03-06 15:13:37 -08:00
See the [example sketches ](./sketches/README.md ):
- [sketches/wolfssl_server ](./sketches/wolfssl_server/README.md )
- [sketches/wolfssl_client ](./sketches/wolfssl_client/README.md )
When publishing a new version to the Arduino Registry, be sure to edit `WOLFSSL_VERSION_ARUINO_SUFFIX` in the `wolfssl-arduino.sh` script.
## Boards
2024-02-07 13:52:18 -08:00
Many of the supported boards are natively built-in to the [Arduino IDE Board Manager ](https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-board-manager/ )
2024-02-01 08:31:00 -08:00
and by adding [additional cores ](https://docs.arduino.cc/learn/starting-guide/cores/ ) as needed.
2024-02-07 13:52:18 -08:00
STM32 Support can be added by including this link in the "Additional Boards Managers URLs" field
from [stm32duino/Arduino_Core_STM32 ](https://github.com/stm32duino/Arduino_Core_STM32?tab=readme-ov-file#getting-started ) .
2024-02-01 08:31:00 -08:00
2024-02-07 13:52:18 -08:00
```
2024-02-01 08:31:00 -08:00
https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
2024-02-07 13:52:18 -08:00
```
2024-02-01 08:31:00 -08:00
2024-02-07 13:52:18 -08:00
## Using wolfSSL from the Arduino IDE
2024-03-06 15:13:37 -08:00
The Official wolfSSL: https://github.com/wolfSSL/arduino-wolfSSL See [PR #1 ](https://github.com/wolfSSL/Arduino-wolfSSL/pull/1 ).
2024-02-07 13:52:18 -08:00
This option will allow wolfSSL to be installed directly using the native Arduino tools.
## Manually Reformatting wolfSSL as a Compatible Arduino Library
2024-02-01 08:31:00 -08:00
2024-02-07 13:52:18 -08:00
Use [this ](./wolfssl-arduino.sh ) shell script that will re-organize the wolfSSL library to be
compatible with [Arduino Library Specification ](https://arduino.github.io/arduino-cli/0.35/library-specification/ )
for projects that use Arduino IDE 1.5.0 or newer.
2024-02-01 08:31:00 -08:00
2024-02-07 13:52:18 -08:00
The Arduino IDE requires a library's source files to be in the library's root directory with a
header file in the name of the library. This script moves all `src/` files to the `IDE/ARDUINO/wolfSSL/src`
directory and creates a stub header file called `wolfssl.h` inside that directory.
2024-02-01 08:31:00 -08:00
2024-02-07 13:52:18 -08:00
### Step 1:
2016-01-08 11:54:46 -07:00
2024-03-06 15:13:37 -08:00
To configure wolfSSL with Arduino, enter ONE of the following 4 commands
2024-02-01 08:31:00 -08:00
from within the `wolfssl/IDE/ARDUINO` directory:
2016-01-08 11:54:46 -07:00
2024-02-01 08:31:00 -08:00
1. `./wolfssl-arduino.sh`
2024-02-07 13:52:18 -08:00
- Creates an Arduino Library directory structure in the local `wolfSSL` directory of `IDE/ARDUINO` .
- You can add your own `user_settings.h` , or copy/rename the [default ](../../examples/configs/user_settings_arduino.h ).
2. `./wolfssl-arduino.sh INSTALL` (The most common option)
- Creates an Arduino Library in the local `wolfSSL` directory
- Moves that directory to the Arduino library directory:
- `$HOME/Arduino/libraries` for most bash environments
- `/mnt/c/Users/$USER/Documents/Arduino/libraries` (for WSL)
- Adds the [default ](../../examples/configs/user_settings_arduino.h ) as `user_settings.h` .
- The wolfSSL library is now available from the Arduino IDE.
3. `./wolfssl-arduino.sh INSTALL /path/to/repository` (Used to update [arduino-wolfSSL ](https://github.com/wolfSSL/arduino-wolfSSL ))
2024-02-01 08:31:00 -08:00
- Creates an Arduino Library in `wolfSSL` directory
2024-02-07 13:52:18 -08:00
- Copies that directory contents to the specified `/path/to/repository`
- Adds the [default ](../../examples/configs/user_settings_arduino.h ) as `user_settings.h` .
2024-02-01 08:31:00 -08:00
4. `./wolfssl-arduino.sh INSTALL /path/to/any/other/directory`
2024-02-07 13:52:18 -08:00
- Creates an Arduino Library in `wolfSSL` directory
- Copies that directory contents to the specified `/path/to/any/other/directory`
### Step 2:
2016-09-14 16:53:06 -06:00
2024-02-07 13:52:18 -08:00
Edit `<arduino-libraries>/wolfSSL/src/user_settings.h`
2019-05-22 10:38:26 -06:00
If building for Intel Galileo platform add: `#define INTEL_GALILEO` .
2024-02-07 13:52:18 -08:00
Add any other custom settings. For a good start see the examples in wolfssl root
"[/examples/configs/user_settings_*.h ](https://github.com/wolfssl/wolfssl/tree/master/examples/configs )"
### Step 3:
2019-05-22 10:38:26 -06:00
2024-02-07 13:52:18 -08:00
If you experience any issues with custom `user_settings.h` see the wolfssl
2019-05-22 10:38:26 -06:00
porting guide here for more assistance: https://www.wolfssl.com/docs/porting-guide/
2024-02-01 08:31:00 -08:00
If you have any issues contact support@wolfssl .com for help.
2024-02-07 13:52:18 -08:00
# Including wolfSSL in Arduino Libraries (for Arduino version 2.0 or greater)
2024-02-01 08:31:00 -08:00
1. In the Arduino IDE:
The wolfSSL library should automatically be detected when found in the `libraries`
directory.
2024-02-07 13:52:18 -08:00
- In `Sketch -> Include Library` choose wolfSSL for new sketches.
2024-02-01 08:31:00 -08:00
2016-09-14 16:53:06 -06:00
2019-01-07 11:47:33 -08:00
##### Including wolfSSL in Arduino Libraries (for Arduino version 1.6.6)
2018-06-08 14:27:54 -07:00
1. In the Arduino IDE:
- In `Sketch -> Include Library -> Add .ZIP Library...` and choose the
`IDE/ARDUNIO/wolfSSL` folder.
- In `Sketch -> Include Library` choose wolfSSL.
2024-02-01 08:31:00 -08:00
##### wolfSSL Examples
Open an example Arduino sketch for wolfSSL:
2024-02-07 13:52:18 -08:00
- wolfSSL [Client INO sketch ](./sketches/wolfssl_client/README.md ): `sketches/wolfssl_client/wolfssl_client.ino`
2024-02-01 08:31:00 -08:00
2024-02-07 13:52:18 -08:00
- wolfSSL [Server INO sketch ](./sketches/wolfssl_server/README.md ): `sketches/wolfssl_server/wolfssl_server.ino`
2024-02-01 08:31:00 -08:00
#### Script Examples
2024-03-06 15:13:37 -08:00
Refresh the local Windows Arduino wolfSSL library from GitHub repository directory using WSL:
Don't forget to edit `WOLFSSL_VERSION_ARUINO_SUFFIX` !
```bash
# Change to the wolfSSL Arduino IDE directory
cd /mnt/c/workspace/wolfssl-$USER/IDE/ARDUINO
# remove current Arduino wolfSSL library
rm -rf /mnt/c/Users/$USER/Documents/Arduino/libraries/wolfssl
# Install wolfSSL as an Arduino library
./wolfssl-arduino.sh INSTALL
```
Publish wolfSSL from WSL to a `Arduino-wolfSSL-$USER` repository.
2024-02-01 08:31:00 -08:00
```bash
2024-03-06 15:13:37 -08:00
cd /mnt/c/workspace/wolfssl-$USER/IDE/ARDUINO
2024-02-01 08:31:00 -08:00
rm -rf /mnt/c/Users/$USER/Documents/Arduino/libraries/wolfSSL
rm -rf /mnt/c/workspace/wolfssl-$USER/IDE/ARDUINO/wolfSSL
./wolfssl-arduino.sh INSTALL /mnt/c/workspace/Arduino-wolfSSL-$USER/
```
Publish wolfSSL from WSL to default Windows local library.
```bash
2024-03-13 12:24:00 -07:00
cd /mnt/c/workspace/wolfssl-$USER/IDE/ARDUINO
2024-02-01 08:31:00 -08:00
rm -rf /mnt/c/Users/$USER/Documents/Arduino/libraries/wolfSSL
rm -rf /mnt/c/workspace/wolfssl-arduino/IDE/ARDUINO/wolfSSL
./wolfssl-arduino.sh INSTALL
```
Test the TLS server by running a local command-line client.
```bash
cd /mnt/c/workspace/wolfssl-$USER
./examples/client/client -h 192.168.1.43 -p 11111 -v 3
```
2024-02-07 13:52:18 -08:00
Build wolfSSL to include wolfSSH support to an alternate development directory.
2024-02-01 08:31:00 -08:00
```bash
2024-02-07 13:52:18 -08:00
cd /mnt/c/workspace/wolfssl-$USER
./configure --prefix=/mnt/c/workspace/wolfssh-$USER/wolfssl_install --enable-ssh
make
make install
2024-02-01 08:31:00 -08:00
```
Build wolfSSH with wolfSSL not installed to default directory.
```bash
cd /mnt/c/workspace/wolfssh-$USER
./configure --with-wolfssl=/mnt/c/workspace/wolfssh-$USER/wolfssl_install
make
./examples/client/client -u jill -h 192.168.1.34 -p 22222 -P upthehill
```
Test the current wolfSSL.
```bash
cd /mnt/c/workspace/wolfssl-arduino
git status
./autogen.sh
./configure --enable-all
make clean
make && make test
```
2024-02-07 13:52:18 -08:00
Build and run `testwolfcrypt` .
2024-02-01 08:31:00 -08:00
```bash
./autogen.sh
./configure --enable-all
make clean && make && ./wolfcrypt/test/testwolfcrypt
```