diff --git a/pkg/tweetnacl/Makefile b/pkg/tweetnacl/Makefile index b30d17ed36..c2d1bff57c 100644 --- a/pkg/tweetnacl/Makefile +++ b/pkg/tweetnacl/Makefile @@ -6,7 +6,6 @@ PKG_LICENSE=PD .PHONY: all all: git-download - @cp $(RIOTBASE)/pkg/tweetnacl/src/* $(PKG_BUILDDIR) - "$(MAKE)" -C $(PKG_BUILDDIR) + $(Q)"$(MAKE)" -C $(PKG_BUILDDIR) -f $(CURDIR)/Makefile.riot -include $(RIOTBASE)/pkg/pkg.mk \ No newline at end of file +include $(RIOTBASE)/pkg/pkg.mk diff --git a/pkg/tweetnacl/Makefile.riot b/pkg/tweetnacl/Makefile.riot new file mode 100644 index 0000000000..23ba5ad3e2 --- /dev/null +++ b/pkg/tweetnacl/Makefile.riot @@ -0,0 +1,3 @@ +MODULE=tweetnacl + +include $(RIOTBASE)/Makefile.base diff --git a/pkg/tweetnacl/patches/0001-RIOT-Use-RIOT-random_bytes-function-instead-of-rando.patch b/pkg/tweetnacl/patches/0001-RIOT-Use-RIOT-random_bytes-function-instead-of-rando.patch new file mode 100644 index 0000000000..ac6a91d216 --- /dev/null +++ b/pkg/tweetnacl/patches/0001-RIOT-Use-RIOT-random_bytes-function-instead-of-rando.patch @@ -0,0 +1,48 @@ +From cf440385f3aef5e9e94739c3fcdb5130d553f66c Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= +Date: Tue, 15 May 2018 13:08:50 +0200 +Subject: [PATCH] RIOT: Use RIOT random_bytes function instead of randombytes + +--- + tweetnacl.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/tweetnacl.c b/tweetnacl.c +index 96a847b57c..6b49b17fdc 100644 +--- a/tweetnacl.c ++++ b/tweetnacl.c +@@ -1,4 +1,5 @@ + #include "tweetnacl.h" ++#include "random.h" + #define FOR(i,n) for (i = 0;i < n;++i) + #define sv static void + +@@ -7,7 +8,6 @@ typedef unsigned long u32; + typedef unsigned long long u64; + typedef long long i64; + typedef i64 gf[16]; +-extern void randombytes(u8 *,u64); + + static const u8 + _0[16], +@@ -450,7 +450,7 @@ int crypto_scalarmult_base(u8 *q,const u8 *n) + + int crypto_box_keypair(u8 *y,u8 *x) + { +- randombytes(x,32); ++ random_bytes(x,32); + return crypto_scalarmult_base(y,x); + } + +@@ -660,7 +660,7 @@ int crypto_sign_keypair(u8 *pk, u8 *sk) + gf p[4]; + int i; + +- randombytes(sk, 32); ++ random_bytes(sk, 32); + crypto_hash(d, sk, 32); + d[0] &= 248; + d[31] &= 127; +-- +2.17.0 + diff --git a/pkg/tweetnacl/src/Makefile b/pkg/tweetnacl/src/Makefile deleted file mode 100644 index 2af2531e48..0000000000 --- a/pkg/tweetnacl/src/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -MODULE=tweetnacl - -include $(RIOTBASE)/Makefile.base \ No newline at end of file diff --git a/pkg/tweetnacl/src/randombytes.c b/pkg/tweetnacl/src/randombytes.c deleted file mode 100644 index ce3f938566..0000000000 --- a/pkg/tweetnacl/src/randombytes.c +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Copyright (C) 2016 Kaspar Schleiser - * - * 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. - */ - -#include -#include "random.h" - -void randombytes(uint8_t *target, uint64_t n) -{ - /* tweetnacl needs uint64_t as "n" parameter, random provides uint32 */ - random_bytes(target, n); -}