mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-20 02:42:09 +03:00
@@ -1181,10 +1181,10 @@ static int channel_request_auth_agent(LIBSSH2_CHANNEL *channel,
|
||||
size_t data_len;
|
||||
unsigned char code;
|
||||
|
||||
rc = _libssh2_packet_requirev(
|
||||
session, reply_codes, &data, &data_len, 1,
|
||||
channel->req_auth_agent_local_channel,
|
||||
4, &channel->req_auth_agent_requirev_state);
|
||||
rc = _libssh2_packet_requirev(session, reply_codes, &data, &data_len,
|
||||
1, channel->req_auth_agent_local_channel,
|
||||
4,
|
||||
&channel->req_auth_agent_requirev_state);
|
||||
if(rc == LIBSSH2_ERROR_EAGAIN) {
|
||||
return rc;
|
||||
}
|
||||
@@ -2387,7 +2387,7 @@ _libssh2_channel_write(LIBSSH2_CHANNEL *channel, int stream_id,
|
||||
*/
|
||||
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;
|
||||
|
||||
22
src/kex.c
22
src/kex.c
@@ -1325,8 +1325,9 @@ kex_method_diffie_hellman_group18_sha512_key_exchange(LIBSSH2_SESSION *session,
|
||||
* Negotiates random(ish) group for secret derivation
|
||||
*/
|
||||
static int
|
||||
kex_method_diffie_hellman_group_exchange_sha1_key_exchange
|
||||
(LIBSSH2_SESSION * session, key_exchange_state_low_t * key_state)
|
||||
kex_method_diffie_hellman_group_exchange_sha1_key_exchange(
|
||||
LIBSSH2_SESSION * session,
|
||||
key_exchange_state_low_t * key_state)
|
||||
{
|
||||
int ret = 0;
|
||||
int rc;
|
||||
@@ -1442,8 +1443,9 @@ kex_method_diffie_hellman_group_exchange_sha1_key_exchange
|
||||
* Negotiates random(ish) group for secret derivation
|
||||
*/
|
||||
static int
|
||||
kex_method_diffie_hellman_group_exchange_sha256_key_exchange
|
||||
(LIBSSH2_SESSION * session, key_exchange_state_low_t * key_state)
|
||||
kex_method_diffie_hellman_group_exchange_sha256_key_exchange(
|
||||
LIBSSH2_SESSION * session,
|
||||
key_exchange_state_low_t * key_state)
|
||||
{
|
||||
int ret = 0;
|
||||
int rc;
|
||||
@@ -2173,7 +2175,6 @@ static int ecdh_sha2_nistp(LIBSSH2_SESSION *session, libssh2_curve_type type,
|
||||
}
|
||||
_libssh2_debug((session, LIBSSH2_TRACE_KEX,
|
||||
"Server to Client compression initialized"));
|
||||
|
||||
}
|
||||
|
||||
clean_exit:
|
||||
@@ -2322,7 +2323,6 @@ ecdh_clean_exit:
|
||||
/* curve25519_sha256
|
||||
* Elliptic Curve Key Exchange
|
||||
*/
|
||||
|
||||
static int
|
||||
curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data,
|
||||
size_t data_len,
|
||||
@@ -2809,7 +2809,6 @@ clean_exit:
|
||||
* Elliptic Curve X25519 Key Exchange with SHA256 hash
|
||||
*
|
||||
*/
|
||||
|
||||
static int
|
||||
kex_method_curve25519_key_exchange
|
||||
(LIBSSH2_SESSION * session, key_exchange_state_low_t * key_state)
|
||||
@@ -3980,14 +3979,12 @@ libssh2_session_method_pref(LIBSSH2_SESSION * session, int method_type,
|
||||
|
||||
case LIBSSH2_METHOD_COMP_CS:
|
||||
prefvar = &session->local.comp_prefs;
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)
|
||||
_libssh2_comp_methods(session);
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_comp_methods(session);
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_COMP_SC:
|
||||
prefvar = &session->remote.comp_prefs;
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)
|
||||
_libssh2_comp_methods(session);
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_comp_methods(session);
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_LANG_CS:
|
||||
@@ -4096,8 +4093,7 @@ LIBSSH2_API int libssh2_session_supported_algs(LIBSSH2_SESSION* session,
|
||||
|
||||
case LIBSSH2_METHOD_COMP_CS:
|
||||
case LIBSSH2_METHOD_COMP_SC:
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)
|
||||
_libssh2_comp_methods(session);
|
||||
mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_comp_methods(session);
|
||||
break;
|
||||
|
||||
case LIBSSH2_METHOD_SIGN_ALGO:
|
||||
|
||||
@@ -59,14 +59,14 @@ _libssh2_rsa_new(libssh2_rsa_ctx ** rsa,
|
||||
const unsigned char *coeffdata, unsigned long coefflen)
|
||||
{
|
||||
int rc;
|
||||
|
||||
(void)e1data;
|
||||
(void)e1len;
|
||||
(void)e2data;
|
||||
(void)e2len;
|
||||
|
||||
if(ddata) {
|
||||
rc = gcry_sexp_build
|
||||
(rsa, NULL,
|
||||
rc = gcry_sexp_build(rsa, NULL,
|
||||
"(private-key(rsa(n%b)(e%b)(d%b)(q%b)(p%b)(u%b)))",
|
||||
nlen, ndata, elen, edata, dlen, ddata, plen, pdata,
|
||||
qlen, qdata, coefflen, coeffdata);
|
||||
@@ -130,8 +130,7 @@ _libssh2_dsa_new(libssh2_dsa_ctx ** dsactx,
|
||||
int rc;
|
||||
|
||||
if(x_len) {
|
||||
rc = gcry_sexp_build
|
||||
(dsactx, NULL,
|
||||
rc = gcry_sexp_build(dsactx, NULL,
|
||||
"(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);
|
||||
}
|
||||
|
||||
@@ -614,7 +614,8 @@ _libssh2_mbedtls_rsa_sha1_sign(LIBSSH2_SESSION * session,
|
||||
libssh2_rsa_ctx * rsactx,
|
||||
const unsigned char *hash,
|
||||
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,
|
||||
signature, signature_len);
|
||||
|
||||
@@ -491,6 +491,7 @@ _libssh2_cipher_crypt(_libssh2_cipher_ctx * ctx,
|
||||
unsigned char buf[EVP_MAX_BLOCK_LENGTH];
|
||||
int ret;
|
||||
int rc = 1;
|
||||
|
||||
(void)algo;
|
||||
(void)encrypt;
|
||||
|
||||
@@ -544,6 +545,7 @@ static int
|
||||
passphrase_cb(char *buf, int size, int rwflag, char *passphrase)
|
||||
{
|
||||
int passphrase_len = (int) strlen(passphrase);
|
||||
|
||||
(void)rwflag;
|
||||
|
||||
if(passphrase_len > (size - 1)) {
|
||||
@@ -1003,11 +1005,14 @@ _libssh2_dsa_new_private_frommemory(libssh2_dsa_ctx ** dsa,
|
||||
_libssh2_init_if_needed();
|
||||
|
||||
rc = read_private_key_from_memory((void **)dsa, read_dsa,
|
||||
filedata, filedata_len, passphrase);
|
||||
filedata, filedata_len,
|
||||
passphrase);
|
||||
|
||||
if(rc) {
|
||||
rc = read_openssh_private_key_from_memory((void **)dsa, session,
|
||||
"ssh-dsa", filedata, filedata_len, passphrase);
|
||||
"ssh-dsa",
|
||||
filedata, filedata_len,
|
||||
passphrase);
|
||||
}
|
||||
|
||||
return rc;
|
||||
@@ -1299,7 +1304,8 @@ _libssh2_dsa_new_private(libssh2_dsa_ctx ** dsa,
|
||||
int
|
||||
_libssh2_ecdsa_new_private_frommemory(libssh2_ecdsa_ctx ** ec_ctx,
|
||||
LIBSSH2_SESSION * session,
|
||||
const char *filedata, size_t filedata_len,
|
||||
const char *filedata,
|
||||
size_t filedata_len,
|
||||
unsigned const char *passphrase)
|
||||
{
|
||||
int rc;
|
||||
@@ -1310,12 +1316,14 @@ _libssh2_ecdsa_new_private_frommemory(libssh2_ecdsa_ctx ** ec_ctx,
|
||||
_libssh2_init_if_needed();
|
||||
|
||||
rc = read_private_key_from_memory((void **) ec_ctx, read_ec,
|
||||
filedata, filedata_len, passphrase);
|
||||
filedata, filedata_len,
|
||||
passphrase);
|
||||
|
||||
if(rc) {
|
||||
rc = read_openssh_private_key_from_memory((void **)ec_ctx, session,
|
||||
"ssh-ecdsa", filedata,
|
||||
filedata_len, passphrase);
|
||||
"ssh-ecdsa",
|
||||
filedata, filedata_len,
|
||||
passphrase);
|
||||
}
|
||||
|
||||
return rc;
|
||||
@@ -1942,7 +1950,8 @@ _libssh2_ed25519_new_private_frommemory(libssh2_ed25519_ctx ** ed_ctx,
|
||||
if(read_private_key_from_memory((void **)&ctx,
|
||||
(pem_read_bio_func)
|
||||
&PEM_read_bio_PrivateKey,
|
||||
filedata, filedata_len, passphrase) == 0) {
|
||||
filedata, filedata_len,
|
||||
passphrase) == 0) {
|
||||
if(EVP_PKEY_id(ctx) != EVP_PKEY_ED25519) {
|
||||
_libssh2_ed25519_free(ctx);
|
||||
return _libssh2_error(session, LIBSSH2_ERROR_PROTO,
|
||||
@@ -2082,6 +2091,7 @@ _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx,
|
||||
const BIGNUM * r;
|
||||
const BIGNUM * s;
|
||||
int r_len, s_len;
|
||||
|
||||
(void)hash_len;
|
||||
|
||||
sig = DSA_do_sign(hash, SHA_DIGEST_LENGTH, dsactx);
|
||||
|
||||
@@ -2839,8 +2839,8 @@ static int sftp_rename(LIBSSH2_SFTP *sftp, const char *source_filename,
|
||||
size_t data_len = 0;
|
||||
int retcode;
|
||||
uint32_t packet_len =
|
||||
source_filename_len + dest_filename_len + 17 + (sftp->version >=
|
||||
5 ? 4 : 0);
|
||||
source_filename_len + dest_filename_len + 17 +
|
||||
(sftp->version >= 5 ? 4 : 0);
|
||||
/* packet_len(4) + packet_type(1) + request_id(4) +
|
||||
source_filename_len(4) + dest_filename_len(4) + flags(4){SFTP5+) */
|
||||
unsigned char *data = NULL;
|
||||
|
||||
@@ -201,8 +201,7 @@ fullpacket(LIBSSH2_SESSION * session, int encrypted /* 1 or 0 */ )
|
||||
session->fullpacket_payload_len -= p->padding_length;
|
||||
|
||||
/* Check for and deal with decompression */
|
||||
compressed =
|
||||
session->local.comp &&
|
||||
compressed = session->local.comp &&
|
||||
session->local.comp->compress &&
|
||||
((session->state & LIBSSH2_STATE_AUTHENTICATED) ||
|
||||
session->local.comp->use_in_auth);
|
||||
@@ -372,8 +371,7 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session)
|
||||
}
|
||||
|
||||
/* now read a big chunk from the network into the temp buffer */
|
||||
nread =
|
||||
LIBSSH2_RECV(session, &p->buf[remainbuf],
|
||||
nread = LIBSSH2_RECV(session, &p->buf[remainbuf],
|
||||
PACKETBUFSIZE - remainbuf,
|
||||
LIBSSH2_SOCKET_RECV_FLAGS(session));
|
||||
if(nread <= 0) {
|
||||
@@ -461,8 +459,7 @@ int _libssh2_transport_read(LIBSSH2_SESSION * session)
|
||||
|
||||
/* total_num is the number of bytes following the initial
|
||||
(5 bytes) packet length and padding length fields */
|
||||
total_num =
|
||||
p->packet_length - 1 +
|
||||
total_num = p->packet_length - 1 +
|
||||
(encrypted ? session->remote.mac->mac_len : 0);
|
||||
|
||||
/* RFC4253 section 6.1 Maximum Packet Length says:
|
||||
@@ -771,8 +768,7 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session,
|
||||
|
||||
encrypted = (session->state & LIBSSH2_STATE_NEWKEYS) ? 1 : 0;
|
||||
|
||||
compressed =
|
||||
session->local.comp &&
|
||||
compressed = session->local.comp &&
|
||||
session->local.comp->compress &&
|
||||
((session->state & LIBSSH2_STATE_AUTHENTICATED) ||
|
||||
session->local.comp->use_in_auth);
|
||||
|
||||
Reference in New Issue
Block a user