wolfssl-examples/can-bus
tim-weller-wolfssl c628d837c2 Add ./configure shell command to enable ISOTP support in wolfSSL for can-bus example 2023-04-04 11:37:03 -05:00
..
Makefile Alter ISO-TP example to use wolfSSL native 2022-01-06 11:40:36 +00:00
README.md Add ./configure shell command to enable ISOTP support in wolfSSL for can-bus example 2023-04-04 11:37:03 -05:00
client.c Fix CAN messages 2022-01-06 18:02:11 +00:00
common.c Alter ISO-TP example to use wolfSSL native 2022-01-06 11:40:36 +00:00
common.h Alter ISO-TP example to use wolfSSL native 2022-01-06 11:40:36 +00:00
generate_ssl.sh
server.c Fix CAN messages 2022-01-06 18:02:11 +00:00

README.md

wolfSSL CAN Bus Example

This example implements a simple echo client and server that uses TLS over a CAN bus using ISO-TP as a transport protocol. This is because the raw CAN bus protocol can only support payloads of up to 8 bytes. The example requires Linux to run but can modified to work on any setup that uses CAN bus.

Building

You need to have wolfSSL installed on your computer prior to building, this will need to be built with WOLFSSL_ISOTP defined to provide ISO-TP functionality.

In the wolfssl directory:

$ ./autogen.sh (this step might not be required if the configure script already exists)
$ ./configure CFLAGS="-DWOLFSSL_ISOTP"
$ make all
$ sudo make install

Then in the wolfssl-examples/can-bus directory:

$ ./generate_ssl.sh
$ make

The client and 'serverapplications will be available in thewolfssl-examples/can-bus' directory, as well as the required SSL certificates.

Setting Up

If you do not have a physical CAN bus between too machines you can use the virtual CAN bus which is a Linux kernel module. This behaves just like a real CAN bus with a similar bandwidth. To enable this run the following commands:

$ sudo modprobe vcan
$ sudo ip link add dev vcan0 type vcan
$ sudo ip link set vcan0 up

Running

On one console run the server, this should be executed first or the handshake will fail. This is executed using:

$ server vcan0

Then in another terminal run the client:

$ client vcan0

On both ends you will see:

SSL handshake done!

Once you see the message "SSL handshake done!" on both consoles you can enter text into the client console. When you hit "enter" this will be sent to the server via the TLS encrypted CAN bus and will echo there.

For example, on the client if we type "Hello world, this is a TLS test!":

Hello world! This is a CAN bus test!
Sending: Hello world! This is a CAN bus test!

Message sent

The server will echo:

Got message: Hello world! This is a CAN bus test!

Cleaning Up

If you wish to disable the virtual CAN bus you can turn it off by doing:

$ sudo ip link set vcan0 down