1
0
mirror of https://github.com/libssh2/libssh2.git synced 2025-11-20 02:42:09 +03:00

Add support for a wolfSSL crypto backend. (#629)

It uses wolfSSL's OpenSSL compatibility layer, so rather than introduce new
wolfssl.h/c files, the new backend just reuses openssl.h/c. Additionally,
replace EVP_Cipher() calls with EVP_CipherUpdate(), since EVP_Cipher() is not
recommended.

Credit: Hayden Roche
This commit is contained in:
Hayden Roche
2022-01-06 10:25:34 -08:00
committed by GitHub
parent e24a4a9d48
commit 17c9c1fcdf
7 changed files with 69 additions and 15 deletions

View File

@@ -40,7 +40,8 @@
#include "libssh2_priv.h"
#ifdef LIBSSH2_OPENSSL /* compile only if we build with openssl */
/* compile only if we build with openssl or wolfSSL */
#if defined(LIBSSH2_OPENSSL) || defined(LIBSSH2_WOLFSSL)
#include <string.h>
#include "misc.h"
@@ -455,27 +456,20 @@ _libssh2_cipher_crypt(_libssh2_cipher_ctx * ctx,
{
unsigned char buf[EVP_MAX_BLOCK_LENGTH];
int ret;
int outlen;
(void) algo;
(void) encrypt;
#ifdef HAVE_OPAQUE_STRUCTS
ret = EVP_Cipher(*ctx, buf, block, blocksize);
ret = EVP_CipherUpdate(*ctx, buf, &outlen, block, blocksize);
#else
ret = EVP_Cipher(ctx, buf, block, blocksize);
ret = EVP_CipherUpdate(ctx, buf, &outlen, block, blocksize);
#endif
#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
if(ret != -1) {
#else
if(ret == 1) {
#endif
memcpy(block, buf, blocksize);
}
#if defined(OPENSSL_VERSION_MAJOR) && OPENSSL_VERSION_MAJOR >= 3
return ret != -1 ? 0 : 1;
#else
return ret == 1 ? 0 : 1;
#endif
}
#if LIBSSH2_AES_CTR && !defined(HAVE_EVP_AES_128_CTR)