Migrate DH module to EVP_PKEY APIs with OpenSSL 1.x/3.x compatibility#345
Merged
Conversation
Co-authored-by: zhaozg <542599+zhaozg@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix DH module warnings by migrating to EVP_PKEY keygen APIs
Migrate DH module to EVP_PKEY APIs for OpenSSL 3.0 compatibility
Nov 8, 2025
Owner
|
@copilot Ok, please fix CI in https://github.com/zhaozg/lua-openssl/actions/runs/19193534197/job/54871260645 |
…d 3.x Co-authored-by: zhaozg <542599+zhaozg@users.noreply.github.com>
Contributor
Author
Fixed in commit 1d82365. The issue was that the OpenSSL 3.0-specific APIs (
All 177 tests pass on both OpenSSL versions. |
Copilot
AI
changed the title
Migrate DH module to EVP_PKEY APIs for OpenSSL 3.0 compatibility
Migrate DH module to EVP_PKEY APIs with OpenSSL 1.x/3.x compatibility
Nov 8, 2025
zhaozg
marked this pull request as ready for review
November 8, 2025 13:42
23 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The DH module was using deprecated OpenSSL 3.0 APIs, generating 14 compiler warnings. This PR migrates to modern EVP_PKEY APIs for OpenSSL 3.0+ while maintaining full backward compatibility with OpenSSL 1.x through conditional compilation.
Related Issue
Fixes #344
Type of Change
Changes Made
Conditional Compilation Added:
#if OPENSSL_VERSION_NUMBER >= 0x30000000Lchecks to support both OpenSSL 1.x and 3.xcore_names.h,param_build.h) included conditionallyFor OpenSSL 3.0+ - Modern EVP_PKEY APIs:
openssl_dh_generate_parameters): UseEVP_PKEY_CTX_new_from_name()+EVP_PKEY_paramgen()instead ofDH_generate_parameters_ex()openssl_dh_generate_key): UseEVP_PKEY_keygen_init()+EVP_PKEY_keygen()instead ofDHparams_dup()+DH_generate_key()openssl_dh_parse): UseEVP_PKEY_get_bn_param()withOSSL_PKEY_PARAM_FFC_P/G/QandOSSL_PKEY_PARAM_PUB/PRIV_KEYinstead ofDH_get0_pqg()+DH_get0_key()openssl_dh_check): UseEVP_PKEY_param_check()+EVP_PKEY_public_check()instead ofDH_check()+DH_check_pub_key()For OpenSSL 1.x - Legacy DH APIs:
DH_generate_parameters_ex(),DH_generate_key(),DH_check(),DH_get0_pqg(),DH_get0_key(), etc.Backward Compatibility:
EVP_PKEY_set1_DH,EVP_PKEY_get1_DH,DH_free)Testing
Test Results:
Checklist
OpenSSL Compatibility
Please indicate which OpenSSL versions were tested (if applicable):
Additional Notes
Version-Specific Implementation:
The solution uses conditional compilation to provide optimal implementation for each OpenSSL version:
Security:
CI Compatibility:
For comprehensive code review findings and recommendations, see:
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.