You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.4 KiB

  1. --- a/src/lib-dcrypt/dcrypt-openssl.c
  2. +++ b/src/lib-dcrypt/dcrypt-openssl.c
  3. @@ -20,10 +20,12 @@
  4. #include <openssl/bio.h>
  5. #include <openssl/pem.h>
  6. #include <openssl/x509.h>
  7. -#include <openssl/engine.h>
  8. #include <openssl/hmac.h>
  9. #include <openssl/objects.h>
  10. #include <openssl/bn.h>
  11. +#ifndef OPENSSL_NO_ENGINE
  12. +#include <openssl/engine.h>
  13. +#endif
  14. #include "dcrypt.h"
  15. #include "dcrypt-private.h"
  16. @@ -236,11 +238,13 @@ dcrypt_openssl_padding_mode(enum dcrypt_
  17. static bool dcrypt_openssl_initialize(const struct dcrypt_settings *set,
  18. const char **error_r)
  19. {
  20. +#ifndef OPENSSL_NO_ENGINE
  21. if (set->crypto_device != NULL && set->crypto_device[0] != '\0') {
  22. if (dovecot_openssl_common_global_set_engine(
  23. set->crypto_device, error_r) <= 0)
  24. return FALSE;
  25. }
  26. +#endif
  27. return TRUE;
  28. }
  29. --- a/src/lib-ssl-iostream/dovecot-openssl-common.c
  30. +++ b/src/lib-ssl-iostream/dovecot-openssl-common.c
  31. @@ -5,11 +5,14 @@
  32. #include "dovecot-openssl-common.h"
  33. #include <openssl/ssl.h>
  34. -#include <openssl/engine.h>
  35. #include <openssl/rand.h>
  36. +#ifndef OPENSSL_NO_ENGINE
  37. +#include <openssl/engine.h>
  38. -static int openssl_init_refcount = 0;
  39. static ENGINE *dovecot_openssl_engine;
  40. +#endif
  41. +
  42. +static int openssl_init_refcount = 0;
  43. #ifdef HAVE_SSL_NEW_MEM_FUNCS
  44. static void *dovecot_openssl_malloc(size_t size, const char *u0 ATTR_UNUSED, int u1 ATTR_UNUSED)
  45. @@ -77,10 +80,12 @@ bool dovecot_openssl_common_global_unref
  46. if (--openssl_init_refcount > 0)
  47. return TRUE;
  48. +#ifndef OPENSSL_NO_ENGINE
  49. if (dovecot_openssl_engine != NULL) {
  50. ENGINE_finish(dovecot_openssl_engine);
  51. dovecot_openssl_engine = NULL;
  52. }
  53. +#endif
  54. #if OPENSSL_VERSION_NUMBER < 0x10100000L
  55. /* OBJ_cleanup() is called automatically by EVP_cleanup() in
  56. newer versions. Doesn't hurt to call it anyway. */
  57. @@ -88,7 +93,9 @@ bool dovecot_openssl_common_global_unref
  58. #ifdef HAVE_SSL_COMP_FREE_COMPRESSION_METHODS
  59. SSL_COMP_free_compression_methods();
  60. #endif
  61. +#ifndef OPENSSL_NO_ENGINE
  62. ENGINE_cleanup();
  63. +#endif
  64. EVP_cleanup();
  65. CRYPTO_cleanup_all_ex_data();
  66. #ifdef HAVE_OPENSSL_AUTO_THREAD_DEINIT
  67. @@ -111,6 +118,7 @@ bool dovecot_openssl_common_global_unref
  68. int dovecot_openssl_common_global_set_engine(const char *engine,
  69. const char **error_r)
  70. {
  71. +#ifndef OPENSSL_NO_ENGINE
  72. if (dovecot_openssl_engine != NULL)
  73. return 1;
  74. @@ -132,5 +140,6 @@ int dovecot_openssl_common_global_set_en
  75. dovecot_openssl_engine = NULL;
  76. return -1;
  77. }
  78. +#endif
  79. return 1;
  80. }