μNaCl – The Networking and Cryptography library for microcontrollers


Curve25519 for TI MSP430


The software described below is a standalone Curve25519 implementation optimized for speed. It includes two versions, one called "mul16" and one called "fast". Both of those are optimized for speed. The mul32 version targets MSP430 microcontrollers with a 32-bit multiplier; the mul16 version targets MSP430 microcontrollers with a 16-bit multiplier.


Build instructions

Installing an MSP430 GNU toolchain

In order to build Curve25519 for MSP430 you need an MSP430 GNU toolchain installed. On a Debian (jessie) systems this is easily achieved by running the following commands (as root):

apt-get update
apt-get install binutils-msp430 gcc-msp430 msp430-libc mspdebug

Building libmsp430.so for MSP430-FR5969 Launchpad

We are using the TI MSP430-FR5969 Launchpad for testing and benchmarking. In order to use mspdebug with this board, you need libmsp430.so. The following description describes how to build libmsp430.so and use mspdebug together with this library to communicate with the board.
First download the most recent version of slac460 from the TI MSPDS Open Source Package Website. The following description assumes that this file is slac460k.zip.

Now install boost, which is required for building libmsp430.so, on a Debian system this works by simply running (as root):

apt-get install libboost-all-dev

Now unpack and build libmsp430.so using the following commands:

unzip slac460k.zip
cd MSPDebugStack_OS_Package/
mkdir ThirdParty/lib/
mkdir ThirdParty/include/
git clone https://github.com/signal11/hidapi.git
cd hidapi
./bootstrap
./configure
make
cd ..
cp hidapi/libusb/.libs/hid.o ThirdParty/lib/hid-libusb.o
cp hidapi/hidapi/hidapi.h ThirdParty/include/
make

Still in the same directory, which now contains the file libmsp430.so, run the following commands as root to upgrade the firmware of the board:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:`pwd`
mspdebug --allow-fw-update tilib
mspdebug --allow-fw-update tilib

Building Curve25519 for TI MSP430

To download and build the software for TI MSP430, run the following commands:

wget https://munacl.cryptojedi.org/data/curve25519-msp430-20150415.tar.bz2
tar xjvf curve25519-msp430-20150415.tar.bz2
cd curve25519-msp430-20150415/mul16
make
cd ../mul32/
make

Running tests and benchmarks

Each of the two versions of the software comes with 3 testing and benchmarking routines:

To run those scripts, first edit each of them to set the variable LIBMSP430_PATH to the directory that contains libmsp430.so (see above). Each of those scripts will program the MSP430 on the Launchpad board (connected on /dev/ttyACM1) and print the output through USB-serial to standard out. Note that test_msp430fr5969.sh does not print anything if the test is successful. For benchmarks at 16MHz, please uncomment the corresponding block of code in test/speed.c.