-
Notifications
You must be signed in to change notification settings - Fork 986
Add OpenSSL compat: BIO_get_new_index, i2d_PUBKEY_bio, OpenSSL_version #10294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Roy-Carter
wants to merge
6
commits into
wolfSSL:master
Choose a base branch
from
Roy-Carter:feature/extra_enhancement_to_compatibility_layer
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c4b7723
Initial commit to add some more openssl compatibility layer functions
Roy-Carter ab66264
Refactor : fix some buggy logic + cleaned code
Roy-Carter ff59aa1
Fix: Handle build errors with .deb package + date build time
Roy-Carter aae8160
Fix note regarding unitest handling
Roy-Carter 46f6269
Refactor - Implement PR fix for better behavior
Roy-Carter 50098b1
Fix - change test string default case
Roy-Carter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18519,6 +18519,71 @@ defined(OPENSSL_EXTRA) && defined(WOLFSSL_DH_EXTRA) | |
| return EXPECT_RESULT(); | ||
| } | ||
|
|
||
| static int test_wolfSSL_i2d_PUBKEY_bio(void) | ||
| { | ||
| EXPECT_DECLS; | ||
| #if defined(OPENSSL_EXTRA) && !defined(NO_BIO) && \ | ||
| !defined(NO_ASN) && !defined(NO_PWDBASED) | ||
| BIO* bio = NULL; | ||
| EVP_PKEY* pkey = NULL; | ||
| EVP_PKEY* pkey2 = NULL; | ||
|
|
||
| /* NULL parameter tests */ | ||
| ExpectIntEQ(wolfSSL_i2d_PUBKEY_bio(NULL, NULL), WOLFSSL_FAILURE); | ||
|
|
||
| #if defined(USE_CERT_BUFFERS_2048) && !defined(NO_RSA) | ||
| { | ||
| const unsigned char* p = client_keypub_der_2048; | ||
| /* Load an RSA public key from DER buffer */ | ||
| ExpectNotNull(pkey = d2i_PUBKEY(NULL, &p, | ||
| sizeof_client_keypub_der_2048)); | ||
|
|
||
| /* Write it to BIO */ | ||
| ExpectNotNull(bio = BIO_new(BIO_s_mem())); | ||
| ExpectIntEQ(i2d_PUBKEY_bio(bio, pkey), WOLFSSL_SUCCESS); | ||
|
|
||
| /* Read it back and verify round-trip */ | ||
| ExpectNotNull(pkey2 = d2i_PUBKEY_bio(bio, NULL)); | ||
|
|
||
| EVP_PKEY_free(pkey2); | ||
| pkey2 = NULL; | ||
| EVP_PKEY_free(pkey); | ||
| pkey = NULL; | ||
| BIO_free(bio); | ||
| bio = NULL; | ||
| } | ||
| #endif | ||
|
|
||
| #if defined(USE_CERT_BUFFERS_256) && defined(HAVE_ECC) | ||
| { | ||
| const unsigned char* p = ecc_clikeypub_der_256; | ||
| /* Load an ECC public key from DER buffer */ | ||
| ExpectNotNull(pkey = d2i_PUBKEY(NULL, &p, | ||
| sizeof_ecc_clikeypub_der_256)); | ||
|
|
||
| /* Write it to BIO */ | ||
| ExpectNotNull(bio = BIO_new(BIO_s_mem())); | ||
| ExpectIntEQ(i2d_PUBKEY_bio(bio, pkey), WOLFSSL_SUCCESS); | ||
|
|
||
| /* Read it back and verify round-trip */ | ||
| ExpectNotNull(pkey2 = d2i_PUBKEY_bio(bio, NULL)); | ||
|
|
||
| EVP_PKEY_free(pkey2); | ||
| pkey2 = NULL; | ||
| EVP_PKEY_free(pkey); | ||
| pkey = NULL; | ||
| BIO_free(bio); | ||
| bio = NULL; | ||
| } | ||
| #endif | ||
|
|
||
| (void)pkey; | ||
| (void)pkey2; | ||
| (void)bio; | ||
| #endif | ||
| return EXPECT_RESULT(); | ||
| } | ||
|
|
||
| #if (defined(OPENSSL_ALL) || defined(WOLFSSL_ASIO)) && !defined(NO_RSA) && \ | ||
| !defined(NO_TLS) | ||
| static int test_wolfSSL_d2i_PrivateKeys_bio(void) | ||
|
|
@@ -27620,12 +27685,42 @@ static int test_wolfSSL_OpenSSL_version(void) | |
| const char* ver; | ||
|
|
||
| #if defined(OPENSSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x10100000L | ||
| ExpectNotNull(ver = OpenSSL_version(0)); | ||
| ExpectNotNull(ver = OpenSSL_version(OPENSSL_VERSION)); | ||
| ExpectStrEQ(ver, "wolfSSL " LIBWOLFSSL_VERSION_STRING); | ||
|
|
||
| /* Test OPENSSL_CFLAGS type */ | ||
| ExpectNotNull(ver = OpenSSL_version(OPENSSL_CFLAGS)); | ||
| ExpectStrEQ(ver, "compiler: information not available"); | ||
|
|
||
| /* Test OPENSSL_BUILT_ON type */ | ||
| ExpectNotNull(ver = OpenSSL_version(OPENSSL_BUILT_ON)); | ||
| #ifdef HAVE_REPRODUCIBLE_BUILD | ||
| ExpectStrEQ(ver, "built on: date not available"); | ||
| #else | ||
| /* __DATE__/__TIME__ differ between translation units, so just check | ||
| * the prefix is present. */ | ||
| ExpectNotNull(XSTRSTR(ver, "built on: ")); | ||
| #endif | ||
|
|
||
| /* Test OPENSSL_PLATFORM type */ | ||
| ExpectNotNull(ver = OpenSSL_version(OPENSSL_PLATFORM)); | ||
| ExpectStrEQ(ver, "platform: information not available"); | ||
|
|
||
| /* Test OPENSSL_DIR type */ | ||
| ExpectNotNull(ver = OpenSSL_version(OPENSSL_DIR)); | ||
| ExpectStrEQ(ver, "OPENSSLDIR: N/A"); | ||
|
|
||
| /* Test OPENSSL_ENGINES_DIR type */ | ||
| ExpectNotNull(ver = OpenSSL_version(OPENSSL_ENGINES_DIR)); | ||
| ExpectStrEQ(ver, "ENGINESDIR: N/A"); | ||
|
|
||
| /* Test unknown type falls back to version string */ | ||
| ExpectNotNull(ver = OpenSSL_version(99)); | ||
| ExpectStrEQ(ver, "not available"); | ||
|
Comment on lines
+27717
to
+27719
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: comment is wrong here |
||
| #else | ||
| ExpectNotNull(ver = OpenSSL_version()); | ||
| ExpectStrEQ(ver, "wolfSSL " LIBWOLFSSL_VERSION_STRING); | ||
| #endif | ||
| ExpectIntEQ(XMEMCMP(ver, "wolfSSL " LIBWOLFSSL_VERSION_STRING, | ||
| XSTRLEN("wolfSSL " LIBWOLFSSL_VERSION_STRING)), 0); | ||
| #endif | ||
| return EXPECT_RESULT(); | ||
| } | ||
|
|
@@ -34672,6 +34767,7 @@ TEST_CASE testCases[] = { | |
| TEST_DECL(test_wolfSSL_d2i_and_i2d_PublicKey_ecc), | ||
| #ifndef NO_BIO | ||
| TEST_DECL(test_wolfSSL_d2i_PUBKEY), | ||
| TEST_DECL(test_wolfSSL_i2d_PUBKEY_bio), | ||
| #endif | ||
| TEST_DECL(test_wolfSSL_d2i_and_i2d_DSAparams), | ||
| TEST_DECL(test_wolfSSL_i2d_PrivateKey), | ||
|
|
||
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
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.