Add OpenSSL compat: BIO_get_new_index, i2d_PUBKEY_bio, OpenSSL_version - #11020
Open
julek-wolfssl wants to merge 9 commits into
Open
Add OpenSSL compat: BIO_get_new_index, i2d_PUBKEY_bio, OpenSSL_version#11020julek-wolfssl wants to merge 9 commits into
julek-wolfssl wants to merge 9 commits into
Conversation
wolfSSL_OpenSSL_version() was declared with either an int or a void parameter list depending on OPENSSL_VERSION_NUMBER. That macro does not evaluate the same way in the library and in the application: with OPENSSL_COEXIST the library additionally pulls in the real OpenSSL headers and gets their version number, while an application that turns coexist off gets wolfSSL's default. The two builds then disagreed on the argument list and the selector read garbage, so OpenSSL_version() always hit the default case. Give the function a single unconditional signature. Also match the test guards for wolfSSL_i2d_PUBKEY_bio and wolfSSL_OpenSSL_version to the guards on their implementations.
The Linux kernel build compiles with -Werror=date-time, so OPENSSL_BUILT_ON broke libwolfssl.ko.
3 tasks
Contributor
There was a problem hiding this comment.
Pull request overview
This PR extends wolfSSL’s OpenSSL-compat layer by adding missing APIs used by OpenSSL-compatible applications: BIO_get_new_index(), i2d_PUBKEY_bio(), and fuller OpenSSL_version(type) selector handling.
Changes:
- Add
wolfSSL_BIO_get_new_index()plusBIO_TYPE_STARTmapping for allocating custom BIO method type IDs. - Add
wolfSSL_i2d_PUBKEY_bio()to write DER-encoded public keys to a BIO, plus unit test coverage. - Standardize
wolfSSL_OpenSSL_version(int type)and implement selector-based strings forOPENSSL_*constants, with tests.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| wolfssl/ssl.h | Adds BIO type range macros, declares wolfSSL_BIO_get_new_index, adds wolfSSL_i2d_PUBKEY_bio, and standardizes wolfSSL_OpenSSL_version(int). |
| wolfssl/openssl/ssl.h | Maps i2d_PUBKEY_bio and simplifies OpenSSL_version(x) mapping to always pass the selector. |
| wolfssl/openssl/opensslv.h | Defines OPENSSL_* selector constants (0–5) when missing. |
| wolfssl/openssl/bio.h | Exposes BIO_TYPE_START and maps BIO_get_new_index to wolfSSL. |
| wolfcrypt/src/evp_pk.c | Implements wolfSSL_i2d_PUBKEY_bio() for writing DER public keys to a BIO. |
| src/ssl.c | Implements selector-based wolfSSL_OpenSSL_version(int type) and avoids signature dependence on OPENSSL_VERSION_NUMBER. |
| src/bio.c | Implements wolfSSL_BIO_get_new_index() using a static counter (needs thread-safety fix per review comment). |
| tests/api/test_ossl_bio.h | Adds declaration and registration for the new BIO index test. |
| tests/api/test_ossl_bio.c | Adds BIO_get_new_index() API test for uniqueness and range. |
| tests/api.c | Adds i2d_PUBKEY_bio round-trip tests and expands OpenSSL_version(type) selector tests. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Member
Author
|
retest this please |
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
As part of the continuous integration of OpenSSL to wolfSSL, this adds a few missing functions needed for OpenSSL-compat APIs:
BIO_get_new_index()(unique custom BIO type IDs, 128–255),i2d_PUBKEY_bio()(write public-key DER to a BIO), andOpenSSL_version(type)handling for the six standardOPENSSL_*selector constants (plus unknown → version string). Headers/macros updated underOPENSSL_EXTRA/!NO_BIOas appropriate.Originally authored by @Roy-Carter in #10294, which was closed. Re-opening from julek-wolfssl with the same branch and follow-up fixes applied.
Testing
Ran
./tests/unit.testwith-~BIO_get_new_index,-~OpenSSL_version, and-~i2d_PUBKEY_bio(substring filters). All passed.Checklist