0004-add-compatibility-with-mbed-tls-3-0-0.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From 28cc9b5d98179d161673d20e79333ae5a4864228 Mon Sep 17 00:00:00 2001
  2. From: Jianhui Zhao <zhaojh329@gmail.com>
  3. Date: Sat, 4 May 2024 19:40:07 +0800
  4. Subject: [PATCH] Add compatibility with Mbed TLS 3.0.0
  5. Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
  6. Upstream: https://github.com/zhaojh329/ssl/commit/28cc9b5d98179d161673d20e79333ae5a4864228
  7. [thomas:
  8. - Apply to submodule directory
  9. - Rename 'urandom' to '_urandom'
  10. - Adapt line numbers
  11. ]
  12. Signed-off-by: Thomas Perale <thomas.perale@mind.be>
  13. ---
  14. src/ssl/mbedtls.c | 11 +++++++++--
  15. 1 file changed, 9 insertions(+), 2 deletions(-)
  16. diff --git a/src/ssl/mbedtls.c b/src/ssl/mbedtls.c
  17. index 2e02e1c..cad7e00 100644
  18. --- a/src/ssl/mbedtls.c
  19. +++ b/src/ssl/mbedtls.c
  20. @@ -49,7 +49,6 @@
  21. #include "ssl.h"
  22. #include <mbedtls/ssl.h>
  23. -#include <mbedtls/certs.h>
  24. #include <mbedtls/x509.h>
  25. #include <mbedtls/rsa.h>
  26. #include <mbedtls/error.h>
  27. @@ -136,9 +135,13 @@ static const int default_ciphersuites_client[] =
  28. AES_CBC_CIPHERS(ECDHE_ECDSA),
  29. AES_CBC_CIPHERS(ECDHE_RSA),
  30. AES_CBC_CIPHERS(DHE_RSA),
  31. +#ifdef MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA
  32. MBEDTLS_TLS_DHE_RSA_WITH_3DES_EDE_CBC_SHA,
  33. +#endif
  34. AES_CIPHERS(RSA),
  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. @@ -221,7 +224,7 @@ static void ssl_update_own_cert(struct ssl_context *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. @@ -258,7 +261,11 @@ int ssl_load_key_file(struct ssl_context *ctx, const char *file)
  48. {
  49. int ret;
  50. +#if (MBEDTLS_VERSION_NUMBER >= 0x03000000)
  51. + ret = mbedtls_pk_parse_keyfile(&ctx->key, file, NULL, _urandom, NULL);
  52. +#else
  53. ret = mbedtls_pk_parse_keyfile(&ctx->key, file, NULL);
  54. +#endif
  55. if (ret)
  56. return -1;