Merge pull request #8781 from kaspar030/add_qdsa_pkg
pkg: add qDSA package
This commit is contained in:
commit
88e61ed353
@ -6,7 +6,7 @@ export CFLAGS_CPU = -mcpu=$(MCPU) -mlittle-endian -mthumb $(CFLAGS_FPU)
|
|||||||
ifneq (llvm,$(TOOLCHAIN))
|
ifneq (llvm,$(TOOLCHAIN))
|
||||||
# Clang (observed with v3.7) does not understand -mno-thumb-interwork, only add if
|
# Clang (observed with v3.7) does not understand -mno-thumb-interwork, only add if
|
||||||
# not building with LLVM
|
# not building with LLVM
|
||||||
export CFLAGS_CPU += -mno-thumb-interwork
|
export CFLAGS += -mno-thumb-interwork
|
||||||
endif
|
endif
|
||||||
export CFLAGS_LINK = -ffunction-sections -fdata-sections -fno-builtin -fshort-enums
|
export CFLAGS_LINK = -ffunction-sections -fdata-sections -fno-builtin -fshort-enums
|
||||||
export CFLAGS_DBG ?= -ggdb -g3
|
export CFLAGS_DBG ?= -ggdb -g3
|
||||||
|
|||||||
11
pkg/qDSA/Makefile
Normal file
11
pkg/qDSA/Makefile
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
PKG_NAME=qDSA
|
||||||
|
PKG_URL=https://github.com/RIOT-OS/qDSA.git
|
||||||
|
PKG_VERSION=dd2392b0c81ce4187fd3e1e2d3e0a4767f75782e
|
||||||
|
PKG_LICENSE=PD
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
|
||||||
|
all: git-download
|
||||||
|
"$(MAKE)" -C $(PKG_BUILDDIR)/$(QDSA_IMPL)
|
||||||
|
|
||||||
|
include $(RIOTBASE)/pkg/pkg.mk
|
||||||
3
pkg/qDSA/Makefile.dep
Normal file
3
pkg/qDSA/Makefile.dep
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
ifneq (,$(filter atmega_common cortexm_common,$(USEMODULE)))
|
||||||
|
USEMODULE += qDSA_asm
|
||||||
|
endif
|
||||||
13
pkg/qDSA/Makefile.include
Normal file
13
pkg/qDSA/Makefile.include
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
ifneq (,$(filter cortexm_common,$(USEMODULE)))
|
||||||
|
QDSA_IMPL ?= arm
|
||||||
|
else
|
||||||
|
ifneq (,$(filter atmega_common,$(USEMODULE)))
|
||||||
|
QDSA_IMPL ?= avr
|
||||||
|
else
|
||||||
|
QDSA_IMPL ?= cref
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
export QDSA_IMPL
|
||||||
|
|
||||||
|
INCLUDES += -I$(PKGDIRBASE)/qDSA/$(QDSA_IMPL)
|
||||||
12
pkg/qDSA/doc.txt
Normal file
12
pkg/qDSA/doc.txt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
/**
|
||||||
|
* @defgroup pkg_qDSA qDSA
|
||||||
|
* @ingroup pkg
|
||||||
|
* @ingroup sys
|
||||||
|
* @brief Small and Secure Digital Signatures with Curve-based Diffie-Hellman Key Pairs
|
||||||
|
*
|
||||||
|
* # License
|
||||||
|
*
|
||||||
|
* The package code is released to public domain
|
||||||
|
*
|
||||||
|
* @see https://www.cs.ru.nl/~jrenes/
|
||||||
|
*/
|
||||||
@ -24,6 +24,7 @@ BOARD_INSUFFICIENT_MEMORY := airfy-beacon \
|
|||||||
microbit \
|
microbit \
|
||||||
msb-430 \
|
msb-430 \
|
||||||
msb-430h \
|
msb-430h \
|
||||||
|
msba2 \
|
||||||
nrf51dongle \
|
nrf51dongle \
|
||||||
nrf6310 \
|
nrf6310 \
|
||||||
nucleo32-f031 \
|
nucleo32-f031 \
|
||||||
@ -206,6 +207,15 @@ ifneq (,$(filter tests-cpp_%, $(UNIT_TESTS)))
|
|||||||
export CPPMIX := 1
|
export CPPMIX := 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifneq (, $(filter $(AVR_BOARDS), $(BOARD)))
|
||||||
|
LARGE_STACK_TESTS += tests-qDSA
|
||||||
|
endif
|
||||||
|
|
||||||
|
LARGE_STACK_TESTS += tests-tweetnacl
|
||||||
|
ifneq (,$(filter $(LARGE_STACK_TESTS), $(UNIT_TESTS)))
|
||||||
|
CFLAGS += -DTHREAD_STACKSIZE_MAIN=\(4*THREAD_STACKSIZE_DEFAULT+THREAD_EXTRA_STACKSIZE_PRINTF\)
|
||||||
|
endif
|
||||||
|
|
||||||
DISABLE_MODULE += auto_init
|
DISABLE_MODULE += auto_init
|
||||||
|
|
||||||
# Pull in `Makefile.include`s from the test suites:
|
# Pull in `Makefile.include`s from the test suites:
|
||||||
|
|||||||
1
tests/unittests/tests-qDSA/Makefile
Normal file
1
tests/unittests/tests-qDSA/Makefile
Normal file
@ -0,0 +1 @@
|
|||||||
|
include $(RIOTBASE)/Makefile.base
|
||||||
2
tests/unittests/tests-qDSA/Makefile.include
Normal file
2
tests/unittests/tests-qDSA/Makefile.include
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
USEMODULE += random
|
||||||
|
USEPKG += qDSA
|
||||||
80
tests/unittests/tests-qDSA/tests-qDSA.c
Normal file
80
tests/unittests/tests-qDSA/tests-qDSA.c
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 Kaspar Schleiser <kaspar@schleiser.de>
|
||||||
|
*
|
||||||
|
* This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
* directory for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup unittests
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
* @brief qDSA crypto library tests
|
||||||
|
*
|
||||||
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||||
|
*
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "embUnit.h"
|
||||||
|
#include "tests-qDSA.h"
|
||||||
|
|
||||||
|
#include "random.h"
|
||||||
|
#include "sign.h"
|
||||||
|
|
||||||
|
static const unsigned char m[] = "0123456789abcdef";
|
||||||
|
|
||||||
|
#define SMLEN (sizeof(m) + 64)
|
||||||
|
|
||||||
|
static unsigned char sm[SMLEN];
|
||||||
|
static unsigned char m_result[sizeof(m)];
|
||||||
|
static unsigned char sk[64];
|
||||||
|
static unsigned char pk[32];
|
||||||
|
|
||||||
|
static void setUp(void)
|
||||||
|
{
|
||||||
|
/* Initialize */
|
||||||
|
random_init(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tearDown(void)
|
||||||
|
{
|
||||||
|
/* Finalize */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_qDSA_sign_verify(void)
|
||||||
|
{
|
||||||
|
unsigned long long smlen;
|
||||||
|
|
||||||
|
random_bytes(sk, 32);
|
||||||
|
keypair(pk, sk);
|
||||||
|
|
||||||
|
sign(sm, &smlen, m, sizeof(m), pk, sk);
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT(SMLEN, smlen);
|
||||||
|
TEST_ASSERT_EQUAL_STRING("0123456789abcdef", (const char *)(sm + 64));
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT(0, verify(m_result, 0, sm, smlen, pk));
|
||||||
|
TEST_ASSERT_EQUAL_STRING("0123456789abcdef", (const char *)m_result);
|
||||||
|
|
||||||
|
sm[70] = 'x';
|
||||||
|
|
||||||
|
TEST_ASSERT_EQUAL_INT(1, verify(m_result, 0, sm, smlen, pk));
|
||||||
|
}
|
||||||
|
|
||||||
|
Test *tests_qDSA_all(void)
|
||||||
|
{
|
||||||
|
EMB_UNIT_TESTFIXTURES(fixtures) {
|
||||||
|
new_TestFixture(test_qDSA_sign_verify),
|
||||||
|
};
|
||||||
|
|
||||||
|
EMB_UNIT_TESTCALLER(qDSA_tests, setUp, tearDown, fixtures);
|
||||||
|
return (Test*)&qDSA_tests;
|
||||||
|
}
|
||||||
|
|
||||||
|
void tests_qDSA(void)
|
||||||
|
{
|
||||||
|
TESTS_RUN(tests_qDSA_all());
|
||||||
|
}
|
||||||
44
tests/unittests/tests-qDSA/tests-qDSA.h
Normal file
44
tests/unittests/tests-qDSA/tests-qDSA.h
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2018 Kaspar Schleiser <kaspar@schleiser.de>
|
||||||
|
*
|
||||||
|
* This file is subject to the terms and conditions of the GNU Lesser
|
||||||
|
* General Public License v2.1. See the file LICENSE in the top level
|
||||||
|
* directory for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup unittests
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* @file
|
||||||
|
* @brief Unittests for the qDSA package
|
||||||
|
*
|
||||||
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||||||
|
*/
|
||||||
|
#ifndef TESTS_QDSA_H
|
||||||
|
#define TESTS_QDSA_H
|
||||||
|
|
||||||
|
#include "embUnit/embUnit.h"
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief The entry point of this test suite.
|
||||||
|
*/
|
||||||
|
void tests_qDSA(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Generates tests for qDSA
|
||||||
|
*
|
||||||
|
* @return embUnit tests if successful, NULL if not.
|
||||||
|
*/
|
||||||
|
Test *tests_dDSA_tests(void);
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* TESTS_QDSA_H */
|
||||||
|
/** @} */
|
||||||
@ -1,4 +1,2 @@
|
|||||||
USEMODULE += random
|
USEMODULE += random
|
||||||
USEPKG += tweetnacl
|
USEPKG += tweetnacl
|
||||||
|
|
||||||
CFLAGS += -DTHREAD_STACKSIZE_MAIN=\(4*THREAD_STACKSIZE_DEFAULT+THREAD_EXTRA_STACKSIZE_PRINTF\)
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user