mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-20 02:42:09 +03:00
lib: fix various compiler warnings
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/* Copyright (c) 2004-2007 Sara Golemon <sarag@libssh2.org>
|
/* Copyright (c) 2004-2007 Sara Golemon <sarag@libssh2.org>
|
||||||
* Copyright (c) 2005 Mikhail Gusarov <dottedmag@dottedmag.net>
|
* Copyright (c) 2005 Mikhail Gusarov <dottedmag@dottedmag.net>
|
||||||
* Copyright (c) 2008-2014 by Daniel Stenberg
|
* Copyright (c) 2008-2019 by Daniel Stenberg
|
||||||
*
|
*
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -1180,7 +1180,7 @@ channel_x11_req(LIBSSH2_CHANNEL *channel, int single_connection,
|
|||||||
|
|
||||||
_libssh2_random(buffer, LIBSSH2_X11_RANDOM_COOKIE_LEN / 2);
|
_libssh2_random(buffer, LIBSSH2_X11_RANDOM_COOKIE_LEN / 2);
|
||||||
for(i = 0; i < (LIBSSH2_X11_RANDOM_COOKIE_LEN / 2); i++) {
|
for(i = 0; i < (LIBSSH2_X11_RANDOM_COOKIE_LEN / 2); i++) {
|
||||||
snprintf((char *)&s[i*2], 3, "%02X%c", buffer[i], '\0');
|
snprintf((char *)&s[i*2], 3, "%02X", buffer[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s += cookie_len;
|
s += cookie_len;
|
||||||
@@ -1439,7 +1439,7 @@ _libssh2_channel_flush(LIBSSH2_CHANNEL *channel, int streamid)
|
|||||||
&& ((packet->data_len >= 5)
|
&& ((packet->data_len >= 5)
|
||||||
&& (_libssh2_ntohu32(packet->data + 1) == channel->local.id))) {
|
&& (_libssh2_ntohu32(packet->data + 1) == channel->local.id))) {
|
||||||
/* It's our channel at least */
|
/* It's our channel at least */
|
||||||
unsigned int packet_stream_id;
|
int packet_stream_id;
|
||||||
|
|
||||||
if(packet_type == SSH_MSG_CHANNEL_DATA) {
|
if(packet_type == SSH_MSG_CHANNEL_DATA) {
|
||||||
packet_stream_id = 0;
|
packet_stream_id = 0;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Copyright (C) 2009, 2010 Simon Josefsson
|
/* Copyright (C) 2009, 2010 Simon Josefsson
|
||||||
* Copyright (C) 2006, 2007 The Written Word, Inc. All rights reserved.
|
* Copyright (C) 2006, 2007 The Written Word, Inc. All rights reserved.
|
||||||
* Copyright (C) 2010 Daniel Stenberg
|
* Copyright (C) 2010-2019 Daniel Stenberg
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms,
|
* Redistribution and use in source and binary forms,
|
||||||
* with or without modification, are permitted provided
|
* with or without modification, are permitted provided
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Copyright (c) 2004-2006, Sara Golemon <sarag@libssh2.org>
|
/* Copyright (c) 2004-2006, Sara Golemon <sarag@libssh2.org>
|
||||||
* Copyright (c) 2009-2014 by Daniel Stenberg
|
* Copyright (c) 2009-2019 by Daniel Stenberg
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms,
|
* Redistribution and use in source and binary forms,
|
||||||
@@ -66,7 +66,7 @@ hostkey_method_ssh_rsa_init(LIBSSH2_SESSION * session,
|
|||||||
libssh2_rsa_ctx *rsactx;
|
libssh2_rsa_ctx *rsactx;
|
||||||
unsigned char *e, *n;
|
unsigned char *e, *n;
|
||||||
int e_len, n_len;
|
int e_len, n_len;
|
||||||
struct string_buf buf = { .len = 0, .offset = 0 };
|
struct string_buf buf;
|
||||||
|
|
||||||
if(*abstract) {
|
if(*abstract) {
|
||||||
hostkey_method_ssh_rsa_dtor(session, abstract);
|
hostkey_method_ssh_rsa_dtor(session, abstract);
|
||||||
@@ -79,6 +79,7 @@ hostkey_method_ssh_rsa_init(LIBSSH2_SESSION * session,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf.offset = 0;
|
||||||
buf.data = (unsigned char*)hostkey_data;
|
buf.data = (unsigned char*)hostkey_data;
|
||||||
buf.dataptr = buf.data;
|
buf.dataptr = buf.data;
|
||||||
buf.len = hostkey_data_len;
|
buf.len = hostkey_data_len;
|
||||||
@@ -284,7 +285,7 @@ hostkey_method_ssh_dss_init(LIBSSH2_SESSION * session,
|
|||||||
libssh2_dsa_ctx *dsactx;
|
libssh2_dsa_ctx *dsactx;
|
||||||
unsigned char *p, *q, *g, *y;
|
unsigned char *p, *q, *g, *y;
|
||||||
int p_len, q_len, g_len, y_len;
|
int p_len, q_len, g_len, y_len;
|
||||||
struct string_buf buf = { .len = 0, .offset = 0 };
|
struct string_buf buf;
|
||||||
|
|
||||||
if(*abstract) {
|
if(*abstract) {
|
||||||
hostkey_method_ssh_dss_dtor(session, abstract);
|
hostkey_method_ssh_dss_dtor(session, abstract);
|
||||||
@@ -297,6 +298,7 @@ hostkey_method_ssh_dss_init(LIBSSH2_SESSION * session,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf.offset = 0;
|
||||||
buf.data = (unsigned char*)hostkey_data;
|
buf.data = (unsigned char*)hostkey_data;
|
||||||
buf.dataptr = buf.data;
|
buf.dataptr = buf.data;
|
||||||
buf.len = hostkey_data_len;
|
buf.len = hostkey_data_len;
|
||||||
@@ -508,7 +510,7 @@ hostkey_method_ssh_ecdsa_init(LIBSSH2_SESSION * session,
|
|||||||
unsigned char *type_str, *domain, *public_key;
|
unsigned char *type_str, *domain, *public_key;
|
||||||
int key_len;
|
int key_len;
|
||||||
libssh2_curve_type type;
|
libssh2_curve_type type;
|
||||||
struct string_buf buf = { .len = 0, .offset = 0 };
|
struct string_buf buf;
|
||||||
|
|
||||||
if(abstract != NULL && *abstract) {
|
if(abstract != NULL && *abstract) {
|
||||||
hostkey_method_ssh_ecdsa_dtor(session, abstract);
|
hostkey_method_ssh_ecdsa_dtor(session, abstract);
|
||||||
@@ -521,6 +523,7 @@ hostkey_method_ssh_ecdsa_init(LIBSSH2_SESSION * session,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf.offset = 0;
|
||||||
buf.data = (unsigned char*)hostkey_data;
|
buf.data = (unsigned char*)hostkey_data;
|
||||||
buf.dataptr = buf.data;
|
buf.dataptr = buf.data;
|
||||||
buf.len = hostkey_data_len;
|
buf.len = hostkey_data_len;
|
||||||
@@ -636,7 +639,7 @@ hostkey_method_ssh_ecdsa_sig_verify(LIBSSH2_SESSION * session,
|
|||||||
{
|
{
|
||||||
unsigned char *r, *s, *name;
|
unsigned char *r, *s, *name;
|
||||||
unsigned int r_len, s_len, len;
|
unsigned int r_len, s_len, len;
|
||||||
struct string_buf buf = { .len = 0, .offset = 0 };
|
struct string_buf buf;
|
||||||
libssh2_ecdsa_ctx *ctx = (libssh2_ecdsa_ctx *) (*abstract);
|
libssh2_ecdsa_ctx *ctx = (libssh2_ecdsa_ctx *) (*abstract);
|
||||||
|
|
||||||
(void) session;
|
(void) session;
|
||||||
@@ -645,6 +648,7 @@ hostkey_method_ssh_ecdsa_sig_verify(LIBSSH2_SESSION * session,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* keyname_len(4) + keyname(19){"ecdsa-sha2-nistp256"} + signature_len(4) */
|
/* keyname_len(4) + keyname(19){"ecdsa-sha2-nistp256"} + signature_len(4) */
|
||||||
|
buf.offset = 0;
|
||||||
buf.data = (unsigned char*)sig;
|
buf.data = (unsigned char*)sig;
|
||||||
buf.dataptr = buf.data;
|
buf.dataptr = buf.data;
|
||||||
buf.len = sig_len;
|
buf.len = sig_len;
|
||||||
@@ -815,7 +819,7 @@ hostkey_method_ssh_ed25519_init(LIBSSH2_SESSION * session,
|
|||||||
|
|
||||||
s += 11;
|
s += 11;
|
||||||
|
|
||||||
//public key
|
/* public key */
|
||||||
key_len = _libssh2_ntohu32(s);
|
key_len = _libssh2_ntohu32(s);
|
||||||
s += 4;
|
s += 4;
|
||||||
|
|
||||||
|
|||||||
34
src/kex.c
34
src/kex.c
@@ -1,5 +1,5 @@
|
|||||||
/* Copyright (c) 2004-2007, Sara Golemon <sarag@libssh2.org>
|
/* Copyright (c) 2004-2007, Sara Golemon <sarag@libssh2.org>
|
||||||
* Copyright (c) 2010, Daniel Stenberg <daniel@haxx.se>
|
* Copyright (c) 2010-2019, Daniel Stenberg <daniel@haxx.se>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms,
|
* Redistribution and use in source and binary forms,
|
||||||
@@ -1667,7 +1667,7 @@ kex_method_diffie_hellman_group_exchange_sha1_key_exchange
|
|||||||
if(key_state->state == libssh2_NB_state_sent1) {
|
if(key_state->state == libssh2_NB_state_sent1) {
|
||||||
unsigned int p_len, g_len;
|
unsigned int p_len, g_len;
|
||||||
unsigned char *p, *g;
|
unsigned char *p, *g;
|
||||||
struct string_buf buf = { .len = 0, .offset = 0 };
|
struct string_buf buf;
|
||||||
|
|
||||||
if(key_state->data_len < 9) {
|
if(key_state->data_len < 9) {
|
||||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||||
@@ -1675,6 +1675,7 @@ kex_method_diffie_hellman_group_exchange_sha1_key_exchange
|
|||||||
goto dh_gex_clean_exit;
|
goto dh_gex_clean_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf.offset = 0;
|
||||||
buf.data = key_state->data;
|
buf.data = key_state->data;
|
||||||
buf.dataptr = buf.data;
|
buf.dataptr = buf.data;
|
||||||
buf.len = key_state->data_len;
|
buf.len = key_state->data_len;
|
||||||
@@ -1789,7 +1790,7 @@ kex_method_diffie_hellman_group_exchange_sha256_key_exchange
|
|||||||
if(key_state->state == libssh2_NB_state_sent1) {
|
if(key_state->state == libssh2_NB_state_sent1) {
|
||||||
unsigned char *p, *g;
|
unsigned char *p, *g;
|
||||||
unsigned long p_len, g_len;
|
unsigned long p_len, g_len;
|
||||||
struct string_buf buf = { .len = 0, .offset = 0 };
|
struct string_buf buf;
|
||||||
|
|
||||||
if(key_state->data_len < 9) {
|
if(key_state->data_len < 9) {
|
||||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||||
@@ -1797,6 +1798,7 @@ kex_method_diffie_hellman_group_exchange_sha256_key_exchange
|
|||||||
goto dh_gex_clean_exit;
|
goto dh_gex_clean_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf.offset = 0;
|
||||||
buf.data = key_state->data;
|
buf.data = key_state->data;
|
||||||
buf.dataptr = buf.data;
|
buf.dataptr = buf.data;
|
||||||
buf.len = key_state->data_len;
|
buf.len = key_state->data_len;
|
||||||
@@ -2602,7 +2604,7 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
|||||||
/* parse INIT reply data */
|
/* parse INIT reply data */
|
||||||
unsigned char *server_public_key, *server_host_key;
|
unsigned char *server_public_key, *server_host_key;
|
||||||
unsigned int server_public_key_len;
|
unsigned int server_public_key_len;
|
||||||
struct string_buf buf = { .len = 0, .offset = 0 };
|
struct string_buf buf;
|
||||||
|
|
||||||
if(data_len < 5) {
|
if(data_len < 5) {
|
||||||
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||||
@@ -2610,6 +2612,7 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
|||||||
goto clean_exit;
|
goto clean_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
buf.offset = 0;
|
||||||
buf.data = data;
|
buf.data = data;
|
||||||
buf.len = data_len;
|
buf.len = data_len;
|
||||||
buf.dataptr = buf.data;
|
buf.dataptr = buf.data;
|
||||||
@@ -2743,7 +2746,7 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute the shared secret K
|
/* Compute the shared secret K */
|
||||||
rc = _libssh2_curve25519_gen_k(&exchange_state->k, private_key, server_public_key);
|
rc = _libssh2_curve25519_gen_k(&exchange_state->k, private_key, server_public_key);
|
||||||
if( rc != 0) {
|
if( rc != 0) {
|
||||||
ret = _libssh2_error(session, LIBSSH2_ERROR_KEX_FAILURE,
|
ret = _libssh2_error(session, LIBSSH2_ERROR_KEX_FAILURE,
|
||||||
@@ -2753,7 +2756,7 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
|||||||
|
|
||||||
exchange_state->k_value_len = _libssh2_bn_bytes(exchange_state->k) + 5;
|
exchange_state->k_value_len = _libssh2_bn_bytes(exchange_state->k) + 5;
|
||||||
if(_libssh2_bn_bits(exchange_state->k) % 8) {
|
if(_libssh2_bn_bits(exchange_state->k) % 8) {
|
||||||
// don't need leading 00
|
/* don't need leading 00 */
|
||||||
exchange_state->k_value_len--;
|
exchange_state->k_value_len--;
|
||||||
}
|
}
|
||||||
exchange_state->k_value =
|
exchange_state->k_value =
|
||||||
@@ -2772,7 +2775,7 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
|||||||
_libssh2_bn_to_bin(exchange_state->k, exchange_state->k_value + 5);
|
_libssh2_bn_to_bin(exchange_state->k, exchange_state->k_value + 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
// verify hash
|
/*/ verify hash */
|
||||||
LIBSSH2_KEX_METHOD_EC_SHA_HASH_CREATE_VERIFY(256);
|
LIBSSH2_KEX_METHOD_EC_SHA_HASH_CREATE_VERIFY(256);
|
||||||
|
|
||||||
if( rc != 0) {
|
if( rc != 0) {
|
||||||
@@ -2809,11 +2812,14 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
|||||||
goto clean_exit;
|
goto clean_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The first key exchange has been performed, switch to active crypt/comp/mac mode
|
/* The first key exchange has been performed, switch to active
|
||||||
|
crypt/comp/mac mode */
|
||||||
|
|
||||||
session->state |= LIBSSH2_STATE_NEWKEYS;
|
session->state |= LIBSSH2_STATE_NEWKEYS;
|
||||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX, "Received NEWKEYS message");
|
_libssh2_debug(session, LIBSSH2_TRACE_KEX, "Received NEWKEYS message");
|
||||||
|
|
||||||
// This will actually end up being just packet_type(1) for this packet type anyway
|
/* This will actually end up being just packet_type(1) for this packet
|
||||||
|
type anyway */
|
||||||
LIBSSH2_FREE(session, exchange_state->tmp);
|
LIBSSH2_FREE(session, exchange_state->tmp);
|
||||||
|
|
||||||
if(!session->session_id) {
|
if(!session->session_id) {
|
||||||
@@ -2831,13 +2837,13 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
|||||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX, "session_id calculated");
|
_libssh2_debug(session, LIBSSH2_TRACE_KEX, "session_id calculated");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 */
|
||||||
if(session->local.crypt->init) {
|
if(session->local.crypt->init) {
|
||||||
unsigned char *iv = NULL, *secret = NULL;
|
unsigned char *iv = NULL, *secret = NULL;
|
||||||
int free_iv = 0, free_secret = 0;
|
int free_iv = 0, free_secret = 0;
|
||||||
@@ -2882,7 +2888,7 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
|||||||
"Client to Server IV and Key calculated");
|
"Client to Server IV and Key calculated");
|
||||||
|
|
||||||
if(session->remote.crypt->dtor) {
|
if(session->remote.crypt->dtor) {
|
||||||
// Cleanup any existing cipher
|
/* Cleanup any existing cipher */
|
||||||
session->remote.crypt->dtor(session,
|
session->remote.crypt->dtor(session,
|
||||||
&session->remote.crypt_abstract);
|
&session->remote.crypt_abstract);
|
||||||
}
|
}
|
||||||
@@ -2984,9 +2990,9 @@ static int curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
|||||||
_libssh2_debug(session, LIBSSH2_TRACE_KEX,
|
_libssh2_debug(session, LIBSSH2_TRACE_KEX,
|
||||||
"Server to Client HMAC Key calculated");
|
"Server to Client HMAC Key calculated");
|
||||||
|
|
||||||
// Initialize compression for each direction
|
/* Initialize compression for each direction */
|
||||||
|
|
||||||
// Cleanup any existing compression
|
/* Cleanup any existing compression */
|
||||||
if(session->local.comp && session->local.comp->dtor) {
|
if(session->local.comp && session->local.comp->dtor) {
|
||||||
session->local.comp->dtor(session, 1,
|
session->local.comp->dtor(session, 1,
|
||||||
&session->local.comp_abstract);
|
&session->local.comp_abstract);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009-2014 by Daniel Stenberg
|
* Copyright (c) 2009-2019 by Daniel Stenberg
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms,
|
* Redistribution and use in source and binary forms,
|
||||||
@@ -1048,6 +1048,7 @@ knownhost_writeline(LIBSSH2_KNOWNHOSTS *hosts,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* otherwise fallback to default and error */
|
/* otherwise fallback to default and error */
|
||||||
|
/* FALL-THROUGH */
|
||||||
default:
|
default:
|
||||||
return _libssh2_error(hosts->session,
|
return _libssh2_error(hosts->session,
|
||||||
LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
|
LIBSSH2_ERROR_METHOD_NOT_SUPPORTED,
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/* Copyright (c) 2004-2007 Sara Golemon <sarag@libssh2.org>
|
/* Copyright (c) 2004-2007 Sara Golemon <sarag@libssh2.org>
|
||||||
* Copyright (c) 2009-2014 by Daniel Stenberg
|
* Copyright (c) 2009-2019 by Daniel Stenberg
|
||||||
* Copyright (c) 2010 Simon Josefsson
|
* Copyright (c) 2010 Simon Josefsson
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -785,7 +785,7 @@ int _libssh2_get_bignum_bytes(struct string_buf *buf, unsigned char **outbuf)
|
|||||||
bn_len = data_len;
|
bn_len = data_len;
|
||||||
bnptr = buf->dataptr;
|
bnptr = buf->dataptr;
|
||||||
|
|
||||||
// trim leading zeros
|
/* trim leading zeros */
|
||||||
while(bn_len > 0 && *bnptr == 0x00) {
|
while(bn_len > 0 && *bnptr == 0x00) {
|
||||||
bn_len--;
|
bn_len--;
|
||||||
bnptr++;
|
bnptr++;
|
||||||
|
|||||||
@@ -871,8 +871,7 @@ gen_publickey_from_rsa_evp(LIBSSH2_SESSION *session,
|
|||||||
"Unable to allocate memory for private key data");
|
"Unable to allocate memory for private key data");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int _libssh2_rsa_new_additional_parameters(RSA *rsa)
|
||||||
_libssh2_rsa_new_additional_parameters(RSA *rsa)
|
|
||||||
{
|
{
|
||||||
BN_CTX *ctx = NULL;
|
BN_CTX *ctx = NULL;
|
||||||
BIGNUM *aux = NULL;
|
BIGNUM *aux = NULL;
|
||||||
@@ -940,7 +939,7 @@ out:
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
gen_publickey_from_rsa_openssh_priv_data(LIBSSH2_SESSION *session,
|
gen_publickey_from_rsa_openssh_priv_data(LIBSSH2_SESSION *session,
|
||||||
struct string_buf *decrypted,
|
struct string_buf *decrypted,
|
||||||
unsigned char **method,
|
unsigned char **method,
|
||||||
@@ -959,7 +958,7 @@ gen_publickey_from_rsa_openssh_priv_data(LIBSSH2_SESSION *session,
|
|||||||
LIBSSH2_TRACE_AUTH,
|
LIBSSH2_TRACE_AUTH,
|
||||||
"Computing RSA keys from private key data");
|
"Computing RSA keys from private key data");
|
||||||
|
|
||||||
// public key data
|
/* public key data */
|
||||||
if((nlen = _libssh2_get_bignum_bytes(decrypted, &n)) <= 0) {
|
if((nlen = _libssh2_get_bignum_bytes(decrypted, &n)) <= 0) {
|
||||||
_libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
_libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||||
"RSA no n");
|
"RSA no n");
|
||||||
@@ -972,7 +971,7 @@ gen_publickey_from_rsa_openssh_priv_data(LIBSSH2_SESSION *session,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private key data
|
/* private key data */
|
||||||
if((dlen = _libssh2_get_bignum_bytes(decrypted, &d)) <= 0) {
|
if((dlen = _libssh2_get_bignum_bytes(decrypted, &d)) <= 0) {
|
||||||
_libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
_libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||||
"RSA no d");
|
"RSA no d");
|
||||||
@@ -1043,7 +1042,7 @@ fail:
|
|||||||
"Unable to allocate memory for private key data");
|
"Unable to allocate memory for private key data");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
_libssh2_rsa_new_openssh_private(libssh2_rsa_ctx ** rsa,
|
_libssh2_rsa_new_openssh_private(libssh2_rsa_ctx ** rsa,
|
||||||
LIBSSH2_SESSION * session,
|
LIBSSH2_SESSION * session,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
@@ -1257,7 +1256,7 @@ gen_publickey_from_dsa_evp(LIBSSH2_SESSION *session,
|
|||||||
"Unable to allocate memory for private key data");
|
"Unable to allocate memory for private key data");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
gen_publickey_from_dsa_openssh_priv_data(LIBSSH2_SESSION *session,
|
gen_publickey_from_dsa_openssh_priv_data(LIBSSH2_SESSION *session,
|
||||||
struct string_buf *decrypted,
|
struct string_buf *decrypted,
|
||||||
unsigned char **method,
|
unsigned char **method,
|
||||||
@@ -1342,7 +1341,7 @@ fail:
|
|||||||
"Unable to allocate memory for private key data");
|
"Unable to allocate memory for private key data");
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
_libssh2_dsa_new_openssh_private(libssh2_dsa_ctx ** dsa,
|
_libssh2_dsa_new_openssh_private(libssh2_dsa_ctx ** dsa,
|
||||||
LIBSSH2_SESSION * session,
|
LIBSSH2_SESSION * session,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
@@ -1557,7 +1556,7 @@ cleanExit:
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
gen_publickey_from_ed25519_openssh_priv_data(LIBSSH2_SESSION *session,
|
gen_publickey_from_ed25519_openssh_priv_data(LIBSSH2_SESSION *session,
|
||||||
struct string_buf *decrypted,
|
struct string_buf *decrypted,
|
||||||
unsigned char **method,
|
unsigned char **method,
|
||||||
@@ -2304,7 +2303,7 @@ clean_exit:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
gen_publickey_from_ecdsa_openssh_priv_data(LIBSSH2_SESSION *session,
|
gen_publickey_from_ecdsa_openssh_priv_data(LIBSSH2_SESSION *session,
|
||||||
libssh2_curve_type curve_type,
|
libssh2_curve_type curve_type,
|
||||||
struct string_buf *decrypted,
|
struct string_buf *decrypted,
|
||||||
@@ -2388,7 +2387,7 @@ fail:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
_libssh2_ecdsa_new_openssh_private(libssh2_ecdsa_ctx ** ec_ctx,
|
_libssh2_ecdsa_new_openssh_private(libssh2_ecdsa_ctx ** ec_ctx,
|
||||||
LIBSSH2_SESSION * session,
|
LIBSSH2_SESSION * session,
|
||||||
const char *filename,
|
const char *filename,
|
||||||
@@ -2751,7 +2750,7 @@ _libssh2_ed25519_verify(libssh2_ed25519_ctx *ctx, const uint8_t *s,
|
|||||||
|
|
||||||
#endif /* LIBSSH2_ED25519 */
|
#endif /* LIBSSH2_ED25519 */
|
||||||
|
|
||||||
int
|
static int
|
||||||
_libssh2_pub_priv_openssh_keyfile(LIBSSH2_SESSION *session,
|
_libssh2_pub_priv_openssh_keyfile(LIBSSH2_SESSION *session,
|
||||||
unsigned char **method,
|
unsigned char **method,
|
||||||
size_t *method_len,
|
size_t *method_len,
|
||||||
@@ -2936,7 +2935,7 @@ _libssh2_pub_priv_keyfile(LIBSSH2_SESSION *session,
|
|||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
static int
|
||||||
_libssh2_pub_priv_openssh_keyfilememory(LIBSSH2_SESSION *session,
|
_libssh2_pub_priv_openssh_keyfilememory(LIBSSH2_SESSION *session,
|
||||||
void **key_ctx,
|
void **key_ctx,
|
||||||
const char *key_type,
|
const char *key_type,
|
||||||
|
|||||||
@@ -81,8 +81,11 @@
|
|||||||
#if OPENSSL_VERSION_NUMBER >= 0x10101000L && \
|
#if OPENSSL_VERSION_NUMBER >= 0x10101000L && \
|
||||||
!defined(LIBRESSL_VERSION_NUMBER)
|
!defined(LIBRESSL_VERSION_NUMBER)
|
||||||
# define LIBSSH2_ED25519 1
|
# define LIBSSH2_ED25519 1
|
||||||
|
#else
|
||||||
|
# define LIBSSH2_ED25519 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#ifdef OPENSSL_NO_MD5
|
#ifdef OPENSSL_NO_MD5
|
||||||
# define LIBSSH2_MD5 0
|
# define LIBSSH2_MD5 0
|
||||||
#else
|
#else
|
||||||
@@ -300,7 +303,7 @@ extern void _libssh2_openssl_crypto_exit(void);
|
|||||||
|
|
||||||
#define _libssh2_dsa_free(dsactx) DSA_free(dsactx)
|
#define _libssh2_dsa_free(dsactx) DSA_free(dsactx)
|
||||||
|
|
||||||
#if LIBSSH2_ECDSA
|
#ifdef LIBSSH2_ECDSA
|
||||||
#define libssh2_ecdsa_ctx EC_KEY
|
#define libssh2_ecdsa_ctx EC_KEY
|
||||||
#define _libssh2_ecdsa_free(ecdsactx) EC_KEY_free(ecdsactx)
|
#define _libssh2_ecdsa_free(ecdsactx) EC_KEY_free(ecdsactx)
|
||||||
#define _libssh2_ec_key EC_KEY
|
#define _libssh2_ec_key EC_KEY
|
||||||
@@ -308,14 +311,14 @@ extern void _libssh2_openssl_crypto_exit(void);
|
|||||||
typedef enum {
|
typedef enum {
|
||||||
LIBSSH2_EC_CURVE_NISTP256 = NID_X9_62_prime256v1,
|
LIBSSH2_EC_CURVE_NISTP256 = NID_X9_62_prime256v1,
|
||||||
LIBSSH2_EC_CURVE_NISTP384 = NID_secp384r1,
|
LIBSSH2_EC_CURVE_NISTP384 = NID_secp384r1,
|
||||||
LIBSSH2_EC_CURVE_NISTP521 = NID_secp521r1,
|
LIBSSH2_EC_CURVE_NISTP521 = NID_secp521r1
|
||||||
}
|
}
|
||||||
libssh2_curve_type;
|
libssh2_curve_type;
|
||||||
#else
|
#else
|
||||||
#define _libssh2_ec_key void
|
#define _libssh2_ec_key void
|
||||||
#endif /* LIBSSH2_ECDSA */
|
#endif /* LIBSSH2_ECDSA */
|
||||||
|
|
||||||
#if LIBSSH2_ED25519
|
#ifdef LIBSSH2_ED25519
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
EVP_PKEY *public_key;
|
EVP_PKEY *public_key;
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ _libssh2_pem_parse_memory(LIBSSH2_SESSION * session,
|
|||||||
#define OPENSSL_HEADER_BEGIN "-----BEGIN OPENSSH PRIVATE KEY-----"
|
#define OPENSSL_HEADER_BEGIN "-----BEGIN OPENSSH PRIVATE KEY-----"
|
||||||
#define OPENSSL_HEADER_END "-----END OPENSSH PRIVATE KEY-----"
|
#define OPENSSL_HEADER_END "-----END OPENSSH PRIVATE KEY-----"
|
||||||
|
|
||||||
int
|
static int
|
||||||
_libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session,
|
_libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session,
|
||||||
const unsigned char *passphrase,
|
const unsigned char *passphrase,
|
||||||
const char *b64data, size_t b64datalen,
|
const char *b64data, size_t b64datalen,
|
||||||
@@ -575,7 +575,7 @@ _libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session,
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (len_decrypted <= decrypted.len - blocksize) {
|
while ((size_t)len_decrypted <= decrypted.len - blocksize) {
|
||||||
if (method->crypt(session, decrypted.data + len_decrypted, blocksize,
|
if (method->crypt(session, decrypted.data + len_decrypted, blocksize,
|
||||||
&abstract)) {
|
&abstract)) {
|
||||||
ret = LIBSSH2_ERROR_DECRYPT;
|
ret = LIBSSH2_ERROR_DECRYPT;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
/* Copyright (c) 2009-2010 by Daniel Stenberg
|
/* Copyright (c) 2009-2019 by Daniel Stenberg
|
||||||
* Copyright (c) 2004-2008, Sara Golemon <sarag@libssh2.org>
|
* Copyright (c) 2004-2008, Sara Golemon <sarag@libssh2.org>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
@@ -776,8 +776,9 @@ libssh2_scp_recv(LIBSSH2_SESSION *session, const char *path, struct stat * sb)
|
|||||||
LIBSSH2_CHANNEL *ptr;
|
LIBSSH2_CHANNEL *ptr;
|
||||||
|
|
||||||
/* scp_recv uses libssh2_struct_stat, so pass one if the caller gave us a struct to populate... */
|
/* scp_recv uses libssh2_struct_stat, so pass one if the caller gave us a struct to populate... */
|
||||||
libssh2_struct_stat sb_intl = {0};
|
libssh2_struct_stat sb_intl;
|
||||||
libssh2_struct_stat *sb_ptr;
|
libssh2_struct_stat *sb_ptr;
|
||||||
|
memset(&sb_intl, 0, sizeof(sb_intl));
|
||||||
sb_ptr = sb ? &sb_intl : NULL;
|
sb_ptr = sb ? &sb_intl : NULL;
|
||||||
|
|
||||||
BLOCK_ADJUST_ERRNO(ptr, session, scp_recv(session, path, sb_ptr));
|
BLOCK_ADJUST_ERRNO(ptr, session, scp_recv(session, path, sb_ptr));
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/* Copyright (c) 2004-2008, Sara Golemon <sarag@libssh2.org>
|
/* Copyright (c) 2004-2008, Sara Golemon <sarag@libssh2.org>
|
||||||
* Copyright (c) 2007 Eli Fant <elifantu@mail.ru>
|
* Copyright (c) 2007 Eli Fant <elifantu@mail.ru>
|
||||||
* Copyright (c) 2009-2014 by Daniel Stenberg
|
* Copyright (c) 2009-2019 by Daniel Stenberg
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms,
|
* Redistribution and use in source and binary forms,
|
||||||
@@ -1416,7 +1416,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
|||||||
"read request id %d sent (offset: %d, size: %d)",
|
"read request id %d sent (offset: %d, size: %d)",
|
||||||
request_id, (int)chunk->offset, (int)chunk->len);
|
request_id, (int)chunk->offset, (int)chunk->len);
|
||||||
}
|
}
|
||||||
|
/* FALL-THROUGH */
|
||||||
case libssh2_NB_state_sent:
|
case libssh2_NB_state_sent:
|
||||||
|
|
||||||
sftp->read_state = libssh2_NB_state_idle;
|
sftp->read_state = libssh2_NB_state_idle;
|
||||||
@@ -1456,6 +1456,7 @@ static ssize_t sftp_read(LIBSSH2_SFTP_HANDLE * handle, char *buffer,
|
|||||||
/* move on to the next chunk with data to send */
|
/* move on to the next chunk with data to send */
|
||||||
chunk = _libssh2_list_next(&chunk->node);
|
chunk = _libssh2_list_next(&chunk->node);
|
||||||
}
|
}
|
||||||
|
/* FALL-THROUGH */
|
||||||
|
|
||||||
case libssh2_NB_state_sent2:
|
case libssh2_NB_state_sent2:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user