mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-23 01:22:37 +03:00
src/crypto.h src/userauth.c: Fix conditional RSA support
Most of libssh2 already has conditional support for RSA according to the LIBSSH2_RSA crypto backend #define, but crypto.h and userauth.c needed a few small fixes.
This commit is contained in:
committed by
Alexander Lamaison
parent
8a7232be61
commit
3806115d3d
@@ -58,6 +58,7 @@
|
|||||||
#include "mbedtls.h"
|
#include "mbedtls.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if LIBSSH2_RSA
|
||||||
int _libssh2_rsa_new(libssh2_rsa_ctx ** rsa,
|
int _libssh2_rsa_new(libssh2_rsa_ctx ** rsa,
|
||||||
const unsigned char *edata,
|
const unsigned char *edata,
|
||||||
unsigned long elen,
|
unsigned long elen,
|
||||||
@@ -92,6 +93,7 @@ int _libssh2_rsa_new_private_frommemory(libssh2_rsa_ctx ** rsa,
|
|||||||
LIBSSH2_SESSION * session,
|
LIBSSH2_SESSION * session,
|
||||||
const char *filedata, size_t filedata_len,
|
const char *filedata, size_t filedata_len,
|
||||||
unsigned const char *passphrase);
|
unsigned const char *passphrase);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if LIBSSH2_DSA
|
#if LIBSSH2_DSA
|
||||||
int _libssh2_dsa_new(libssh2_dsa_ctx ** dsa,
|
int _libssh2_dsa_new(libssh2_dsa_ctx ** dsa,
|
||||||
|
|||||||
@@ -786,6 +786,11 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session,
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
#if !LIBSSH2_RSA
|
||||||
|
return _libssh2_error(session, LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
|
||||||
|
"RSA is not supported by crypto backend");
|
||||||
|
#endif
|
||||||
|
|
||||||
if (session->userauth_host_state == libssh2_NB_state_idle) {
|
if (session->userauth_host_state == libssh2_NB_state_idle) {
|
||||||
const LIBSSH2_HOSTKEY_METHOD *privkeyobj;
|
const LIBSSH2_HOSTKEY_METHOD *privkeyobj;
|
||||||
unsigned char *pubkeydata, *sig = NULL;
|
unsigned char *pubkeydata, *sig = NULL;
|
||||||
@@ -1378,6 +1383,11 @@ userauth_publickey_frommemory(LIBSSH2_SESSION *session,
|
|||||||
void *abstract = &privkey_file;
|
void *abstract = &privkey_file;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
#if !LIBSSH2_RSA
|
||||||
|
return _libssh2_error(session, LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
|
||||||
|
"RSA is not supported by crypto backend");
|
||||||
|
#endif
|
||||||
|
|
||||||
privkey_file.filename = privatekeydata;
|
privkey_file.filename = privatekeydata;
|
||||||
privkey_file.passphrase = passphrase;
|
privkey_file.passphrase = passphrase;
|
||||||
|
|
||||||
@@ -1435,6 +1445,11 @@ userauth_publickey_fromfile(LIBSSH2_SESSION *session,
|
|||||||
void *abstract = &privkey_file;
|
void *abstract = &privkey_file;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
#if !LIBSSH2_RSA
|
||||||
|
return _libssh2_error(session, LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
|
||||||
|
"RSA is not supported by crypto backend");
|
||||||
|
#endif
|
||||||
|
|
||||||
privkey_file.filename = privatekey;
|
privkey_file.filename = privatekey;
|
||||||
privkey_file.passphrase = passphrase;
|
privkey_file.passphrase = passphrase;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user