-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/libcose: bump, set random function on init
- Loading branch information
Showing
12 changed files
with
191 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
MODULE := libcose_crypt | ||
SUBMODULES = 1 | ||
|
||
SRC += keygen_symm.c | ||
|
||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
MODULE = libcose_crypt_riot | ||
|
||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (C) 2022 Inria | ||
* | ||
* 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 pkg_libcose | ||
* | ||
* @{ | ||
* | ||
* @file | ||
* @brief Crypto function api for glueing RIOT crypto libraries | ||
* | ||
* @author Francisco Molina <francois-xavier.molina@inria.fr> | ||
*/ | ||
|
||
#ifndef COSE_CRYPTO_RIOT_H | ||
#define COSE_CRYPTO_RIOT_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
#ifndef AUTO_INIT_PRIO_MOD_LIBCOSE | ||
/** | ||
* @brief libCOSE init priority | ||
*/ | ||
#define AUTO_INIT_PRIO_MOD_LIBCOSE 1050 | ||
#endif | ||
|
||
/** | ||
* @brief Initialize libCOSE RIOT crypto backend | ||
* | ||
* @note Automatically called if 'auto_init_libcose_crypt_riot' is included | ||
* | ||
*/ | ||
void libcose_crypt_init(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* COSE_CRYPTO_RIOT_H */ | ||
|
||
/** @} */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
MODULE = libcose_crypt_init | ||
|
||
include $(RIOTBASE)/Makefile.base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright (C) 2022 Inria | ||
* | ||
* 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 pkg_libcose | ||
* @{ | ||
* | ||
* @file | ||
* @brief RIOT as a crypto backend common functions | ||
* | ||
* @author Francisco Molina <francois-xavier.molina@inria.fr> | ||
* | ||
* @} | ||
*/ | ||
|
||
|
||
#include <stdint.h> | ||
#include "random.h" | ||
#include "kernel_defines.h" | ||
#include "xfa.h" | ||
|
||
#include "cose/crypto.h" | ||
|
||
#if IS_USED(MODULE_AUTO_INIT) | ||
#include "auto_init_utils.h" | ||
#endif | ||
|
||
static int _riot_random_bytes(void* arg, unsigned char * buf, size_t len) | ||
{ | ||
(void)arg; | ||
random_bytes((uint8_t*) buf, len); | ||
return 1; | ||
} | ||
|
||
void libcose_crypt_init(void) | ||
{ | ||
cose_crypt_set_rng(_riot_random_bytes, NULL); | ||
} | ||
|
||
#if IS_USED(MODULE_AUTO_INIT_LIBCOSE_CRYPT) | ||
/* initialize just after random module */ | ||
AUTO_INIT(libcose_crypt_init, AUTO_INIT_PRIO_MOD_LIBCOSE); | ||
#endif |
102 changes: 0 additions & 102 deletions
102
pkg/libcose/patches/0001-RIOT-Use-RIOT-random_bytes-function-instead-of-rando.patch
This file was deleted.
Oops, something went wrong.
55 changes: 55 additions & 0 deletions
55
pkg/libcose/patches/0001-cose-crypto-add-defines-for-RIOT-crypto-backend.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
From 27c9da70b2bc80030dd55cc2e449a22c1b290e9d Mon Sep 17 00:00:00 2001 | ||
From: Francisco Molina <femolina@uc.cl> | ||
Date: Thu, 24 Feb 2022 13:20:46 +0100 | ||
Subject: [PATCH] cose/crypto: add defines for RIOT crypto backend | ||
|
||
--- | ||
include/cose/crypto.h | 3 +++ | ||
include/cose/crypto/selectors.h | 6 ++++-- | ||
2 files changed, 7 insertions(+), 2 deletions(-) | ||
|
||
diff --git a/include/cose/crypto.h b/include/cose/crypto.h | ||
index e81fd2c..6df6d14 100644 | ||
--- a/include/cose/crypto.h | ||
+++ b/include/cose/crypto.h | ||
@@ -48,6 +48,9 @@ | ||
#if defined(CRYPTO_TINYCRYPT) | ||
#include "cose/crypto/tinycrypt.h" | ||
#endif | ||
+#ifdef CRYPTO_RIOT | ||
+#include "cose/crypto/riot.h" | ||
+#endif | ||
|
||
#include "cose/crypto/selectors.h" | ||
|
||
diff --git a/include/cose/crypto/selectors.h b/include/cose/crypto/selectors.h | ||
index 575263a..cc5c786 100644 | ||
--- a/include/cose/crypto/selectors.h | ||
+++ b/include/cose/crypto/selectors.h | ||
@@ -46,6 +46,8 @@ | ||
#define CRYPTO_MBEDTLS_INCLUDE_CHACHAPOLY | ||
#elif defined(CRYPTO_HACL) | ||
#define CRYPTO_HACL_INCLUDE_CHACHAPOLY | ||
+#elif defined(CRYPTO_RIOT) | ||
+#define CRYPTO_RIOT_INCLUDE_CHACHAPOLY | ||
#endif | ||
/** @} */ | ||
|
||
@@ -61,8 +63,6 @@ | ||
#endif | ||
#endif | ||
|
||
-#endif /* COSE_CRYPTO_SELECTORS_H */ | ||
- | ||
#if defined(HAVE_ALGO_AES128GCM) || \ | ||
defined(HAVE_ALGO_AES192GCM) || \ | ||
defined(HAVE_ALGO_AES256GCM) | ||
@@ -81,3 +81,5 @@ | ||
#endif | ||
|
||
/** @} */ | ||
+ | ||
+#endif /* COSE_CRYPTO_SELECTORS_H */ | ||
-- | ||
2.32.0 | ||
|