Skip to content

Commit 1db95a9

Browse files
panvanpaun
authored andcommitted
src: update OpenSSL pqc checks
PR-URL: nodejs/node#59436 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <richard.lau@ibm.com>
1 parent 0252ff3 commit 1db95a9

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
@@ -715,7 +718,7 @@ class EVPKeyPointer final {
715718
const Buffer<const unsigned char>& data);
716719
static EVPKeyPointer NewRawPrivate(int id,
717720
const Buffer<const unsigned char>& data);
718-
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
721+
#if OPENSSL_WITH_PQC
719722
static EVPKeyPointer NewRawSeed(int id,
720723
const Buffer<const unsigned char>& data);
721724
#endif
@@ -812,7 +815,7 @@ class EVPKeyPointer final {
812815
DataPointer rawPrivateKey() const;
813816
BIOPointer derPublicKey() const;
814817

815-
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
818+
#if OPENSSL_WITH_PQC
816819
DataPointer rawSeed() const;
817820
#endif
818821

src/ncrypto.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,7 +1983,7 @@ EVPKeyPointer EVPKeyPointer::NewRawPrivate(
19831983
EVP_PKEY_new_raw_private_key(id, nullptr, data.data, data.len));
19841984
}
19851985

1986-
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
1986+
#if OPENSSL_WITH_PQC
19871987
EVPKeyPointer EVPKeyPointer::NewRawSeed(
19881988
int id, const Buffer<const unsigned char>& data) {
19891989
if (id == 0) return {};
@@ -2066,7 +2066,7 @@ EVP_PKEY* EVPKeyPointer::release() {
20662066
int EVPKeyPointer::id(const EVP_PKEY* key) {
20672067
if (key == nullptr) return 0;
20682068
int type = EVP_PKEY_id(key);
2069-
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
2069+
#if OPENSSL_WITH_PQC
20702070
// https://github.com/openssl/openssl/issues/27738#issuecomment-3013215870
20712071
if (type == -1) {
20722072
if (EVP_PKEY_is_a(key, "ML-DSA-44")) return EVP_PKEY_ML_DSA_44;
@@ -2130,7 +2130,7 @@ DataPointer EVPKeyPointer::rawPublicKey() const {
21302130
return {};
21312131
}
21322132

2133-
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
2133+
#if OPENSSL_WITH_PQC
21342134
DataPointer EVPKeyPointer::rawSeed() const {
21352135
if (!pkey_) return {};
21362136
switch (id()) {
@@ -2608,7 +2608,7 @@ bool EVPKeyPointer::isOneShotVariant() const {
26082608
switch (type) {
26092609
case EVP_PKEY_ED25519:
26102610
case EVP_PKEY_ED448:
2611-
#if OPENSSL_VERSION_MAJOR >= 3 && OPENSSL_VERSION_MINOR >= 5
2611+
#if OPENSSL_WITH_PQC
26122612
case EVP_PKEY_ML_DSA_44:
26132613
case EVP_PKEY_ML_DSA_65:
26142614
case EVP_PKEY_ML_DSA_87:

0 commit comments

Comments
 (0)