diff --git a/pkg/hacl/Makefile b/pkg/hacl/Makefile index cf3f0d5634..59ffa9408d 100644 --- a/pkg/hacl/Makefile +++ b/pkg/hacl/Makefile @@ -6,7 +6,6 @@ PKG_LICENSE=MIT .PHONY: all all: git-download - @cp $(RIOTBASE)/pkg/hacl/src/* $(PKG_BUILDDIR) "$(MAKE)" -C $(PKG_BUILDDIR) -f $(CURDIR)/Makefile.$(PKG_NAME) include $(RIOTBASE)/pkg/pkg.mk diff --git a/pkg/hacl/patches/0001-RIOT-Use-RIOT-random_bytes-function-instead-of-rando.patch b/pkg/hacl/patches/0001-RIOT-Use-RIOT-random_bytes-function-instead-of-rando.patch new file mode 100644 index 0000000000..6a189cf050 --- /dev/null +++ b/pkg/hacl/patches/0001-RIOT-Use-RIOT-random_bytes-function-instead-of-rando.patch @@ -0,0 +1,43 @@ +From 23c0d7e698ec5a31d65d7da172891f6aabad39d5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Joakim=20Nohlg=C3=A5rd?= +Date: Tue, 15 May 2018 13:17:38 +0200 +Subject: [PATCH] RIOT: Use RIOT random_bytes function instead of randombytes + +--- + haclnacl.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/haclnacl.c b/haclnacl.c +index e9bf635309..072a2db6b3 100644 +--- a/haclnacl.c ++++ b/haclnacl.c +@@ -28,7 +28,7 @@ + #include "NaCl.h" + + +-extern void randombytes(uint8_t *bytes, uint64_t bytes_len); ++#include "random.h" + + + /* HACL* Primitives and Constructions */ +@@ -93,7 +93,7 @@ int crypto_auth_verify(const unsigned char *tag, const unsigned char *input, uns + + + int crypto_box_keypair(unsigned char *pk, unsigned char *sk){ +- randombytes(sk, 32); ++ random_bytes(sk, 32); + uint8_t basepoint[32] = {9}; + curve25519_scalarmult(pk, sk, basepoint); + return 0; +@@ -241,7 +241,7 @@ int crypto_sign_open(unsigned char *unsigned_msg, unsigned long long *unsigned_m + } + + int crypto_sign_keypair(uint8_t pk[32], uint8_t sk[64]){ +- randombytes(sk, 32 * sizeof(uint8_t)); ++ random_bytes(sk, 32 * sizeof(uint8_t)); + Hacl_Ed25519_secret_to_public(pk, sk); + for (int i = 0; i < 32; i++) sk[32+i] = pk[i]; + return 0; +-- +2.17.0 + diff --git a/pkg/hacl/src/randombytes.c b/pkg/hacl/src/randombytes.c deleted file mode 100644 index e318dfa3b2..0000000000 --- a/pkg/hacl/src/randombytes.c +++ /dev/null @@ -1,18 +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) -{ - /* HACL* (haclnacl.c) needs uint64_t as "n" parameter, random provides uint32 */ - random_bytes(target, n); -}