Nilorea Library
C utilities for networking, threading, graphics
Loading...
Searching...
No Matches
n_openssl_compat.h
Go to the documentation of this file.
1
/*
2
* Nilorea Library
3
* Copyright (C) 2005-2026 Castagnier Mickael
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14
* implied. See the License for the specific language governing
15
* permissions and limitations under the License.
16
*
17
* SPDX-License-Identifier: Apache-2.0
18
*/
19
26
27
#ifndef __NILOREA_OPENSSL_COMPAT_HEADER
28
#define __NILOREA_OPENSSL_COMPAT_HEADER
29
30
#ifdef __cplusplus
31
extern
"C"
{
32
#endif
33
38
39
#ifdef HAVE_OPENSSL
40
41
#include <openssl/opensslv.h>
42
43
/* Why this file exists.
44
*
45
* OPENSSL_VERSION_NUMBER is not a feature test on LibreSSL. LibreSSL pins it
46
* at 0x20000000L and says so in its own opensslv.h ("These will never change"),
47
* shipping its real version in LIBRESSL_VERSION_NUMBER instead. So the obvious
48
* test, OPENSSL_VERSION_NUMBER >= 0x10101000L, is TRUE on every LibreSSL ever
49
* released, including the ones that lack the API being tested for, and the
50
* build breaks on a missing declaration precisely where the guard was supposed
51
* to prevent it.
52
*
53
* It is not only a problem for old releases: LibreSSL has no BLAKE2 at all, at
54
* any version, so a bare OPENSSL_VERSION_NUMBER test picks the implemented path
55
* on every LibreSSL and never builds.
56
*
57
* Each feature below therefore carries two thresholds, one per implementation.
58
* The LibreSSL ones were read off the commit that introduced the symbol in the
59
* LibreSSL tree and rounded up to the next release, so an off-by-one release
60
* costs a stubbed feature (safe) rather than a broken build.
61
*
62
* Supported LibreSSL floor: 2.9.0. Below that the SSL_set1_host() shim needs
63
* SSL_get0_param(), which LibreSSL only grew in 2.7.0.
64
*/
65
67
#ifdef LIBRESSL_VERSION_NUMBER
68
#define N_OSSL_IS_LIBRESSL 1
69
#else
70
#define N_OSSL_IS_LIBRESSL 0
71
#endif
72
73
#if N_OSSL_IS_LIBRESSL
75
#define N_OSSL_OPENSSL_ATLEAST(v) 0
77
#define N_OSSL_LIBRESSL_ATLEAST(v) (LIBRESSL_VERSION_NUMBER >= (v))
78
#else
80
#define N_OSSL_OPENSSL_ATLEAST(v) (OPENSSL_VERSION_NUMBER >= (v))
82
#define N_OSSL_LIBRESSL_ATLEAST(v) 0
83
#endif
84
88
#if N_OSSL_OPENSSL_ATLEAST(0x10100000L) || N_OSSL_LIBRESSL_ATLEAST(0x2090000fL)
89
#define N_OSSL_HAVE_PROTO_VERSION_SETTERS 1
90
#else
91
#define N_OSSL_HAVE_PROTO_VERSION_SETTERS 0
92
#endif
93
96
#if N_OSSL_OPENSSL_ATLEAST(0x10100000L) || N_OSSL_LIBRESSL_ATLEAST(0x2090000fL)
97
#define N_OSSL_HAVE_SSL_SET1_HOST 1
98
#else
99
#define N_OSSL_HAVE_SSL_SET1_HOST 0
100
#endif
101
105
#if N_OSSL_OPENSSL_ATLEAST(0x10101000L) || N_OSSL_LIBRESSL_ATLEAST(0x3050000fL)
106
#define N_OSSL_HAVE_TLS13 1
107
#else
108
#define N_OSSL_HAVE_TLS13 0
109
#endif
110
113
#if N_OSSL_OPENSSL_ATLEAST(0x10100000L)
114
#define N_OSSL_HAVE_BLAKE2B512 1
115
#else
116
#define N_OSSL_HAVE_BLAKE2B512 0
117
#endif
118
121
#if N_OSSL_OPENSSL_ATLEAST(0x10100000L) || N_OSSL_LIBRESSL_ATLEAST(0x3060000fL)
122
#define N_OSSL_HAVE_CHACHA20POLY1305 1
123
#else
124
#define N_OSSL_HAVE_CHACHA20POLY1305 0
125
#endif
126
130
#if N_OSSL_OPENSSL_ATLEAST(0x10101000L) || N_OSSL_LIBRESSL_ATLEAST(0x3070000fL)
131
#define N_OSSL_HAVE_RAW_EVP_25519 1
132
#else
133
#define N_OSSL_HAVE_RAW_EVP_25519 0
134
#endif
135
138
#if N_OSSL_OPENSSL_ATLEAST(0x30000000L)
139
#define N_OSSL_HAVE_EVP_KDF 1
140
#else
141
#define N_OSSL_HAVE_EVP_KDF 0
142
#endif
143
144
#endif
/* HAVE_OPENSSL */
145
147
148
#ifdef __cplusplus
149
}
150
#endif
151
152
#endif
/* __NILOREA_OPENSSL_COMPAT_HEADER */
include
nilorea
n_openssl_compat.h
Generated on
for Nilorea Library by
1.15.0