Compiling on Linux using i2c userspace - DurandA/atca-ecdhe GitHub Wiki

CryptoAuthLib is a portable C library meant to be used in a wide variety of devices (mainly microcontrollers). The hardware abstraction layer (HAL) enables a common interface which does not depend on the underlying hardware. For exmample, this library can be used from Linux using i2c or even using a USB interface on a PC.

CryptoAuthLib provides several HALs, including Linux i2c userspace. Unfortunately, MicroChip does not provide a makefile for this platform. We can make our own or hack the one from cryptoauth-openssl-engineโ€”an OpenSSL Engine implementation using ATECC508. The modified Makefile is available as a gist. To use it, copy the makefile on the root of the CryptoAuthLib folder and make libcryptoauth. It will create a static library libcryptoauth.a in the .build folder. Build CryptoAuthLib with CMake:

$ export CFLAGS="-DATCA_NO_POLL=1"
$ cmake . -DATCA_BUILD_SHARED_LIBS=OFF -DATCA_HAL_I2C=ON
$ make

Once compiled, the library can be used on any Linux machine with i2c headers (e.g. Raspberry Pi or C.H.I.P.) or using a using a USB->i2c adapter (e.g. CP2112 which is supported on Kernel >= 3.15).

The example can be compiled using gcc -Wall -std=c99 -I/home/pi/cryptoauthlib/lib crypto.c /home/pi/cryptoauthlib/lib/libcryptoauth.a -o crypto.