From 886686859d9a2102c8983b6295d23607bfa4956f Mon Sep 17 00:00:00 2001 From: Brad Anderson Date: Thu, 4 Dec 2025 10:12:29 -0500 Subject: [PATCH 1/2] fix: use BN_GENCB_get_arg accessor --- src/ncrypto.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/ncrypto.cpp b/src/ncrypto.cpp index f482c53..304afd7 100644 --- a/src/ncrypto.cpp +++ b/src/ncrypto.cpp @@ -473,11 +473,9 @@ int BignumPointer::isPrime(int nchecks, // TODO(@jasnell): This could be refactored to allow inlining. // Not too important right now tho. [](int a, int b, BN_GENCB* ctx) mutable -> int { - PrimeCheckCallback& ptr = *static_cast(ctx->arg); - // Newer versions of openssl and boringssl define the BN_GENCB_get_arg - // API which is what is supposed to be used here. Older versions, - // however, omit that API. - // *static_cast(BN_GENCB_get_arg(ctx)); + // BN_GENCB is opaque in OpenSSL 3.x, must use accessor + PrimeCheckCallback& ptr = + *static_cast(BN_GENCB_get_arg(ctx)); return ptr(a, b) ? 1 : 0; }, &innerCb); @@ -507,11 +505,9 @@ bool BignumPointer::generate(const PrimeConfig& params, BN_GENCB_set( cb.get(), [](int a, int b, BN_GENCB* ctx) mutable -> int { - PrimeCheckCallback& ptr = *static_cast(ctx->arg); - // Newer versions of openssl and boringssl define the BN_GENCB_get_arg - // API which is what is supposed to be used here. Older versions, - // however, omit that API. - // *static_cast(BN_GENCB_get_arg(ctx)); + // BN_GENCB is opaque in OpenSSL 3.x, must use accessor + PrimeCheckCallback& ptr = + *static_cast(BN_GENCB_get_arg(ctx)); return ptr(a, b) ? 1 : 0; }, &innerCb); From a68a41956174fb648916c32275a85a9a8cbe7819 Mon Sep 17 00:00:00 2001 From: Brad Anderson Date: Thu, 4 Dec 2025 22:45:16 -0500 Subject: [PATCH 2/2] fix: remove cipher.h include as it's not in 3.x --- src/ncrypto.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/ncrypto.cpp b/src/ncrypto.cpp index 304afd7..f2ee855 100644 --- a/src/ncrypto.cpp +++ b/src/ncrypto.cpp @@ -8,7 +8,6 @@ #include #include #include -#include "openssl/cipher.h" #ifndef NCRYPTO_NO_KDF_H #include