From 11ab90391de9b4271db60219bd12064b768ec29c Mon Sep 17 00:00:00 2001 From: Damien George Date: Fri, 1 Apr 2022 10:21:47 +1100 Subject: [PATCH] extmod/extmod.cmake: Add micropy_lib_mbedtls component. Signed-off-by: Damien George --- extmod/extmod.cmake | 94 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/extmod/extmod.cmake b/extmod/extmod.cmake index 9c05237774..adaa04f131 100644 --- a/extmod/extmod.cmake +++ b/extmod/extmod.cmake @@ -97,3 +97,97 @@ if(EXISTS "${MICROPY_LIB_BERKELEY_DIR}/btree/bt_close.c") "virt_fd_t=void*" ) endif() + +# Library for mbedtls + +set(MICROPY_LIB_MBEDTLS_DIR "${MICROPY_DIR}/lib/mbedtls") + +if(EXISTS "${MICROPY_LIB_MBEDTLS_DIR}/library/aes.c") + add_library(micropy_lib_mbedtls INTERFACE) + + target_include_directories(micropy_lib_mbedtls INTERFACE + ${MICROPY_LIB_MBEDTLS_DIR}/include + ) + + target_sources(micropy_lib_mbedtls INTERFACE + ${MICROPY_LIB_MBEDTLS_DIR}/library/aes.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/aesni.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/arc4.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/asn1parse.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/asn1write.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/base64.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/bignum.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/blowfish.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/camellia.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/ccm.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/certs.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/chacha20.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/chachapoly.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/cipher.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/cipher_wrap.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/cmac.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/ctr_drbg.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/debug.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/des.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/dhm.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/ecdh.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/ecdsa.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/ecjpake.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/ecp.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/ecp_curves.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/entropy.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/entropy_poll.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/error.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/gcm.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/havege.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/hmac_drbg.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/md2.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/md4.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/md5.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/md.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/md_wrap.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/oid.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/padlock.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/pem.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/pk.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/pkcs11.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/pkcs12.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/pkcs5.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/pkparse.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/pk_wrap.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/pkwrite.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/platform.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/platform_util.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/poly1305.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/ripemd160.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/rsa.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/rsa_internal.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/sha1.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/sha256.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/sha512.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/ssl_cache.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/ssl_ciphersuites.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/ssl_cli.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/ssl_cookie.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/ssl_srv.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/ssl_ticket.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/ssl_tls.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/timing.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/x509.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/x509_create.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/x509_crl.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/x509_crt.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/x509_csr.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/x509write_crt.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/x509write_csr.c + ${MICROPY_LIB_MBEDTLS_DIR}/library/xtea.c + ) + + target_compile_definitions(micropy_lib_mbedtls INTERFACE + MBEDTLS_CONFIG_FILE="ports/stm32/mbedtls/mbedtls_config.h" + ) + + list(APPEND MICROPY_INC_CORE + "${MICROPY_LIB_MBEDTLS_DIR}/include" + ) +endif()