mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-20 02:42:09 +03:00
@@ -62,8 +62,8 @@
|
|||||||
|
|
||||||
/* Blowfish context */
|
/* Blowfish context */
|
||||||
typedef struct BlowfishContext {
|
typedef struct BlowfishContext {
|
||||||
uint32_t S[4][256]; /* S-Boxes */
|
uint32_t S[4][256]; /* S-Boxes */
|
||||||
uint32_t P[BLF_N + 2]; /* Subkeys */
|
uint32_t P[BLF_N + 2]; /* Subkeys */
|
||||||
} blf_ctx;
|
} blf_ctx;
|
||||||
|
|
||||||
/* Raw access to customized Blowfish
|
/* Raw access to customized Blowfish
|
||||||
@@ -104,10 +104,10 @@ static uint32_t Blowfish_stream2word(const uint8_t *, uint16_t, uint16_t *);
|
|||||||
|
|
||||||
/* Function for Feistel Networks */
|
/* Function for Feistel Networks */
|
||||||
|
|
||||||
#define F(s, x) ((((s)[ (((x)>>24)&0xFF)] \
|
#define F(s, x) ((((s)[ (((x) >> 24) & 0xFF)] \
|
||||||
+ (s)[0x100 + (((x)>>16)&0xFF)]) \
|
+ (s)[0x100 + (((x) >> 16) & 0xFF)]) \
|
||||||
^ (s)[0x200 + (((x)>> 8)&0xFF)]) \
|
^ (s)[0x200 + (((x) >> 8) & 0xFF)]) \
|
||||||
+ (s)[0x300 + ( (x) &0xFF)])
|
+ (s)[0x300 + ( (x) & 0xFF)])
|
||||||
|
|
||||||
#define BLFRND(s,p,i,j,n) (i ^= F(s,j) ^ (p)[n])
|
#define BLFRND(s,p,i,j,n) (i ^= F(s,j) ^ (p)[n])
|
||||||
|
|
||||||
|
|||||||
@@ -327,14 +327,14 @@ _libssh2_channel_open(LIBSSH2_SESSION * session, const char *channel_type,
|
|||||||
/* Clear out packets meant for this channel */
|
/* Clear out packets meant for this channel */
|
||||||
_libssh2_htonu32(channel_id, session->open_channel->local.id);
|
_libssh2_htonu32(channel_id, session->open_channel->local.id);
|
||||||
while((_libssh2_packet_ask(session, SSH_MSG_CHANNEL_DATA,
|
while((_libssh2_packet_ask(session, SSH_MSG_CHANNEL_DATA,
|
||||||
&session->open_data,
|
&session->open_data,
|
||||||
&session->open_data_len, 1,
|
&session->open_data_len, 1,
|
||||||
channel_id, 4) >= 0)
|
channel_id, 4) >= 0)
|
||||||
||
|
||
|
||||||
(_libssh2_packet_ask(session, SSH_MSG_CHANNEL_EXTENDED_DATA,
|
(_libssh2_packet_ask(session, SSH_MSG_CHANNEL_EXTENDED_DATA,
|
||||||
&session->open_data,
|
&session->open_data,
|
||||||
&session->open_data_len, 1,
|
&session->open_data_len, 1,
|
||||||
channel_id, 4) >= 0)) {
|
channel_id, 4) >= 0)) {
|
||||||
LIBSSH2_FREE(session, session->open_data);
|
LIBSSH2_FREE(session, session->open_data);
|
||||||
session->open_data = NULL;
|
session->open_data = NULL;
|
||||||
}
|
}
|
||||||
@@ -1181,10 +1181,10 @@ static int channel_request_auth_agent(LIBSSH2_CHANNEL *channel,
|
|||||||
size_t data_len;
|
size_t data_len;
|
||||||
unsigned char code;
|
unsigned char code;
|
||||||
|
|
||||||
rc = _libssh2_packet_requirev(
|
rc = _libssh2_packet_requirev(session, reply_codes, &data, &data_len,
|
||||||
session, reply_codes, &data, &data_len, 1,
|
1, channel->req_auth_agent_local_channel,
|
||||||
channel->req_auth_agent_local_channel,
|
4,
|
||||||
4, &channel->req_auth_agent_requirev_state);
|
&channel->req_auth_agent_requirev_state);
|
||||||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
@@ -1300,9 +1300,9 @@ channel_request_pty_size(LIBSSH2_CHANNEL * channel, int width,
|
|||||||
sizeof(channel->reqPTY_packet_requirev_state));
|
sizeof(channel->reqPTY_packet_requirev_state));
|
||||||
|
|
||||||
_libssh2_debug((session, LIBSSH2_TRACE_CONN,
|
_libssh2_debug((session, LIBSSH2_TRACE_CONN,
|
||||||
"changing tty size on channel %lu/%lu",
|
"changing tty size on channel %lu/%lu",
|
||||||
channel->local.id,
|
channel->local.id,
|
||||||
channel->remote.id));
|
channel->remote.id));
|
||||||
|
|
||||||
s = channel->reqPTY_packet;
|
s = channel->reqPTY_packet;
|
||||||
|
|
||||||
@@ -1654,7 +1654,7 @@ LIBSSH2_API void
|
|||||||
libssh2_channel_set_blocking(LIBSSH2_CHANNEL * channel, int blocking)
|
libssh2_channel_set_blocking(LIBSSH2_CHANNEL * channel, int blocking)
|
||||||
{
|
{
|
||||||
if(channel)
|
if(channel)
|
||||||
(void) _libssh2_session_set_blocking(channel->session, blocking);
|
(void)_libssh2_session_set_blocking(channel->session, blocking);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -2387,7 +2387,7 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id,
|
|||||||
*/
|
*/
|
||||||
session->socket_block_directions = LIBSSH2_SESSION_BLOCK_INBOUND;
|
session->socket_block_directions = LIBSSH2_SESSION_BLOCK_INBOUND;
|
||||||
|
|
||||||
return (rc == LIBSSH2_ERROR_EAGAIN?rc:0);
|
return rc == LIBSSH2_ERROR_EAGAIN ? rc : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
channel->write_bufwrite = buflen;
|
channel->write_bufwrite = buflen;
|
||||||
@@ -2855,10 +2855,10 @@ int _libssh2_channel_free(LIBSSH2_CHANNEL *channel)
|
|||||||
/* Clear out packets meant for this channel */
|
/* Clear out packets meant for this channel */
|
||||||
_libssh2_htonu32(channel_id, channel->local.id);
|
_libssh2_htonu32(channel_id, channel->local.id);
|
||||||
while((_libssh2_packet_ask(session, SSH_MSG_CHANNEL_DATA, &data,
|
while((_libssh2_packet_ask(session, SSH_MSG_CHANNEL_DATA, &data,
|
||||||
&data_len, 1, channel_id, 4) >= 0)
|
&data_len, 1, channel_id, 4) >= 0)
|
||||||
||
|
||
|
||||||
(_libssh2_packet_ask(session, SSH_MSG_CHANNEL_EXTENDED_DATA, &data,
|
(_libssh2_packet_ask(session, SSH_MSG_CHANNEL_EXTENDED_DATA, &data,
|
||||||
&data_len, 1, channel_id, 4) >= 0)) {
|
&data_len, 1, channel_id, 4) >= 0)) {
|
||||||
LIBSSH2_FREE(session, data);
|
LIBSSH2_FREE(session, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
18
src/comp.c
18
src/comp.c
@@ -61,12 +61,12 @@ comp_method_none_comp(LIBSSH2_SESSION *session,
|
|||||||
size_t src_len,
|
size_t src_len,
|
||||||
void **abstract)
|
void **abstract)
|
||||||
{
|
{
|
||||||
(void) session;
|
(void)session;
|
||||||
(void) abstract;
|
(void)abstract;
|
||||||
(void) dest;
|
(void)dest;
|
||||||
(void) dest_len;
|
(void)dest_len;
|
||||||
(void) src;
|
(void)src;
|
||||||
(void) src_len;
|
(void)src_len;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -84,9 +84,9 @@ comp_method_none_decomp(LIBSSH2_SESSION * session,
|
|||||||
const unsigned char *src,
|
const unsigned char *src,
|
||||||
size_t src_len, void **abstract)
|
size_t src_len, void **abstract)
|
||||||
{
|
{
|
||||||
(void) session;
|
(void)session;
|
||||||
(void) payload_limit;
|
(void)payload_limit;
|
||||||
(void) abstract;
|
(void)abstract;
|
||||||
*dest = (unsigned char *) src;
|
*dest = (unsigned char *) src;
|
||||||
*dest_len = src_len;
|
*dest_len = src_len;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
crypt_none_crypt(LIBSSH2_SESSION * session, unsigned char *buf,
|
crypt_none_crypt(LIBSSH2_SESSION * session, unsigned char *buf,
|
||||||
void **abstract)
|
void **abstract)
|
||||||
{
|
{
|
||||||
/* Do nothing to the data! */
|
/* Do nothing to the data! */
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ hostkey_method_ssh_rsa_sig_verify(LIBSSH2_SESSION * session,
|
|||||||
size_t m_len, void **abstract)
|
size_t m_len, void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
/* Skip past keyname_len(4) + keyname(7){"ssh-rsa"} + signature_len(4) */
|
/* Skip past keyname_len(4) + keyname(7){"ssh-rsa"} + signature_len(4) */
|
||||||
if(sig_len < 15)
|
if(sig_len < 15)
|
||||||
@@ -260,13 +260,13 @@ hostkey_method_ssh_rsa_signv(LIBSSH2_SESSION * session,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
hostkey_method_ssh_rsa_sha2_256_sig_verify(LIBSSH2_SESSION * session,
|
hostkey_method_ssh_rsa_sha2_256_sig_verify(LIBSSH2_SESSION * session,
|
||||||
const unsigned char *sig,
|
const unsigned char *sig,
|
||||||
size_t sig_len,
|
size_t sig_len,
|
||||||
const unsigned char *m,
|
const unsigned char *m,
|
||||||
size_t m_len, void **abstract)
|
size_t m_len, void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
/* Skip past keyname_len(4) + keyname(12){"rsa-sha2-256"} +
|
/* Skip past keyname_len(4) + keyname(12){"rsa-sha2-256"} +
|
||||||
signature_len(4) */
|
signature_len(4) */
|
||||||
@@ -287,11 +287,11 @@ hostkey_method_ssh_rsa_sha2_256_sig_verify(LIBSSH2_SESSION * session,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
hostkey_method_ssh_rsa_sha2_256_signv(LIBSSH2_SESSION * session,
|
hostkey_method_ssh_rsa_sha2_256_signv(LIBSSH2_SESSION * session,
|
||||||
unsigned char **signature,
|
unsigned char **signature,
|
||||||
size_t *signature_len,
|
size_t *signature_len,
|
||||||
int veccount,
|
int veccount,
|
||||||
const struct iovec datavec[],
|
const struct iovec datavec[],
|
||||||
void **abstract)
|
void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
||||||
|
|
||||||
@@ -330,13 +330,13 @@ hostkey_method_ssh_rsa_sha2_256_signv(LIBSSH2_SESSION * session,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
hostkey_method_ssh_rsa_sha2_512_sig_verify(LIBSSH2_SESSION * session,
|
hostkey_method_ssh_rsa_sha2_512_sig_verify(LIBSSH2_SESSION * session,
|
||||||
const unsigned char *sig,
|
const unsigned char *sig,
|
||||||
size_t sig_len,
|
size_t sig_len,
|
||||||
const unsigned char *m,
|
const unsigned char *m,
|
||||||
size_t m_len, void **abstract)
|
size_t m_len, void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
/* Skip past keyname_len(4) + keyname(12){"rsa-sha2-512"} +
|
/* Skip past keyname_len(4) + keyname(12){"rsa-sha2-512"} +
|
||||||
signature_len(4) */
|
signature_len(4) */
|
||||||
@@ -357,11 +357,11 @@ hostkey_method_ssh_rsa_sha2_512_sig_verify(LIBSSH2_SESSION * session,
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
hostkey_method_ssh_rsa_sha2_512_signv(LIBSSH2_SESSION * session,
|
hostkey_method_ssh_rsa_sha2_512_signv(LIBSSH2_SESSION * session,
|
||||||
unsigned char **signature,
|
unsigned char **signature,
|
||||||
size_t *signature_len,
|
size_t *signature_len,
|
||||||
int veccount,
|
int veccount,
|
||||||
const struct iovec datavec[],
|
const struct iovec datavec[],
|
||||||
void **abstract)
|
void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
||||||
|
|
||||||
@@ -404,7 +404,7 @@ static int
|
|||||||
hostkey_method_ssh_rsa_dtor(LIBSSH2_SESSION * session, void **abstract)
|
hostkey_method_ssh_rsa_dtor(LIBSSH2_SESSION * session, void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract);
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
_libssh2_rsa_free(rsactx);
|
_libssh2_rsa_free(rsactx);
|
||||||
|
|
||||||
@@ -673,7 +673,7 @@ static int
|
|||||||
hostkey_method_ssh_dss_dtor(LIBSSH2_SESSION * session, void **abstract)
|
hostkey_method_ssh_dss_dtor(LIBSSH2_SESSION * session, void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_dsa_ctx *dsactx = (libssh2_dsa_ctx *) (*abstract);
|
libssh2_dsa_ctx *dsactx = (libssh2_dsa_ctx *) (*abstract);
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
_libssh2_dsa_free(dsactx);
|
_libssh2_dsa_free(dsactx);
|
||||||
|
|
||||||
@@ -712,9 +712,9 @@ hostkey_method_ssh_ecdsa_dtor(LIBSSH2_SESSION * session,
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
hostkey_method_ssh_ecdsa_init(LIBSSH2_SESSION * session,
|
hostkey_method_ssh_ecdsa_init(LIBSSH2_SESSION * session,
|
||||||
const unsigned char *hostkey_data,
|
const unsigned char *hostkey_data,
|
||||||
size_t hostkey_data_len,
|
size_t hostkey_data_len,
|
||||||
void **abstract)
|
void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_ecdsa_ctx *ecdsactx = NULL;
|
libssh2_ecdsa_ctx *ecdsactx = NULL;
|
||||||
unsigned char *type_str, *domain, *public_key;
|
unsigned char *type_str, *domain, *public_key;
|
||||||
@@ -793,9 +793,9 @@ hostkey_method_ssh_ecdsa_init(LIBSSH2_SESSION * session,
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
hostkey_method_ssh_ecdsa_initPEM(LIBSSH2_SESSION * session,
|
hostkey_method_ssh_ecdsa_initPEM(LIBSSH2_SESSION * session,
|
||||||
const char *privkeyfile,
|
const char *privkeyfile,
|
||||||
unsigned const char *passphrase,
|
unsigned const char *passphrase,
|
||||||
void **abstract)
|
void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_ecdsa_ctx *ec_ctx = NULL;
|
libssh2_ecdsa_ctx *ec_ctx = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -821,10 +821,10 @@ hostkey_method_ssh_ecdsa_initPEM(LIBSSH2_SESSION * session,
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
hostkey_method_ssh_ecdsa_initPEMFromMemory(LIBSSH2_SESSION * session,
|
hostkey_method_ssh_ecdsa_initPEMFromMemory(LIBSSH2_SESSION * session,
|
||||||
const char *privkeyfiledata,
|
const char *privkeyfiledata,
|
||||||
size_t privkeyfiledata_len,
|
size_t privkeyfiledata_len,
|
||||||
unsigned const char *passphrase,
|
unsigned const char *passphrase,
|
||||||
void **abstract)
|
void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_ecdsa_ctx *ec_ctx = NULL;
|
libssh2_ecdsa_ctx *ec_ctx = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -866,7 +866,7 @@ hostkey_method_ssh_ecdsa_sig_verify(LIBSSH2_SESSION * session,
|
|||||||
struct string_buf buf;
|
struct string_buf buf;
|
||||||
libssh2_ecdsa_ctx *ctx = (libssh2_ecdsa_ctx *) (*abstract);
|
libssh2_ecdsa_ctx *ctx = (libssh2_ecdsa_ctx *) (*abstract);
|
||||||
|
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
if(sig_len < 35)
|
if(sig_len < 35)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -952,7 +952,7 @@ static int
|
|||||||
hostkey_method_ssh_ecdsa_dtor(LIBSSH2_SESSION * session, void **abstract)
|
hostkey_method_ssh_ecdsa_dtor(LIBSSH2_SESSION * session, void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_ecdsa_ctx *keyctx = (libssh2_ecdsa_ctx *) (*abstract);
|
libssh2_ecdsa_ctx *keyctx = (libssh2_ecdsa_ctx *) (*abstract);
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
if(keyctx)
|
if(keyctx)
|
||||||
_libssh2_ecdsa_free(keyctx);
|
_libssh2_ecdsa_free(keyctx);
|
||||||
@@ -1102,9 +1102,9 @@ hostkey_method_ssh_ed25519_init(LIBSSH2_SESSION * session,
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
hostkey_method_ssh_ed25519_initPEM(LIBSSH2_SESSION * session,
|
hostkey_method_ssh_ed25519_initPEM(LIBSSH2_SESSION * session,
|
||||||
const char *privkeyfile,
|
const char *privkeyfile,
|
||||||
unsigned const char *passphrase,
|
unsigned const char *passphrase,
|
||||||
void **abstract)
|
void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_ed25519_ctx *ec_ctx = NULL;
|
libssh2_ed25519_ctx *ec_ctx = NULL;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -1172,7 +1172,7 @@ hostkey_method_ssh_ed25519_sig_verify(LIBSSH2_SESSION * session,
|
|||||||
size_t m_len, void **abstract)
|
size_t m_len, void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_ed25519_ctx *ctx = (libssh2_ed25519_ctx *) (*abstract);
|
libssh2_ed25519_ctx *ctx = (libssh2_ed25519_ctx *) (*abstract);
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
if(sig_len < 19)
|
if(sig_len < 19)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -1195,11 +1195,11 @@ hostkey_method_ssh_ed25519_sig_verify(LIBSSH2_SESSION * session,
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
hostkey_method_ssh_ed25519_signv(LIBSSH2_SESSION * session,
|
hostkey_method_ssh_ed25519_signv(LIBSSH2_SESSION * session,
|
||||||
unsigned char **signature,
|
unsigned char **signature,
|
||||||
size_t *signature_len,
|
size_t *signature_len,
|
||||||
int veccount,
|
int veccount,
|
||||||
const struct iovec datavec[],
|
const struct iovec datavec[],
|
||||||
void **abstract)
|
void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_ed25519_ctx *ctx = (libssh2_ed25519_ctx *) (*abstract);
|
libssh2_ed25519_ctx *ctx = (libssh2_ed25519_ctx *) (*abstract);
|
||||||
|
|
||||||
@@ -1221,7 +1221,7 @@ static int
|
|||||||
hostkey_method_ssh_ed25519_dtor(LIBSSH2_SESSION * session, void **abstract)
|
hostkey_method_ssh_ed25519_dtor(LIBSSH2_SESSION * session, void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_ed25519_ctx *keyctx = (libssh2_ed25519_ctx*) (*abstract);
|
libssh2_ed25519_ctx *keyctx = (libssh2_ed25519_ctx*) (*abstract);
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
if(keyctx)
|
if(keyctx)
|
||||||
_libssh2_ed25519_free(keyctx);
|
_libssh2_ed25519_free(keyctx);
|
||||||
|
|||||||
@@ -42,9 +42,9 @@
|
|||||||
/* Keep-alive stuff. */
|
/* Keep-alive stuff. */
|
||||||
|
|
||||||
LIBSSH2_API void
|
LIBSSH2_API void
|
||||||
libssh2_keepalive_config (LIBSSH2_SESSION *session,
|
libssh2_keepalive_config(LIBSSH2_SESSION *session,
|
||||||
int want_reply,
|
int want_reply,
|
||||||
unsigned interval)
|
unsigned interval)
|
||||||
{
|
{
|
||||||
if(interval == 1)
|
if(interval == 1)
|
||||||
session->keepalive_interval = 2;
|
session->keepalive_interval = 2;
|
||||||
@@ -54,8 +54,8 @@ libssh2_keepalive_config (LIBSSH2_SESSION *session,
|
|||||||
}
|
}
|
||||||
|
|
||||||
LIBSSH2_API int
|
LIBSSH2_API int
|
||||||
libssh2_keepalive_send (LIBSSH2_SESSION *session,
|
libssh2_keepalive_send(LIBSSH2_SESSION *session,
|
||||||
int *seconds_to_next)
|
int *seconds_to_next)
|
||||||
{
|
{
|
||||||
time_t now;
|
time_t now;
|
||||||
|
|
||||||
|
|||||||
134
src/kex.c
134
src/kex.c
@@ -176,10 +176,10 @@ static void _libssh2_sha_algo_ctx_final(int sha_algo, void *ctx,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void _libssh2_sha_algo_value_hash(int sha_algo,
|
static void _libssh2_sha_algo_value_hash(int sha_algo,
|
||||||
LIBSSH2_SESSION *session,
|
LIBSSH2_SESSION *session,
|
||||||
kmdhgGPshakex_state_t *exchange_state,
|
kmdhgGPshakex_state_t *exchange_state,
|
||||||
unsigned char **data, size_t data_len,
|
unsigned char **data, size_t data_len,
|
||||||
const unsigned char *version)
|
const unsigned char *version)
|
||||||
{
|
{
|
||||||
if(sha_algo == 512) {
|
if(sha_algo == 512) {
|
||||||
LIBSSH2_KEX_METHOD_SHA_VALUE_HASH(512, *data, data_len, version);
|
LIBSSH2_KEX_METHOD_SHA_VALUE_HASH(512, *data, data_len, version);
|
||||||
@@ -234,7 +234,7 @@ static int diffie_hellman_sha_algo(LIBSSH2_SESSION *session,
|
|||||||
digest_len = SHA1_DIGEST_LENGTH;
|
digest_len = SHA1_DIGEST_LENGTH;
|
||||||
else {
|
else {
|
||||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||||
"sha algo value is unimplemented");
|
"sha algo value is unimplemented");
|
||||||
goto clean_exit;
|
goto clean_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -479,8 +479,8 @@ static int diffie_hellman_sha_algo(LIBSSH2_SESSION *session,
|
|||||||
|
|
||||||
|
|
||||||
if(session->hostkey->init(session, session->server_hostkey,
|
if(session->hostkey->init(session, session->server_hostkey,
|
||||||
session->server_hostkey_len,
|
session->server_hostkey_len,
|
||||||
&session->server_hostkey_abstract)) {
|
&session->server_hostkey_abstract)) {
|
||||||
ret = _libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_INIT,
|
ret = _libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_INIT,
|
||||||
"Unable to initialize hostkey importer");
|
"Unable to initialize hostkey importer");
|
||||||
goto clean_exit;
|
goto clean_exit;
|
||||||
@@ -537,8 +537,8 @@ static int diffie_hellman_sha_algo(LIBSSH2_SESSION *session,
|
|||||||
_libssh2_sha_algo_ctx_update(sha_algo_value, exchange_hash_ctx,
|
_libssh2_sha_algo_ctx_update(sha_algo_value, exchange_hash_ctx,
|
||||||
exchange_state->h_sig_comp, 4);
|
exchange_state->h_sig_comp, 4);
|
||||||
_libssh2_sha_algo_ctx_update(sha_algo_value, exchange_hash_ctx,
|
_libssh2_sha_algo_ctx_update(sha_algo_value, exchange_hash_ctx,
|
||||||
session->local.banner,
|
session->local.banner,
|
||||||
strlen((char *) session->local.banner) - 2);
|
strlen((char *) session->local.banner) - 2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||||
@@ -546,9 +546,9 @@ static int diffie_hellman_sha_algo(LIBSSH2_SESSION *session,
|
|||||||
_libssh2_sha_algo_ctx_update(sha_algo_value, exchange_hash_ctx,
|
_libssh2_sha_algo_ctx_update(sha_algo_value, exchange_hash_ctx,
|
||||||
exchange_state->h_sig_comp, 4);
|
exchange_state->h_sig_comp, 4);
|
||||||
_libssh2_sha_algo_ctx_update(sha_algo_value, exchange_hash_ctx,
|
_libssh2_sha_algo_ctx_update(sha_algo_value, exchange_hash_ctx,
|
||||||
(unsigned char *)
|
(unsigned char *)
|
||||||
LIBSSH2_SSH_DEFAULT_BANNER,
|
LIBSSH2_SSH_DEFAULT_BANNER,
|
||||||
sizeof(LIBSSH2_SSH_DEFAULT_BANNER) - 1);
|
sizeof(LIBSSH2_SSH_DEFAULT_BANNER) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
_libssh2_htonu32(exchange_state->h_sig_comp,
|
_libssh2_htonu32(exchange_state->h_sig_comp,
|
||||||
@@ -853,7 +853,7 @@ static int diffie_hellman_sha_algo(LIBSSH2_SESSION *session,
|
|||||||
|
|
||||||
if(session->local.comp && session->local.comp->init) {
|
if(session->local.comp && session->local.comp->init) {
|
||||||
if(session->local.comp->init(session, 1,
|
if(session->local.comp->init(session, 1,
|
||||||
&session->local.comp_abstract)) {
|
&session->local.comp_abstract)) {
|
||||||
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
||||||
goto clean_exit;
|
goto clean_exit;
|
||||||
}
|
}
|
||||||
@@ -868,7 +868,7 @@ static int diffie_hellman_sha_algo(LIBSSH2_SESSION *session,
|
|||||||
|
|
||||||
if(session->remote.comp && session->remote.comp->init) {
|
if(session->remote.comp && session->remote.comp->init) {
|
||||||
if(session->remote.comp->init(session, 0,
|
if(session->remote.comp->init(session, 0,
|
||||||
&session->remote.comp_abstract)) {
|
&session->remote.comp_abstract)) {
|
||||||
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
||||||
goto clean_exit;
|
goto clean_exit;
|
||||||
}
|
}
|
||||||
@@ -1050,8 +1050,8 @@ kex_method_diffie_hellman_group14_key_exchange(LIBSSH2_SESSION *session,
|
|||||||
key_state->state = libssh2_NB_state_created;
|
key_state->state = libssh2_NB_state_created;
|
||||||
}
|
}
|
||||||
ret = hashfunc(session, key_state->g, key_state->p,
|
ret = hashfunc(session, key_state->g, key_state->p,
|
||||||
256, sha_algo_value, exchange_hash_ctx, SSH_MSG_KEXDH_INIT,
|
256, sha_algo_value, exchange_hash_ctx, SSH_MSG_KEXDH_INIT,
|
||||||
SSH_MSG_KEXDH_REPLY, NULL, 0, &key_state->exchange_state);
|
SSH_MSG_KEXDH_REPLY, NULL, 0, &key_state->exchange_state);
|
||||||
if(ret == LIBSSH2_ERROR_EAGAIN) {
|
if(ret == LIBSSH2_ERROR_EAGAIN) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -1077,9 +1077,9 @@ kex_method_diffie_hellman_group14_sha1_key_exchange(LIBSSH2_SESSION *session,
|
|||||||
{
|
{
|
||||||
libssh2_sha1_ctx ctx;
|
libssh2_sha1_ctx ctx;
|
||||||
return kex_method_diffie_hellman_group14_key_exchange(session,
|
return kex_method_diffie_hellman_group14_key_exchange(session,
|
||||||
key_state, 1,
|
key_state, 1,
|
||||||
&ctx,
|
&ctx,
|
||||||
diffie_hellman_sha_algo);
|
diffie_hellman_sha_algo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1094,9 +1094,9 @@ kex_method_diffie_hellman_group14_sha256_key_exchange(LIBSSH2_SESSION *session,
|
|||||||
{
|
{
|
||||||
libssh2_sha256_ctx ctx;
|
libssh2_sha256_ctx ctx;
|
||||||
return kex_method_diffie_hellman_group14_key_exchange(session,
|
return kex_method_diffie_hellman_group14_key_exchange(session,
|
||||||
key_state, 256,
|
key_state, 256,
|
||||||
&ctx,
|
&ctx,
|
||||||
diffie_hellman_sha_algo);
|
diffie_hellman_sha_algo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* kex_method_diffie_hellman_group16_sha512_key_exchange
|
/* kex_method_diffie_hellman_group16_sha512_key_exchange
|
||||||
@@ -1325,8 +1325,9 @@ kex_method_diffie_hellman_group18_sha512_key_exchange(LIBSSH2_SESSION *session,
|
|||||||
* Negotiates random(ish) group for secret derivation
|
* Negotiates random(ish) group for secret derivation
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
kex_method_diffie_hellman_group_exchange_sha1_key_exchange
|
kex_method_diffie_hellman_group_exchange_sha1_key_exchange(
|
||||||
(LIBSSH2_SESSION * session, key_exchange_state_low_t * key_state)
|
LIBSSH2_SESSION * session,
|
||||||
|
key_exchange_state_low_t * key_state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -1442,8 +1443,9 @@ kex_method_diffie_hellman_group_exchange_sha1_key_exchange
|
|||||||
* Negotiates random(ish) group for secret derivation
|
* Negotiates random(ish) group for secret derivation
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
kex_method_diffie_hellman_group_exchange_sha256_key_exchange
|
kex_method_diffie_hellman_group_exchange_sha256_key_exchange(
|
||||||
(LIBSSH2_SESSION * session, key_exchange_state_low_t * key_state)
|
LIBSSH2_SESSION * session,
|
||||||
|
key_exchange_state_low_t * key_state)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int rc;
|
int rc;
|
||||||
@@ -1741,7 +1743,7 @@ static int ecdh_sha2_nistp(LIBSSH2_SESSION *session, libssh2_curve_type type,
|
|||||||
buf.dataptr = buf.data;
|
buf.dataptr = buf.data;
|
||||||
buf.dataptr++; /* Advance past packet type */
|
buf.dataptr++; /* Advance past packet type */
|
||||||
|
|
||||||
if(_libssh2_copy_string(session, &buf, &(session->server_hostkey),
|
if(_libssh2_copy_string(session, &buf, &(session->server_hostkey),
|
||||||
&server_public_key_len)) {
|
&server_public_key_len)) {
|
||||||
ret = _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
ret = _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||||
"Unable to allocate memory for a copy "
|
"Unable to allocate memory for a copy "
|
||||||
@@ -1840,8 +1842,8 @@ static int ecdh_sha2_nistp(LIBSSH2_SESSION *session, libssh2_curve_type type,
|
|||||||
#endif /* LIBSSH2DEBUG */
|
#endif /* LIBSSH2DEBUG */
|
||||||
|
|
||||||
if(session->hostkey->init(session, session->server_hostkey,
|
if(session->hostkey->init(session, session->server_hostkey,
|
||||||
session->server_hostkey_len,
|
session->server_hostkey_len,
|
||||||
&session->server_hostkey_abstract)) {
|
&session->server_hostkey_abstract)) {
|
||||||
ret = _libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_INIT,
|
ret = _libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_INIT,
|
||||||
"Unable to initialize hostkey importer");
|
"Unable to initialize hostkey importer");
|
||||||
goto clean_exit;
|
goto clean_exit;
|
||||||
@@ -2006,8 +2008,8 @@ static int ecdh_sha2_nistp(LIBSSH2_SESSION *session, libssh2_curve_type type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
LIBSSH2_KEX_METHOD_EC_SHA_VALUE_HASH(secret,
|
LIBSSH2_KEX_METHOD_EC_SHA_VALUE_HASH(secret,
|
||||||
session->local.crypt->
|
session->local.crypt->
|
||||||
secret_len, "C");
|
secret_len, "C");
|
||||||
|
|
||||||
if(!secret) {
|
if(!secret) {
|
||||||
LIBSSH2_FREE(session, iv);
|
LIBSSH2_FREE(session, iv);
|
||||||
@@ -2151,7 +2153,7 @@ static int ecdh_sha2_nistp(LIBSSH2_SESSION *session, libssh2_curve_type type,
|
|||||||
|
|
||||||
if(session->local.comp && session->local.comp->init) {
|
if(session->local.comp && session->local.comp->init) {
|
||||||
if(session->local.comp->init(session, 1,
|
if(session->local.comp->init(session, 1,
|
||||||
&session->local.comp_abstract)) {
|
&session->local.comp_abstract)) {
|
||||||
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
||||||
goto clean_exit;
|
goto clean_exit;
|
||||||
}
|
}
|
||||||
@@ -2166,14 +2168,13 @@ static int ecdh_sha2_nistp(LIBSSH2_SESSION *session, libssh2_curve_type type,
|
|||||||
|
|
||||||
if(session->remote.comp && session->remote.comp->init) {
|
if(session->remote.comp && session->remote.comp->init) {
|
||||||
if(session->remote.comp->init(session, 0,
|
if(session->remote.comp->init(session, 0,
|
||||||
&session->remote.comp_abstract)) {
|
&session->remote.comp_abstract)) {
|
||||||
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
||||||
goto clean_exit;
|
goto clean_exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_libssh2_debug((session, LIBSSH2_TRACE_KEX,
|
_libssh2_debug((session, LIBSSH2_TRACE_KEX,
|
||||||
"Server to Client compression initialized"));
|
"Server to Client compression initialized"));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
clean_exit:
|
clean_exit:
|
||||||
@@ -2322,7 +2323,6 @@ ecdh_clean_exit:
|
|||||||
/* curve25519_sha256
|
/* curve25519_sha256
|
||||||
* Elliptic Curve Key Exchange
|
* Elliptic Curve Key Exchange
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
||||||
size_t data_len,
|
size_t data_len,
|
||||||
@@ -2472,8 +2472,8 @@ curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
|||||||
#endif /* LIBSSH2DEBUG */
|
#endif /* LIBSSH2DEBUG */
|
||||||
|
|
||||||
if(session->hostkey->init(session, session->server_hostkey,
|
if(session->hostkey->init(session, session->server_hostkey,
|
||||||
session->server_hostkey_len,
|
session->server_hostkey_len,
|
||||||
&session->server_hostkey_abstract)) {
|
&session->server_hostkey_abstract)) {
|
||||||
ret = _libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_INIT,
|
ret = _libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_INIT,
|
||||||
"Unable to initialize hostkey importer");
|
"Unable to initialize hostkey importer");
|
||||||
goto clean_exit;
|
goto clean_exit;
|
||||||
@@ -2483,7 +2483,7 @@ curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
|||||||
if(_libssh2_get_string(&buf, &server_public_key,
|
if(_libssh2_get_string(&buf, &server_public_key,
|
||||||
&server_public_key_len)) {
|
&server_public_key_len)) {
|
||||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||||
"Unexpected key length");
|
"Unexpected key length");
|
||||||
goto clean_exit;
|
goto clean_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2604,7 +2604,7 @@ curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
|||||||
/* Cleanup any existing cipher */
|
/* Cleanup any existing cipher */
|
||||||
if(session->local.crypt->dtor) {
|
if(session->local.crypt->dtor) {
|
||||||
session->local.crypt->dtor(session,
|
session->local.crypt->dtor(session,
|
||||||
&session->local.crypt_abstract);
|
&session->local.crypt_abstract);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate IV/Secret/Key for each direction */
|
/* Calculate IV/Secret/Key for each direction */
|
||||||
@@ -2766,7 +2766,7 @@ curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
|||||||
|
|
||||||
if(session->local.comp && session->local.comp->init) {
|
if(session->local.comp && session->local.comp->init) {
|
||||||
if(session->local.comp->init(session, 1,
|
if(session->local.comp->init(session, 1,
|
||||||
&session->local.comp_abstract)) {
|
&session->local.comp_abstract)) {
|
||||||
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
||||||
goto clean_exit;
|
goto clean_exit;
|
||||||
}
|
}
|
||||||
@@ -2776,12 +2776,12 @@ curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
|||||||
|
|
||||||
if(session->remote.comp && session->remote.comp->dtor) {
|
if(session->remote.comp && session->remote.comp->dtor) {
|
||||||
session->remote.comp->dtor(session, 0,
|
session->remote.comp->dtor(session, 0,
|
||||||
&session->remote.comp_abstract);
|
&session->remote.comp_abstract);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(session->remote.comp && session->remote.comp->init) {
|
if(session->remote.comp && session->remote.comp->init) {
|
||||||
if(session->remote.comp->init(session, 0,
|
if(session->remote.comp->init(session, 0,
|
||||||
&session->remote.comp_abstract)) {
|
&session->remote.comp_abstract)) {
|
||||||
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
ret = LIBSSH2_ERROR_KEX_FAILURE;
|
||||||
goto clean_exit;
|
goto clean_exit;
|
||||||
}
|
}
|
||||||
@@ -2809,7 +2809,6 @@ clean_exit:
|
|||||||
* Elliptic Curve X25519 Key Exchange with SHA256 hash
|
* Elliptic Curve X25519 Key Exchange with SHA256 hash
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int
|
static int
|
||||||
kex_method_curve25519_key_exchange
|
kex_method_curve25519_key_exchange
|
||||||
(LIBSSH2_SESSION * session, key_exchange_state_low_t * key_state)
|
(LIBSSH2_SESSION * session, key_exchange_state_low_t * key_state)
|
||||||
@@ -3042,7 +3041,7 @@ static const LIBSSH2_KEX_METHOD *libssh2_kex_methods[] = {
|
|||||||
&kex_method_diffie_helman_group1_sha1,
|
&kex_method_diffie_helman_group1_sha1,
|
||||||
&kex_method_diffie_helman_group_exchange_sha1,
|
&kex_method_diffie_helman_group_exchange_sha1,
|
||||||
&kex_method_extension_negotiation,
|
&kex_method_extension_negotiation,
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _LIBSSH2_COMMON_METHOD
|
typedef struct _LIBSSH2_COMMON_METHOD
|
||||||
@@ -3105,7 +3104,7 @@ kex_method_list(unsigned char *buf, uint32_t list_strlen,
|
|||||||
|
|
||||||
#define LIBSSH2_METHOD_PREFS_LEN(prefvar, defaultvar) \
|
#define LIBSSH2_METHOD_PREFS_LEN(prefvar, defaultvar) \
|
||||||
(uint32_t)((prefvar) ? strlen(prefvar) : \
|
(uint32_t)((prefvar) ? strlen(prefvar) : \
|
||||||
kex_method_strlen((LIBSSH2_COMMON_METHOD**)(defaultvar)))
|
kex_method_strlen((LIBSSH2_COMMON_METHOD**)(defaultvar)))
|
||||||
|
|
||||||
#define LIBSSH2_METHOD_PREFS_STR(buf, prefvarlen, prefvar, defaultvar) \
|
#define LIBSSH2_METHOD_PREFS_STR(buf, prefvarlen, prefvar, defaultvar) \
|
||||||
do { \
|
do { \
|
||||||
@@ -3168,8 +3167,8 @@ static int kexinit(LIBSSH2_SESSION * session)
|
|||||||
LIBSSH2_METHOD_PREFS_LEN(session->remote.lang_prefs, NULL);
|
LIBSSH2_METHOD_PREFS_LEN(session->remote.lang_prefs, NULL);
|
||||||
|
|
||||||
data_len += kex_len + hostkey_len + crypt_cs_len + crypt_sc_len +
|
data_len += kex_len + hostkey_len + crypt_cs_len + crypt_sc_len +
|
||||||
comp_cs_len + comp_sc_len + mac_cs_len + mac_sc_len +
|
comp_cs_len + comp_sc_len + mac_cs_len + mac_sc_len +
|
||||||
lang_cs_len + lang_sc_len;
|
lang_cs_len + lang_sc_len;
|
||||||
|
|
||||||
s = data = LIBSSH2_ALLOC(session, data_len);
|
s = data = LIBSSH2_ALLOC(session, data_len);
|
||||||
if(!data) {
|
if(!data) {
|
||||||
@@ -3478,7 +3477,7 @@ static int kex_agree_kex_hostkey(LIBSSH2_SESSION * session, unsigned char *kex,
|
|||||||
* Can we agree on a hostkey that works with this kex?
|
* Can we agree on a hostkey that works with this kex?
|
||||||
*/
|
*/
|
||||||
if(kex_agree_hostkey(session, method->flags, hostkey,
|
if(kex_agree_hostkey(session, method->flags, hostkey,
|
||||||
hostkey_len) == 0) {
|
hostkey_len) == 0) {
|
||||||
session->kex = method;
|
session->kex = method;
|
||||||
if(session->burn_optimistic_kexinit && (kex == q)) {
|
if(session->burn_optimistic_kexinit && (kex == q)) {
|
||||||
/* Server sent an optimistic packet, and client agrees
|
/* Server sent an optimistic packet, and client agrees
|
||||||
@@ -3504,7 +3503,7 @@ static int kex_agree_kex_hostkey(LIBSSH2_SESSION * session, unsigned char *kex,
|
|||||||
* Can we agree on a hostkey that works with this kex?
|
* Can we agree on a hostkey that works with this kex?
|
||||||
*/
|
*/
|
||||||
if(kex_agree_hostkey(session, (*kexp)->flags, hostkey,
|
if(kex_agree_hostkey(session, (*kexp)->flags, hostkey,
|
||||||
hostkey_len) == 0) {
|
hostkey_len) == 0) {
|
||||||
session->kex = *kexp;
|
session->kex = *kexp;
|
||||||
if(session->burn_optimistic_kexinit && (kex == s)) {
|
if(session->burn_optimistic_kexinit && (kex == s)) {
|
||||||
/* Server sent an optimistic packet, and client agrees
|
/* Server sent an optimistic packet, and client agrees
|
||||||
@@ -3533,7 +3532,7 @@ static int kex_agree_crypt(LIBSSH2_SESSION * session,
|
|||||||
const LIBSSH2_CRYPT_METHOD **cryptp = libssh2_crypt_methods();
|
const LIBSSH2_CRYPT_METHOD **cryptp = libssh2_crypt_methods();
|
||||||
unsigned char *s;
|
unsigned char *s;
|
||||||
|
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
if(endpoint->crypt_prefs) {
|
if(endpoint->crypt_prefs) {
|
||||||
s = (unsigned char *) endpoint->crypt_prefs;
|
s = (unsigned char *) endpoint->crypt_prefs;
|
||||||
@@ -3588,7 +3587,7 @@ static int kex_agree_mac(LIBSSH2_SESSION * session,
|
|||||||
{
|
{
|
||||||
const LIBSSH2_MAC_METHOD **macp = _libssh2_mac_methods();
|
const LIBSSH2_MAC_METHOD **macp = _libssh2_mac_methods();
|
||||||
unsigned char *s;
|
unsigned char *s;
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
if(endpoint->mac_prefs) {
|
if(endpoint->mac_prefs) {
|
||||||
s = (unsigned char *) endpoint->mac_prefs;
|
s = (unsigned char *) endpoint->mac_prefs;
|
||||||
@@ -3641,7 +3640,7 @@ static int kex_agree_comp(LIBSSH2_SESSION *session,
|
|||||||
{
|
{
|
||||||
const LIBSSH2_COMP_METHOD **compp = _libssh2_comp_methods(session);
|
const LIBSSH2_COMP_METHOD **compp = _libssh2_comp_methods(session);
|
||||||
unsigned char *s;
|
unsigned char *s;
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
if(endpoint->comp_prefs) {
|
if(endpoint->comp_prefs) {
|
||||||
s = (unsigned char *) endpoint->comp_prefs;
|
s = (unsigned char *) endpoint->comp_prefs;
|
||||||
@@ -3890,7 +3889,7 @@ _libssh2_kex_exchange(LIBSSH2_SESSION * session, int reexchange,
|
|||||||
session->remote.kexinit_len = key_state->data_len;
|
session->remote.kexinit_len = key_state->data_len;
|
||||||
|
|
||||||
if(kex_agree_methods(session, key_state->data,
|
if(kex_agree_methods(session, key_state->data,
|
||||||
key_state->data_len))
|
key_state->data_len))
|
||||||
rc = LIBSSH2_ERROR_KEX_FAILURE;
|
rc = LIBSSH2_ERROR_KEX_FAILURE;
|
||||||
|
|
||||||
key_state->state = libssh2_NB_state_sent2;
|
key_state->state = libssh2_NB_state_sent2;
|
||||||
@@ -3950,44 +3949,42 @@ libssh2_session_method_pref(LIBSSH2_SESSION * session, int method_type,
|
|||||||
switch(method_type) {
|
switch(method_type) {
|
||||||
case LIBSSH2_METHOD_KEX:
|
case LIBSSH2_METHOD_KEX:
|
||||||
prefvar = &session->kex_prefs;
|
prefvar = &session->kex_prefs;
|
||||||
mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_kex_methods;
|
mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_kex_methods;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIBSSH2_METHOD_HOSTKEY:
|
case LIBSSH2_METHOD_HOSTKEY:
|
||||||
prefvar = &session->hostkey_prefs;
|
prefvar = &session->hostkey_prefs;
|
||||||
mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_hostkey_methods();
|
mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_hostkey_methods();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIBSSH2_METHOD_CRYPT_CS:
|
case LIBSSH2_METHOD_CRYPT_CS:
|
||||||
prefvar = &session->local.crypt_prefs;
|
prefvar = &session->local.crypt_prefs;
|
||||||
mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_crypt_methods();
|
mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_crypt_methods();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIBSSH2_METHOD_CRYPT_SC:
|
case LIBSSH2_METHOD_CRYPT_SC:
|
||||||
prefvar = &session->remote.crypt_prefs;
|
prefvar = &session->remote.crypt_prefs;
|
||||||
mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_crypt_methods();
|
mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_crypt_methods();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIBSSH2_METHOD_MAC_CS:
|
case LIBSSH2_METHOD_MAC_CS:
|
||||||
prefvar = &session->local.mac_prefs;
|
prefvar = &session->local.mac_prefs;
|
||||||
mlist = (const LIBSSH2_COMMON_METHOD **) _libssh2_mac_methods();
|
mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_mac_methods();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIBSSH2_METHOD_MAC_SC:
|
case LIBSSH2_METHOD_MAC_SC:
|
||||||
prefvar = &session->remote.mac_prefs;
|
prefvar = &session->remote.mac_prefs;
|
||||||
mlist = (const LIBSSH2_COMMON_METHOD **) _libssh2_mac_methods();
|
mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_mac_methods();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIBSSH2_METHOD_COMP_CS:
|
case LIBSSH2_METHOD_COMP_CS:
|
||||||
prefvar = &session->local.comp_prefs;
|
prefvar = &session->local.comp_prefs;
|
||||||
mlist = (const LIBSSH2_COMMON_METHOD **)
|
mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_comp_methods(session);
|
||||||
_libssh2_comp_methods(session);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIBSSH2_METHOD_COMP_SC:
|
case LIBSSH2_METHOD_COMP_SC:
|
||||||
prefvar = &session->remote.comp_prefs;
|
prefvar = &session->remote.comp_prefs;
|
||||||
mlist = (const LIBSSH2_COMMON_METHOD **)
|
mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_comp_methods(session);
|
||||||
_libssh2_comp_methods(session);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIBSSH2_METHOD_LANG_CS:
|
case LIBSSH2_METHOD_LANG_CS:
|
||||||
@@ -4077,27 +4074,26 @@ LIBSSH2_API int libssh2_session_supported_algs(LIBSSH2_SESSION* session,
|
|||||||
|
|
||||||
switch(method_type) {
|
switch(method_type) {
|
||||||
case LIBSSH2_METHOD_KEX:
|
case LIBSSH2_METHOD_KEX:
|
||||||
mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_kex_methods;
|
mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_kex_methods;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIBSSH2_METHOD_HOSTKEY:
|
case LIBSSH2_METHOD_HOSTKEY:
|
||||||
mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_hostkey_methods();
|
mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_hostkey_methods();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIBSSH2_METHOD_CRYPT_CS:
|
case LIBSSH2_METHOD_CRYPT_CS:
|
||||||
case LIBSSH2_METHOD_CRYPT_SC:
|
case LIBSSH2_METHOD_CRYPT_SC:
|
||||||
mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_crypt_methods();
|
mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_crypt_methods();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIBSSH2_METHOD_MAC_CS:
|
case LIBSSH2_METHOD_MAC_CS:
|
||||||
case LIBSSH2_METHOD_MAC_SC:
|
case LIBSSH2_METHOD_MAC_SC:
|
||||||
mlist = (const LIBSSH2_COMMON_METHOD **) _libssh2_mac_methods();
|
mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_mac_methods();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIBSSH2_METHOD_COMP_CS:
|
case LIBSSH2_METHOD_COMP_CS:
|
||||||
case LIBSSH2_METHOD_COMP_SC:
|
case LIBSSH2_METHOD_COMP_SC:
|
||||||
mlist = (const LIBSSH2_COMMON_METHOD **)
|
mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_comp_methods(session);
|
||||||
_libssh2_comp_methods(session);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LIBSSH2_METHOD_SIGN_ALGO:
|
case LIBSSH2_METHOD_SIGN_ALGO:
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ static struct libssh2_knownhost *knownhost_to_external(struct known_host *node)
|
|||||||
ext->magic = KNOWNHOST_MAGIC;
|
ext->magic = KNOWNHOST_MAGIC;
|
||||||
ext->node = node;
|
ext->node = node;
|
||||||
ext->name = ((node->typemask & LIBSSH2_KNOWNHOST_TYPE_MASK) ==
|
ext->name = ((node->typemask & LIBSSH2_KNOWNHOST_TYPE_MASK) ==
|
||||||
LIBSSH2_KNOWNHOST_TYPE_PLAIN)? node->name:NULL;
|
LIBSSH2_KNOWNHOST_TYPE_PLAIN) ? node->name : NULL;
|
||||||
ext->key = node->key;
|
ext->key = node->key;
|
||||||
ext->typemask = node->typemask;
|
ext->typemask = node->typemask;
|
||||||
|
|
||||||
|
|||||||
@@ -59,17 +59,17 @@ _libssh2_rsa_new(libssh2_rsa_ctx ** rsa,
|
|||||||
const unsigned char *coeffdata, unsigned long coefflen)
|
const unsigned char *coeffdata, unsigned long coefflen)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
(void) e1data;
|
|
||||||
(void) e1len;
|
(void)e1data;
|
||||||
(void) e2data;
|
(void)e1len;
|
||||||
(void) e2len;
|
(void)e2data;
|
||||||
|
(void)e2len;
|
||||||
|
|
||||||
if(ddata) {
|
if(ddata) {
|
||||||
rc = gcry_sexp_build
|
rc = gcry_sexp_build(rsa, NULL,
|
||||||
(rsa, NULL,
|
"(private-key(rsa(n%b)(e%b)(d%b)(q%b)(p%b)(u%b)))",
|
||||||
"(private-key(rsa(n%b)(e%b)(d%b)(q%b)(p%b)(u%b)))",
|
nlen, ndata, elen, edata, dlen, ddata, plen, pdata,
|
||||||
nlen, ndata, elen, edata, dlen, ddata, plen, pdata,
|
qlen, qdata, coefflen, coeffdata);
|
||||||
qlen, qdata, coefflen, coeffdata);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rc = gcry_sexp_build(rsa, NULL, "(public-key(rsa(n%b)(e%b)))",
|
rc = gcry_sexp_build(rsa, NULL, "(public-key(rsa(n%b)(e%b)))",
|
||||||
@@ -130,10 +130,9 @@ _libssh2_dsa_new(libssh2_dsa_ctx ** dsactx,
|
|||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if(x_len) {
|
if(x_len) {
|
||||||
rc = gcry_sexp_build
|
rc = gcry_sexp_build(dsactx, NULL,
|
||||||
(dsactx, NULL,
|
"(private-key(dsa(p%b)(q%b)(g%b)(y%b)(x%b)))",
|
||||||
"(private-key(dsa(p%b)(q%b)(g%b)(y%b)(x%b)))",
|
p_len, p, q_len, q, g_len, g, y_len, y, x_len, x);
|
||||||
p_len, p, q_len, q, g_len, g, y_len, y, x_len, x);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rc = gcry_sexp_build(dsactx, NULL,
|
rc = gcry_sexp_build(dsactx, NULL,
|
||||||
@@ -198,7 +197,7 @@ _libssh2_rsa_new_private(libssh2_rsa_ctx ** rsa,
|
|||||||
ret = -1;
|
ret = -1;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
/* First read Version field (should be 0). */
|
/* First read Version field (should be 0). */
|
||||||
ret = _libssh2_pem_decode_integer(&data, &datalen, &n, &nlen);
|
ret = _libssh2_pem_decode_integer(&data, &datalen, &n, &nlen);
|
||||||
if(ret || (nlen != 1 && *n != '\0')) {
|
if(ret || (nlen != 1 && *n != '\0')) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
@@ -254,7 +253,7 @@ _libssh2_rsa_new_private(libssh2_rsa_ctx ** rsa,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(_libssh2_rsa_new(rsa, e, elen, n, nlen, d, dlen, p, plen,
|
if(_libssh2_rsa_new(rsa, e, elen, n, nlen, d, dlen, p, plen,
|
||||||
q, qlen, e1, e1len, e2, e2len, coeff, coefflen)) {
|
q, qlen, e1, e1len, e2, e2len, coeff, coefflen)) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@@ -316,7 +315,7 @@ _libssh2_dsa_new_private(libssh2_dsa_ctx ** dsa,
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* First read Version field (should be 0). */
|
/* First read Version field (should be 0). */
|
||||||
ret = _libssh2_pem_decode_integer(&data, &datalen, &p, &plen);
|
ret = _libssh2_pem_decode_integer(&data, &datalen, &p, &plen);
|
||||||
if(ret || (plen != 1 && *p != '\0')) {
|
if(ret || (plen != 1 && *p != '\0')) {
|
||||||
ret = -1;
|
ret = -1;
|
||||||
@@ -388,8 +387,8 @@ _libssh2_rsa_sha1_sign(LIBSSH2_SESSION * session,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(gcry_sexp_build(&data, NULL,
|
if(gcry_sexp_build(&data, NULL,
|
||||||
"(data (flags pkcs1) (hash sha1 %b))",
|
"(data (flags pkcs1) (hash sha1 %b))",
|
||||||
hash_len, hash)) {
|
hash_len, hash)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -464,7 +463,7 @@ _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx,
|
|||||||
|
|
||||||
memset(sig, 0, 40);
|
memset(sig, 0, 40);
|
||||||
|
|
||||||
/* Extract R. */
|
/* Extract R. */
|
||||||
|
|
||||||
data = gcry_sexp_find_token(sig_sexp, "r", 0);
|
data = gcry_sexp_find_token(sig_sexp, "r", 0);
|
||||||
if(!data)
|
if(!data)
|
||||||
@@ -486,7 +485,7 @@ _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx,
|
|||||||
|
|
||||||
gcry_sexp_release(data);
|
gcry_sexp_release(data);
|
||||||
|
|
||||||
/* Extract S. */
|
/* Extract S. */
|
||||||
|
|
||||||
data = gcry_sexp_find_token(sig_sexp, "s", 0);
|
data = gcry_sexp_find_token(sig_sexp, "s", 0);
|
||||||
if(!data)
|
if(!data)
|
||||||
@@ -533,12 +532,12 @@ _libssh2_dsa_sha1_verify(libssh2_dsa_ctx * dsactx,
|
|||||||
hash[0] = 0;
|
hash[0] = 0;
|
||||||
|
|
||||||
if(gcry_sexp_build(&s_hash, NULL, "(data(flags raw)(value %b))",
|
if(gcry_sexp_build(&s_hash, NULL, "(data(flags raw)(value %b))",
|
||||||
SHA_DIGEST_LENGTH + 1, hash)) {
|
SHA_DIGEST_LENGTH + 1, hash)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(gcry_sexp_build(&s_sig, NULL, "(sig-val(dsa(r %b)(s %b)))",
|
if(gcry_sexp_build(&s_sig, NULL, "(sig-val(dsa(r %b)(s %b)))",
|
||||||
20, sig, 20, sig + 20)) {
|
20, sig, 20, sig + 20)) {
|
||||||
gcry_sexp_release(s_hash);
|
gcry_sexp_release(s_hash);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -560,7 +559,7 @@ _libssh2_cipher_init(_libssh2_cipher_ctx * h,
|
|||||||
int mode = _libssh2_gcry_mode(algo);
|
int mode = _libssh2_gcry_mode(algo);
|
||||||
size_t keylen = gcry_cipher_get_algo_keylen(cipher);
|
size_t keylen = gcry_cipher_get_algo_keylen(cipher);
|
||||||
|
|
||||||
(void) encrypt;
|
(void)encrypt;
|
||||||
|
|
||||||
ret = gcry_cipher_open(h, cipher, mode, 0);
|
ret = gcry_cipher_open(h, cipher, mode, 0);
|
||||||
if(ret) {
|
if(ret) {
|
||||||
|
|||||||
32
src/mac.c
32
src/mac.c
@@ -84,7 +84,7 @@ mac_method_common_init(LIBSSH2_SESSION * session, unsigned char *key,
|
|||||||
{
|
{
|
||||||
*abstract = key;
|
*abstract = key;
|
||||||
*free_key = 0;
|
*free_key = 0;
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -113,15 +113,15 @@ mac_method_common_dtor(LIBSSH2_SESSION * session, void **abstract)
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
mac_method_hmac_sha2_512_hash(LIBSSH2_SESSION * session,
|
mac_method_hmac_sha2_512_hash(LIBSSH2_SESSION * session,
|
||||||
unsigned char *buf, uint32_t seqno,
|
unsigned char *buf, uint32_t seqno,
|
||||||
const unsigned char *packet,
|
const unsigned char *packet,
|
||||||
size_t packet_len,
|
size_t packet_len,
|
||||||
const unsigned char *addtl,
|
const unsigned char *addtl,
|
||||||
size_t addtl_len, void **abstract)
|
size_t addtl_len, void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_hmac_ctx ctx;
|
libssh2_hmac_ctx ctx;
|
||||||
unsigned char seqno_buf[4];
|
unsigned char seqno_buf[4];
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
_libssh2_htonu32(seqno_buf, seqno);
|
_libssh2_htonu32(seqno_buf, seqno);
|
||||||
|
|
||||||
@@ -158,15 +158,15 @@ static const LIBSSH2_MAC_METHOD mac_method_hmac_sha2_512 = {
|
|||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
mac_method_hmac_sha2_256_hash(LIBSSH2_SESSION * session,
|
mac_method_hmac_sha2_256_hash(LIBSSH2_SESSION * session,
|
||||||
unsigned char *buf, uint32_t seqno,
|
unsigned char *buf, uint32_t seqno,
|
||||||
const unsigned char *packet,
|
const unsigned char *packet,
|
||||||
size_t packet_len,
|
size_t packet_len,
|
||||||
const unsigned char *addtl,
|
const unsigned char *addtl,
|
||||||
size_t addtl_len, void **abstract)
|
size_t addtl_len, void **abstract)
|
||||||
{
|
{
|
||||||
libssh2_hmac_ctx ctx;
|
libssh2_hmac_ctx ctx;
|
||||||
unsigned char seqno_buf[4];
|
unsigned char seqno_buf[4];
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
_libssh2_htonu32(seqno_buf, seqno);
|
_libssh2_htonu32(seqno_buf, seqno);
|
||||||
|
|
||||||
@@ -211,7 +211,7 @@ mac_method_hmac_sha1_hash(LIBSSH2_SESSION * session,
|
|||||||
{
|
{
|
||||||
libssh2_hmac_ctx ctx;
|
libssh2_hmac_ctx ctx;
|
||||||
unsigned char seqno_buf[4];
|
unsigned char seqno_buf[4];
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
_libssh2_htonu32(seqno_buf, seqno);
|
_libssh2_htonu32(seqno_buf, seqno);
|
||||||
|
|
||||||
@@ -284,7 +284,7 @@ mac_method_hmac_md5_hash(LIBSSH2_SESSION * session, unsigned char *buf,
|
|||||||
{
|
{
|
||||||
libssh2_hmac_ctx ctx;
|
libssh2_hmac_ctx ctx;
|
||||||
unsigned char seqno_buf[4];
|
unsigned char seqno_buf[4];
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
_libssh2_htonu32(seqno_buf, seqno);
|
_libssh2_htonu32(seqno_buf, seqno);
|
||||||
|
|
||||||
@@ -357,7 +357,7 @@ mac_method_hmac_ripemd160_hash(LIBSSH2_SESSION * session,
|
|||||||
{
|
{
|
||||||
libssh2_hmac_ctx ctx;
|
libssh2_hmac_ctx ctx;
|
||||||
unsigned char seqno_buf[4];
|
unsigned char seqno_buf[4];
|
||||||
(void) session;
|
(void)session;
|
||||||
|
|
||||||
_libssh2_htonu32(seqno_buf, seqno);
|
_libssh2_htonu32(seqno_buf, seqno);
|
||||||
|
|
||||||
|
|||||||
133
src/mbedtls.c
133
src/mbedtls.c
@@ -145,8 +145,8 @@ _libssh2_mbedtls_cipher_crypt(_libssh2_cipher_ctx *ctx,
|
|||||||
unsigned char *output;
|
unsigned char *output;
|
||||||
size_t osize, olen, finish_olen;
|
size_t osize, olen, finish_olen;
|
||||||
|
|
||||||
(void) encrypt;
|
(void)encrypt;
|
||||||
(void) algo;
|
(void)algo;
|
||||||
|
|
||||||
osize = blocklen + mbedtls_cipher_get_block_size(ctx);
|
osize = blocklen + mbedtls_cipher_get_block_size(ctx);
|
||||||
|
|
||||||
@@ -182,8 +182,8 @@ _libssh2_mbedtls_cipher_dtor(_libssh2_cipher_ctx *ctx)
|
|||||||
|
|
||||||
int
|
int
|
||||||
_libssh2_mbedtls_hash_init(mbedtls_md_context_t *ctx,
|
_libssh2_mbedtls_hash_init(mbedtls_md_context_t *ctx,
|
||||||
mbedtls_md_type_t mdtype,
|
mbedtls_md_type_t mdtype,
|
||||||
const unsigned char *key, unsigned long keylen)
|
const unsigned char *key, unsigned long keylen)
|
||||||
{
|
{
|
||||||
const mbedtls_md_info_t *md_info;
|
const mbedtls_md_info_t *md_info;
|
||||||
int ret, hmac;
|
int ret, hmac;
|
||||||
@@ -315,22 +315,22 @@ _libssh2_mbedtls_bignum_random(_libssh2_bn *bn, int bits, int top, int bottom)
|
|||||||
|
|
||||||
int
|
int
|
||||||
_libssh2_mbedtls_rsa_new(libssh2_rsa_ctx **rsa,
|
_libssh2_mbedtls_rsa_new(libssh2_rsa_ctx **rsa,
|
||||||
const unsigned char *edata,
|
const unsigned char *edata,
|
||||||
unsigned long elen,
|
unsigned long elen,
|
||||||
const unsigned char *ndata,
|
const unsigned char *ndata,
|
||||||
unsigned long nlen,
|
unsigned long nlen,
|
||||||
const unsigned char *ddata,
|
const unsigned char *ddata,
|
||||||
unsigned long dlen,
|
unsigned long dlen,
|
||||||
const unsigned char *pdata,
|
const unsigned char *pdata,
|
||||||
unsigned long plen,
|
unsigned long plen,
|
||||||
const unsigned char *qdata,
|
const unsigned char *qdata,
|
||||||
unsigned long qlen,
|
unsigned long qlen,
|
||||||
const unsigned char *e1data,
|
const unsigned char *e1data,
|
||||||
unsigned long e1len,
|
unsigned long e1len,
|
||||||
const unsigned char *e2data,
|
const unsigned char *e2data,
|
||||||
unsigned long e2len,
|
unsigned long e2len,
|
||||||
const unsigned char *coeffdata,
|
const unsigned char *coeffdata,
|
||||||
unsigned long coefflen)
|
unsigned long coefflen)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
libssh2_rsa_ctx *ctx;
|
libssh2_rsa_ctx *ctx;
|
||||||
@@ -391,9 +391,9 @@ _libssh2_mbedtls_rsa_new(libssh2_rsa_ctx **rsa,
|
|||||||
|
|
||||||
int
|
int
|
||||||
_libssh2_mbedtls_rsa_new_private(libssh2_rsa_ctx **rsa,
|
_libssh2_mbedtls_rsa_new_private(libssh2_rsa_ctx **rsa,
|
||||||
LIBSSH2_SESSION *session,
|
LIBSSH2_SESSION *session,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
const unsigned char *passphrase)
|
const unsigned char *passphrase)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
mbedtls_pk_context pkey;
|
mbedtls_pk_context pkey;
|
||||||
@@ -434,10 +434,10 @@ _libssh2_mbedtls_rsa_new_private(libssh2_rsa_ctx **rsa,
|
|||||||
|
|
||||||
int
|
int
|
||||||
_libssh2_mbedtls_rsa_new_private_frommemory(libssh2_rsa_ctx **rsa,
|
_libssh2_mbedtls_rsa_new_private_frommemory(libssh2_rsa_ctx **rsa,
|
||||||
LIBSSH2_SESSION *session,
|
LIBSSH2_SESSION *session,
|
||||||
const char *filedata,
|
const char *filedata,
|
||||||
size_t filedata_len,
|
size_t filedata_len,
|
||||||
unsigned const char *passphrase)
|
unsigned const char *passphrase)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
mbedtls_pk_context pkey;
|
mbedtls_pk_context pkey;
|
||||||
@@ -492,10 +492,10 @@ _libssh2_mbedtls_rsa_new_private_frommemory(libssh2_rsa_ctx **rsa,
|
|||||||
|
|
||||||
int
|
int
|
||||||
_libssh2_mbedtls_rsa_sha2_verify(libssh2_rsa_ctx * rsactx,
|
_libssh2_mbedtls_rsa_sha2_verify(libssh2_rsa_ctx * rsactx,
|
||||||
size_t hash_len,
|
size_t hash_len,
|
||||||
const unsigned char *sig,
|
const unsigned char *sig,
|
||||||
unsigned long sig_len,
|
unsigned long sig_len,
|
||||||
const unsigned char *m, unsigned long m_len)
|
const unsigned char *m, unsigned long m_len)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
int md_type;
|
int md_type;
|
||||||
@@ -544,9 +544,9 @@ _libssh2_mbedtls_rsa_sha2_verify(libssh2_rsa_ctx * rsactx,
|
|||||||
|
|
||||||
int
|
int
|
||||||
_libssh2_mbedtls_rsa_sha1_verify(libssh2_rsa_ctx * rsactx,
|
_libssh2_mbedtls_rsa_sha1_verify(libssh2_rsa_ctx * rsactx,
|
||||||
const unsigned char *sig,
|
const unsigned char *sig,
|
||||||
unsigned long sig_len,
|
unsigned long sig_len,
|
||||||
const unsigned char *m, unsigned long m_len)
|
const unsigned char *m, unsigned long m_len)
|
||||||
{
|
{
|
||||||
return _libssh2_mbedtls_rsa_sha2_verify(rsactx, SHA_DIGEST_LENGTH,
|
return _libssh2_mbedtls_rsa_sha2_verify(rsactx, SHA_DIGEST_LENGTH,
|
||||||
sig, sig_len, m, m_len);
|
sig, sig_len, m, m_len);
|
||||||
@@ -554,11 +554,11 @@ _libssh2_mbedtls_rsa_sha1_verify(libssh2_rsa_ctx * rsactx,
|
|||||||
|
|
||||||
int
|
int
|
||||||
_libssh2_mbedtls_rsa_sha2_sign(LIBSSH2_SESSION *session,
|
_libssh2_mbedtls_rsa_sha2_sign(LIBSSH2_SESSION *session,
|
||||||
libssh2_rsa_ctx *rsa,
|
libssh2_rsa_ctx *rsa,
|
||||||
const unsigned char *hash,
|
const unsigned char *hash,
|
||||||
size_t hash_len,
|
size_t hash_len,
|
||||||
unsigned char **signature,
|
unsigned char **signature,
|
||||||
size_t *signature_len)
|
size_t *signature_len)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
unsigned char *sig;
|
unsigned char *sig;
|
||||||
@@ -611,13 +611,14 @@ _libssh2_mbedtls_rsa_sha2_sign(LIBSSH2_SESSION *session,
|
|||||||
|
|
||||||
int
|
int
|
||||||
_libssh2_mbedtls_rsa_sha1_sign(LIBSSH2_SESSION * session,
|
_libssh2_mbedtls_rsa_sha1_sign(LIBSSH2_SESSION * session,
|
||||||
libssh2_rsa_ctx * rsactx,
|
libssh2_rsa_ctx * rsactx,
|
||||||
const unsigned char *hash,
|
const unsigned char *hash,
|
||||||
size_t hash_len,
|
size_t hash_len,
|
||||||
unsigned char **signature, size_t *signature_len)
|
unsigned char **signature,
|
||||||
|
size_t *signature_len)
|
||||||
{
|
{
|
||||||
return _libssh2_mbedtls_rsa_sha2_sign(session, rsactx, hash, hash_len,
|
return _libssh2_mbedtls_rsa_sha2_sign(session, rsactx, hash, hash_len,
|
||||||
signature, signature_len);
|
signature, signature_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -629,8 +630,8 @@ _libssh2_mbedtls_rsa_free(libssh2_rsa_ctx *ctx)
|
|||||||
|
|
||||||
static unsigned char *
|
static unsigned char *
|
||||||
gen_publickey_from_rsa(LIBSSH2_SESSION *session,
|
gen_publickey_from_rsa(LIBSSH2_SESSION *session,
|
||||||
mbedtls_rsa_context *rsa,
|
mbedtls_rsa_context *rsa,
|
||||||
size_t *keylen)
|
size_t *keylen)
|
||||||
{
|
{
|
||||||
uint32_t e_bytes, n_bytes;
|
uint32_t e_bytes, n_bytes;
|
||||||
uint32_t len;
|
uint32_t len;
|
||||||
@@ -670,11 +671,11 @@ gen_publickey_from_rsa(LIBSSH2_SESSION *session,
|
|||||||
|
|
||||||
static int
|
static int
|
||||||
_libssh2_mbedtls_pub_priv_key(LIBSSH2_SESSION *session,
|
_libssh2_mbedtls_pub_priv_key(LIBSSH2_SESSION *session,
|
||||||
unsigned char **method,
|
unsigned char **method,
|
||||||
size_t *method_len,
|
size_t *method_len,
|
||||||
unsigned char **pubkeydata,
|
unsigned char **pubkeydata,
|
||||||
size_t *pubkeydata_len,
|
size_t *pubkeydata_len,
|
||||||
mbedtls_pk_context *pkey)
|
mbedtls_pk_context *pkey)
|
||||||
{
|
{
|
||||||
unsigned char *key = NULL, *mth = NULL;
|
unsigned char *key = NULL, *mth = NULL;
|
||||||
size_t keylen = 0, mthlen = 0;
|
size_t keylen = 0, mthlen = 0;
|
||||||
@@ -722,12 +723,12 @@ _libssh2_mbedtls_pub_priv_key(LIBSSH2_SESSION *session,
|
|||||||
|
|
||||||
int
|
int
|
||||||
_libssh2_mbedtls_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
_libssh2_mbedtls_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
||||||
unsigned char **method,
|
unsigned char **method,
|
||||||
size_t *method_len,
|
size_t *method_len,
|
||||||
unsigned char **pubkeydata,
|
unsigned char **pubkeydata,
|
||||||
size_t *pubkeydata_len,
|
size_t *pubkeydata_len,
|
||||||
const char *privatekey,
|
const char *privatekey,
|
||||||
const char *passphrase)
|
const char *passphrase)
|
||||||
{
|
{
|
||||||
mbedtls_pk_context pkey;
|
mbedtls_pk_context pkey;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
@@ -748,7 +749,7 @@ _libssh2_mbedtls_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = _libssh2_mbedtls_pub_priv_key(session, method, method_len,
|
ret = _libssh2_mbedtls_pub_priv_key(session, method, method_len,
|
||||||
pubkeydata, pubkeydata_len, &pkey);
|
pubkeydata, pubkeydata_len, &pkey);
|
||||||
|
|
||||||
mbedtls_pk_free(&pkey);
|
mbedtls_pk_free(&pkey);
|
||||||
|
|
||||||
@@ -757,13 +758,13 @@ _libssh2_mbedtls_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
|||||||
|
|
||||||
int
|
int
|
||||||
_libssh2_mbedtls_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
_libssh2_mbedtls_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
||||||
unsigned char **method,
|
unsigned char **method,
|
||||||
size_t *method_len,
|
size_t *method_len,
|
||||||
unsigned char **pubkeydata,
|
unsigned char **pubkeydata,
|
||||||
size_t *pubkeydata_len,
|
size_t *pubkeydata_len,
|
||||||
const char *privatekeydata,
|
const char *privatekeydata,
|
||||||
size_t privatekeydata_len,
|
size_t privatekeydata_len,
|
||||||
const char *passphrase)
|
const char *passphrase)
|
||||||
{
|
{
|
||||||
mbedtls_pk_context pkey;
|
mbedtls_pk_context pkey;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
@@ -806,7 +807,7 @@ _libssh2_mbedtls_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ret = _libssh2_mbedtls_pub_priv_key(session, method, method_len,
|
ret = _libssh2_mbedtls_pub_priv_key(session, method, method_len,
|
||||||
pubkeydata, pubkeydata_len, &pkey);
|
pubkeydata, pubkeydata_len, &pkey);
|
||||||
|
|
||||||
mbedtls_pk_free(&pkey);
|
mbedtls_pk_free(&pkey);
|
||||||
|
|
||||||
|
|||||||
16
src/misc.c
16
src/misc.c
@@ -162,7 +162,7 @@ _libssh2_recv(libssh2_socket_t sock, void *buffer, size_t length,
|
|||||||
{
|
{
|
||||||
ssize_t rc;
|
ssize_t rc;
|
||||||
|
|
||||||
(void) abstract;
|
(void)abstract;
|
||||||
|
|
||||||
rc = recv(sock, buffer, length, flags);
|
rc = recv(sock, buffer, length, flags);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@@ -195,7 +195,7 @@ _libssh2_send(libssh2_socket_t sock, const void *buffer, size_t length,
|
|||||||
{
|
{
|
||||||
ssize_t rc;
|
ssize_t rc;
|
||||||
|
|
||||||
(void) abstract;
|
(void)abstract;
|
||||||
|
|
||||||
rc = send(sock, buffer, length, flags);
|
rc = send(sock, buffer, length, flags);
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@@ -372,7 +372,7 @@ libssh2_base64_decode(LIBSSH2_SESSION *session, char **data,
|
|||||||
|
|
||||||
/* ---- Base64 Encoding/Decoding Table --- */
|
/* ---- Base64 Encoding/Decoding Table --- */
|
||||||
static const char table64[]=
|
static const char table64[]=
|
||||||
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* _libssh2_base64_encode
|
* _libssh2_base64_encode
|
||||||
@@ -545,8 +545,8 @@ _libssh2_debug_low(LIBSSH2_SESSION * session, int context, const char *format,
|
|||||||
LIBSSH2_API int
|
LIBSSH2_API int
|
||||||
libssh2_trace(LIBSSH2_SESSION * session, int bitmask)
|
libssh2_trace(LIBSSH2_SESSION * session, int bitmask)
|
||||||
{
|
{
|
||||||
(void) session;
|
(void)session;
|
||||||
(void) bitmask;
|
(void)bitmask;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -554,9 +554,9 @@ LIBSSH2_API int
|
|||||||
libssh2_trace_sethandler(LIBSSH2_SESSION *session, void *handler_context,
|
libssh2_trace_sethandler(LIBSSH2_SESSION *session, void *handler_context,
|
||||||
libssh2_trace_handler_func callback)
|
libssh2_trace_handler_func callback)
|
||||||
{
|
{
|
||||||
(void) session;
|
(void)session;
|
||||||
(void) handler_context;
|
(void)handler_context;
|
||||||
(void) callback;
|
(void)callback;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -420,9 +420,9 @@ _libssh2_ecdsa_curve_name_with_octal_new(libssh2_ecdsa_ctx ** ec_ctx,
|
|||||||
|
|
||||||
int
|
int
|
||||||
_libssh2_ecdsa_verify(libssh2_ecdsa_ctx * ctx,
|
_libssh2_ecdsa_verify(libssh2_ecdsa_ctx * ctx,
|
||||||
const unsigned char *r, size_t r_len,
|
const unsigned char *r, size_t r_len,
|
||||||
const unsigned char *s, size_t s_len,
|
const unsigned char *s, size_t s_len,
|
||||||
const unsigned char *m, size_t m_len)
|
const unsigned char *m, size_t m_len)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
EC_KEY *ec_key = (EC_KEY*)ctx;
|
EC_KEY *ec_key = (EC_KEY*)ctx;
|
||||||
@@ -491,8 +491,9 @@ _libssh2_cipher_crypt(_libssh2_cipher_ctx * ctx,
|
|||||||
unsigned char buf[EVP_MAX_BLOCK_LENGTH];
|
unsigned char buf[EVP_MAX_BLOCK_LENGTH];
|
||||||
int ret;
|
int ret;
|
||||||
int rc = 1;
|
int rc = 1;
|
||||||
(void) algo;
|
|
||||||
(void) encrypt;
|
(void)algo;
|
||||||
|
(void)encrypt;
|
||||||
|
|
||||||
#ifdef HAVE_OPAQUE_STRUCTS
|
#ifdef HAVE_OPAQUE_STRUCTS
|
||||||
ret = EVP_Cipher(*ctx, buf, block, (unsigned int) blocksize);
|
ret = EVP_Cipher(*ctx, buf, block, (unsigned int) blocksize);
|
||||||
@@ -544,7 +545,8 @@ static int
|
|||||||
passphrase_cb(char *buf, int size, int rwflag, char *passphrase)
|
passphrase_cb(char *buf, int size, int rwflag, char *passphrase)
|
||||||
{
|
{
|
||||||
int passphrase_len = (int) strlen(passphrase);
|
int passphrase_len = (int) strlen(passphrase);
|
||||||
(void) rwflag;
|
|
||||||
|
(void)rwflag;
|
||||||
|
|
||||||
if(passphrase_len > (size - 1)) {
|
if(passphrase_len > (size - 1)) {
|
||||||
passphrase_len = size - 1;
|
passphrase_len = size - 1;
|
||||||
@@ -1003,11 +1005,14 @@ _libssh2_dsa_new_private_frommemory(libssh2_dsa_ctx ** dsa,
|
|||||||
_libssh2_init_if_needed();
|
_libssh2_init_if_needed();
|
||||||
|
|
||||||
rc = read_private_key_from_memory((void **)dsa, read_dsa,
|
rc = read_private_key_from_memory((void **)dsa, read_dsa,
|
||||||
filedata, filedata_len, passphrase);
|
filedata, filedata_len,
|
||||||
|
passphrase);
|
||||||
|
|
||||||
if(rc) {
|
if(rc) {
|
||||||
rc = read_openssh_private_key_from_memory((void **)dsa, session,
|
rc = read_openssh_private_key_from_memory((void **)dsa, session,
|
||||||
"ssh-dsa", filedata, filedata_len, passphrase);
|
"ssh-dsa",
|
||||||
|
filedata, filedata_len,
|
||||||
|
passphrase);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
@@ -1298,9 +1303,10 @@ _libssh2_dsa_new_private(libssh2_dsa_ctx ** dsa,
|
|||||||
|
|
||||||
int
|
int
|
||||||
_libssh2_ecdsa_new_private_frommemory(libssh2_ecdsa_ctx ** ec_ctx,
|
_libssh2_ecdsa_new_private_frommemory(libssh2_ecdsa_ctx ** ec_ctx,
|
||||||
LIBSSH2_SESSION * session,
|
LIBSSH2_SESSION * session,
|
||||||
const char *filedata, size_t filedata_len,
|
const char *filedata,
|
||||||
unsigned const char *passphrase)
|
size_t filedata_len,
|
||||||
|
unsigned const char *passphrase)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
@@ -1310,12 +1316,14 @@ _libssh2_ecdsa_new_private_frommemory(libssh2_ecdsa_ctx ** ec_ctx,
|
|||||||
_libssh2_init_if_needed();
|
_libssh2_init_if_needed();
|
||||||
|
|
||||||
rc = read_private_key_from_memory((void **) ec_ctx, read_ec,
|
rc = read_private_key_from_memory((void **) ec_ctx, read_ec,
|
||||||
filedata, filedata_len, passphrase);
|
filedata, filedata_len,
|
||||||
|
passphrase);
|
||||||
|
|
||||||
if(rc) {
|
if(rc) {
|
||||||
rc = read_openssh_private_key_from_memory((void **)ec_ctx, session,
|
rc = read_openssh_private_key_from_memory((void **)ec_ctx, session,
|
||||||
"ssh-ecdsa", filedata,
|
"ssh-ecdsa",
|
||||||
filedata_len, passphrase);
|
filedata, filedata_len,
|
||||||
|
passphrase);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
@@ -1333,7 +1341,7 @@ int _libssh2_ecdsa_new_private_frommemory_sk(libssh2_ecdsa_ctx ** ec_ctx,
|
|||||||
{
|
{
|
||||||
int algorithm;
|
int algorithm;
|
||||||
return _libssh2_sk_pub_openssh_keyfilememory(session,
|
return _libssh2_sk_pub_openssh_keyfilememory(session,
|
||||||
(void **)ec_ctx,
|
(void **)ec_ctx,
|
||||||
"sk-ecdsa-sha2-nistp256@openssh.com",
|
"sk-ecdsa-sha2-nistp256@openssh.com",
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
@@ -1942,7 +1950,8 @@ _libssh2_ed25519_new_private_frommemory(libssh2_ed25519_ctx ** ed_ctx,
|
|||||||
if(read_private_key_from_memory((void **)&ctx,
|
if(read_private_key_from_memory((void **)&ctx,
|
||||||
(pem_read_bio_func)
|
(pem_read_bio_func)
|
||||||
&PEM_read_bio_PrivateKey,
|
&PEM_read_bio_PrivateKey,
|
||||||
filedata, filedata_len, passphrase) == 0) {
|
filedata, filedata_len,
|
||||||
|
passphrase) == 0) {
|
||||||
if(EVP_PKEY_id(ctx) != EVP_PKEY_ED25519) {
|
if(EVP_PKEY_id(ctx) != EVP_PKEY_ED25519) {
|
||||||
_libssh2_ed25519_free(ctx);
|
_libssh2_ed25519_free(ctx);
|
||||||
return _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
return _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||||
@@ -2082,7 +2091,8 @@ _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx,
|
|||||||
const BIGNUM * r;
|
const BIGNUM * r;
|
||||||
const BIGNUM * s;
|
const BIGNUM * s;
|
||||||
int r_len, s_len;
|
int r_len, s_len;
|
||||||
(void) hash_len;
|
|
||||||
|
(void)hash_len;
|
||||||
|
|
||||||
sig = DSA_do_sign(hash, SHA_DIGEST_LENGTH, dsactx);
|
sig = DSA_do_sign(hash, SHA_DIGEST_LENGTH, dsactx);
|
||||||
if(!sig) {
|
if(!sig) {
|
||||||
@@ -2121,8 +2131,8 @@ _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx,
|
|||||||
|
|
||||||
int
|
int
|
||||||
_libssh2_ecdsa_sign(LIBSSH2_SESSION * session, libssh2_ecdsa_ctx * ec_ctx,
|
_libssh2_ecdsa_sign(LIBSSH2_SESSION * session, libssh2_ecdsa_ctx * ec_ctx,
|
||||||
const unsigned char *hash, unsigned long hash_len,
|
const unsigned char *hash, unsigned long hash_len,
|
||||||
unsigned char **signature, size_t *signature_len)
|
unsigned char **signature, size_t *signature_len)
|
||||||
{
|
{
|
||||||
int r_len, s_len;
|
int r_len, s_len;
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
@@ -2448,8 +2458,8 @@ gen_publickey_from_ec_evp(LIBSSH2_SESSION *session,
|
|||||||
libssh2_curve_type type;
|
libssh2_curve_type type;
|
||||||
|
|
||||||
_libssh2_debug((session,
|
_libssh2_debug((session,
|
||||||
LIBSSH2_TRACE_AUTH,
|
LIBSSH2_TRACE_AUTH,
|
||||||
"Computing public key from EC private key envelope"));
|
"Computing public key from EC private key envelope"));
|
||||||
|
|
||||||
bn_ctx = BN_CTX_new();
|
bn_ctx = BN_CTX_new();
|
||||||
if(!bn_ctx)
|
if(!bn_ctx)
|
||||||
@@ -2473,7 +2483,7 @@ gen_publickey_from_ec_evp(LIBSSH2_SESSION *session,
|
|||||||
method_buf = LIBSSH2_ALLOC(session, *method_len);
|
method_buf = LIBSSH2_ALLOC(session, *method_len);
|
||||||
if(!method_buf) {
|
if(!method_buf) {
|
||||||
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
return _libssh2_error(session, LIBSSH2_ERROR_ALLOC,
|
||||||
"out of memory");
|
"out of memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(is_sk)
|
if(is_sk)
|
||||||
@@ -2486,8 +2496,8 @@ gen_publickey_from_ec_evp(LIBSSH2_SESSION *session,
|
|||||||
memcpy(method_buf, "ecdsa-sha2-nistp521", *method_len);
|
memcpy(method_buf, "ecdsa-sha2-nistp521", *method_len);
|
||||||
else {
|
else {
|
||||||
_libssh2_debug((session,
|
_libssh2_debug((session,
|
||||||
LIBSSH2_TRACE_ERROR,
|
LIBSSH2_TRACE_ERROR,
|
||||||
"Unsupported EC private key type"));
|
"Unsupported EC private key type"));
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto clean_exit;
|
goto clean_exit;
|
||||||
}
|
}
|
||||||
@@ -2805,7 +2815,7 @@ _libssh2_ecdsa_new_openssh_private(libssh2_ecdsa_ctx ** ec_ctx,
|
|||||||
|
|
||||||
if(!session) {
|
if(!session) {
|
||||||
_libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
_libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||||
"Session is required");
|
"Session is required");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2867,7 +2877,7 @@ _libssh2_ecdsa_new_openssh_private_sk(libssh2_ecdsa_ctx ** ec_ctx,
|
|||||||
|
|
||||||
if(!session) {
|
if(!session) {
|
||||||
_libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
_libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||||
"Session is required");
|
"Session is required");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3551,7 +3561,7 @@ _libssh2_pub_priv_openssh_keyfilememory(LIBSSH2_SESSION *session,
|
|||||||
method, method_len,
|
method, method_len,
|
||||||
pubkeydata,
|
pubkeydata,
|
||||||
pubkeydata_len,
|
pubkeydata_len,
|
||||||
(libssh2_rsa_ctx**)key_ctx);
|
(libssh2_rsa_ctx**)key_ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -3559,10 +3569,10 @@ _libssh2_pub_priv_openssh_keyfilememory(LIBSSH2_SESSION *session,
|
|||||||
if(strcmp("ssh-dss", (const char *)buf) == 0) {
|
if(strcmp("ssh-dss", (const char *)buf) == 0) {
|
||||||
if(!key_type || strcmp("ssh-dss", key_type) == 0) {
|
if(!key_type || strcmp("ssh-dss", key_type) == 0) {
|
||||||
rc = gen_publickey_from_dsa_openssh_priv_data(session, decrypted,
|
rc = gen_publickey_from_dsa_openssh_priv_data(session, decrypted,
|
||||||
method, method_len,
|
method, method_len,
|
||||||
pubkeydata,
|
pubkeydata,
|
||||||
pubkeydata_len,
|
pubkeydata_len,
|
||||||
(libssh2_dsa_ctx**)key_ctx);
|
(libssh2_dsa_ctx**)key_ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -3578,7 +3588,7 @@ _libssh2_pub_priv_openssh_keyfilememory(LIBSSH2_SESSION *session,
|
|||||||
NULL,
|
NULL,
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
NULL,
|
NULL,
|
||||||
(libssh2_ecdsa_ctx**)key_ctx);
|
(libssh2_ecdsa_ctx**)key_ctx);
|
||||||
}
|
}
|
||||||
else if(_libssh2_ecdsa_curve_type_from_name((const char *)buf, &type)
|
else if(_libssh2_ecdsa_curve_type_from_name((const char *)buf, &type)
|
||||||
== 0) {
|
== 0) {
|
||||||
@@ -3588,7 +3598,7 @@ _libssh2_pub_priv_openssh_keyfilememory(LIBSSH2_SESSION *session,
|
|||||||
method, method_len,
|
method, method_len,
|
||||||
pubkeydata,
|
pubkeydata,
|
||||||
pubkeydata_len,
|
pubkeydata_len,
|
||||||
(libssh2_ecdsa_ctx**)key_ctx);
|
(libssh2_ecdsa_ctx**)key_ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3687,7 +3697,7 @@ _libssh2_sk_pub_openssh_keyfilememory(LIBSSH2_SESSION *session,
|
|||||||
application,
|
application,
|
||||||
key_handle,
|
key_handle,
|
||||||
handle_len,
|
handle_len,
|
||||||
(libssh2_ecdsa_ctx**)key_ctx);
|
(libssh2_ecdsa_ctx**)key_ctx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -3757,7 +3767,7 @@ _libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session,
|
|||||||
pubkeydata_len,
|
pubkeydata_len,
|
||||||
privatekeydata,
|
privatekeydata,
|
||||||
privatekeydata_len,
|
privatekeydata_len,
|
||||||
(unsigned const char *)passphrase);
|
(unsigned const char *)passphrase);
|
||||||
if(st)
|
if(st)
|
||||||
return st;
|
return st;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
10
src/packet.c
10
src/packet.c
@@ -1240,8 +1240,8 @@ _libssh2_packet_require(LIBSSH2_SESSION * session, unsigned char packet_type,
|
|||||||
{
|
{
|
||||||
if(state->start == 0) {
|
if(state->start == 0) {
|
||||||
if(_libssh2_packet_ask(session, packet_type, data, data_len,
|
if(_libssh2_packet_ask(session, packet_type, data, data_len,
|
||||||
match_ofs, match_buf,
|
match_ofs, match_buf,
|
||||||
match_len) == 0) {
|
match_len) == 0) {
|
||||||
/* A packet was available in the packet brigade */
|
/* A packet was available in the packet brigade */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1305,7 +1305,7 @@ _libssh2_packet_burn(LIBSSH2_SESSION * session,
|
|||||||
all_packets[254] = 0;
|
all_packets[254] = 0;
|
||||||
|
|
||||||
if(_libssh2_packet_askv(session, all_packets, &data, &data_len, 0,
|
if(_libssh2_packet_askv(session, all_packets, &data, &data_len, 0,
|
||||||
NULL, 0) == 0) {
|
NULL, 0) == 0) {
|
||||||
i = data[0];
|
i = data[0];
|
||||||
/* A packet was available in the packet brigade, burn it */
|
/* A packet was available in the packet brigade, burn it */
|
||||||
LIBSSH2_FREE(session, data);
|
LIBSSH2_FREE(session, data);
|
||||||
@@ -1334,7 +1334,7 @@ _libssh2_packet_burn(LIBSSH2_SESSION * session,
|
|||||||
/* Be lazy, let packet_ask pull it out of the brigade */
|
/* Be lazy, let packet_ask pull it out of the brigade */
|
||||||
if(0 ==
|
if(0 ==
|
||||||
_libssh2_packet_ask(session, (unsigned char)ret,
|
_libssh2_packet_ask(session, (unsigned char)ret,
|
||||||
&data, &data_len, 0, NULL, 0)) {
|
&data, &data_len, 0, NULL, 0)) {
|
||||||
/* Smoke 'em if you got 'em */
|
/* Smoke 'em if you got 'em */
|
||||||
LIBSSH2_FREE(session, data);
|
LIBSSH2_FREE(session, data);
|
||||||
*state = libssh2_NB_state_idle;
|
*state = libssh2_NB_state_idle;
|
||||||
@@ -1363,7 +1363,7 @@ _libssh2_packet_requirev(LIBSSH2_SESSION *session,
|
|||||||
packet_requirev_state_t * state)
|
packet_requirev_state_t * state)
|
||||||
{
|
{
|
||||||
if(_libssh2_packet_askv(session, packet_types, data, data_len, match_ofs,
|
if(_libssh2_packet_askv(session, packet_types, data, data_len, match_ofs,
|
||||||
match_buf, match_len) == 0) {
|
match_buf, match_len) == 0) {
|
||||||
/* One of the packets listed was available in the packet brigade */
|
/* One of the packets listed was available in the packet brigade */
|
||||||
state->start = 0;
|
state->start = 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
12
src/pem.c
12
src/pem.c
@@ -427,7 +427,7 @@ _libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session,
|
|||||||
if(_libssh2_get_string(&decoded, &kdfname, &tmp_len) ||
|
if(_libssh2_get_string(&decoded, &kdfname, &tmp_len) ||
|
||||||
tmp_len == 0) {
|
tmp_len == 0) {
|
||||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||||
"kdfname is missing");
|
"kdfname is missing");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -480,7 +480,7 @@ _libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session,
|
|||||||
|
|
||||||
if(_libssh2_get_string(&decoded, &buf, &tmp_len) || tmp_len == 0) {
|
if(_libssh2_get_string(&decoded, &buf, &tmp_len) || tmp_len == 0) {
|
||||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||||
"Private key data not found");
|
"Private key data not found");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -505,7 +505,7 @@ _libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session,
|
|||||||
|
|
||||||
if(!method) {
|
if(!method) {
|
||||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||||
"No supported cipher found");
|
"No supported cipher found");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -522,7 +522,7 @@ _libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session,
|
|||||||
key = LIBSSH2_CALLOC(session, total_len);
|
key = LIBSSH2_CALLOC(session, total_len);
|
||||||
if(!key) {
|
if(!key) {
|
||||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||||
"Could not alloc key");
|
"Could not alloc key");
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -547,7 +547,7 @@ _libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ret = _libssh2_error(session, LIBSSH2_ERROR_KEYFILE_AUTH_FAILED,
|
ret = _libssh2_error(session, LIBSSH2_ERROR_KEYFILE_AUTH_FAILED,
|
||||||
"bcrypted without passphrase");
|
"bcrypted without passphrase");
|
||||||
LIBSSH2_FREE(session, key);
|
LIBSSH2_FREE(session, key);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@@ -574,7 +574,7 @@ _libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session,
|
|||||||
|
|
||||||
/* Initialize the decryption */
|
/* Initialize the decryption */
|
||||||
if(method->init(session, method, iv_part, &free_iv, key_part,
|
if(method->init(session, method, iv_part, &free_iv, key_part,
|
||||||
&free_secret, 0, &abstract)) {
|
&free_secret, 0, &abstract)) {
|
||||||
ret = LIBSSH2_ERROR_DECRYPT;
|
ret = LIBSSH2_ERROR_DECRYPT;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/scp.c
10
src/scp.c
@@ -282,7 +282,7 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, libssh2_struct_stat * sb)
|
|||||||
session->scpRecv_atime = 0;
|
session->scpRecv_atime = 0;
|
||||||
|
|
||||||
session->scpRecv_command_len =
|
session->scpRecv_command_len =
|
||||||
_libssh2_shell_quotedsize(path) + sizeof("scp -f ") + (sb?1:0);
|
_libssh2_shell_quotedsize(path) + sizeof("scp -f ") + (sb ? 1 : 0);
|
||||||
|
|
||||||
session->scpRecv_command =
|
session->scpRecv_command =
|
||||||
LIBSSH2_ALLOC(session, session->scpRecv_command_len);
|
LIBSSH2_ALLOC(session, session->scpRecv_command_len);
|
||||||
@@ -296,7 +296,7 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, libssh2_struct_stat * sb)
|
|||||||
|
|
||||||
snprintf((char *)session->scpRecv_command,
|
snprintf((char *)session->scpRecv_command,
|
||||||
session->scpRecv_command_len,
|
session->scpRecv_command_len,
|
||||||
"scp -%sf ", sb?"p":"");
|
"scp -%sf ", sb ? "p" : "");
|
||||||
|
|
||||||
cmd_len = strlen((char *)session->scpRecv_command);
|
cmd_len = strlen((char *)session->scpRecv_command);
|
||||||
cmd_len += shell_quotearg(path,
|
cmd_len += shell_quotearg(path,
|
||||||
@@ -384,7 +384,7 @@ scp_recv(LIBSSH2_SESSION * session, const char *path, libssh2_struct_stat * sb)
|
|||||||
if((session->scpRecv_state == libssh2_NB_state_sent2)
|
if((session->scpRecv_state == libssh2_NB_state_sent2)
|
||||||
|| (session->scpRecv_state == libssh2_NB_state_sent3)) {
|
|| (session->scpRecv_state == libssh2_NB_state_sent3)) {
|
||||||
while(sb && (session->scpRecv_response_len <
|
while(sb && (session->scpRecv_response_len <
|
||||||
LIBSSH2_SCP_RESPONSE_BUFLEN)) {
|
LIBSSH2_SCP_RESPONSE_BUFLEN)) {
|
||||||
unsigned char *s, *p;
|
unsigned char *s, *p;
|
||||||
|
|
||||||
if(session->scpRecv_state == libssh2_NB_state_sent2) {
|
if(session->scpRecv_state == libssh2_NB_state_sent2) {
|
||||||
@@ -843,7 +843,7 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
|||||||
if(session->scpSend_state == libssh2_NB_state_idle) {
|
if(session->scpSend_state == libssh2_NB_state_idle) {
|
||||||
session->scpSend_command_len =
|
session->scpSend_command_len =
|
||||||
_libssh2_shell_quotedsize(path) + sizeof("scp -t ") +
|
_libssh2_shell_quotedsize(path) + sizeof("scp -t ") +
|
||||||
((mtime || atime)?1:0);
|
((mtime || atime) ? 1 : 0);
|
||||||
|
|
||||||
session->scpSend_command =
|
session->scpSend_command =
|
||||||
LIBSSH2_ALLOC(session, session->scpSend_command_len);
|
LIBSSH2_ALLOC(session, session->scpSend_command_len);
|
||||||
@@ -857,7 +857,7 @@ scp_send(LIBSSH2_SESSION * session, const char *path, int mode,
|
|||||||
|
|
||||||
snprintf((char *)session->scpSend_command,
|
snprintf((char *)session->scpSend_command,
|
||||||
session->scpSend_command_len,
|
session->scpSend_command_len,
|
||||||
"scp -%st ", (mtime || atime)?"p":"");
|
"scp -%st ", (mtime || atime) ? "p" : "");
|
||||||
|
|
||||||
cmd_len = strlen((char *)session->scpSend_command);
|
cmd_len = strlen((char *)session->scpSend_command);
|
||||||
cmd_len += shell_quotearg(path,
|
cmd_len += shell_quotearg(path,
|
||||||
|
|||||||
@@ -75,7 +75,7 @@
|
|||||||
static
|
static
|
||||||
LIBSSH2_ALLOC_FUNC(libssh2_default_alloc)
|
LIBSSH2_ALLOC_FUNC(libssh2_default_alloc)
|
||||||
{
|
{
|
||||||
(void) abstract;
|
(void)abstract;
|
||||||
return malloc(count);
|
return malloc(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,7 +84,7 @@ LIBSSH2_ALLOC_FUNC(libssh2_default_alloc)
|
|||||||
static
|
static
|
||||||
LIBSSH2_FREE_FUNC(libssh2_default_free)
|
LIBSSH2_FREE_FUNC(libssh2_default_free)
|
||||||
{
|
{
|
||||||
(void) abstract;
|
(void)abstract;
|
||||||
free(ptr);
|
free(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ LIBSSH2_FREE_FUNC(libssh2_default_free)
|
|||||||
static
|
static
|
||||||
LIBSSH2_REALLOC_FUNC(libssh2_default_realloc)
|
LIBSSH2_REALLOC_FUNC(libssh2_default_realloc)
|
||||||
{
|
{
|
||||||
(void) abstract;
|
(void)abstract;
|
||||||
return realloc(ptr, count);
|
return realloc(ptr, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,15 +121,15 @@ banner_receive(LIBSSH2_SESSION * session)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while((banner_len < sizeof(session->banner_TxRx_banner)) &&
|
while((banner_len < sizeof(session->banner_TxRx_banner)) &&
|
||||||
((banner_len == 0)
|
((banner_len == 0)
|
||||||
|| (session->banner_TxRx_banner[banner_len - 1] != '\n'))) {
|
|| (session->banner_TxRx_banner[banner_len - 1] != '\n'))) {
|
||||||
char c = '\0';
|
char c = '\0';
|
||||||
|
|
||||||
/* no incoming block yet! */
|
/* no incoming block yet! */
|
||||||
session->socket_block_directions &= ~LIBSSH2_SESSION_BLOCK_INBOUND;
|
session->socket_block_directions &= ~LIBSSH2_SESSION_BLOCK_INBOUND;
|
||||||
|
|
||||||
ret = LIBSSH2_RECV(session, &c, 1,
|
ret = LIBSSH2_RECV(session, &c, 1,
|
||||||
LIBSSH2_SOCKET_RECV_FLAGS(session));
|
LIBSSH2_SOCKET_RECV_FLAGS(session));
|
||||||
if(ret < 0) {
|
if(ret < 0) {
|
||||||
if(session->api_block_mode || (ret != -EAGAIN))
|
if(session->api_block_mode || (ret != -EAGAIN))
|
||||||
/* ignore EAGAIN when non-blocking */
|
/* ignore EAGAIN when non-blocking */
|
||||||
@@ -174,8 +174,8 @@ banner_receive(LIBSSH2_SESSION * session)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while(banner_len &&
|
while(banner_len &&
|
||||||
((session->banner_TxRx_banner[banner_len - 1] == '\n') ||
|
((session->banner_TxRx_banner[banner_len - 1] == '\n') ||
|
||||||
(session->banner_TxRx_banner[banner_len - 1] == '\r'))) {
|
(session->banner_TxRx_banner[banner_len - 1] == '\r'))) {
|
||||||
banner_len--;
|
banner_len--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -249,9 +249,9 @@ banner_send(LIBSSH2_SESSION * session)
|
|||||||
session->socket_block_directions &= ~LIBSSH2_SESSION_BLOCK_OUTBOUND;
|
session->socket_block_directions &= ~LIBSSH2_SESSION_BLOCK_OUTBOUND;
|
||||||
|
|
||||||
ret = LIBSSH2_SEND(session,
|
ret = LIBSSH2_SEND(session,
|
||||||
banner + session->banner_TxRx_total_send,
|
banner + session->banner_TxRx_total_send,
|
||||||
banner_len - session->banner_TxRx_total_send,
|
banner_len - session->banner_TxRx_total_send,
|
||||||
LIBSSH2_SOCKET_SEND_FLAGS(session));
|
LIBSSH2_SOCKET_SEND_FLAGS(session));
|
||||||
if(ret < 0)
|
if(ret < 0)
|
||||||
_libssh2_debug((session, LIBSSH2_TRACE_SOCKET,
|
_libssh2_debug((session, LIBSSH2_TRACE_SOCKET,
|
||||||
"Error sending %d bytes: %d",
|
"Error sending %d bytes: %d",
|
||||||
@@ -414,7 +414,7 @@ get_socket_nonblocking(libssh2_socket_t sockfd)
|
|||||||
size_t size = sizeof(int);
|
size_t size = sizeof(int);
|
||||||
|
|
||||||
callstat = getsockopt(sockfd, SOL_SOCKET, SO_STATE,
|
callstat = getsockopt(sockfd, SOL_SOCKET, SO_STATE,
|
||||||
(char *)&sockstat, &size);
|
(char *)&sockstat, &size);
|
||||||
if(callstat == -1) {
|
if(callstat == -1) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1428,7 +1428,7 @@ _libssh2_session_set_blocking(LIBSSH2_SESSION *session, int blocking)
|
|||||||
{
|
{
|
||||||
int bl = session->api_block_mode;
|
int bl = session->api_block_mode;
|
||||||
_libssh2_debug((session, LIBSSH2_TRACE_CONN,
|
_libssh2_debug((session, LIBSSH2_TRACE_CONN,
|
||||||
"Setting blocking mode %s", blocking?"ON":"OFF"));
|
"Setting blocking mode %s", blocking ? "ON" : "OFF"));
|
||||||
session->api_block_mode = blocking;
|
session->api_block_mode = blocking;
|
||||||
|
|
||||||
return bl;
|
return bl;
|
||||||
@@ -1442,7 +1442,7 @@ _libssh2_session_set_blocking(LIBSSH2_SESSION *session, int blocking)
|
|||||||
LIBSSH2_API void
|
LIBSSH2_API void
|
||||||
libssh2_session_set_blocking(LIBSSH2_SESSION * session, int blocking)
|
libssh2_session_set_blocking(LIBSSH2_SESSION * session, int blocking)
|
||||||
{
|
{
|
||||||
(void) _libssh2_session_set_blocking(session, blocking);
|
(void)_libssh2_session_set_blocking(session, blocking);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* libssh2_session_get_blocking
|
/* libssh2_session_get_blocking
|
||||||
|
|||||||
18
src/sftp.c
18
src/sftp.c
@@ -573,7 +573,7 @@ sftp_packet_requirev(LIBSSH2_SFTP *sftp, int num_valid_responses,
|
|||||||
while(sftp->channel->session->socket_state == LIBSSH2_SOCKET_CONNECTED) {
|
while(sftp->channel->session->socket_state == LIBSSH2_SOCKET_CONNECTED) {
|
||||||
for(i = 0; i < num_valid_responses; i++) {
|
for(i = 0; i < num_valid_responses; i++) {
|
||||||
if(sftp_packet_ask(sftp, valid_responses[i], request_id,
|
if(sftp_packet_ask(sftp, valid_responses[i], request_id,
|
||||||
data, data_len) == 0) {
|
data, data_len) == 0) {
|
||||||
/*
|
/*
|
||||||
* Set to zero before all returns to say
|
* Set to zero before all returns to say
|
||||||
* the timeout is not active
|
* the timeout is not active
|
||||||
@@ -741,8 +741,8 @@ LIBSSH2_CHANNEL_CLOSE_FUNC(libssh2_sftp_dtor)
|
|||||||
{
|
{
|
||||||
LIBSSH2_SFTP *sftp = (LIBSSH2_SFTP *) (*channel_abstract);
|
LIBSSH2_SFTP *sftp = (LIBSSH2_SFTP *) (*channel_abstract);
|
||||||
|
|
||||||
(void) session_abstract;
|
(void)session_abstract;
|
||||||
(void) channel;
|
(void)channel;
|
||||||
|
|
||||||
/* Free the partial packet storage for sftp_packet_read */
|
/* Free the partial packet storage for sftp_packet_read */
|
||||||
if(sftp->partial_packet) {
|
if(sftp->partial_packet) {
|
||||||
@@ -971,7 +971,7 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session)
|
|||||||
|
|
||||||
sftp_init_error:
|
sftp_init_error:
|
||||||
while(_libssh2_channel_free(session->sftpInit_channel) ==
|
while(_libssh2_channel_free(session->sftpInit_channel) ==
|
||||||
LIBSSH2_ERROR_EAGAIN);
|
LIBSSH2_ERROR_EAGAIN);
|
||||||
session->sftpInit_channel = NULL;
|
session->sftpInit_channel = NULL;
|
||||||
if(session->sftpInit_sftp) {
|
if(session->sftpInit_sftp) {
|
||||||
LIBSSH2_FREE(session, session->sftpInit_sftp);
|
LIBSSH2_FREE(session, session->sftpInit_sftp);
|
||||||
@@ -1107,7 +1107,7 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename,
|
|||||||
};
|
};
|
||||||
unsigned char *s;
|
unsigned char *s;
|
||||||
ssize_t rc;
|
ssize_t rc;
|
||||||
int open_file = (open_type == LIBSSH2_SFTP_OPENFILE)?1:0;
|
int open_file = (open_type == LIBSSH2_SFTP_OPENFILE) ? 1 : 0;
|
||||||
|
|
||||||
if(sftp->open_state == libssh2_NB_state_idle) {
|
if(sftp->open_state == libssh2_NB_state_idle) {
|
||||||
sftp->last_errno = LIBSSH2_FX_OK;
|
sftp->last_errno = LIBSSH2_FX_OK;
|
||||||
@@ -2059,8 +2059,8 @@ static ssize_t sftp_write(LIBSSH2_SFTP_HANDLE *handle, const char *buffer,
|
|||||||
acked but we haven't been able to return as such yet, so we will
|
acked but we haven't been able to return as such yet, so we will
|
||||||
get that data as well passed in here again.
|
get that data as well passed in here again.
|
||||||
*/
|
*/
|
||||||
already = (size_t) (handle->u.file.offset_sent -
|
already = (size_t)(handle->u.file.offset_sent -
|
||||||
handle->u.file.offset)+
|
handle->u.file.offset)+
|
||||||
handle->u.file.acked;
|
handle->u.file.acked;
|
||||||
|
|
||||||
if(count >= already) {
|
if(count >= already) {
|
||||||
@@ -2839,8 +2839,8 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename,
|
|||||||
size_t data_len = 0;
|
size_t data_len = 0;
|
||||||
int retcode;
|
int retcode;
|
||||||
uint32_t packet_len =
|
uint32_t packet_len =
|
||||||
source_filename_len + dest_filename_len + 17 + (sftp->version >=
|
source_filename_len + dest_filename_len + 17 +
|
||||||
5 ? 4 : 0);
|
(sftp->version >= 5 ? 4 : 0);
|
||||||
/* packet_len(4) + packet_type(1) + request_id(4) +
|
/* packet_len(4) + packet_type(1) + request_id(4) +
|
||||||
source_filename_len(4) + dest_filename_len(4) + flags(4){SFTP5+) */
|
source_filename_len(4) + dest_filename_len(4) + flags(4){SFTP5+) */
|
||||||
unsigned char *data = NULL;
|
unsigned char *data = NULL;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ struct sftp_zombie_requests {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#ifndef MIN
|
#ifndef MIN
|
||||||
#define MIN(x,y) ((x)<(y)?(x):(y))
|
#define MIN(x,y) ((x) < (y) ? (x) : (y))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct _LIBSSH2_SFTP_PACKET
|
struct _LIBSSH2_SFTP_PACKET
|
||||||
|
|||||||
@@ -141,7 +141,7 @@ decrypt(LIBSSH2_SESSION * session, unsigned char *source,
|
|||||||
|
|
||||||
while(len >= blocksize) {
|
while(len >= blocksize) {
|
||||||
if(session->remote.crypt->crypt(session, source, blocksize,
|
if(session->remote.crypt->crypt(session, source, blocksize,
|
||||||
&session->remote.crypt_abstract)) {
|
&session->remote.crypt_abstract)) {
|
||||||
LIBSSH2_FREE(session, p->payload);
|
LIBSSH2_FREE(session, p->payload);
|
||||||
return LIBSSH2_ERROR_DECRYPT;
|
return LIBSSH2_ERROR_DECRYPT;
|
||||||
}
|
}
|
||||||
@@ -201,11 +201,10 @@ fullpacket(LIBSSH2_SESSION * session, int encrypted /* 1 or 0 */ )
|
|||||||
session->fullpacket_payload_len -= p->padding_length;
|
session->fullpacket_payload_len -= p->padding_length;
|
||||||
|
|
||||||
/* Check for and deal with decompression */
|
/* Check for and deal with decompression */
|
||||||
compressed =
|
compressed = session->local.comp &&
|
||||||
session->local.comp &&
|
session->local.comp->compress &&
|
||||||
session->local.comp->compress &&
|
((session->state & LIBSSH2_STATE_AUTHENTICATED) ||
|
||||||
((session->state & LIBSSH2_STATE_AUTHENTICATED) ||
|
session->local.comp->use_in_auth);
|
||||||
session->local.comp->use_in_auth);
|
|
||||||
|
|
||||||
if(compressed && session->remote.comp_abstract) {
|
if(compressed && session->remote.comp_abstract) {
|
||||||
/*
|
/*
|
||||||
@@ -372,10 +371,9 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* now read a big chunk from the network into the temp buffer */
|
/* now read a big chunk from the network into the temp buffer */
|
||||||
nread =
|
nread = LIBSSH2_RECV(session, &p->buf[remainbuf],
|
||||||
LIBSSH2_RECV(session, &p->buf[remainbuf],
|
PACKETBUFSIZE - remainbuf,
|
||||||
PACKETBUFSIZE - remainbuf,
|
LIBSSH2_SOCKET_RECV_FLAGS(session));
|
||||||
LIBSSH2_SOCKET_RECV_FLAGS(session));
|
|
||||||
if(nread <= 0) {
|
if(nread <= 0) {
|
||||||
/* check if this is due to EAGAIN and return the special
|
/* check if this is due to EAGAIN and return the special
|
||||||
return code if so, error out normally otherwise */
|
return code if so, error out normally otherwise */
|
||||||
@@ -461,9 +459,8 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session)
|
|||||||
|
|
||||||
/* total_num is the number of bytes following the initial
|
/* total_num is the number of bytes following the initial
|
||||||
(5 bytes) packet length and padding length fields */
|
(5 bytes) packet length and padding length fields */
|
||||||
total_num =
|
total_num = p->packet_length - 1 +
|
||||||
p->packet_length - 1 +
|
(encrypted ? session->remote.mac->mac_len : 0);
|
||||||
(encrypted ? session->remote.mac->mac_len : 0);
|
|
||||||
|
|
||||||
/* RFC4253 section 6.1 Maximum Packet Length says:
|
/* RFC4253 section 6.1 Maximum Packet Length says:
|
||||||
*
|
*
|
||||||
@@ -658,7 +655,7 @@ send_existing(LIBSSH2_SESSION *session, const unsigned char *data,
|
|||||||
length = p->ototal_num - p->osent;
|
length = p->ototal_num - p->osent;
|
||||||
|
|
||||||
rc = LIBSSH2_SEND(session, &p->outbuf[p->osent], length,
|
rc = LIBSSH2_SEND(session, &p->outbuf[p->osent], length,
|
||||||
LIBSSH2_SOCKET_SEND_FLAGS(session));
|
LIBSSH2_SOCKET_SEND_FLAGS(session));
|
||||||
if(rc < 0)
|
if(rc < 0)
|
||||||
_libssh2_debug((session, LIBSSH2_TRACE_SOCKET,
|
_libssh2_debug((session, LIBSSH2_TRACE_SOCKET,
|
||||||
"Error sending %d bytes: %d", length, -rc));
|
"Error sending %d bytes: %d", length, -rc));
|
||||||
@@ -771,11 +768,10 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
|
|||||||
|
|
||||||
encrypted = (session->state & LIBSSH2_STATE_NEWKEYS) ? 1 : 0;
|
encrypted = (session->state & LIBSSH2_STATE_NEWKEYS) ? 1 : 0;
|
||||||
|
|
||||||
compressed =
|
compressed = session->local.comp &&
|
||||||
session->local.comp &&
|
session->local.comp->compress &&
|
||||||
session->local.comp->compress &&
|
((session->state & LIBSSH2_STATE_AUTHENTICATED) ||
|
||||||
((session->state & LIBSSH2_STATE_AUTHENTICATED) ||
|
session->local.comp->use_in_auth);
|
||||||
session->local.comp->use_in_auth);
|
|
||||||
|
|
||||||
if(encrypted && compressed && session->local.comp_abstract) {
|
if(encrypted && compressed && session->local.comp_abstract) {
|
||||||
/* the idea here is that these function must fail if the output gets
|
/* the idea here is that these function must fail if the output gets
|
||||||
@@ -892,8 +888,8 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
|
|||||||
for(i = 0; i < packet_length; i += session->local.crypt->blocksize) {
|
for(i = 0; i < packet_length; i += session->local.crypt->blocksize) {
|
||||||
unsigned char *ptr = &p->outbuf[i];
|
unsigned char *ptr = &p->outbuf[i];
|
||||||
if(session->local.crypt->crypt(session, ptr,
|
if(session->local.crypt->crypt(session, ptr,
|
||||||
session->local.crypt->blocksize,
|
session->local.crypt->blocksize,
|
||||||
&session->local.crypt_abstract))
|
&session->local.crypt_abstract))
|
||||||
return LIBSSH2_ERROR_ENCRYPT; /* encryption failure */
|
return LIBSSH2_ERROR_ENCRYPT; /* encryption failure */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -901,7 +897,7 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
|
|||||||
session->local.seqno++;
|
session->local.seqno++;
|
||||||
|
|
||||||
ret = LIBSSH2_SEND(session, p->outbuf, total_length,
|
ret = LIBSSH2_SEND(session, p->outbuf, total_length,
|
||||||
LIBSSH2_SOCKET_SEND_FLAGS(session));
|
LIBSSH2_SOCKET_SEND_FLAGS(session));
|
||||||
if(ret < 0)
|
if(ret < 0)
|
||||||
_libssh2_debug((session, LIBSSH2_TRACE_SOCKET,
|
_libssh2_debug((session, LIBSSH2_TRACE_SOCKET,
|
||||||
"Error sending %d bytes: %d", total_length, -ret));
|
"Error sending %d bytes: %d", total_length, -ret));
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ static char *userauth_list(LIBSSH2_SESSION *session, const char *username,
|
|||||||
}
|
}
|
||||||
|
|
||||||
session->userauth_list_state = libssh2_NB_state_idle;
|
session->userauth_list_state = libssh2_NB_state_idle;
|
||||||
return (char *) session->userauth_list_data;
|
return (char *)session->userauth_list_data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* libssh2_userauth_list
|
/* libssh2_userauth_list
|
||||||
@@ -276,7 +276,7 @@ libssh2_userauth_banner(LIBSSH2_SESSION *session, char **banner)
|
|||||||
LIBSSH2_API int
|
LIBSSH2_API int
|
||||||
libssh2_userauth_authenticated(LIBSSH2_SESSION * session)
|
libssh2_userauth_authenticated(LIBSSH2_SESSION * session)
|
||||||
{
|
{
|
||||||
return (session->state & LIBSSH2_STATE_AUTHENTICATED)?1:0;
|
return (session->state & LIBSSH2_STATE_AUTHENTICATED) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -610,9 +610,9 @@ memory_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
|
|||||||
sp2 = pubkey + pubkey_len;
|
sp2 = pubkey + pubkey_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(libssh2_base64_decode(session, (char **) &tmp, &tmp_len,
|
if(libssh2_base64_decode(session, (char **)&tmp, &tmp_len,
|
||||||
(const char *) sp1,
|
(const char *)sp1,
|
||||||
(unsigned int)(sp2 - sp1))) {
|
(unsigned int)(sp2 - sp1))) {
|
||||||
LIBSSH2_FREE(session, pubkey);
|
LIBSSH2_FREE(session, pubkey);
|
||||||
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
||||||
"Invalid key data, not base64 encoded");
|
"Invalid key data, not base64 encoded");
|
||||||
@@ -715,9 +715,9 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method,
|
|||||||
sp2 = pubkey + pubkey_len;
|
sp2 = pubkey + pubkey_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(libssh2_base64_decode(session, (char **) &tmp, &tmp_len,
|
if(libssh2_base64_decode(session, (char **)&tmp, &tmp_len,
|
||||||
(const char *) sp1,
|
(const char *)sp1,
|
||||||
(unsigned int)(sp2 - sp1))) {
|
(unsigned int)(sp2 - sp1))) {
|
||||||
LIBSSH2_FREE(session, pubkey);
|
LIBSSH2_FREE(session, pubkey);
|
||||||
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
return _libssh2_error(session, LIBSSH2_ERROR_FILE,
|
||||||
"Invalid key data, not base64 encoded");
|
"Invalid key data, not base64 encoded");
|
||||||
@@ -843,7 +843,7 @@ sign_frommemory(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len,
|
|||||||
datavec.iov_len = data_len;
|
datavec.iov_len = data_len;
|
||||||
|
|
||||||
if(privkeyobj->signv(session, sig, sig_len, 1, &datavec,
|
if(privkeyobj->signv(session, sig, sig_len, 1, &datavec,
|
||||||
&hostkey_abstract)) {
|
&hostkey_abstract)) {
|
||||||
if(privkeyobj->dtor) {
|
if(privkeyobj->dtor) {
|
||||||
privkeyobj->dtor(session, &hostkey_abstract);
|
privkeyobj->dtor(session, &hostkey_abstract);
|
||||||
}
|
}
|
||||||
@@ -879,7 +879,7 @@ sign_fromfile(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len,
|
|||||||
datavec.iov_len = data_len;
|
datavec.iov_len = data_len;
|
||||||
|
|
||||||
if(privkeyobj->signv(session, sig, sig_len, 1, &datavec,
|
if(privkeyobj->signv(session, sig, sig_len, 1, &datavec,
|
||||||
&hostkey_abstract)) {
|
&hostkey_abstract)) {
|
||||||
if(privkeyobj->dtor) {
|
if(privkeyobj->dtor) {
|
||||||
privkeyobj->dtor(session, &hostkey_abstract);
|
privkeyobj->dtor(session, &hostkey_abstract);
|
||||||
}
|
}
|
||||||
@@ -1106,8 +1106,8 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session,
|
|||||||
datavec[2].iov_len = session->userauth_host_packet_len;
|
datavec[2].iov_len = session->userauth_host_packet_len;
|
||||||
|
|
||||||
if(privkeyobj && privkeyobj->signv &&
|
if(privkeyobj && privkeyobj->signv &&
|
||||||
privkeyobj->signv(session, &sig, &sig_len, 3,
|
privkeyobj->signv(session, &sig, &sig_len, 3,
|
||||||
datavec, &abstract)) {
|
datavec, &abstract)) {
|
||||||
LIBSSH2_FREE(session, session->userauth_host_method);
|
LIBSSH2_FREE(session, session->userauth_host_method);
|
||||||
session->userauth_host_method = NULL;
|
session->userauth_host_method = NULL;
|
||||||
LIBSSH2_FREE(session, session->userauth_host_packet);
|
LIBSSH2_FREE(session, session->userauth_host_packet);
|
||||||
@@ -1478,8 +1478,8 @@ _libssh2_userauth_publickey(LIBSSH2_SESSION *session,
|
|||||||
* the key default algo */
|
* the key default algo */
|
||||||
if(auth_attempts == 1) {
|
if(auth_attempts == 1) {
|
||||||
rc = _libssh2_key_sign_algorithm(session,
|
rc = _libssh2_key_sign_algorithm(session,
|
||||||
&session->userauth_pblc_method,
|
&session->userauth_pblc_method,
|
||||||
&session->userauth_pblc_method_len);
|
&session->userauth_pblc_method_len);
|
||||||
|
|
||||||
if(rc)
|
if(rc)
|
||||||
return rc;
|
return rc;
|
||||||
@@ -1972,7 +1972,7 @@ libssh2_userauth_publickey(LIBSSH2_SESSION *session,
|
|||||||
const unsigned char *pubkeydata,
|
const unsigned char *pubkeydata,
|
||||||
size_t pubkeydata_len,
|
size_t pubkeydata_len,
|
||||||
LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC
|
LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC
|
||||||
((*sign_callback)),
|
((*sign_callback)),
|
||||||
void **abstract)
|
void **abstract)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
@@ -1999,7 +1999,7 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session,
|
|||||||
const char *username,
|
const char *username,
|
||||||
unsigned int username_len,
|
unsigned int username_len,
|
||||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC
|
LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC
|
||||||
((*response_callback)))
|
((*response_callback)))
|
||||||
{
|
{
|
||||||
unsigned char *s;
|
unsigned char *s;
|
||||||
|
|
||||||
@@ -2273,7 +2273,7 @@ libssh2_userauth_keyboard_interactive_ex(LIBSSH2_SESSION *session,
|
|||||||
const char *user,
|
const char *user,
|
||||||
unsigned int user_len,
|
unsigned int user_len,
|
||||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC
|
LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC
|
||||||
((*response_callback)))
|
((*response_callback)))
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
BLOCK_ADJUST(rc, session,
|
BLOCK_ADJUST(rc, session,
|
||||||
@@ -2295,7 +2295,7 @@ libssh2_userauth_publickey_sk(LIBSSH2_SESSION *session,
|
|||||||
size_t privatekeydata_len,
|
size_t privatekeydata_len,
|
||||||
const char *passphrase,
|
const char *passphrase,
|
||||||
LIBSSH2_USERAUTH_SK_SIGN_FUNC
|
LIBSSH2_USERAUTH_SK_SIGN_FUNC
|
||||||
((*sign_callback)),
|
((*sign_callback)),
|
||||||
void **abstract)
|
void **abstract)
|
||||||
{
|
{
|
||||||
unsigned char *pubkeydata = NULL;
|
unsigned char *pubkeydata = NULL;
|
||||||
|
|||||||
22
src/wincng.c
22
src/wincng.c
@@ -604,12 +604,12 @@ _libssh2_wincng_hmac_cleanup(_libssh2_wincng_hash_ctx *ctx)
|
|||||||
|
|
||||||
int
|
int
|
||||||
_libssh2_wincng_key_sha_verify(_libssh2_wincng_key_ctx *ctx,
|
_libssh2_wincng_key_sha_verify(_libssh2_wincng_key_ctx *ctx,
|
||||||
unsigned long hashlen,
|
unsigned long hashlen,
|
||||||
const unsigned char *sig,
|
const unsigned char *sig,
|
||||||
unsigned long sig_len,
|
unsigned long sig_len,
|
||||||
const unsigned char *m,
|
const unsigned char *m,
|
||||||
unsigned long m_len,
|
unsigned long m_len,
|
||||||
unsigned long flags)
|
unsigned long flags)
|
||||||
{
|
{
|
||||||
BCRYPT_PKCS1_PADDING_INFO paddingInfoPKCS1;
|
BCRYPT_PKCS1_PADDING_INFO paddingInfoPKCS1;
|
||||||
BCRYPT_ALG_HANDLE hAlgHash;
|
BCRYPT_ALG_HANDLE hAlgHash;
|
||||||
@@ -1267,11 +1267,11 @@ _libssh2_wincng_rsa_sha2_verify(libssh2_rsa_ctx* rsa,
|
|||||||
|
|
||||||
int
|
int
|
||||||
_libssh2_wincng_rsa_sha_sign(LIBSSH2_SESSION *session,
|
_libssh2_wincng_rsa_sha_sign(LIBSSH2_SESSION *session,
|
||||||
libssh2_rsa_ctx *rsa,
|
libssh2_rsa_ctx *rsa,
|
||||||
const unsigned char *hash,
|
const unsigned char *hash,
|
||||||
size_t hash_len,
|
size_t hash_len,
|
||||||
unsigned char **signature,
|
unsigned char **signature,
|
||||||
size_t *signature_len)
|
size_t *signature_len)
|
||||||
{
|
{
|
||||||
BCRYPT_PKCS1_PADDING_INFO paddingInfo;
|
BCRYPT_PKCS1_PADDING_INFO paddingInfo;
|
||||||
unsigned char *data, *sig;
|
unsigned char *data, *sig;
|
||||||
|
|||||||
Reference in New Issue
Block a user