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