Skip to content

Init OpenSSL libctx and use it for pkey #18282

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
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bukka
Copy link
Member

@bukka bukka commented Apr 8, 2025

This adds initial setup for libctx and make use of it in PKEY handling.

@@ -44,6 +44,16 @@ void php_openssl_backend_shutdown(void)
#endif
}

EVP_PKEY_CTX *php_openssl_pkey_new_from_name(const char *name, int id)
Copy link
Member

Choose a reason for hiding this comment

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

Isn't name unnecessary?

Copy link
Member

Choose a reason for hiding this comment

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

To be fair, I think he had to for the sake of ssl apis inter-compatibility (look at the version for openssl 3.x), maybe just adding (void)name; should do.

@@ -1487,6 +1487,37 @@ int php_openssl_get_evp_pkey_type(int key_type) {
}
}

const char *php_openssl_get_evp_pkey_name(int key_type) {
Copy link
Member

Choose a reason for hiding this comment

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

Are there any drawbacks to making it static?

Comment on lines +32 to +48
void php_openssl_backend_init_libctx(OSSL_LIB_CTX **plibctx, char **ppropq)
{
/* The return value is not checked because we cannot reasonable fail in GINIT so using NULL
* (default context) is probably better. */
*plibctx = OSSL_LIB_CTX_new();
*ppropq = NULL;
}

void php_openssl_backend_destroy_libctx(OSSL_LIB_CTX *libctx, char *propq)
{
if (libctx != NULL) {
OSSL_LIB_CTX_free(libctx);
}
if (propq != NULL) {
free(propq);
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Is it okay to omit #if PHP_OPENSSL_API_VERSION >= 0x30000?

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

Successfully merging this pull request may close these issues.

3 participants