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

Support dynamically linking with OpenSSL 3.0 #37669

Closed
wants to merge 40 commits into from

Commits on Mar 15, 2021

  1. src: fix crypto_hkdf.cc compilation error

    Currently there are three compilation errors generated for
    crypto_hkdf.cc:
    ./src/crypto/crypto_hkdf.cc:
    In static member function ‘static bool
    node::crypto::HKDFTraits::DeriveBits(node::Environment*,
        const node::crypto::HKDFConfig&, node::crypto::ByteSource*)’:
    ../src/crypto/crypto_hkdf.cc:113:24: error:
    invalid conversion from ‘const char*’ to ‘const unsigned char*’
    [-fpermissive]
      113 |         params.salt.get(),
          |         ~~~~~~~~~~~~~~~^~
          |                        |
          |                        const char*
    In file included from ../src/crypto/crypto_util.h:18,
                     from ../src/crypto/crypto_keys.h:6,
                     from ../src/crypto/crypto_hkdf.h:6,
                     from ../src/crypto/crypto_hkdf.cc:1:
    /openssl_build_master/include/openssl/kdf.h:130:54: note:
    initializing argument 2 of ‘int EVP_PKEY_CTX_set1_hkdf_salt(
    EVP_PKEY_CTX*, const unsigned char*, int)’
      130 |    const unsigned char *salt, int saltlen);
          |    ~~~~~~~~~~~~~~~~~~~~~^~~~
    danbev committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    a88e77a View commit details
    Browse the repository at this point in the history
  2. build: add OPENSSL_API_COMPAT macro

    This commit adds the OPENSSL_API_COMPAT macro and sets it to version
    1.0.0 of OpenSSL when linking with a shared OpenSSL library.
    
    The motivation for this is that when linking against OpenSSL 3.x there
    are a lot of deprecation warnings and this allows them to be avoided.
    When we later upgrade the code base to 3.x this value can then be
    updated.
    danbev committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    3d9a5e5 View commit details
    Browse the repository at this point in the history
  3. test: add hasOpenSSL3 constant

    This commit adds a constant to identify if the version of OpenSSl is
    3 or above.
    
    The motivation for this is it allows for checking this value in tests
    to make sure that they work with OpenSSL 3.x, and also with earlier
    versions.
    danbev committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    a8d117c View commit details
    Browse the repository at this point in the history
  4. test: fix diffie-hellman 'module to small' failures

    This commit fixes a number of test failures reported when using OpenSSL
    3.0, for example:
    
    Error: error:0500007E:Diffie-Hellman routines::modulus too small
    
    Check have been added for OpenSSL 3 and use the larger sizes only for
    OpenSSL 3.0 as these sizes seem to cause timeouts when using
    OpenSSL 1.1.1.
    danbev committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    2a68e7b View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    dbd2206 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    b8e7c2d View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    b1b268b View commit details
    Browse the repository at this point in the history
  8. Configuration menu
    Copy the full SHA
    5ecbb48 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    470fc73 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    80834e2 View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    d6eae6d View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    e27bde8 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    f879b9c View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    b320aa3 View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    183d4d9 View commit details
    Browse the repository at this point in the history
  16. test: add min/max iv lengths for OpenSSL3 test-crypto-cipheriv-deciph…

    …eriv.js
    
    This commit adds min and max IV lengths to the test
    crypto-cipheriv-decipher-iv when OpenSSL 3.x is in use.
    
    The motivation for this is that OpenSSL 3.x has a check in
    providers/implementations/ciphers/ciphercommon_gcm:
    
      if (iv != NULL) {
        if (ivlen < ctx->ivlen_min || ivlen > sizeof(ctx->iv)) {
          ERR_raise(ERR_LIB_PROV, PROV_R_INVALID_IV_LENGTH);
          return 0;
        }
    
    And the ivlen_min is 8 and max is 64:
    (lldb) expr ctx->ivlen_min
    (size_t) $25 = 8
    
    (lldb) expr sizeof(ctx->iv)
    (unsigned long) $28 = 64
    (size_t) $25 = 8
    danbev committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    f135cd0 View commit details
    Browse the repository at this point in the history
  17. test: skip blowfish if using OpenSSL3 test-crypto-ecb.js

    This commit adds a check and a skip if using OpenSSL 3.x. The reason for
    this is that Blowfish (BF) is only available when using the legacy
    provider in OpenSSL 3.x.
    danbev committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    9afc54d View commit details
    Browse the repository at this point in the history
  18. Configuration menu
    Copy the full SHA
    ae768e2 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    6145d57 View commit details
    Browse the repository at this point in the history
  20. Configuration menu
    Copy the full SHA
    fda8d72 View commit details
    Browse the repository at this point in the history
  21. test: add openssl 3.x check to --openssl-config tests test-crypto-fip…

    …s.js
    
    This commit adds a check to skip tests that depend on OpenSSL 1.x config
    files. These test will not work with OpenSSL 3.x as the configuration
    files have changed. Once FIPS support is available in OpenSSL 3.x we
    should revisit these test and add tests specific to OpenSSL 3.x.
    danbev committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    1ff4d8d View commit details
    Browse the repository at this point in the history
  22. test: specify security level 0 for tls-session-cache test-tls-session…

    …-cache.js
    
    Currently this test will fail if the default security level 1 is used
    when linked against OpenSSL 3.x.
    danbev committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    0f8b754 View commit details
    Browse the repository at this point in the history
  23. test: set security level to 0 test-https-agent-session-eviction.js, t…

    …est-tls-getprotocol.js, test-tls-min-max-version.js
    danbev committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    14973b5 View commit details
    Browse the repository at this point in the history
  24. test: test-crypto-keygen fixes for OpenSSL 3.x test-crypto-keygen.js

    Note that there is still an issue with OpenSSL 3.x for which there is an
    open issue:
    openssl/openssl#12384
    danbev committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    e2d3592 View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    3e117b9 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    4003105 View commit details
    Browse the repository at this point in the history
  27. Configuration menu
    Copy the full SHA
    2964e25 View commit details
    Browse the repository at this point in the history
  28. Configuration menu
    Copy the full SHA
    af5997f View commit details
    Browse the repository at this point in the history
  29. Configuration menu
    Copy the full SHA
    ed88487 View commit details
    Browse the repository at this point in the history
  30. Configuration menu
    Copy the full SHA
    8a42ca9 View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    408186f View commit details
    Browse the repository at this point in the history
  32. test: add OpenSSL3.x checks test-crypto-x509.js

    This commit adds an check for OpenSSL 3.0 to deal with changes to the
    newline output of infoAccess.
    
    Refs:
    https://github.com/danbev/learning-libcrypto/blob/master/notes/issues.md#test-crypto-x509js
    danbev committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    875f060 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    37bb747 View commit details
    Browse the repository at this point in the history
  34. Configuration menu
    Copy the full SHA
    4aff4cb View commit details
    Browse the repository at this point in the history
  35. Configuration menu
    Copy the full SHA
    7d59871 View commit details
    Browse the repository at this point in the history
  36. Configuration menu
    Copy the full SHA
    d92e224 View commit details
    Browse the repository at this point in the history
  37. src: use EVP_default_properties_is_fips_enabled

    This commit adds a macro check for OpenSSL 3 and used
    EVP_default_properties_is_fips_enabled instead of FIPS_mode which has
    been removed in OpenSSL 3.
    danbev committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    ec3237a View commit details
    Browse the repository at this point in the history
  38. Configuration menu
    Copy the full SHA
    8efd22a View commit details
    Browse the repository at this point in the history
  39. src: aquire mutex lock in ManagedEVPPKey::operator=

    This commit aquires the Mutex in ManagedEVPPKey::operator= to avoid
    multiple threads updating the underlying EVP_PKEY in OpenSSL 3.0.
    There are additional changes to the code to avoid dead locks, making
    sure to release the lock before aquiring a new lock.
    
    Refs: nodejs@79d44baae2
    danbev committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    23b653f View commit details
    Browse the repository at this point in the history
  40. src: use const for EVP_PKEY legacy function calls

    This commit add const to EC_KEY, DSA, RSA pointer to avoid compilation
    errors when linking against OpenSSL 3.0.
    
    Refs: openssl/openssl@7bc0fdd
    danbev committed Mar 15, 2021
    Configuration menu
    Copy the full SHA
    6b8c504 View commit details
    Browse the repository at this point in the history