component.mk 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #
  2. # Component Makefile
  3. #
  4. COMPONENT_ADD_INCLUDEDIRS := port/include mbedtls/include esp_crt_bundle/include
  5. COMPONENT_SRCDIRS := mbedtls/library port port/$(IDF_TARGET) port/sha port/sha/parallel_engine port/aes port/aes/block port/md esp_crt_bundle
  6. COMPONENT_OBJEXCLUDE := mbedtls/library/net_sockets.o
  7. ifdef CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1
  8. COMPONENT_OBJEXCLUDE += \
  9. mbedtls/library/ssl_ciphersuites.o \
  10. mbedtls/library/ecp.o \
  11. mbedtls/library/cipher_wrap.o \
  12. mbedtls/library/oid.o \
  13. mbedtls/library/ecp_curves.o \
  14. mbedtls/library/pk_wrap.o \
  15. mbedtls/library/ecdsa.o \
  16. mbedtls/library/x509_crt.o \
  17. mbedtls/library/ssl_tls.o \
  18. mbedtls/library/ssl_cli.o
  19. endif
  20. COMPONENT_SUBMODULES += mbedtls
  21. # Note: some mbedTLS hardware acceleration can be enabled/disabled by config.
  22. #
  23. # We don't need to exclude aes.o as these functions use a different prefix (esp_aes_x) and the
  24. # config option only changes the prefixes in the header so mbedtls_aes_x compiles to esp_aes_x
  25. #
  26. # The other port-specific files don't override internal mbedTLS functions, they just add new functions.
  27. ifndef CONFIG_MBEDTLS_HARDWARE_MPI
  28. COMPONENT_OBJEXCLUDE += port/esp_bignum.o port/$(IDF_TARGET)/bignum.o
  29. endif
  30. ifndef CONFIG_MBEDTLS_HARDWARE_SHA
  31. COMPONENT_OBJEXCLUDE += port/parallel_engine/esp_sha1.o port/parallel_engine/esp_sha256.o port/parallel_engine/esp_sha512.o
  32. endif
  33. ifdef CONFIG_MBEDTLS_CERTIFICATE_BUNDLE
  34. GEN_CRT_BUNDLEPY := $(PYTHON) $(COMPONENT_PATH)/esp_crt_bundle/gen_crt_bundle.py
  35. DEFAULT_CRT_DIR := ${COMPONENT_PATH}/esp_crt_bundle
  36. X509_CERTIFICATE_BUNDLE := $(abspath x509_crt_bundle)
  37. CUSTOM_BUNDLE_PATH := $(PROJECT_PATH)/$(CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE_PATH)
  38. ifdef CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE
  39. CRT_PATHS += $(CUSTOM_BUNDLE_PATH)
  40. endif
  41. ifdef CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL
  42. CRT_PATHS += ${DEFAULT_CRT_DIR}/cacrt_all.pem
  43. endif
  44. ifdef CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN
  45. CRT_PATHS += ${DEFAULT_CRT_DIR}/cacrt_all.pem
  46. ARGS += --filter ${DEFAULT_CRT_DIR}/cmn_crt_authorities.csv
  47. endif
  48. ARGS += --input $(CRT_PATHS) -q
  49. # Generate certificate bundle using generate_cert_bundle.py
  50. $(X509_CERTIFICATE_BUNDLE) : $(SDKCONFIG_MAKEFILE)
  51. $(GEN_CRT_BUNDLEPY) $(ARGS)
  52. COMPONENT_EXTRA_CLEAN += $(X509_CERTIFICATE_BUNDLE)
  53. COMPONENT_EMBED_FILES := $(X509_CERTIFICATE_BUNDLE)
  54. endif
  55. ifdef CONFIG_MBEDTLS_DYNAMIC_BUFFER
  56. WRAP_FUNCTIONS = mbedtls_ssl_handshake_client_step \
  57. mbedtls_ssl_handshake_server_step \
  58. mbedtls_ssl_read \
  59. mbedtls_ssl_write \
  60. mbedtls_ssl_session_reset \
  61. mbedtls_ssl_free \
  62. mbedtls_ssl_setup \
  63. mbedtls_ssl_send_alert_message \
  64. mbedtls_ssl_close_notify
  65. COMPONENT_SRCDIRS += port/dynamic
  66. endif
  67. ifdef CONFIG_MBEDTLS_HARDWARE_MPI
  68. WRAP_FUNCTIONS += mbedtls_mpi_exp_mod
  69. endif
  70. ifneq ($(origin WRAP_FUNCTIONS),undefined)
  71. WRAP_ARGUMENT := -Wl,--wrap=
  72. COMPONENT_ADD_LDFLAGS = -l$(COMPONENT_NAME) $(addprefix $(WRAP_ARGUMENT),$(WRAP_FUNCTIONS))
  73. endif