openssl-compat.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #ifndef OPENSSL_COMPAT_H
  2. #define OPENSSL_COMPAT_H
  3. #include <openssl/bio.h>
  4. #include "util-internal.h"
  5. #if (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
  6. (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L)
  7. static inline BIO_METHOD *BIO_meth_new(int type, const char *name)
  8. {
  9. BIO_METHOD *biom = calloc(1, sizeof(BIO_METHOD));
  10. if (biom != NULL) {
  11. biom->type = type;
  12. biom->name = name;
  13. }
  14. return biom;
  15. }
  16. #define BIO_meth_set_write(b, f) (b)->bwrite = (f)
  17. #define BIO_meth_set_read(b, f) (b)->bread = (f)
  18. #define BIO_meth_set_puts(b, f) (b)->bputs = (f)
  19. #define BIO_meth_set_ctrl(b, f) (b)->ctrl = (f)
  20. #define BIO_meth_set_create(b, f) (b)->create = (f)
  21. #define BIO_meth_set_destroy(b, f) (b)->destroy = (f)
  22. #define BIO_set_init(b, val) (b)->init = (val)
  23. #define BIO_set_data(b, val) (b)->ptr = (val)
  24. #define BIO_set_shutdown(b, val) (b)->shutdown = (val)
  25. #define BIO_get_init(b) (b)->init
  26. #define BIO_get_data(b) (b)->ptr
  27. #define BIO_get_shutdown(b) (b)->shutdown
  28. #define TLS_method SSLv23_method
  29. #define X509_getm_notBefore X509_get_notBefore
  30. #define X509_getm_notAfter X509_get_notAfter
  31. #endif /* (OPENSSL_VERSION_NUMBER < 0x10100000L) || \
  32. (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x20700000L) */
  33. #if defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x20700000L
  34. #define BIO_get_init(b) (b)->init
  35. #endif
  36. #endif /* OPENSSL_COMPAT_H */