FourQlib/FourQ_ARM
Patrick Longa 36e13fc9f2 Update eccp2_no_endo.c 2017-05-16 14:15:18 -07:00
..
ARM Add files via upload 2017-05-08 17:47:34 -07:00
libopencm3 Add files via upload 2017-05-08 17:47:34 -07:00
random Add files via upload 2017-05-08 17:47:34 -07:00
tests Add files via upload 2017-05-08 17:47:34 -07:00
tests_Cortex-M4 Add files via upload 2017-05-08 17:47:34 -07:00
FourQ.h Update FourQ.h 2017-05-16 13:59:17 -07:00
FourQ_api.h Add files via upload 2017-05-09 12:06:50 -07:00
FourQ_internal.h Add files via upload 2017-05-08 17:47:34 -07:00
FourQ_params.h Add files via upload 2017-05-08 17:47:34 -07:00
FourQ_tables.h Update FourQ_tables.h 2017-05-11 21:15:24 -07:00
README.md Update README.md 2017-05-09 11:56:42 -07:00
crypto_util.c Add files via upload 2017-05-08 17:47:34 -07:00
eccp2.c Add files via upload 2017-05-16 14:07:01 -07:00
eccp2_no_endo.c Update eccp2_no_endo.c 2017-05-16 14:15:18 -07:00
kex.c Add files via upload 2017-05-08 17:47:34 -07:00
makefile Add files via upload 2017-05-09 12:06:50 -07:00
makefile_Cortex-M4 Add files via upload 2017-05-16 14:05:14 -07:00
schnorrq.c Add files via upload 2017-05-09 12:06:50 -07:00
stm32f4_wrapper.c Add files via upload 2017-05-09 12:06:50 -07:00
stm32f4_wrapper.h Add files via upload 2017-05-09 12:06:50 -07:00
stm32f407x6.ld Add files via upload 2017-05-09 12:06:50 -07:00
table_lookup.h Add files via upload 2017-05-08 17:47:34 -07:00

README.md

FourQlib v3.0 (C Edition):

Optimized implementation for 32-bit ARM and ARM Cortex-M4

Contents

The FourQ_ARM folder contains:

stm32f4_wrapper.c and stm32f4_wrapper.h are by Joost Rijneveld and can be found here.

Files in the libopencm3 folder are from the libopencm3 project.

Supported platforms

This implementation is supported on ARM platforms and includes two variants:

  • Implementation for ARM processors based on ARMv6 and ARMv7 architectures. This implementation was optimized for a first generation Raspberry Pi using a 700 MHz ARM1176JZF-S processor (ARMv6 architecture).
  • Implementation for ARM Cortex-M4 processors based on the ARMv7-M architecture. This implementation was developed and optimized on a STM32F4Discovery development board containing a Cortex-M4 STM32F407VG microcontroller (ARMv7-M architecture). It should be possible to extend the support to Cortex-M3 and Cortex-M7 based devices with small modifications.

See instructions below to choose an implementation option and compile on one of the supported platforms.

Complementary crypto functions

Random values are generated with /dev/urandom in the case of the 32-bit ARM implementation, and with the function random_int() in the case of the ARM Cortex-M4 implementation.

The library includes an implementation of SHA-512 which is used by default by SchnorrQ signatures.

Users can experiment with different options by replacing functions in the random, FourQ_ARM/random and sha512 folders and applying the corresponding changes to the settings in FourQ.h.

Instructions

Building the library for ARMv6 or ARMv7

To compile on Linux using the GNU GCC compiler or the clang compiler, execute the following command from the command prompt:

$ make CC=[gcc/clang] USE_ENDO=[TRUE/FALSE] EXTENDED_SET=[TRUE/FALSE] CACHE_MEM=[TRUE/FALSE]

After compilation, run fp_tests, ecc_tests or crypto_tests.

By default GNU GCC is used, as well as endomorphisms and extended settings. Similarly, CACHE_MEM=TRUE is set by default indicating that the targeted platform contains a cache memory.

For example, to compile using GNU GCC with the efficient endomorphisms, execute:

$ make

As another example, to compile using clang with the efficient endomorphisms, execute:

$ make CC=clang

By default EXTENDED_SET is enabled, which sets the following compilation flags: -fwrapv -fomit-frame-pointer -funroll-loops. To disable this, use EXTENDED_SET=FALSE. Users are encouraged to experiment with the different flag options.

Building the library for Cortex-M4 on the STM32F4DISCOVERY board

The following instructions have been tested on a Ubuntu 16.04 Linux machine.

First, install the ARM GNU GCC cross-compiler on the server machine:

$ sudo apt-get install gcc-arm-none-eabi libc6-dev-i386

Then, download, build and install stlink:

$ sudo apt-get install libusb-1.0-0-dev
$ git clone https://github.com/texane/stlink.git
$ cd stlink
$ make
$ cd build/Release/ && sudo make install

To compile the code, execute the following command from the FourQ_ARM folder on the server machine:

$ make -f makefile_Cortex-M4 USE_ENDO=[TRUE/FALSE]

Power the STM32F4DISCOVERY board (with a USB to mini-USB cable) and connect it to the server machine via a USB-TTL converter as follows:

VDD -> VDD
GND -> GND 
TX  -> PA3 
RX  -> PA2 

Then, run from the server machine:

$ sudo ./tests_Cortex-M4/monitor.sh

From a different terminal window on the server machine, program the device with one of the following commands from the FourQ_ARM folder:

$ st-flash write tests_Cortex-M4/fp_tests.bin 0x8000000
$ st-flash write tests_Cortex-M4/ecc_tests.bin 0x8000000
$ st-flash write tests_Cortex-M4/crypto_tests.bin 0x8000000

The tests should begin to run on the first terminal window.