Skip to content

Upgrade to OpenSSL 3#162

Open
glts wants to merge 3 commits into
trusteddomainproject:developfrom
glts:openssl3
Open

Upgrade to OpenSSL 3#162
glts wants to merge 3 commits into
trusteddomainproject:developfrom
glts:openssl3

Conversation

@glts
Copy link
Copy Markdown

@glts glts commented Dec 28, 2022

The proposed change upgrades OpenSSL to version 3.

The change is not too big, it looks sensible to me, it is backwards compatible, and the test suite passes. I have done successful manual testing using opendkim-testmsg for both signing and verifying, using signature algorithms rsa-sha256 and ed25519-sha256. configure.ac hasn’t been updated yet. Feedback welcome.

@thegushi
Copy link
Copy Markdown
Collaborator

I notice new include files. What happens if this is built on a system that doesn't yet support openssl 3?

@glts glts marked this pull request as draft December 28, 2022 14:35
@glts
Copy link
Copy Markdown
Author

glts commented Dec 28, 2022

The new include files already existed in OpenSSL < 3, but there needs to be the appropriate feature detection in configure.ac. I’m marking this pull request as in draft status.

@ghen2
Copy link
Copy Markdown

ghen2 commented Dec 29, 2022

See also #135.

@glts
Copy link
Copy Markdown
Author

glts commented Dec 29, 2022

I cannot spend time investigating compatibility with legacy OpenSSL version 1.1.1 (EOL September 2023), so removing the draft status and moving on for now.

@glts glts marked this pull request as ready for review December 29, 2022 17:22
@glts
Copy link
Copy Markdown
Author

glts commented Jan 2, 2023

Rebased, and added a tiny commit which restores compatibility with OpenSSL version 1.1.1.

The pull request as now proposed simply moves to the non-deprecated APIs in OpenSSL 3, but all APIs were already present in OpenSSL 1.1.1.

@thegushi
Copy link
Copy Markdown
Collaborator

thegushi commented Jan 6, 2023

I'm likely to merge this, but which openSSL 3 system did you test it on?

@glts
Copy link
Copy Markdown
Author

glts commented Jan 6, 2023

@thegushi I used Ubuntu 22.04 LTS with the packaged OpenSSL 3.0.2.

It’s good that for once a pull request is not received with total radio
silence. However, I have four other pull requests open in this project,
and I would prefer if you could merge them first. They are small,
straightforward, benign, and they address real problems. Also they have
been widely tested as they are included in Debian/Ubuntu. Would it be
too much to ask to look through them and press that merge button?

@andreasschulze
Copy link
Copy Markdown

I'm using this patchset (with openssl-3.1.0). RSA and ED25519 signing as well as validation work as expected.
Not tested (because not used here): opendkim-genzone ...

futatuki added a commit to futatuki/OpenDKIM that referenced this pull request Feb 25, 2024
futatuki added a commit to futatuki/OpenDKIM that referenced this pull request Mar 24, 2024
futatuki added a commit to futatuki/OpenDKIM that referenced this pull request Apr 26, 2024
futatuki added a commit to futatuki/OpenDKIM that referenced this pull request Apr 26, 2024
@jcastle-gh
Copy link
Copy Markdown

This code is setting crypto_keysize (key size in bits) as EVP_PKEY_size() * 8. That's not right. EVP_PKEY_size() returns a suggested buffer size, not the key size in bytes. https://docs.openssl.org/1.1.1/man3/EVP_PKEY_size

It's strange that it seems to work out for RSA. For Ed25519 it doesn't. Ed25519 always has a 256-bit key and EVP_PKEY_size() returns 64.

Instead use EVP_PKEY_bits() (same man page above) which returns the number of key bits directly. It works for both RSA and Ed25519.

Careful with the search & replace though. EVP_PKEY_size() is also being used to set crypto_outlen, which seems right.

jcastle-gh added a commit to jcastle-gh/OpenDKIM that referenced this pull request Mar 17, 2025
Depends-On: trusteddomainproject#162
This should be merged after PR trusteddomainproject#162, Upgrade to OpenSSL 3".

1. opendkim-genkey: require openssl >= 1.1.1 for ed25519 instead
   of == 1.1.1.

2. opendkim-testkey: Add options 1, 2, and e to create an rsa-sha1,
   rsa-sha256, or ed25519 signature, respectively. Rsa-sha256 is the
   default.  Previously the tool only created rsa-sha1 signatures.

3. opendkim-genzone: Debian's opendkim includes nsupdate_output.patch
   which was added long ago for Debian bug 849540:
     https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=849540
   The patch originally came from a bug reported against 2.10.3 in the
   opendkim sourceforge bug database:
     https://sourceforge.net/p/opendkim/feature-requests/200
   Somehow that sourceforge bug and fix didn't make it to opendkim
   github. That patch fixes nsupdate output formatting and adds a key
   usage option.  This patch does that and adds support for ed25519.
jcastle-gh added a commit to jcastle-gh/OpenDKIM that referenced this pull request Mar 17, 2025
Depends on trusteddomainproject#162
This should be merged after PR trusteddomainproject#162, Upgrade to OpenSSL 3".

1. opendkim-genkey: require openssl >= 1.1.1 for ed25519 instead of == 1.1.1.

2. opendkim-testkey: Add options 1, 2, and e to create an rsa-sha1,
   rsa-sha256, or ed25519 signature, respectively. Rsa-sha256 is the default.
   Previously the tool could only create rsa-sha1 signatures.

3. opendkim-genzone: Debian's opendkim includes nsupdate_output.patch which
   was added long ago for Debian bug 849540:
     https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=849540
   The patch originally came from a bug reported against 2.10.3 in the
   opendkim sourceforge bug database:
     https://sourceforge.net/p/opendkim/feature-requests/200
   Somehow that sourceforge bug and fix didn't make it to opendkim github.
   That patch fixes nsupdate output formatting and adds a key usage option.
   This patch does that and also adds support for ed25519 keys.
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.

5 participants