Skip to content

Commit a83bd0f

Browse files
panvaanonrig
authored andcommitted
src: update OpenSSL pqc checks
PR-URL: nodejs/node#59436 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent 6589f91 commit a83bd0f

File tree

2 files changed

+12
-9
lines changed

2 files changed

+12
-9
lines changed

include/ncrypto.h

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,14 @@
2828
#include <openssl/fips.h>
2929
#endif // OPENSSL_FIPS
3030

31-
#if OPENSSL_VERSION_MAJOR >= 3
32-
#define OSSL3_CONST const
33-
#if OPENSSL_VERSION_MINOR >= 5
31+
// Define OPENSSL_WITH_PQC for post-quantum cryptography support
32+
#if OPENSSL_VERSION_NUMBER >= 0x30500000L
33+
#define OPENSSL_WITH_PQC 1
3434
#include <openssl/core_names.h>
3535
#endif
36+
37+
#if OPENSSL_VERSION_MAJOR >= 3
38+
#define OSSL3_CONST const
3639
#else
3740
#define OSSL3_CONST
3841
#endif
@@ -837,7 +840,7 @@ class EVPKeyPointer final {
837840
const Buffer<const unsigned char>& data);
838841
static EVPKeyPointer NewRawPrivate(int id,
839842
const Buffer<const unsigned char>& data);
840-
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
843+
#if OPENSSL_WITH_PQC
841844
static EVPKeyPointer NewRawSeed(int id,
842845
const Buffer<const unsigned char>& data);
843846
#endif
@@ -934,7 +937,7 @@ class EVPKeyPointer final {
934937
DataPointer rawPrivateKey() const;
935938
BIOPointer derPublicKey() const;
936939

937-
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
940+
#if OPENSSL_WITH_PQC
938941
DataPointer rawSeed() const;
939942
#endif
940943

src/ncrypto.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2035,7 +2035,7 @@ EVPKeyPointer EVPKeyPointer::NewRawPrivate(
20352035
EVP_PKEY_new_raw_private_key(id, nullptr, data.data, data.len));
20362036
}
20372037

2038-
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
2038+
#if OPENSSL_WITH_PQC
20392039
EVPKeyPointer EVPKeyPointer::NewRawSeed(
20402040
int id, const Buffer<const unsigned char>& data) {
20412041
if (id == 0) return {};
@@ -2118,7 +2118,7 @@ EVP_PKEY* EVPKeyPointer::release() {
21182118
int EVPKeyPointer::id(const EVP_PKEY* key) {
21192119
if (key == nullptr) return 0;
21202120
int type = EVP_PKEY_id(key);
2121-
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
2121+
#if OPENSSL_WITH_PQC
21222122
// https://github.com/openssl/openssl/issues/27738#issuecomment-3013215870
21232123
if (type == -1) {
21242124
if (EVP_PKEY_is_a(key, "ML-DSA-44")) return EVP_PKEY_ML_DSA_44;
@@ -2182,7 +2182,7 @@ DataPointer EVPKeyPointer::rawPublicKey() const {
21822182
return {};
21832183
}
21842184

2185-
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
2185+
#if OPENSSL_WITH_PQC
21862186
DataPointer EVPKeyPointer::rawSeed() const {
21872187
if (!pkey_) return {};
21882188
switch (id()) {
@@ -2660,7 +2660,7 @@ bool EVPKeyPointer::isOneShotVariant() const {
26602660
switch (type) {
26612661
case EVP_PKEY_ED25519:
26622662
case EVP_PKEY_ED448:
2663-
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
2663+
#if OPENSSL_WITH_PQC
26642664
case EVP_PKEY_ML_DSA_44:
26652665
case EVP_PKEY_ML_DSA_65:
26662666
case EVP_PKEY_ML_DSA_87:

0 commit comments

Comments
 (0)