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

tidy-up: more whitespace in src

Closes #966
This commit is contained in:
Viktor Szakats
2023-04-15 02:49:52 +00:00
parent 5d399233d8
commit c627c1256b
22 changed files with 396 additions and 394 deletions

View File

@@ -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;
} }
@@ -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;

View File

@@ -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;
@@ -2173,7 +2175,6 @@ static int ecdh_sha2_nistp(LIBSSH2_SESSION *session, libssh2_curve_type type,
} }
_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,
@@ -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)
@@ -3980,14 +3979,12 @@ libssh2_session_method_pref(LIBSSH2_SESSION * session, int method_type,
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:
@@ -4096,8 +4093,7 @@ LIBSSH2_API int libssh2_session_supported_algs(LIBSSH2_SESSION* session,
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:

View File

@@ -59,14 +59,14 @@ _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)e1data;
(void)e1len; (void)e1len;
(void)e2data; (void)e2data;
(void)e2len; (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);
@@ -130,8 +130,7 @@ _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);
} }

View File

@@ -614,7 +614,8 @@ _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);

View File

@@ -491,6 +491,7 @@ _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)algo;
(void)encrypt; (void)encrypt;
@@ -544,6 +545,7 @@ 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)) {
@@ -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;
@@ -1299,7 +1304,8 @@ _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,
size_t filedata_len,
unsigned const char *passphrase) 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;
@@ -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,6 +2091,7 @@ _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);

View File

@@ -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;

View File

@@ -201,8 +201,7 @@ 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);
@@ -372,8 +371,7 @@ 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) {
@@ -461,8 +459,7 @@ 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:
@@ -771,8 +768,7 @@ 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);