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

hmac: use EVP_PKEY_new_raw_private_key() if available #538

Merged
merged 1 commit into from
Sep 2, 2022

Conversation

rhenium
Copy link
Member

@rhenium rhenium commented Sep 2, 2022

Current OpenSSL 3.0.x release has a regression with zero-length MAC
keys. While this issue should be fixed in a future release of OpenSSL,
we can use EVP_PKEY_new_raw_private_key() in place of the problematic
EVP_PKEY_new_mac_key() to avoid the issue. OpenSSL 3.0's man page
recommends using it regardless:

EVP_PKEY_new_mac_key() works in the same way as
EVP_PKEY_new_raw_private_key(). New applications should use
EVP_PKEY_new_raw_private_key() instead.

Fixes #369 (comment)

Current OpenSSL 3.0.x release has a regression with zero-length MAC
keys. While this issue should be fixed in a future release of OpenSSL,
we can use EVP_PKEY_new_raw_private_key() in place of the problematic
EVP_PKEY_new_mac_key() to avoid the issue. OpenSSL 3.0's man page
recommends using it regardless:

> EVP_PKEY_new_mac_key() works in the same way as
> EVP_PKEY_new_raw_private_key().  New applications should use
> EVP_PKEY_new_raw_private_key() instead.

Fixes ruby#369 (comment)
@rhenium rhenium merged commit ab4d58e into ruby:maint-3.0 Sep 2, 2022
@simi
Copy link

simi commented Sep 2, 2022

❤️

philr added a commit to philr/putty-key that referenced this pull request Oct 15, 2022
An empty string should work for the MAC, but OpenSSL::HMAC fails when
used with OpenSSL 3:

  EVP_PKEY_new_mac_key: malloc failure (OpenSSL::HMACError).

See ruby/openssl#538 and
openssl/openssl#13089.

Ruby 3.1.3 should contain the workaround from ruby/openssl PR 538.

Use "\0" as the MAC key for a workaround for Ruby < 3.1.3.
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