Skip to content

Commit

Permalink
crypto: Remove CRYPTO_SW_AES and CRYPTO_BLAKE2S
Browse files Browse the repository at this point in the history
since it's more simple to let linker remove the unused functions from the final image

Signed-off-by: Xiang Xiao <[email protected]>
  • Loading branch information
xiaoxiang781216 committed Aug 13, 2023
1 parent 903e87a commit dcad9ec
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 56 deletions.
1 change: 1 addition & 0 deletions boards/sim/sim/sim/configs/crypto/defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ CONFIG_BOOT_RUNFROMEXTSRAM=y
CONFIG_BUILTIN=y
CONFIG_CRYPTO=y
CONFIG_CRYPTO_CRYPTODEV=y
CONFIG_CRYPTO_CRYPTODEV_SOFTWARE=y
CONFIG_CRYPTO_RANDOM_POOL=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_DEV_GPIO=y
Expand Down
34 changes: 24 additions & 10 deletions crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,33 @@ if(CONFIG_CRYPTO)

if(CONFIG_CRYPTO_CRYPTODEV)
list(APPEND SRCS cryptodev.c)
list(APPEND SRCS xform.c)
endif()

# Software AES library
# Software crypto library

if(CONFIG_CRYPTO_SW_AES)
list(APPEND SRCS aes.c)
endif()

# BLAKE2s hash algorithm

if(CONFIG_CRYPTO_BLAKE2S)
list(APPEND SRCS blake2s.c)
endif()
list(APPEND SRCS aes.c)
list(APPEND SRCS blake2s.c)
list(APPEND SRCS blf.c)
list(APPEND SRCS cast.c)
list(APPEND SRCS chachapoly.c)
list(APPEND SRCS ecb_enc.c)
list(APPEND SRCS ecb3_enc.c)
list(APPEND SRCS set_key.c)
list(APPEND SRCS md5.c)
list(APPEND SRCS poly1305.c)
list(APPEND SRCS rijndael.c)
list(APPEND SRCS rmd160.c)
list(APPEND SRCS sha1.c)
list(APPEND SRCS sha2.c)
list(APPEND SRCS gmac.c)
list(APPEND SRCS cmac.c)
list(APPEND SRCS hmac.c)
list(APPEND SRCS idgen.c)
list(APPEND SRCS key_wrap.c)
list(APPEND SRCS siphash.c)
list(APPEND SRCS hmac_buff.c)
list(APPEND SRCS curve25519.c)

# Entropy pool random number generator

Expand Down
19 changes: 0 additions & 19 deletions crypto/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,9 @@ config CRYPTO_CRYPTODEV_HARDWARE
depends on CRYPTO_CRYPTODEV
default n

config CRYPTO_SW_AES
bool "Software AES library"
depends on ALLOW_BSD_COMPONENTS
default n
---help---
Enable the software AES library as described in
include/nuttx/crypto/aes.h

TODO: Adapt interfaces so that they are consistent with H/W AES
implementations. This needs to support up_aesinitialize() and
aes_cypher() per include/nuttx/crypto/crypto.h.

config CRYPTO_BLAKE2S
bool "BLAKE2s hash algorithm"
default n
---help---
Enable the BLAKE2s hash algorithm

config CRYPTO_RANDOM_POOL
bool "Entropy pool and strong randon number generator"
default n
select CRYPTO_BLAKE2S
---help---
Entropy pool gathers environmental noise from device drivers,
user-space, etc., and returns good random numbers, suitable
Expand Down
52 changes: 25 additions & 27 deletions crypto/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,35 @@ ifeq ($(CONFIG_CRYPTO_CRYPTODEV),y)
CRYPTO_CSRCS += cryptodev.c
ifeq ($(CONFIG_CRYPTO_CRYPTODEV_SOFTWARE),y)
CRYPTO_CSRCS += cryptosoft.c
endif
CRYPTO_CSRCS += xform.c
CRYPTO_CSRCS += aes.c
CRYPTO_CSRCS += blf.c
CRYPTO_CSRCS += cast.c
CRYPTO_CSRCS += chachapoly.c
CRYPTO_CSRCS += ecb_enc.c
CRYPTO_CSRCS += ecb3_enc.c
CRYPTO_CSRCS += set_key.c
CRYPTO_CSRCS += md5.c
CRYPTO_CSRCS += poly1305.c
CRYPTO_CSRCS += rijndael.c
CRYPTO_CSRCS += rmd160.c
CRYPTO_CSRCS += sha1.c
CRYPTO_CSRCS += sha2.c
CRYPTO_CSRCS += gmac.c
CRYPTO_CSRCS += cmac.c
CRYPTO_CSRCS += hmac.c
CRYPTO_CSRCS += idgen.c
CRYPTO_CSRCS += key_wrap.c
CRYPTO_CSRCS += siphash.c
CRYPTO_CSRCS += hmac_buff.c
CRYPTO_CSRCS += curve25519.c
endif

# BLAKE2s hash algorithm

ifeq ($(CONFIG_CRYPTO_BLAKE2S),y)
CRYPTO_CSRCS += blake2s.c
endif

# Software crypto algorithm

CRYPTO_CSRCS += aes.c
CRYPTO_CSRCS += blake2s.c
CRYPTO_CSRCS += blf.c
CRYPTO_CSRCS += cast.c
CRYPTO_CSRCS += chachapoly.c
CRYPTO_CSRCS += ecb_enc.c
CRYPTO_CSRCS += ecb3_enc.c
CRYPTO_CSRCS += set_key.c
CRYPTO_CSRCS += md5.c
CRYPTO_CSRCS += poly1305.c
CRYPTO_CSRCS += rijndael.c
CRYPTO_CSRCS += rmd160.c
CRYPTO_CSRCS += sha1.c
CRYPTO_CSRCS += sha2.c
CRYPTO_CSRCS += gmac.c
CRYPTO_CSRCS += cmac.c
CRYPTO_CSRCS += hmac.c
CRYPTO_CSRCS += idgen.c
CRYPTO_CSRCS += key_wrap.c
CRYPTO_CSRCS += siphash.c
CRYPTO_CSRCS += hmac_buff.c
CRYPTO_CSRCS += curve25519.c

# Entropy pool random number generator

ifeq ($(CONFIG_CRYPTO_RANDOM_POOL),y)
Expand Down

0 comments on commit dcad9ec

Please sign in to comment.