Skip to content

Commit fe2d73c

Browse files
committed
ext/openssl/ossl.h: add helper macros for OpenSSL/LibreSSL versions
Add following convenient macros: - OSSL_IS_LIBRESSL - OSSL_OPENSSL_PREREQ(maj, min, pat) - OSSL_LIBRESSL_PREREQ(maj, min, pat)
1 parent 9b4f761 commit fe2d73c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

ext/openssl/ossl.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,24 @@
4242
#include <openssl/evp.h>
4343
#include <openssl/dh.h>
4444

45+
#ifndef LIBRESSL_VERSION_NUMBER
46+
# define OSSL_IS_LIBRESSL 0
47+
# ifdef OPENSSL_VERSION_PREREQ
48+
# define OSSL_OPENSSL_PREREQ(maj, min, pat) \
49+
OPENSSL_VERSION_PREREQ(maj, min) && OPENSSL_VERSION_PATCH >= pat
50+
# define OSSL_LIBRESSL_PREREQ(maj, min, pat) 0
51+
# else
52+
# define OSSL_OPENSSL_PREREQ(maj, min, pat) \
53+
OPENSSL_VERSION_NUMBER >= (maj << 28) | (min << 20) | (pat << 12)
54+
# define OSSL_LIBRESSL_PREREQ(maj, min, pat) 0
55+
# endif
56+
#else
57+
# define OSSL_IS_LIBRESSL 1
58+
# define OSSL_OPENSSL_PREREQ(maj, min, pat) 0
59+
# define OSSL_LIBRESSL_PREREQ(maj, min, pat) \
60+
LIBRESSL_VERSION_NUMBER >= (maj << 28) | (min << 20) | (pat << 12)
61+
#endif
62+
4563
/*
4664
* Common Module
4765
*/

0 commit comments

Comments
 (0)