Skip to content
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

Implement BN_CTX_get #8388

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

julek-wolfssl
Copy link
Member

No description provided.

*/
WOLFSSL_BN_CTX* wolfSSL_BN_CTX_new(void)
{
/* wolfcrypt doesn't need BN context. */
static int ctx;
WOLFSSL_BN_CTX* ctx = NULL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ifdef to not allocate a BN_CTX.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand. You want a macro to keep the old solution?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BN_CTX is not needed most of the time - only when using the BN_CTX_get() API.
Most projects don't use this API.
Have a ifdef to return to the behaviour that uses less resources.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added option to compile it out.

src/ssl_bn.c Outdated Show resolved Hide resolved
src/ssl_bn.c Outdated
WOLFSSL_ENTER("wolfSSL_BN_CTX_init");
if (ctx != NULL) {
XMEMSET(ctx, 0, sizeof(WOLFSSL_BN_CTX));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old implementations in OpenSSL reset the pool and isn't meant to be called in BN_CTX_new().
API only in 1.0.2 and earlier.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its called in the original implementations of BN_CTX_new (openssl/openssl@9b14112#diff-9ef8217a3064ad4a970c33b34c9c8cabc4d8452ae282e5c1a19cbb0d8793fd88R74). Would you like me to separate the functions out? Maybe we should deprecate wolfSSL_BN_CTX_init as its equivalent is no longer in OpenSSL for a long time.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sigh our implementation is not doing the right thing then.
BN_CTX_init is an OpenSSL API - our implementation has to match theirs.
Definitely deprecate it!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed BN_CTX_init.

@julek-wolfssl
Copy link
Member Author

julek-wolfssl commented Jan 29, 2025

Retest this please.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants