You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
libssh2_session_handshake returns -44 with OpenSSL crypto backend #463
Furthermore, there is this mentioned in their commit:
EVP_Cipher() returns the amount of encrypted / decrypted bytes, or -1 on failure, if the flag B<EVP_CIPH_FLAG_CUSTOM_CIPHER> is set for the cipher. EVP_Cipher() returns 1 on success or 0 on failure, if the flag B<EVP_CIPH_FLAG_CUSTOM_CIPHER> is not set for the cipher.
To my knowledge we're not setting this flag so it should be returning 1, not bytes encrypted.
Looks like this is set by the cipher inside of OpenSSL implicitly. Their release notes: New flag in ciphers: EVP_CIPH_FLAG_CUSTOM_CIPHER. This means the underlying do_cipher function handles all cipher semantics itself including padding and finalisation. Our API call is going to have to check which version of OpenSSL libssh2 is using to handle the possible return code values since 1.1/1.0/3.0 aren't compatible with each other.
Looking at the git commit for OpenSSL it seems like 0 <= ret is success, not just 0 < ret.
You are right, but "0 < ret" decision works with both versions of OpenSSL with no other code.
Correct me if I am wrong, but I expect that libssh2 does not call _libssh2_cipher_crypt with blockssize == 0.
This is one of the simplest solution.
Our API call is going to have to check which version of OpenSSL libssh2
Of course the correct solution is to CHECK MACRO and use special code for every possible case.
but "0 < ret" decision works with both versions of OpenSSL with no other code
and always works whether the function calls ctx->cipher->ccipher, ctx->cipher->cupdate or ctx->cipher->cfinal.
(assumption: libssh2 does not call _libssh2_cipher_crypt with blockssize == 0)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Activity
willco007 commentedon Apr 27, 2020
Have you tried a shipping version of OpenSSL? Seems like a non-zero chance this is a bug in the alpha release of OpenSSL you're using.
SX-80 commentedon Apr 27, 2020
Corrected version
SX-80 commentedon Apr 27, 2020
The changes in OpenSSL library

Now returns 'outl' or '-1'
SX-80 commentedon Apr 27, 2020
willco007 commentedon Apr 27, 2020
Thanks for tracking this down, I'll drop in a fix.
willco007 commentedon Apr 27, 2020
Looking at the git commit for OpenSSL it seems like 0 <= ret is success, not just 0 < ret.
willco007 commentedon Apr 27, 2020
Furthermore, there is this mentioned in their commit:
EVP_Cipher() returns the amount of encrypted / decrypted bytes, or -1 on failure, if the flag B<EVP_CIPH_FLAG_CUSTOM_CIPHER> is set for the cipher. EVP_Cipher() returns 1 on success or 0 on failure, if the flag B<EVP_CIPH_FLAG_CUSTOM_CIPHER> is not set for the cipher.To my knowledge we're not setting this flag so it should be returning 1, not bytes encrypted.
willco007 commentedon Apr 27, 2020
Looks like this is set by the cipher inside of OpenSSL implicitly. Their release notes:
New flag in ciphers: EVP_CIPH_FLAG_CUSTOM_CIPHER. This means the underlying do_cipher function handles all cipher semantics itself including padding and finalisation.Our API call is going to have to check which version of OpenSSL libssh2 is using to handle the possible return code values since 1.1/1.0/3.0 aren't compatible with each other.SX-80 commentedon Apr 28, 2020
You are right, but "0 < ret" decision works with both versions of OpenSSL with no other code.
Correct me if I am wrong, but I expect that libssh2 does not call _libssh2_cipher_crypt with blockssize == 0.
This is one of the simplest solution.
Of course the correct solution is to CHECK MACRO and use special code for every possible case.
SX-80 commentedon Apr 28, 2020
I am not setting this flag too. But function EVP_Cipher in my application calls ctx->cipher->ccipher.
SX-80 commentedon Apr 28, 2020
and always works whether the function calls ctx->cipher->ccipher, ctx->cipher->cupdate or ctx->cipher->cfinal.
(assumption: libssh2 does not call _libssh2_cipher_crypt with blockssize == 0)
stale commentedon Aug 28, 2020
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
stale commentedon Jan 2, 2021
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
jmarchil commentedon Feb 11, 2021
Is there any follow-up on this issue. I am integrating with openssl 3.0 alpha 11 and I am seeing this issue.
openssl.c: Fix EVP_Cipher interface change in openssl 3 #463
willco007 commentedon May 8, 2021
A fix was pushed with #463; could all you who are running into this verify this is fixed?
jmarchil commentedon May 26, 2021
I verified using the latest openssl 3.0 alpha 17 and the problem is resolved
willco007 commentedon May 26, 2021
@jmarchil Great thanks! I'm going to close this issue.