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

Check openssl 3.0 compatibility #1379

Closed
0xxon opened this issue Jan 28, 2021 · 9 comments · Fixed by #1855
Closed

Check openssl 3.0 compatibility #1379

0xxon opened this issue Jan 28, 2021 · 9 comments · Fixed by #1855
Assignees
Milestone

Comments

@0xxon
Copy link
Member

0xxon commented Jan 28, 2021

We should start looking what we have to do to work with OpenSSL 3.

Alpha announcement: https://mta.openssl.org/pipermail/openssl-announce/2021-January/000189.html

@0xxon 0xxon self-assigned this Jan 28, 2021
@0xxon 0xxon changed the title Check openssl 3.0 beta compatibility Check openssl 3.0 compatibility Jan 28, 2021
@0xxon
Copy link
Member Author

0xxon commented Mar 1, 2021

In absolute shocking news, Zeek compiles against the current alpha (alpha 12). We get a couple of deprecation warnings though that I will try to fix:

[985/1176] Building CXX object src/file_analysis/analyzer/x509/CMakeFiles/plugin-Zeek-X509.dir/X509.cc.o
../src/file_analysis/analyzer/x509/X509.cc:211:17: warning: 'EVP_PKEY_get0_RSA' is deprecated [-Wdeprecated-declarations]
                        RSA_get0_key(EVP_PKEY_get0_RSA(pkey), NULL, &e, NULL);
                                     ^
/Users/johanna/bro/install-ossl/include/openssl/evp.h:1254:1: note: 'EVP_PKEY_get0_RSA' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0
^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
../src/file_analysis/analyzer/x509/X509.cc:211:4: warning: 'RSA_get0_key' is deprecated [-Wdeprecated-declarations]
                        RSA_get0_key(EVP_PKEY_get0_RSA(pkey), NULL, &e, NULL);
                        ^
