stm32mp_mbedtls_config-3.h 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * Copyright (c) 2022-2024, STMicroelectronics - All Rights Reserved
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. /*
  7. * Key algorithms currently supported on mbed TLS libraries
  8. */
  9. #define TF_MBEDTLS_USE_RSA 0
  10. #define TF_MBEDTLS_USE_ECDSA 1
  11. /*
  12. * Hash algorithms currently supported on mbed TLS libraries
  13. */
  14. #define TF_MBEDTLS_SHA256 1
  15. #define TF_MBEDTLS_SHA384 2
  16. #define TF_MBEDTLS_SHA512 3
  17. /*
  18. * Configuration file to build mbed TLS with the required features for
  19. * Trusted Boot
  20. */
  21. #define MBEDTLS_PLATFORM_MEMORY
  22. #define MBEDTLS_PLATFORM_NO_STD_FUNCTIONS
  23. /* Prevent mbed TLS from using snprintf so that it can use tf_snprintf. */
  24. #define MBEDTLS_PLATFORM_SNPRINTF_ALT
  25. #define MBEDTLS_PKCS1_V21
  26. #define MBEDTLS_ASN1_PARSE_C
  27. #define MBEDTLS_ASN1_WRITE_C
  28. #define MBEDTLS_BASE64_C
  29. #define MBEDTLS_BIGNUM_C
  30. #define MBEDTLS_ERROR_C
  31. #define MBEDTLS_MD_C
  32. #define MBEDTLS_MEMORY_BUFFER_ALLOC_C
  33. #define MBEDTLS_OID_C
  34. #define MBEDTLS_PK_C
  35. #define MBEDTLS_PK_PARSE_C
  36. #define MBEDTLS_PK_WRITE_C
  37. #define MBEDTLS_PLATFORM_C
  38. #if TF_MBEDTLS_USE_ECDSA
  39. #define MBEDTLS_ECDSA_C
  40. #define MBEDTLS_ECP_C
  41. #define MBEDTLS_ECP_DP_SECP256R1_ENABLED
  42. #endif
  43. #if TF_MBEDTLS_USE_RSA
  44. #define MBEDTLS_RSA_C
  45. #define MBEDTLS_X509_RSASSA_PSS_SUPPORT
  46. #endif
  47. /* The library does not currently support enabling SHA-256 without SHA-224. */
  48. #define MBEDTLS_SHA224_C
  49. #define MBEDTLS_SHA256_C
  50. #if (TF_MBEDTLS_HASH_ALG_ID != TF_MBEDTLS_SHA256)
  51. #define MBEDTLS_SHA384_C
  52. #define MBEDTLS_SHA512_C
  53. #endif
  54. #define MBEDTLS_VERSION_C
  55. #define MBEDTLS_X509_USE_C
  56. #define MBEDTLS_X509_CRT_PARSE_C
  57. #if TF_MBEDTLS_USE_AES_GCM
  58. #define MBEDTLS_AES_C
  59. #define MBEDTLS_CIPHER_C
  60. #define MBEDTLS_GCM_C
  61. #endif
  62. /* MPI / BIGNUM options */
  63. #define MBEDTLS_MPI_WINDOW_SIZE 2
  64. #if TF_MBEDTLS_USE_RSA
  65. #if TF_MBEDTLS_KEY_SIZE <= 2048
  66. #define MBEDTLS_MPI_MAX_SIZE 256
  67. #else
  68. #define MBEDTLS_MPI_MAX_SIZE 512
  69. #endif
  70. #else
  71. #define MBEDTLS_MPI_MAX_SIZE 256
  72. #endif
  73. /* Memory buffer allocator options */
  74. #define MBEDTLS_MEMORY_ALIGN_MULTIPLE 8
  75. /*
  76. * Prevent the use of 128-bit division which
  77. * creates dependency on external libraries.
  78. */
  79. #define MBEDTLS_NO_UDBL_DIVISION
  80. #ifndef __ASSEMBLER__
  81. /* System headers required to build mbed TLS with the current configuration */
  82. #include <stdlib.h>
  83. #endif
  84. /*
  85. * Mbed TLS heap size is smal as we only use the asn1
  86. * parsing functions
  87. * digest, signature and crypto algorithm are done by
  88. * other library.
  89. */
  90. #define TF_MBEDTLS_HEAP_SIZE U(5120)