0002-ustream-mbedtls-add-compatibility-with-mbed-tls-3-0-0.patch 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From 91666a38b7bd4bd353394986d8343a33ba61d8e2 Mon Sep 17 00:00:00 2001
  2. From: Hauke Mehrtens <hauke@hauke-m.de>
  3. Date: Sat, 11 Nov 2023 22:13:24 +0100
  4. Subject: [PATCH] ustream-mbedtls: Add compatibility with Mbed TLS 3.0.0
  5. This adds support for compiling the code against Mbed TLS 3.0.0.
  6. It still compiles against Mbed TLS 2.28.
  7. The following changes were needed:
  8. * DES and 3DES was removed
  9. * mbedtls_pk_context->pk_info is private, use mbedtls_pk_get_type()
  10. to check if it was initialized
  11. * mbedtls_pk_parse_keyfile() now gets a random callback
  12. * mbedtls/certs.h contains test data and is not installed any more and
  13. not needed.
  14. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
  15. Upstream: https://git.openwrt.org/?p=project/ustream-ssl.git;a=commit;h=91666a38b7bd4bd353394986d8343a33ba61d8e2
  16. Signed-off-by: Thomas Perale <thomas.perale@mind.be>
  17. ---
  18. ustream-mbedtls.c | 12 +++++++++++-
  19. ustream-mbedtls.h | 1 -
  20. 2 files changed, 11 insertions(+), 2 deletions(-)
  21. diff --git a/ustream-mbedtls.c b/ustream-mbedtls.c
  22. index 7fc7874..1c70cac 100644
  23. --- a/ustream-mbedtls.c
  24. +++ b/ustream-mbedtls.c
  25. @@ -110,9 +110,15 @@ static const int default_ciphersuites_client[] =
  26. AES_CBC_CIPHERS(ECDHE_ECDSA),
  27. AES_CBC_CIPHERS(ECDHE_RSA),
  28. AES_CBC_CIPHERS(DHE_RSA),
  29. +/* Removed in Mbed TLS 3.0.0 */
  30. +#ifdef MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
  31. MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA,
  32. +#endif
  33. AES_CIPHERS(RSA),
  34. +/* Removed in Mbed TLS 3.0.0 */
  35. +#ifdef MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA
  36. MBEDTLS_TLS_RSA_WITH_3DES_EDE_CBC_SHA,
  37. +#endif
  38. 0
  39. };
  40. @@ -171,7 +177,7 @@ static void ustream_ssl_update_own_cert(struct ustream_ssl_ctx *ctx)
  41. if (!ctx->cert.version)
  42. return;
  43. - if (!ctx->key.pk_info)
  44. + if (mbedtls_pk_get_type(&ctx->key) == MBEDTLS_PK_NONE)
  45. return;
  46. mbedtls_ssl_conf_own_cert(&ctx->conf, &ctx->cert, &ctx->key);
  47. @@ -206,7 +212,11 @@ __hidden int __ustream_ssl_set_key_file(struct ustream_ssl_ctx *ctx, const char
  48. {
  49. int ret;
  50. +#if (MBEDTLS_VERSION_NUMBER >= 0x03000000)
  51. + ret = mbedtls_pk_parse_keyfile(&ctx->key, file, NULL, _random, NULL);
  52. +#else
  53. ret = mbedtls_pk_parse_keyfile(&ctx->key, file, NULL);
  54. +#endif
  55. if (ret)
  56. return -1;
  57. diff --git a/ustream-mbedtls.h b/ustream-mbedtls.h
  58. index e622e5e..7e7c699 100644
  59. --- a/ustream-mbedtls.h
  60. +++ b/ustream-mbedtls.h
  61. @@ -21,7 +21,6 @@
  62. #include <mbedtls/net_sockets.h>
  63. #include <mbedtls/ssl.h>
  64. -#include <mbedtls/certs.h>
  65. #include <mbedtls/x509.h>
  66. #include <mbedtls/rsa.h>
  67. #include <mbedtls/error.h>
  68. --
  69. 2.30.2