/Users/johanna/bro/install-ossl/include/openssl/rsa.h:218:1: note: 'RSA_get0_key' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 void RSA_get0_key(const RSA *r,
^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
../src/file_analysis/analyzer/x509/X509.cc:463:34: warning: 'EVP_PKEY_get0_EC_KEY' is deprecated [-Wdeprecated-declarations]
        if ( (group = EC_KEY_get0_group(EVP_PKEY_get0_EC_KEY(key))) == NULL )
                                        ^
/Users/johanna/bro/install-ossl/include/openssl/evp.h:1278:1: note: 'EVP_PKEY_get0_EC_KEY' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0
^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
../src/file_analysis/analyzer/x509/X509.cc:463:16: warning: 'EC_KEY_get0_group' is deprecated [-Wdeprecated-declarations]
        if ( (group = EC_KEY_get0_group(EVP_PKEY_get0_EC_KEY(key))) == NULL )
                      ^
/Users/johanna/bro/install-ossl/include/openssl/ec.h:1027:1: note: 'EC_KEY_get0_group' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
../src/file_analysis/analyzer/x509/X509.cc:487:16: warning: 'EVP_PKEY_get0_RSA' is deprecated [-Wdeprecated-declarations]
                RSA_get0_key(EVP_PKEY_get0_RSA(key), &n, NULL, NULL);
                             ^
/Users/johanna/bro/install-ossl/include/openssl/evp.h:1254:1: note: 'EVP_PKEY_get0_RSA' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0
^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
../src/file_analysis/analyzer/x509/X509.cc:487:3: warning: 'RSA_get0_key' is deprecated [-Wdeprecated-declarations]
                RSA_get0_key(EVP_PKEY_get0_RSA(key), &n, NULL, NULL);
                ^
/Users/johanna/bro/install-ossl/include/openssl/rsa.h:218:1: note: 'RSA_get0_key' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 void RSA_get0_key(const RSA *r,
^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
../src/file_analysis/analyzer/x509/X509.cc:492:3: warning: 'DSA_get0_pqg' is deprecated [-Wdeprecated-declarations]
                DSA_get0_pqg(EVP_PKEY_get0_DSA(key), &p, NULL, NULL);
                ^
/Users/johanna/bro/install-ossl/include/openssl/dsa.h:201:1: note: 'DSA_get0_pqg' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 void DSA_get0_pqg(const DSA *d, const BIGNUM **p,
^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
../src/file_analysis/analyzer/x509/X509.cc:503:45: warning: 'EVP_PKEY_get0_EC_KEY' is deprecated [-Wdeprecated-declarations]
                const EC_GROUP *group = EC_KEY_get0_group(EVP_PKEY_get0_EC_KEY(key));
                                                          ^
/Users/johanna/bro/install-ossl/include/openssl/evp.h:1278:1: note: 'EVP_PKEY_get0_EC_KEY' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0
^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
../src/file_analysis/analyzer/x509/X509.cc:503:27: warning: 'EC_KEY_get0_group' is deprecated [-Wdeprecated-declarations]
                const EC_GROUP *group = EC_KEY_get0_group(EVP_PKEY_get0_EC_KEY(key));
                                        ^
/Users/johanna/bro/install-ossl/include/openssl/ec.h:1027:1: note: 'EC_KEY_get0_group' has been explicitly marked deprecated here
OSSL_DEPRECATEDIN_3_0 const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key);
^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:182:49: note: expanded from macro 'OSSL_DEPRECATEDIN_3_0'
#   define OSSL_DEPRECATEDIN_3_0                OSSL_DEPRECATED(3.0)
                                                ^
/Users/johanna/bro/install-ossl/include/openssl/macros.h:62:52: note: expanded from macro 'OSSL_DEPRECATED'
#     define OSSL_DEPRECATED(since) __attribute__((deprecated))
                                                   ^
9 warnings generated.

There also are a few weird segfaults in tests that I will investigate.

@0xxon
Copy link
Member Author

0xxon commented Sep 8, 2021

well, OpenSSL 3.0 is out now - so we should put this on as something to do for the next release.

@0xxon 0xxon added this to Unassigned / Todo in Release 4.2.0 via automation Sep 8, 2021
@0xxon 0xxon added this to the 4.2.0 milestone Sep 8, 2021
@0xxon
Copy link
Member Author

0xxon commented Sep 8, 2021

I tried this again - and there are good and bad news. The good news are - we get a couple of warnings, but we compile. Also - nearly all tests pass - and some of the failures are relatively trivial to catch baseline updates.

On the negative side - two of the tests that do not pass have to do with the serialization of OpaqueVals. Currently, we can serialise Opaques of (md5/sha1) and send them over the network using broker. The way that that works is that we access the private data of OpenSSL - in the case of MD5 with EVP_MD_CTX_md_data.

For OpenSSL 3.0 the code that we have been using crashes. Also - while the function is still public, the data returned by it is marked as private - so I don't think we can really depend on it staying the same in the future. I will take a look to see if we can fix this - but I am kind of tempted to say that perhaps we should just not support sending Opaque of (hash) between nodes.

On the plus side - I can also not really think of a usecase for this.

@0xxon
Copy link
Member Author

0xxon commented Nov 9, 2021

This just got a whole bunch more urgent since, e.g., macports now uses OpenSSL 3 by default.

I talked to @rsmmr a bit about this in the past. His feeling was that we should continue supporting sending opaques of (hash) between nodes. This likely will require us to switch implementations from OpenSSL to something that offers a stable internal representation.

@0xxon
Copy link
Member Author

0xxon commented Nov 10, 2021

I just checked again if there is any way to reliably get access to the internal state of hash data structures in OpenSSL. The definitive answer is no - see openssl/openssl#14222 for details. It seems like support for this might be added in later versions of OpenSSL - but that does not help us.

I am going to look up if we can just switch our hashing implementation to a different library (like crypto++), and if that would give us access to the internal state.

@0xxon
Copy link
Member Author

0xxon commented Nov 11, 2021

Ok, after playing around with OpenSSL a bit more (wishful thinking...) - if we want to keep the functionality, we really have to switch crypto libraries.

I took a look at crypto++ - which seems like it would work - but it will also be some work to interface with our build-system. Like a lot of crypto-libraries, it requires builds that are dependent on the system-architecture, contains assembly-files, etc.

While I get that it is nice to have the ability to serialize the internal state of hash-operations, I am still a tad unconvinced that this really is worth it for functionality for which we don't have a well-defined use-case.

@stevesmoot
Copy link
Contributor

stevesmoot commented Nov 12, 2021 via email

0xxon added a commit that referenced this issue Nov 16, 2021
This commit switches hashing from the more modern EVP message digest to
the older direct function calls, that are deprecated as of OpenSSL 3.0.

The reason is that we require the ability to store the internal state of
hash operations to disk. This is no longer possible with the
architecture that is used by the EVP digests; it is, however, possible
when using the legacy methods.

There might be a way to do this more cleanly in OpenSSL 3.1 - but for
the moment this seems like the easiest solution - even though I am not
really happy about it.

For details see #1379 and openssl/openssl#14222
0xxon added a commit that referenced this issue Nov 17, 2021
This commit fixes the compile-time warnings that OpenSSL 3.0 raises for
our source-code. For the cases where this was necessary we now have two
implementations - one for OpenSSL 1.1 and earlier, and one for OpenSSL
3.0.

This also makes our testsuite pass with OpenSSL 3.0

Relates to GH-1379
@0xxon 0xxon linked a pull request Nov 17, 2021 that will close this issue
0xxon added a commit that referenced this issue Nov 17, 2021
This commit fixes the compile-time warnings that OpenSSL 3.0 raises for
our source-code. For the cases where this was necessary we now have two
implementations - one for OpenSSL 1.1 and earlier, and one for OpenSSL
3.0.

This also makes our testsuite pass with OpenSSL 3.0

Relates to GH-1379
@0xxon 0xxon closed this as completed in 3846f69 Nov 23, 2021
Release 4.2.0 automation moved this from Unassigned / Todo to Done Nov 23, 2021
@0xxon
Copy link
Member Author

0xxon commented Nov 23, 2021

Currently we have one warning that is output when compiling CAF and using OpenSSL 3.0. That one should be fixed when actor-framework/actor-framework#1310 is merged.

@0xxon
Copy link
Member Author

0xxon commented Nov 23, 2021

Sorry, I somehow missed that...

Really not my area but will chime in. Agree switching libraries for an undefined use case seems extreme. I'm a little puzzled, md5/shave are strings no? Is this a blob that converts to string?

So - the final output of md5/sha-1 is a hash that is often represented as a hex-string. The part that we are interested in, of which support was removed, is to sync the internal state of the library inbetween operations. So - start hashing something, sync the state of the hash into a file/database/over the network, and then continue putting data in. For that you need to access the internal datastructures the library uses to track the current state.

But - on the positive side - I found a workaround which is now part of master.

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

Successfully merging a pull request may close this issue.

2 participants