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