1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 14:33:52 +01:00

Merge pull request #13559 from aabadie/pr/sys/crypto_modules_rework

sys/crypto: define cipher using a module instead of CFLAGS
This commit is contained in:
benpicco 2020-03-09 19:41:27 +01:00 committed by GitHub
commit 6f7293d7c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 21 additions and 24 deletions

View File

@ -71,7 +71,7 @@ ifneq (,$(filter gnrc_lorawan,$(USEMODULE)))
USEMODULE += xtimer
USEMODULE += random
USEMODULE += hashes
USEMODULE += crypto
USEMODULE += crypto_aes
USEMODULE += netdev_layer
USEMODULE += gnrc_neterr
endif

View File

@ -19,9 +19,6 @@ DRIVER ?= sx1276
USEMODULE += $(DRIVER)
# Required for the cipher module */
CFLAGS += -DCRYPTO_AES
#
# We can reduce the size of the packet buffer for LoRaWAN, since there's no IP
# support. This will reduce RAM consumption.
CFLAGS += -DGNRC_PKTBUF_SIZE=512

View File

@ -9,6 +9,7 @@ PSEUDOMODULES += cord_ep_standalone
PSEUDOMODULES += core_%
PSEUDOMODULES += cortexm_fpu
PSEUDOMODULES += cpu_check_address
PSEUDOMODULES += crypto_% # crypto_aes or crypto_3des
PSEUDOMODULES += devfs_%
PSEUDOMODULES += dhcpv6_%
PSEUDOMODULES += ecc_%

View File

@ -16,7 +16,15 @@ ifneq (,$(filter i2c_scan,$(USEMODULE)))
endif
ifneq (,$(filter prng_fortuna,$(USEMODULE)))
CFLAGS += -DCRYPTO_AES
USEMODULE += crypto_aes
endif
ifneq (,$(filter crypto_aes_%,$(USEMODULE)))
USEMODULE += crypto_aes
endif
ifneq (,$(filter crypto_%,$(USEMODULE)))
USEMODULE += crypto
endif
include $(RIOTBASE)/sys/test_utils/Makefile.dep

View File

@ -15,18 +15,18 @@
*
* @section ciphers Ciphers
*
* Riot supports the following block ciphers:
* RIOT supports the following block ciphers:
* * AES-128
* * 3DES (deprecated)
* * NULL
*
* You can use them directly by adding "crypto" to your USEMODULE-List.
* You can use them directly by adding `crypto_aes` or `crypto_3des` to your
* USEMODULE-List.
* While you can use the ciphers functions directly, you should resort to
* the generic API for block ciphers whenever possible.
*
* Additionally you need to set a CFLAG for each cipher you want to use in your Makefile:
* * AES-128: CFLAGS += -DCRYPTO_AES
* Setting the CFLAGS initializes a sufficient large buffer size of the cipher_context_t,
* used by the ciphers for en-/de-cryption operations.
* Depending on the selected block ciphers, a sufficient large buffer size of
* the cipher_context_t is used for en-/de-cryption operations.
*
* Example:
* @code

View File

@ -30,17 +30,10 @@ extern "C" {
/* Shared header file for all cipher algorithms */
/* Set the algorithms that should be compiled in here. When these defines
* are set, then packets will be compiled 5 times.
*/
// #define CRYPTO_THREEDES
// #define CRYPTO_AES
/** @brief the length of keys in bytes */
#define CIPHERS_MAX_KEY_SIZE 20
#define CIPHER_MAX_BLOCK_SIZE 16
/**
* Context sizes needed for the different ciphers.
* Always order by number of bytes descending!!! <br><br>
@ -48,9 +41,9 @@ extern "C" {
* threedes needs 24 bytes <br>
* aes needs CIPHERS_MAX_KEY_SIZE bytes <br>
*/
#if defined(CRYPTO_THREEDES)
#if defined(MODULE_CRYPTO_3DES)
#define CIPHER_MAX_CONTEXT_SIZE 24
#elif defined(CRYPTO_AES)
#elif defined(MODULE_CRYPTO_AES)
#define CIPHER_MAX_CONTEXT_SIZE CIPHERS_MAX_KEY_SIZE
#else
/* 0 is not a possibility because 0-sized arrays are not allowed in ISO C */

View File

@ -2,8 +2,7 @@ include ../Makefile.tests_common
USEMODULE += embunit
USEMODULE += crypto
USEMODULE += crypto_3des
USEMODULE += cipher_modes
CFLAGS += -DCRYPTO_THREEDES
include $(RIOTBASE)/Makefile.include

View File

@ -1,3 +1,2 @@
USEMODULE += hashes
USEMODULE += crypto
CFLAGS += -DCRYPTO_AES
USEMODULE += crypto_aes