@@ -124,6 +124,7 @@ define MBEDTLS_ENABLE_HTTP2_FEATURES
124124
125125 $(SED ) "s://# define PSA_WANT_ECC_SECP_R1_521:#define PSA_WANT_ECC_SECP_R1_521:" \
126126 $(@D)/include/psa/crypto_config.h || true
127+
127128endef
128129
129130# Disable problematic programs and tests that are causing linking issues
@@ -135,4 +136,47 @@ override MBEDTLS_CONF_OPTS += -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF
135136override MBEDTLS_CONF_OPTS += -DUSE_SHARED_MBEDTLS_LIBRARY=ON -DUSE_STATIC_MBEDTLS_LIBRARY=OFF
136137
137138# Add the HTTP/2 configuration hook to mbedtls
138- MBEDTLS_PRE_CONFIGURE_HOOKS += MBEDTLS_ENABLE_HTTP2_FEATURES
139+ MBEDTLS_PRE_CONFIGURE_HOOKS += MBEDTLS_ENABLE_HTTP2_FEATURES
140+
141+ # mbedTLS 3.6.6 defaults MBEDTLS_PLATFORM_DEV_RANDOM to /dev/random.
142+ # On low-entropy systems this can block indefinitely in libcurl/uhttpd.
143+ define MBEDTLS_USE_URANDOM
144+ $(SED ) 's:# define MBEDTLS_PLATFORM_DEV_RANDOM "/dev/random":#define MBEDTLS_PLATFORM_DEV_RANDOM "/dev/urandom":' \
145+ $(@D)/include/mbedtls/platform.h
146+ endef
147+ MBEDTLS_PRE_CONFIGURE_HOOKS += MBEDTLS_USE_URANDOM
148+
149+ # ###############################################################################
150+ #
151+ # jz-crypto AES_ALT / CCM_ALT / GCM_ALT — hardware AES via /dev/aes on all
152+ # Ingenic T-series SoCs. The ALT sources live in alt/ next to this file
153+ # (vendored snapshot of jz-crypto/aes/). Runtime requires jz-aes.ko, which
154+ # is built and installed by the ingenic-sdk package.
155+ #
156+ # ###############################################################################
157+
158+ define MBEDTLS_INSTALL_JZ_CRYPTO_ALT
159+ # Enable ALT hooks in mbedtls_config.h
160+ $(SED ) "s://# define MBEDTLS_AES_ALT:#define MBEDTLS_AES_ALT:" \
161+ $(@D)/include/mbedtls/mbedtls_config.h
162+ $(SED ) "s://# define MBEDTLS_CCM_ALT:#define MBEDTLS_CCM_ALT:" \
163+ $(@D)/include/mbedtls/mbedtls_config.h
164+ $(SED ) "s://# define MBEDTLS_GCM_ALT:#define MBEDTLS_GCM_ALT:" \
165+ $(@D)/include/mbedtls/mbedtls_config.h
166+
167+ # Install ALT headers + sources
168+ cp $(THINGINO_EXTERNAL_PATH ) /package/thingino-mbedtls/alt/aes_alt.h $(@D ) /include/mbedtls/
169+ cp $(THINGINO_EXTERNAL_PATH ) /package/thingino-mbedtls/alt/ccm_alt.h $(@D ) /include/mbedtls/
170+ cp $(THINGINO_EXTERNAL_PATH ) /package/thingino-mbedtls/alt/gcm_alt.h $(@D ) /include/mbedtls/
171+ cp $(THINGINO_EXTERNAL_PATH ) /package/thingino-mbedtls/alt/aes_alt.c $(@D ) /library/
172+ cp $(THINGINO_EXTERNAL_PATH ) /package/thingino-mbedtls/alt/ccm_alt.c $(@D ) /library/
173+ cp $(THINGINO_EXTERNAL_PATH ) /package/thingino-mbedtls/alt/gcm_alt.c $(@D ) /library/
174+
175+ # Add ALT .c files to the src_crypto build list (after aes.c)
176+ $(SED ) '/^ aes\.c$$/a\ aes_alt.c\n ccm_alt.c\n gcm_alt.c' \
177+ $(@D ) /library/CMakeLists.txt
178+ endef
179+
180+ ifeq ($(BR2_PACKAGE_THINGINO_MBEDTLS_JZ_CRYPTO_ALT ) ,y)
181+ MBEDTLS_PRE_CONFIGURE_HOOKS += MBEDTLS_INSTALL_JZ_CRYPTO_ALT
182+ endif
0 commit comments