mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 13:27:01 +08:00
crypto: decouple curve25519 and idgen from random pool
This commit modularizes the curve25519 and idgen implementations in the crypto subsystem. Previously, curve25519.c and idgen.c were only compiled when CONFIG_CRYPTO_RANDOM_POOL was enabled. However, cryptosoft.c (used by software cipher support) has a direct dependency on curve25519 functions. This caused linker errors (undefined reference to curve25519) when software crypto was enabled but the random pool was disabled. Changes: - Introduce hidden Kconfig options CRYPTO_CURVE25519 and CRYPTO_IDGEN. - Make CRYPTO_RANDOM_POOL select both CRYPTO_IDGEN and CRYPTO_CURVE25519. - Make CRYPTO_CRYPTODEV_SOFTWARE_CRYPTO/KEYMGMT select CRYPTO_CURVE25519. - Update CMakeLists.txt and Makefile to use the new config flags. This ensures that required algorithms are automatically included in the build regardless of whether the entropy pool is enabled. Signed-off-by: karaketir16 <osmankaraketir@gmail.com>
This commit is contained in:
@@ -57,10 +57,14 @@ if(CONFIG_CRYPTO)
|
|||||||
list(APPEND SRCS gmac.c)
|
list(APPEND SRCS gmac.c)
|
||||||
list(APPEND SRCS cmac.c)
|
list(APPEND SRCS cmac.c)
|
||||||
list(APPEND SRCS hmac.c)
|
list(APPEND SRCS hmac.c)
|
||||||
if(CONFIG_CRYPTO_RANDOM_POOL)
|
if(CONFIG_CRYPTO_IDGEN)
|
||||||
list(APPEND SRCS idgen.c)
|
list(APPEND SRCS idgen.c)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CONFIG_CRYPTO_CURVE25519)
|
||||||
list(APPEND SRCS curve25519.c)
|
list(APPEND SRCS curve25519.c)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND SRCS key_wrap.c)
|
list(APPEND SRCS key_wrap.c)
|
||||||
list(APPEND SRCS siphash.c)
|
list(APPEND SRCS siphash.c)
|
||||||
list(APPEND SRCS hmac_buff.c)
|
list(APPEND SRCS hmac_buff.c)
|
||||||
|
|||||||
@@ -43,11 +43,13 @@ config CRYPTO_CRYPTODEV
|
|||||||
config CRYPTO_CRYPTODEV_SOFTWARE_CRYPTO
|
config CRYPTO_CRYPTODEV_SOFTWARE_CRYPTO
|
||||||
bool "cryptodev software cipher support"
|
bool "cryptodev software cipher support"
|
||||||
depends on CRYPTO_CRYPTODEV && CRYPTO_SW_AES
|
depends on CRYPTO_CRYPTODEV && CRYPTO_SW_AES
|
||||||
|
select CRYPTO_CURVE25519
|
||||||
default n
|
default n
|
||||||
|
|
||||||
config CRYPTO_CRYPTODEV_SOFTWARE_KEYMGMT
|
config CRYPTO_CRYPTODEV_SOFTWARE_KEYMGMT
|
||||||
bool "cryptodev software key management support"
|
bool "cryptodev software key management support"
|
||||||
depends on CRYPTO_CRYPTODEV && !MTD_CONFIG_NONE
|
depends on CRYPTO_CRYPTODEV && !MTD_CONFIG_NONE
|
||||||
|
select CRYPTO_CURVE25519
|
||||||
default n
|
default n
|
||||||
|
|
||||||
if CRYPTO_CRYPTODEV_SOFTWARE_KEYMGMT
|
if CRYPTO_CRYPTODEV_SOFTWARE_KEYMGMT
|
||||||
@@ -89,6 +91,8 @@ config CRYPTO_SW_AES
|
|||||||
|
|
||||||
config CRYPTO_RANDOM_POOL
|
config CRYPTO_RANDOM_POOL
|
||||||
bool "Entropy pool and strong random number generator"
|
bool "Entropy pool and strong random number generator"
|
||||||
|
select CRYPTO_IDGEN
|
||||||
|
select CRYPTO_CURVE25519
|
||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
Entropy pool gathers environmental noise from device drivers,
|
Entropy pool gathers environmental noise from device drivers,
|
||||||
@@ -99,6 +103,14 @@ config CRYPTO_RANDOM_POOL
|
|||||||
NOTE: May not actually be cyptographically secure, if
|
NOTE: May not actually be cyptographically secure, if
|
||||||
not enough entropy is made available to the entropy pool.
|
not enough entropy is made available to the entropy pool.
|
||||||
|
|
||||||
|
config CRYPTO_CURVE25519
|
||||||
|
bool
|
||||||
|
default n
|
||||||
|
|
||||||
|
config CRYPTO_IDGEN
|
||||||
|
bool
|
||||||
|
default n
|
||||||
|
|
||||||
if CRYPTO_RANDOM_POOL
|
if CRYPTO_RANDOM_POOL
|
||||||
|
|
||||||
config CRYPTO_RANDOM_POOL_COLLECT_IRQ_RANDOMNESS
|
config CRYPTO_RANDOM_POOL_COLLECT_IRQ_RANDOMNESS
|
||||||
|
|||||||
+5
-1
@@ -60,10 +60,14 @@ CRYPTO_CSRCS += sha2.c
|
|||||||
CRYPTO_CSRCS += gmac.c
|
CRYPTO_CSRCS += gmac.c
|
||||||
CRYPTO_CSRCS += cmac.c
|
CRYPTO_CSRCS += cmac.c
|
||||||
CRYPTO_CSRCS += hmac.c
|
CRYPTO_CSRCS += hmac.c
|
||||||
ifeq ($(CONFIG_CRYPTO_RANDOM_POOL),y)
|
ifeq ($(CONFIG_CRYPTO_IDGEN),y)
|
||||||
CRYPTO_CSRCS += idgen.c
|
CRYPTO_CSRCS += idgen.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_CRYPTO_CURVE25519),y)
|
||||||
CRYPTO_CSRCS += curve25519.c
|
CRYPTO_CSRCS += curve25519.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CRYPTO_CSRCS += key_wrap.c
|
CRYPTO_CSRCS += key_wrap.c
|
||||||
CRYPTO_CSRCS += siphash.c
|
CRYPTO_CSRCS += siphash.c
|
||||||
CRYPTO_CSRCS += hmac_buff.c
|
CRYPTO_CSRCS += hmac_buff.c
|
||||||
|
|||||||
Reference in New Issue
Block a user