4242
4343// The FIPS-related functions are only available
4444// when the OpenSSL itself was compiled with FIPS support.
45- #if defined(OPENSSL_FIPS) && OPENSSL_VERSION_MAJOR < 3
45+ #if defined(OPENSSL_FIPS) && !OPENSSL_VERSION_PREREQ(3, 0)
4646#include < openssl/fips.h>
4747#endif // OPENSSL_FIPS
4848
49- // Define OPENSSL_WITH_PQC for post-quantum cryptography support
50- #if OPENSSL_VERSION_NUMBER >= 0x30500000L
49+ #if OPENSSL_VERSION_PREREQ(3, 0)
50+ #define OPENSSL_WITH_AES_OCB 1
51+ #else
52+ #define OPENSSL_WITH_AES_OCB 0
53+ #endif
54+
55+ #if !defined(OPENSSL_NO_ARGON2) && OPENSSL_VERSION_PREREQ(3, 2)
56+ #define OPENSSL_WITH_ARGON2 1
57+ #else
58+ #define OPENSSL_WITH_ARGON2 0
59+ #endif
60+
61+ #if OPENSSL_VERSION_PREREQ(3, 0)
62+ #define OPENSSL_WITH_KEM 1
63+ #else
64+ #define OPENSSL_WITH_KEM 0
65+ #endif
66+
67+ #if OPENSSL_VERSION_PREREQ(3, 0)
68+ #define OPENSSL_WITH_KMAC 1
69+ #else
70+ #define OPENSSL_WITH_KMAC 0
71+ #endif
72+
73+ #if OPENSSL_VERSION_PREREQ(3, 2)
74+ #define OPENSSL_WITH_SIGNATURE_CONTEXT_STRING 1
75+ #else
76+ #define OPENSSL_WITH_SIGNATURE_CONTEXT_STRING 0
77+ #endif
78+
79+ #if !defined(OPENSSL_IS_BORINGSSL) && OPENSSL_VERSION_PREREQ(3, 2)
80+ #define OPENSSL_WITH_OPENSSL_DHKEM 1
81+ #else
82+ #define OPENSSL_WITH_OPENSSL_DHKEM 0
83+ #endif
84+
85+ #if OPENSSL_WITH_KEM && !OPENSSL_VERSION_PREREQ(3, 5)
86+ #define OPENSSL_WITH_KEM_OPERATION_PARAM 1
87+ #else
88+ #define OPENSSL_WITH_KEM_OPERATION_PARAM 0
89+ #endif
90+
91+ // Define OPENSSL_WITH_PQC for post-quantum cryptography support.
92+ #if OPENSSL_VERSION_PREREQ(3, 5)
5193#define OPENSSL_WITH_PQC 1
94+ #else
95+ #define OPENSSL_WITH_PQC 0
96+ #endif
97+
98+ #if OPENSSL_WITH_PQC
5299#define EVP_PKEY_ML_KEM_512 NID_ML_KEM_512
53100#define EVP_PKEY_ML_KEM_768 NID_ML_KEM_768
54101#define EVP_PKEY_ML_KEM_1024 NID_ML_KEM_1024
55102#include < openssl/core_names.h>
56103#endif
57104
58- #if OPENSSL_VERSION_MAJOR >= 3
105+ #if OPENSSL_VERSION_PREREQ(3, 0)
59106#define OSSL3_CONST const
60107#else
61108#define OSSL3_CONST
@@ -1492,7 +1539,7 @@ class HMACCtxPointer final {
14921539 DeleteFnPtr<HMAC_CTX, HMAC_CTX_free> ctx_;
14931540};
14941541
1495- #if OPENSSL_VERSION_MAJOR >= 3
1542+ #if OPENSSL_WITH_KMAC
14961543class EVPMacPointer final {
14971544 public:
14981545 EVPMacPointer () = default ;
@@ -1540,7 +1587,7 @@ class EVPMacCtxPointer final {
15401587 private:
15411588 DeleteFnPtr<EVP_MAC_CTX, EVP_MAC_CTX_free> ctx_;
15421589};
1543- #endif // OPENSSL_VERSION_MAJOR >= 3
1590+ #endif // OPENSSL_WITH_KMAC
15441591
15451592#ifndef OPENSSL_NO_ENGINE
15461593class EnginePointer final {
@@ -1653,8 +1700,7 @@ DataPointer pbkdf2(const Digest& md,
16531700 uint32_t iterations,
16541701 size_t length);
16551702
1656- #if OPENSSL_VERSION_NUMBER >= 0x30200000L
1657- #ifndef OPENSSL_NO_ARGON2
1703+ #if OPENSSL_WITH_ARGON2
16581704enum class Argon2Type { ARGON2D, ARGON2I, ARGON2ID };
16591705
16601706DataPointer argon2 (const Buffer<const char >& pass,
@@ -1668,11 +1714,10 @@ DataPointer argon2(const Buffer<const char>& pass,
16681714 const Buffer<const unsigned char >& ad,
16691715 Argon2Type type);
16701716#endif
1671- #endif
16721717
16731718// ============================================================================
16741719// KEM (Key Encapsulation Mechanism)
1675- #if OPENSSL_VERSION_MAJOR >= 3
1720+ #if OPENSSL_WITH_KEM
16761721
16771722class KEM final {
16781723 public:
@@ -1696,13 +1741,13 @@ class KEM final {
16961741 const Buffer<const void >& ciphertext);
16971742
16981743 private:
1699- #if !OPENSSL_VERSION_PREREQ(3, 5)
1744+ #if OPENSSL_WITH_KEM_OPERATION_PARAM
17001745 static bool SetOperationParameter (EVP_PKEY_CTX* ctx,
17011746 const EVPKeyPointer& key);
17021747#endif
17031748};
17041749
1705- #endif // OPENSSL_VERSION_MAJOR >= 3
1750+ #endif // OPENSSL_WITH_KEM
17061751
17071752// ============================================================================
17081753// Version metadata
0 commit comments