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

Simplify getting an EVP_MD for all OpenSSL forks #796

Merged
merged 2 commits into from
Mar 22, 2024
Merged

Conversation

botovq
Copy link
Contributor

@botovq botovq commented Mar 22, 2024

In all versions of OpenSSL, EVP_sha{1,256}() return a pointer to static read-only data. There is no need to copy that data into a buffer that is immediately freed after use.

In LibreSSL and OpenSSL 1.x, EVP_PKEY_CTX_set_signature_md() is a wrapper around EVP_PKEY_ctrl() whose void * argument isn't const (contrary to the documented signature), so we need to cast const away in some way. This preserves rs*_get_EVP_MD() to contain the pragma pollution necessary due to -Werror -Wcast-qual.

The negative performance impact of calling EVP_sha*() multiple times called out in the OpenSSL 3.x documentation should not apply in this code.

Closes: #794

In all versions of OpenSSL, EVP_sha{1,256}() return a pointer to
static read-only data. There is no need to copy that data into a
buffer that is immediately freed after use.

In LibreSSL and OpenSSL 1.x, EVP_PKEY_CTX_set_signature_md() is a
wrapper around EVP_PKEY_ctrl() whose void * argument isn't const
(contrary to the documented signature), so we need to cast const
away in some way. This preserves rs*_get_EVP_MD() to contain the
pragma pollution necessary due to -Werror -Wcast-qual.

The negative performance impact of calling EVP_sha*() multiple
times called out in the OpenSSL 3.x application should not apply
in this code.

Closes: Yubico#794
Copy link
Contributor

@LDVG LDVG left a comment

Choose a reason for hiding this comment

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

Thanks!

@LDVG LDVG merged commit 723788f into Yubico:main Mar 22, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants