Skip to content

wolfSSL: libssh2_session_handshake failed: -12/-44 DECRYPT/ENCRYPT #1020

Closed

Description

@vszakats

Activity

  1. changed the title [-]wolfSSL: libssh2_session_handshake failed -12 and -44[/-] [+]wolfSSL: libssh2_session_handshake failed: -12 and -44[/+] on May 2, 2023
  2. changed the title [-]wolfSSL: libssh2_session_handshake failed: -12 and -44[/-] [+]wolfSSL: libssh2_session_handshake failed: -12/-44 DECRYPT/ENCRYPT[/+] on May 2, 2023
  3. vszakats commented on May 2, 2023

    @vszakats
    MemberAuthor

    Reverting the AES-GCM patch #797 / 3c953c0 fixes it.

    The issue might be inside openssl.c / _libssh2_cipher_crypt(). Possibly with the interpretation of the return value of EVP_Cipher(), or EVP_CIPHER_CTX_ctrl().

    @dfandrich Can you take a look?

    The issue happens with both AES-GCM disabled for wolfSSL (as in master) or enabled.

    UPDATE: Now enabled in master: df513c0.

  4. added a commit that references this issue on May 3, 2023
  5. dfandrich commented on May 3, 2023

    @dfandrich
    Contributor

    I'll take a look.

  6. pinned this issue on May 9, 2023
  7. migueldeicaza commented on May 9, 2023

    @migueldeicaza
    Contributor
  8. migueldeicaza commented on May 9, 2023

    @migueldeicaza
    Contributor

    Update: reverting locally the patches for 0048f30 and 3c953c0 did not solve the problem.

    Here is one additional data point: this only happens on an M1 Mac connecting to an M1 Mac, or a CentOS machine. It does not happen from an Intel Mac to those systems, and does not happen with iPhone/iPad on device or simulator.

  9. migueldeicaza commented on May 9, 2023

    @migueldeicaza
    Contributor

    In case someone else runs into this: the issue on the M1 Mac was not related to the AES-GCM patch, that's why it did not make a difference. For some reason the version of OpenSSL I was using on Mac on ARM did not include the LIBSSH2_EC_CURVE_NISTP256 (NID_X9_62_prime256v1) curve, so the call to _libssh2_ecsa_curve_name_with_octal_new was failing which in turn made curve25519_sha256 fail.

    Mind you, this code was not being triggered with the currently public version of libssh2

  10. unpinned this issue on May 24, 2023
  11. kareem-wolfssl commented on May 24, 2023

    @kareem-wolfssl

    Hi @vszakats ,

    I was able to reproduce the failures you're seeing here. Some failures are being caused by our AES-GCM streaming support not being enabled, you can enable this support while building wolfSSL by passing --enable-aesgcm-stream to ./configure. I will add this to --enable-libssh2 once I've confirmed it's working as expected.
    I am still working on debugging the remaining test failures.

    I would strongly recommend you manually build wolfSSL with --enable-libssh2 --enable-aesgcm-stream for your tests. The test appears to be using the Brew package of wolfSSL, which does not enable DES3, DSA or AES-CTR: https://github.com/Homebrew/homebrew-core/blob/7fd778f54e75e1f9f85f41486094a7182225d839/Formula/wolfssl.rb These algorithms are enabled by --enable-libssh2, and if they aren't enabled they will cause additional test failures.

  12. vszakats commented on May 25, 2023

    @vszakats
    MemberAuthor

    @kareem-wolfssl, thanks for jumping in!

    Opened a PR to detect AES-GCM via WOLFSSL_AESGCM_STREAM (instead of HAVE_AESGCM): #1045
    Does this look correct to you?

    I think it'd be useful for most users if the Homebrew package came enabled with everything necessary for AES-GCM. At the moment it lists --enable-aesgcm twice, perhaps one of those was to meant to enable stream support? (as for DSA and DES3, I think the they are OK as disabled by default, libssh2 will adapt.)

    Building wolfSSL from source in CI requires constant maintenance (bumping on each upgrade). Also makes CI builds much slower and complex. I'd like to avoid this and rely on package defaults. This is also what users will encounter on this platform by default.

    This particular issue is also present with AES-GCM disabled, so keeping it open.

  13. 15 remaining items

  14. added a commit that references this issue on Jun 24, 2024
    a5b0fac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions