200-rsa-sign-add-support-for-libressl.patch 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. From 69176c8602e29f4bd30457240374800d88dc39ed Mon Sep 17 00:00:00 2001
  2. From: Hauke Mehrtens <hauke@hauke-m.de>
  3. Date: Sat, 14 Apr 2018 22:39:34 +0200
  4. Subject: [PATCH] rsa-sign: add support for libressl
  5. ---
  6. lib/rsa/rsa-sign.c | 15 +++++++++------
  7. 1 file changed, 9 insertions(+), 6 deletions(-)
  8. --- a/lib/rsa/rsa-sign.c
  9. +++ b/lib/rsa/rsa-sign.c
  10. @@ -21,7 +21,8 @@
  11. #define HAVE_ERR_REMOVE_THREAD_STATE
  12. #endif
  13. -#if OPENSSL_VERSION_NUMBER < 0x10100000L
  14. +#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
  15. + (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
  16. static void RSA_get0_key(const RSA *r,
  17. const BIGNUM **n, const BIGNUM **e, const BIGNUM **d)
  18. {
  19. @@ -300,7 +301,8 @@ static int rsa_init(void)
  20. {
  21. int ret;
  22. -#if OPENSSL_VERSION_NUMBER < 0x10100000L
  23. +#if OPENSSL_VERSION_NUMBER < 0x10100000L || \
  24. + (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL)
  25. ret = SSL_library_init();
  26. #else
  27. ret = OPENSSL_init_ssl(0, NULL);
  28. @@ -309,7 +311,7 @@ static int rsa_init(void)
  29. fprintf(stderr, "Failure to init SSL library\n");
  30. return -1;
  31. }
  32. -#if OPENSSL_VERSION_NUMBER < 0x10100000L
  33. +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
  34. SSL_load_error_strings();
  35. OpenSSL_add_all_algorithms();
  36. @@ -355,7 +357,7 @@ err_set_rsa:
  37. err_engine_init:
  38. ENGINE_free(e);
  39. err_engine_by_id:
  40. -#if OPENSSL_VERSION_NUMBER < 0x10100000L
  41. +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
  42. ENGINE_cleanup();
  43. #endif
  44. return ret;
  45. @@ -363,7 +365,7 @@ err_engine_by_id:
  46. static void rsa_remove(void)
  47. {
  48. -#if OPENSSL_VERSION_NUMBER < 0x10100000L
  49. +#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
  50. CRYPTO_cleanup_all_ex_data();
  51. ERR_free_strings();
  52. #ifdef HAVE_ERR_REMOVE_THREAD_STATE
  53. @@ -433,7 +435,8 @@ static int rsa_sign_with_key(RSA *rsa, s
  54. ret = rsa_err("Could not obtain signature");
  55. goto err_sign;
  56. }
  57. - #if OPENSSL_VERSION_NUMBER < 0x10100000L
  58. + #if OPENSSL_VERSION_NUMBER < 0x10100000L || \
  59. + defined(LIBRESSL_VERSION_NUMBER)
  60. EVP_MD_CTX_cleanup(context);
  61. #else
  62. EVP_MD_CTX_reset(context);