diff --git a/src/blowfish.c b/src/blowfish.c index 40134ef3..b580b717 100644 --- a/src/blowfish.c +++ b/src/blowfish.c @@ -62,8 +62,8 @@ /* Blowfish context */ typedef struct BlowfishContext { - uint32_t S[4][256]; /* S-Boxes */ - uint32_t P[BLF_N + 2]; /* Subkeys */ + uint32_t S[4][256]; /* S-Boxes */ + uint32_t P[BLF_N + 2]; /* Subkeys */ } blf_ctx; /* 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 */ -#define F(s, x) ((((s)[ (((x)>>24)&0xFF)] \ - + (s)[0x100 + (((x)>>16)&0xFF)]) \ - ^ (s)[0x200 + (((x)>> 8)&0xFF)]) \ - + (s)[0x300 + ( (x) &0xFF)]) +#define F(s, x) ((((s)[ (((x) >> 24) & 0xFF)] \ + + (s)[0x100 + (((x) >> 16) & 0xFF)]) \ + ^ (s)[0x200 + (((x) >> 8) & 0xFF)]) \ + + (s)[0x300 + ( (x) & 0xFF)]) #define BLFRND(s,p,i,j,n) (i ^= F(s,j) ^ (p)[n]) diff --git a/src/channel.c b/src/channel.c index 4573556e..ef8827fc 100644 --- a/src/channel.c +++ b/src/channel.c @@ -327,14 +327,14 @@ _libssh2_channel_open(LIBSSH2_SESSION * session, const char *channel_type, /* Clear out packets meant for this channel */ _libssh2_htonu32(channel_id, session->open_channel->local.id); while((_libssh2_packet_ask(session, SSH_MSG_CHANNEL_DATA, - &session->open_data, - &session->open_data_len, 1, - channel_id, 4) >= 0) - || - (_libssh2_packet_ask(session, SSH_MSG_CHANNEL_EXTENDED_DATA, - &session->open_data, - &session->open_data_len, 1, - channel_id, 4) >= 0)) { + &session->open_data, + &session->open_data_len, 1, + channel_id, 4) >= 0) + || + (_libssh2_packet_ask(session, SSH_MSG_CHANNEL_EXTENDED_DATA, + &session->open_data, + &session->open_data_len, 1, + channel_id, 4) >= 0)) { LIBSSH2_FREE(session, session->open_data); session->open_data = NULL; } @@ -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; } @@ -1300,9 +1300,9 @@ channel_request_pty_size(LIBSSH2_CHANNEL * channel, int width, sizeof(channel->reqPTY_packet_requirev_state)); _libssh2_debug((session, LIBSSH2_TRACE_CONN, - "changing tty size on channel %lu/%lu", - channel->local.id, - channel->remote.id)); + "changing tty size on channel %lu/%lu", + channel->local.id, + channel->remote.id)); s = channel->reqPTY_packet; @@ -1654,7 +1654,7 @@ LIBSSH2_API void libssh2_channel_set_blocking(LIBSSH2_CHANNEL * channel, int blocking) { 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; - return (rc == LIBSSH2_ERROR_EAGAIN?rc:0); + return rc == LIBSSH2_ERROR_EAGAIN ? rc : 0; } channel->write_bufwrite = buflen; @@ -2855,10 +2855,10 @@ int _libssh2_channel_free(LIBSSH2_CHANNEL *channel) /* Clear out packets meant for this channel */ _libssh2_htonu32(channel_id, channel->local.id); while((_libssh2_packet_ask(session, SSH_MSG_CHANNEL_DATA, &data, - &data_len, 1, channel_id, 4) >= 0) - || - (_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_packet_ask(session, SSH_MSG_CHANNEL_EXTENDED_DATA, &data, + &data_len, 1, channel_id, 4) >= 0)) { LIBSSH2_FREE(session, data); } diff --git a/src/comp.c b/src/comp.c index cd1146e4..527c516a 100644 --- a/src/comp.c +++ b/src/comp.c @@ -61,12 +61,12 @@ comp_method_none_comp(LIBSSH2_SESSION *session, size_t src_len, void **abstract) { - (void) session; - (void) abstract; - (void) dest; - (void) dest_len; - (void) src; - (void) src_len; + (void)session; + (void)abstract; + (void)dest; + (void)dest_len; + (void)src; + (void)src_len; return 0; } @@ -84,9 +84,9 @@ comp_method_none_decomp(LIBSSH2_SESSION * session, const unsigned char *src, size_t src_len, void **abstract) { - (void) session; - (void) payload_limit; - (void) abstract; + (void)session; + (void)payload_limit; + (void)abstract; *dest = (unsigned char *) src; *dest_len = src_len; return 0; diff --git a/src/crypt.c b/src/crypt.c index aefada08..fbeb5a5a 100644 --- a/src/crypt.c +++ b/src/crypt.c @@ -54,7 +54,7 @@ */ static int crypt_none_crypt(LIBSSH2_SESSION * session, unsigned char *buf, - void **abstract) + void **abstract) { /* Do nothing to the data! */ return 0; diff --git a/src/hostkey.c b/src/hostkey.c index 5384593f..2eda90fd 100644 --- a/src/hostkey.c +++ b/src/hostkey.c @@ -200,7 +200,7 @@ hostkey_method_ssh_rsa_sig_verify(LIBSSH2_SESSION * session, size_t m_len, void **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) */ if(sig_len < 15) @@ -260,13 +260,13 @@ hostkey_method_ssh_rsa_signv(LIBSSH2_SESSION * session, static int hostkey_method_ssh_rsa_sha2_256_sig_verify(LIBSSH2_SESSION * session, - const unsigned char *sig, - size_t sig_len, - const unsigned char *m, - size_t m_len, void **abstract) + const unsigned char *sig, + size_t sig_len, + const unsigned char *m, + size_t m_len, void **abstract) { libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract); - (void) session; + (void)session; /* Skip past keyname_len(4) + keyname(12){"rsa-sha2-256"} + signature_len(4) */ @@ -287,11 +287,11 @@ hostkey_method_ssh_rsa_sha2_256_sig_verify(LIBSSH2_SESSION * session, static int hostkey_method_ssh_rsa_sha2_256_signv(LIBSSH2_SESSION * session, - unsigned char **signature, - size_t *signature_len, - int veccount, - const struct iovec datavec[], - void **abstract) + unsigned char **signature, + size_t *signature_len, + int veccount, + const struct iovec datavec[], + void **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 hostkey_method_ssh_rsa_sha2_512_sig_verify(LIBSSH2_SESSION * session, - const unsigned char *sig, - size_t sig_len, - const unsigned char *m, - size_t m_len, void **abstract) + const unsigned char *sig, + size_t sig_len, + const unsigned char *m, + size_t m_len, void **abstract) { libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract); - (void) session; + (void)session; /* Skip past keyname_len(4) + keyname(12){"rsa-sha2-512"} + signature_len(4) */ @@ -357,11 +357,11 @@ hostkey_method_ssh_rsa_sha2_512_sig_verify(LIBSSH2_SESSION * session, */ static int hostkey_method_ssh_rsa_sha2_512_signv(LIBSSH2_SESSION * session, - unsigned char **signature, - size_t *signature_len, - int veccount, - const struct iovec datavec[], - void **abstract) + unsigned char **signature, + size_t *signature_len, + int veccount, + const struct iovec datavec[], + void **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) { libssh2_rsa_ctx *rsactx = (libssh2_rsa_ctx *) (*abstract); - (void) session; + (void)session; _libssh2_rsa_free(rsactx); @@ -673,7 +673,7 @@ static int hostkey_method_ssh_dss_dtor(LIBSSH2_SESSION * session, void **abstract) { libssh2_dsa_ctx *dsactx = (libssh2_dsa_ctx *) (*abstract); - (void) session; + (void)session; _libssh2_dsa_free(dsactx); @@ -712,9 +712,9 @@ hostkey_method_ssh_ecdsa_dtor(LIBSSH2_SESSION * session, */ static int hostkey_method_ssh_ecdsa_init(LIBSSH2_SESSION * session, - const unsigned char *hostkey_data, - size_t hostkey_data_len, - void **abstract) + const unsigned char *hostkey_data, + size_t hostkey_data_len, + void **abstract) { libssh2_ecdsa_ctx *ecdsactx = NULL; unsigned char *type_str, *domain, *public_key; @@ -793,9 +793,9 @@ hostkey_method_ssh_ecdsa_init(LIBSSH2_SESSION * session, */ static int hostkey_method_ssh_ecdsa_initPEM(LIBSSH2_SESSION * session, - const char *privkeyfile, - unsigned const char *passphrase, - void **abstract) + const char *privkeyfile, + unsigned const char *passphrase, + void **abstract) { libssh2_ecdsa_ctx *ec_ctx = NULL; int ret; @@ -821,10 +821,10 @@ hostkey_method_ssh_ecdsa_initPEM(LIBSSH2_SESSION * session, */ static int hostkey_method_ssh_ecdsa_initPEMFromMemory(LIBSSH2_SESSION * session, - const char *privkeyfiledata, - size_t privkeyfiledata_len, - unsigned const char *passphrase, - void **abstract) + const char *privkeyfiledata, + size_t privkeyfiledata_len, + unsigned const char *passphrase, + void **abstract) { libssh2_ecdsa_ctx *ec_ctx = NULL; int ret; @@ -866,7 +866,7 @@ hostkey_method_ssh_ecdsa_sig_verify(LIBSSH2_SESSION * session, struct string_buf buf; libssh2_ecdsa_ctx *ctx = (libssh2_ecdsa_ctx *) (*abstract); - (void) session; + (void)session; if(sig_len < 35) return -1; @@ -952,7 +952,7 @@ static int hostkey_method_ssh_ecdsa_dtor(LIBSSH2_SESSION * session, void **abstract) { libssh2_ecdsa_ctx *keyctx = (libssh2_ecdsa_ctx *) (*abstract); - (void) session; + (void)session; if(keyctx) _libssh2_ecdsa_free(keyctx); @@ -1102,9 +1102,9 @@ hostkey_method_ssh_ed25519_init(LIBSSH2_SESSION * session, */ static int hostkey_method_ssh_ed25519_initPEM(LIBSSH2_SESSION * session, - const char *privkeyfile, - unsigned const char *passphrase, - void **abstract) + const char *privkeyfile, + unsigned const char *passphrase, + void **abstract) { libssh2_ed25519_ctx *ec_ctx = NULL; int ret; @@ -1172,7 +1172,7 @@ hostkey_method_ssh_ed25519_sig_verify(LIBSSH2_SESSION * session, size_t m_len, void **abstract) { libssh2_ed25519_ctx *ctx = (libssh2_ed25519_ctx *) (*abstract); - (void) session; + (void)session; if(sig_len < 19) return -1; @@ -1195,11 +1195,11 @@ hostkey_method_ssh_ed25519_sig_verify(LIBSSH2_SESSION * session, */ static int hostkey_method_ssh_ed25519_signv(LIBSSH2_SESSION * session, - unsigned char **signature, - size_t *signature_len, - int veccount, - const struct iovec datavec[], - void **abstract) + unsigned char **signature, + size_t *signature_len, + int veccount, + const struct iovec datavec[], + void **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) { libssh2_ed25519_ctx *keyctx = (libssh2_ed25519_ctx*) (*abstract); - (void) session; + (void)session; if(keyctx) _libssh2_ed25519_free(keyctx); diff --git a/src/keepalive.c b/src/keepalive.c index 2151b171..f34255d7 100644 --- a/src/keepalive.c +++ b/src/keepalive.c @@ -42,9 +42,9 @@ /* Keep-alive stuff. */ LIBSSH2_API void -libssh2_keepalive_config (LIBSSH2_SESSION *session, - int want_reply, - unsigned interval) +libssh2_keepalive_config(LIBSSH2_SESSION *session, + int want_reply, + unsigned interval) { if(interval == 1) session->keepalive_interval = 2; @@ -54,8 +54,8 @@ libssh2_keepalive_config (LIBSSH2_SESSION *session, } LIBSSH2_API int -libssh2_keepalive_send (LIBSSH2_SESSION *session, - int *seconds_to_next) +libssh2_keepalive_send(LIBSSH2_SESSION *session, + int *seconds_to_next) { time_t now; diff --git a/src/kex.c b/src/kex.c index 2b12fdfb..53f07a5a 100644 --- a/src/kex.c +++ b/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, - LIBSSH2_SESSION *session, - kmdhgGPshakex_state_t *exchange_state, - unsigned char **data, size_t data_len, - const unsigned char *version) + LIBSSH2_SESSION *session, + kmdhgGPshakex_state_t *exchange_state, + unsigned char **data, size_t data_len, + const unsigned char *version) { if(sha_algo == 512) { 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; else { ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO, - "sha algo value is unimplemented"); + "sha algo value is unimplemented"); goto clean_exit; } @@ -479,8 +479,8 @@ static int diffie_hellman_sha_algo(LIBSSH2_SESSION *session, if(session->hostkey->init(session, session->server_hostkey, - session->server_hostkey_len, - &session->server_hostkey_abstract)) { + session->server_hostkey_len, + &session->server_hostkey_abstract)) { ret = _libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_INIT, "Unable to initialize hostkey importer"); 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, exchange_state->h_sig_comp, 4); _libssh2_sha_algo_ctx_update(sha_algo_value, exchange_hash_ctx, - session->local.banner, - strlen((char *) session->local.banner) - 2); + session->local.banner, + strlen((char *) session->local.banner) - 2); } else { _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, exchange_state->h_sig_comp, 4); _libssh2_sha_algo_ctx_update(sha_algo_value, exchange_hash_ctx, - (unsigned char *) - LIBSSH2_SSH_DEFAULT_BANNER, - sizeof(LIBSSH2_SSH_DEFAULT_BANNER) - 1); + (unsigned char *) + LIBSSH2_SSH_DEFAULT_BANNER, + sizeof(LIBSSH2_SSH_DEFAULT_BANNER) - 1); } _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->init(session, 1, - &session->local.comp_abstract)) { + &session->local.comp_abstract)) { ret = LIBSSH2_ERROR_KEX_FAILURE; 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->init(session, 0, - &session->remote.comp_abstract)) { + &session->remote.comp_abstract)) { ret = LIBSSH2_ERROR_KEX_FAILURE; goto clean_exit; } @@ -1050,8 +1050,8 @@ kex_method_diffie_hellman_group14_key_exchange(LIBSSH2_SESSION *session, key_state->state = libssh2_NB_state_created; } ret = hashfunc(session, key_state->g, key_state->p, - 256, sha_algo_value, exchange_hash_ctx, SSH_MSG_KEXDH_INIT, - SSH_MSG_KEXDH_REPLY, NULL, 0, &key_state->exchange_state); + 256, sha_algo_value, exchange_hash_ctx, SSH_MSG_KEXDH_INIT, + SSH_MSG_KEXDH_REPLY, NULL, 0, &key_state->exchange_state); if(ret == LIBSSH2_ERROR_EAGAIN) { return ret; } @@ -1077,9 +1077,9 @@ kex_method_diffie_hellman_group14_sha1_key_exchange(LIBSSH2_SESSION *session, { libssh2_sha1_ctx ctx; return kex_method_diffie_hellman_group14_key_exchange(session, - key_state, 1, - &ctx, - diffie_hellman_sha_algo); + key_state, 1, + &ctx, + diffie_hellman_sha_algo); } @@ -1094,9 +1094,9 @@ kex_method_diffie_hellman_group14_sha256_key_exchange(LIBSSH2_SESSION *session, { libssh2_sha256_ctx ctx; return kex_method_diffie_hellman_group14_key_exchange(session, - key_state, 256, - &ctx, - diffie_hellman_sha_algo); + key_state, 256, + &ctx, + diffie_hellman_sha_algo); } /* 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 */ 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; @@ -1741,7 +1743,7 @@ static int ecdh_sha2_nistp(LIBSSH2_SESSION *session, libssh2_curve_type type, buf.dataptr = buf.data; 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)) { ret = _libssh2_error(session, LIBSSH2_ERROR_ALLOC, "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 */ if(session->hostkey->init(session, session->server_hostkey, - session->server_hostkey_len, - &session->server_hostkey_abstract)) { + session->server_hostkey_len, + &session->server_hostkey_abstract)) { ret = _libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_INIT, "Unable to initialize hostkey importer"); 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, - session->local.crypt-> - secret_len, "C"); + session->local.crypt-> + secret_len, "C"); if(!secret) { 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->init(session, 1, - &session->local.comp_abstract)) { + &session->local.comp_abstract)) { ret = LIBSSH2_ERROR_KEX_FAILURE; 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->init(session, 0, - &session->remote.comp_abstract)) { + &session->remote.comp_abstract)) { ret = LIBSSH2_ERROR_KEX_FAILURE; goto clean_exit; } } _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, @@ -2472,8 +2472,8 @@ curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data, #endif /* LIBSSH2DEBUG */ if(session->hostkey->init(session, session->server_hostkey, - session->server_hostkey_len, - &session->server_hostkey_abstract)) { + session->server_hostkey_len, + &session->server_hostkey_abstract)) { ret = _libssh2_error(session, LIBSSH2_ERROR_HOSTKEY_INIT, "Unable to initialize hostkey importer"); goto clean_exit; @@ -2483,7 +2483,7 @@ curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data, if(_libssh2_get_string(&buf, &server_public_key, &server_public_key_len)) { ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO, - "Unexpected key length"); + "Unexpected key length"); goto clean_exit; } @@ -2604,7 +2604,7 @@ curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data, /* Cleanup any existing cipher */ if(session->local.crypt->dtor) { session->local.crypt->dtor(session, - &session->local.crypt_abstract); + &session->local.crypt_abstract); } /* 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->init(session, 1, - &session->local.comp_abstract)) { + &session->local.comp_abstract)) { ret = LIBSSH2_ERROR_KEX_FAILURE; goto clean_exit; } @@ -2776,12 +2776,12 @@ curve25519_sha256(LIBSSH2_SESSION *session, unsigned char *data, if(session->remote.comp && session->remote.comp->dtor) { 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->init(session, 0, - &session->remote.comp_abstract)) { + &session->remote.comp_abstract)) { ret = LIBSSH2_ERROR_KEX_FAILURE; goto clean_exit; } @@ -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) @@ -3042,7 +3041,7 @@ static const LIBSSH2_KEX_METHOD *libssh2_kex_methods[] = { &kex_method_diffie_helman_group1_sha1, &kex_method_diffie_helman_group_exchange_sha1, &kex_method_extension_negotiation, - NULL + NULL }; 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) \ (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) \ do { \ @@ -3168,8 +3167,8 @@ static int kexinit(LIBSSH2_SESSION * session) LIBSSH2_METHOD_PREFS_LEN(session->remote.lang_prefs, NULL); data_len += kex_len + hostkey_len + crypt_cs_len + crypt_sc_len + - comp_cs_len + comp_sc_len + mac_cs_len + mac_sc_len + - lang_cs_len + lang_sc_len; + comp_cs_len + comp_sc_len + mac_cs_len + mac_sc_len + + lang_cs_len + lang_sc_len; s = data = LIBSSH2_ALLOC(session, data_len); 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? */ if(kex_agree_hostkey(session, method->flags, hostkey, - hostkey_len) == 0) { + hostkey_len) == 0) { session->kex = method; if(session->burn_optimistic_kexinit && (kex == q)) { /* 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? */ if(kex_agree_hostkey(session, (*kexp)->flags, hostkey, - hostkey_len) == 0) { + hostkey_len) == 0) { session->kex = *kexp; if(session->burn_optimistic_kexinit && (kex == s)) { /* 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(); unsigned char *s; - (void) session; + (void)session; if(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(); unsigned char *s; - (void) session; + (void)session; if(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); unsigned char *s; - (void) session; + (void)session; if(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; if(kex_agree_methods(session, key_state->data, - key_state->data_len)) + key_state->data_len)) rc = LIBSSH2_ERROR_KEX_FAILURE; key_state->state = libssh2_NB_state_sent2; @@ -3950,44 +3949,42 @@ libssh2_session_method_pref(LIBSSH2_SESSION * session, int method_type, switch(method_type) { case LIBSSH2_METHOD_KEX: prefvar = &session->kex_prefs; - mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_kex_methods; + mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_kex_methods; break; case LIBSSH2_METHOD_HOSTKEY: prefvar = &session->hostkey_prefs; - mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_hostkey_methods(); + mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_hostkey_methods(); break; case LIBSSH2_METHOD_CRYPT_CS: prefvar = &session->local.crypt_prefs; - mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_crypt_methods(); + mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_crypt_methods(); break; case LIBSSH2_METHOD_CRYPT_SC: prefvar = &session->remote.crypt_prefs; - mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_crypt_methods(); + mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_crypt_methods(); break; case LIBSSH2_METHOD_MAC_CS: prefvar = &session->local.mac_prefs; - mlist = (const LIBSSH2_COMMON_METHOD **) _libssh2_mac_methods(); + mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_mac_methods(); break; case LIBSSH2_METHOD_MAC_SC: prefvar = &session->remote.mac_prefs; - mlist = (const LIBSSH2_COMMON_METHOD **) _libssh2_mac_methods(); + mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_mac_methods(); break; 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: @@ -4077,27 +4074,26 @@ LIBSSH2_API int libssh2_session_supported_algs(LIBSSH2_SESSION* session, switch(method_type) { case LIBSSH2_METHOD_KEX: - mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_kex_methods; + mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_kex_methods; break; case LIBSSH2_METHOD_HOSTKEY: - mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_hostkey_methods(); + mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_hostkey_methods(); break; case LIBSSH2_METHOD_CRYPT_CS: case LIBSSH2_METHOD_CRYPT_SC: - mlist = (const LIBSSH2_COMMON_METHOD **) libssh2_crypt_methods(); + mlist = (const LIBSSH2_COMMON_METHOD **)libssh2_crypt_methods(); break; case LIBSSH2_METHOD_MAC_CS: case LIBSSH2_METHOD_MAC_SC: - mlist = (const LIBSSH2_COMMON_METHOD **) _libssh2_mac_methods(); + mlist = (const LIBSSH2_COMMON_METHOD **)_libssh2_mac_methods(); break; 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: diff --git a/src/knownhost.c b/src/knownhost.c index c43762f8..30a46451 100644 --- a/src/knownhost.c +++ b/src/knownhost.c @@ -122,7 +122,7 @@ static struct libssh2_knownhost *knownhost_to_external(struct known_host *node) ext->magic = KNOWNHOST_MAGIC; ext->node = node; 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->typemask = node->typemask; diff --git a/src/libgcrypt.c b/src/libgcrypt.c index 1ef4d521..1013129b 100644 --- a/src/libgcrypt.c +++ b/src/libgcrypt.c @@ -59,17 +59,17 @@ _libssh2_rsa_new(libssh2_rsa_ctx ** rsa, const unsigned char *coeffdata, unsigned long coefflen) { int rc; - (void) e1data; - (void) e1len; - (void) e2data; - (void) e2len; + + (void)e1data; + (void)e1len; + (void)e2data; + (void)e2len; if(ddata) { - 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); + 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); } else { 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; if(x_len) { - 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); + 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); } else { rc = gcry_sexp_build(dsactx, NULL, @@ -198,7 +197,7 @@ _libssh2_rsa_new_private(libssh2_rsa_ctx ** rsa, ret = -1; 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); if(ret || (nlen != 1 && *n != '\0')) { 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, - q, qlen, e1, e1len, e2, e2len, coeff, coefflen)) { + q, qlen, e1, e1len, e2, e2len, coeff, coefflen)) { ret = -1; goto fail; } @@ -316,7 +315,7 @@ _libssh2_dsa_new_private(libssh2_dsa_ctx ** dsa, 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); if(ret || (plen != 1 && *p != '\0')) { ret = -1; @@ -388,8 +387,8 @@ _libssh2_rsa_sha1_sign(LIBSSH2_SESSION * session, } if(gcry_sexp_build(&data, NULL, - "(data (flags pkcs1) (hash sha1 %b))", - hash_len, hash)) { + "(data (flags pkcs1) (hash sha1 %b))", + hash_len, hash)) { return -1; } @@ -464,7 +463,7 @@ _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx, memset(sig, 0, 40); -/* Extract R. */ + /* Extract R. */ data = gcry_sexp_find_token(sig_sexp, "r", 0); if(!data) @@ -486,7 +485,7 @@ _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx, gcry_sexp_release(data); -/* Extract S. */ + /* Extract S. */ data = gcry_sexp_find_token(sig_sexp, "s", 0); if(!data) @@ -533,12 +532,12 @@ _libssh2_dsa_sha1_verify(libssh2_dsa_ctx * dsactx, hash[0] = 0; if(gcry_sexp_build(&s_hash, NULL, "(data(flags raw)(value %b))", - SHA_DIGEST_LENGTH + 1, hash)) { + SHA_DIGEST_LENGTH + 1, hash)) { return -1; } 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); return -1; } @@ -560,7 +559,7 @@ _libssh2_cipher_init(_libssh2_cipher_ctx * h, int mode = _libssh2_gcry_mode(algo); size_t keylen = gcry_cipher_get_algo_keylen(cipher); - (void) encrypt; + (void)encrypt; ret = gcry_cipher_open(h, cipher, mode, 0); if(ret) { diff --git a/src/mac.c b/src/mac.c index f0ce9933..ca0a4151 100644 --- a/src/mac.c +++ b/src/mac.c @@ -84,7 +84,7 @@ mac_method_common_init(LIBSSH2_SESSION * session, unsigned char *key, { *abstract = key; *free_key = 0; - (void) session; + (void)session; return 0; } @@ -113,15 +113,15 @@ mac_method_common_dtor(LIBSSH2_SESSION * session, void **abstract) */ static int mac_method_hmac_sha2_512_hash(LIBSSH2_SESSION * session, - unsigned char *buf, uint32_t seqno, - const unsigned char *packet, - size_t packet_len, - const unsigned char *addtl, - size_t addtl_len, void **abstract) + unsigned char *buf, uint32_t seqno, + const unsigned char *packet, + size_t packet_len, + const unsigned char *addtl, + size_t addtl_len, void **abstract) { libssh2_hmac_ctx ctx; unsigned char seqno_buf[4]; - (void) session; + (void)session; _libssh2_htonu32(seqno_buf, seqno); @@ -158,15 +158,15 @@ static const LIBSSH2_MAC_METHOD mac_method_hmac_sha2_512 = { */ static int mac_method_hmac_sha2_256_hash(LIBSSH2_SESSION * session, - unsigned char *buf, uint32_t seqno, - const unsigned char *packet, - size_t packet_len, - const unsigned char *addtl, - size_t addtl_len, void **abstract) + unsigned char *buf, uint32_t seqno, + const unsigned char *packet, + size_t packet_len, + const unsigned char *addtl, + size_t addtl_len, void **abstract) { libssh2_hmac_ctx ctx; unsigned char seqno_buf[4]; - (void) session; + (void)session; _libssh2_htonu32(seqno_buf, seqno); @@ -211,7 +211,7 @@ mac_method_hmac_sha1_hash(LIBSSH2_SESSION * session, { libssh2_hmac_ctx ctx; unsigned char seqno_buf[4]; - (void) session; + (void)session; _libssh2_htonu32(seqno_buf, seqno); @@ -284,7 +284,7 @@ mac_method_hmac_md5_hash(LIBSSH2_SESSION * session, unsigned char *buf, { libssh2_hmac_ctx ctx; unsigned char seqno_buf[4]; - (void) session; + (void)session; _libssh2_htonu32(seqno_buf, seqno); @@ -357,7 +357,7 @@ mac_method_hmac_ripemd160_hash(LIBSSH2_SESSION * session, { libssh2_hmac_ctx ctx; unsigned char seqno_buf[4]; - (void) session; + (void)session; _libssh2_htonu32(seqno_buf, seqno); diff --git a/src/mbedtls.c b/src/mbedtls.c index b6e1ba0f..e8d4f652 100644 --- a/src/mbedtls.c +++ b/src/mbedtls.c @@ -145,8 +145,8 @@ _libssh2_mbedtls_cipher_crypt(_libssh2_cipher_ctx *ctx, unsigned char *output; size_t osize, olen, finish_olen; - (void) encrypt; - (void) algo; + (void)encrypt; + (void)algo; osize = blocklen + mbedtls_cipher_get_block_size(ctx); @@ -182,8 +182,8 @@ _libssh2_mbedtls_cipher_dtor(_libssh2_cipher_ctx *ctx) int _libssh2_mbedtls_hash_init(mbedtls_md_context_t *ctx, - mbedtls_md_type_t mdtype, - const unsigned char *key, unsigned long keylen) + mbedtls_md_type_t mdtype, + const unsigned char *key, unsigned long keylen) { const mbedtls_md_info_t *md_info; int ret, hmac; @@ -315,22 +315,22 @@ _libssh2_mbedtls_bignum_random(_libssh2_bn *bn, int bits, int top, int bottom) int _libssh2_mbedtls_rsa_new(libssh2_rsa_ctx **rsa, - const unsigned char *edata, - unsigned long elen, - const unsigned char *ndata, - unsigned long nlen, - const unsigned char *ddata, - unsigned long dlen, - const unsigned char *pdata, - unsigned long plen, - const unsigned char *qdata, - unsigned long qlen, - const unsigned char *e1data, - unsigned long e1len, - const unsigned char *e2data, - unsigned long e2len, - const unsigned char *coeffdata, - unsigned long coefflen) + const unsigned char *edata, + unsigned long elen, + const unsigned char *ndata, + unsigned long nlen, + const unsigned char *ddata, + unsigned long dlen, + const unsigned char *pdata, + unsigned long plen, + const unsigned char *qdata, + unsigned long qlen, + const unsigned char *e1data, + unsigned long e1len, + const unsigned char *e2data, + unsigned long e2len, + const unsigned char *coeffdata, + unsigned long coefflen) { int ret; libssh2_rsa_ctx *ctx; @@ -391,9 +391,9 @@ _libssh2_mbedtls_rsa_new(libssh2_rsa_ctx **rsa, int _libssh2_mbedtls_rsa_new_private(libssh2_rsa_ctx **rsa, - LIBSSH2_SESSION *session, - const char *filename, - const unsigned char *passphrase) + LIBSSH2_SESSION *session, + const char *filename, + const unsigned char *passphrase) { int ret; mbedtls_pk_context pkey; @@ -434,10 +434,10 @@ _libssh2_mbedtls_rsa_new_private(libssh2_rsa_ctx **rsa, int _libssh2_mbedtls_rsa_new_private_frommemory(libssh2_rsa_ctx **rsa, - LIBSSH2_SESSION *session, - const char *filedata, - size_t filedata_len, - unsigned const char *passphrase) + LIBSSH2_SESSION *session, + const char *filedata, + size_t filedata_len, + unsigned const char *passphrase) { int ret; mbedtls_pk_context pkey; @@ -492,10 +492,10 @@ _libssh2_mbedtls_rsa_new_private_frommemory(libssh2_rsa_ctx **rsa, int _libssh2_mbedtls_rsa_sha2_verify(libssh2_rsa_ctx * rsactx, - size_t hash_len, - const unsigned char *sig, - unsigned long sig_len, - const unsigned char *m, unsigned long m_len) + size_t hash_len, + const unsigned char *sig, + unsigned long sig_len, + const unsigned char *m, unsigned long m_len) { int ret; int md_type; @@ -544,9 +544,9 @@ _libssh2_mbedtls_rsa_sha2_verify(libssh2_rsa_ctx * rsactx, int _libssh2_mbedtls_rsa_sha1_verify(libssh2_rsa_ctx * rsactx, - const unsigned char *sig, - unsigned long sig_len, - const unsigned char *m, unsigned long m_len) + const unsigned char *sig, + unsigned long sig_len, + const unsigned char *m, unsigned long m_len) { return _libssh2_mbedtls_rsa_sha2_verify(rsactx, SHA_DIGEST_LENGTH, sig, sig_len, m, m_len); @@ -554,11 +554,11 @@ _libssh2_mbedtls_rsa_sha1_verify(libssh2_rsa_ctx * rsactx, int _libssh2_mbedtls_rsa_sha2_sign(LIBSSH2_SESSION *session, - libssh2_rsa_ctx *rsa, - const unsigned char *hash, - size_t hash_len, - unsigned char **signature, - size_t *signature_len) + libssh2_rsa_ctx *rsa, + const unsigned char *hash, + size_t hash_len, + unsigned char **signature, + size_t *signature_len) { int ret; unsigned char *sig; @@ -611,13 +611,14 @@ _libssh2_mbedtls_rsa_sha2_sign(LIBSSH2_SESSION *session, int _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) + libssh2_rsa_ctx * rsactx, + const unsigned char *hash, + size_t hash_len, + unsigned char **signature, + size_t *signature_len) { return _libssh2_mbedtls_rsa_sha2_sign(session, rsactx, hash, hash_len, - signature, signature_len); + signature, signature_len); } void @@ -629,8 +630,8 @@ _libssh2_mbedtls_rsa_free(libssh2_rsa_ctx *ctx) static unsigned char * gen_publickey_from_rsa(LIBSSH2_SESSION *session, - mbedtls_rsa_context *rsa, - size_t *keylen) + mbedtls_rsa_context *rsa, + size_t *keylen) { uint32_t e_bytes, n_bytes; uint32_t len; @@ -670,11 +671,11 @@ gen_publickey_from_rsa(LIBSSH2_SESSION *session, static int _libssh2_mbedtls_pub_priv_key(LIBSSH2_SESSION *session, - unsigned char **method, - size_t *method_len, - unsigned char **pubkeydata, - size_t *pubkeydata_len, - mbedtls_pk_context *pkey) + unsigned char **method, + size_t *method_len, + unsigned char **pubkeydata, + size_t *pubkeydata_len, + mbedtls_pk_context *pkey) { unsigned char *key = NULL, *mth = NULL; size_t keylen = 0, mthlen = 0; @@ -722,12 +723,12 @@ _libssh2_mbedtls_pub_priv_key(LIBSSH2_SESSION *session, int _libssh2_mbedtls_pub_priv_keyfile(LIBSSH2_SESSION *session, - unsigned char **method, - size_t *method_len, - unsigned char **pubkeydata, - size_t *pubkeydata_len, - const char *privatekey, - const char *passphrase) + unsigned char **method, + size_t *method_len, + unsigned char **pubkeydata, + size_t *pubkeydata_len, + const char *privatekey, + const char *passphrase) { mbedtls_pk_context pkey; 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, - pubkeydata, pubkeydata_len, &pkey); + pubkeydata, pubkeydata_len, &pkey); mbedtls_pk_free(&pkey); @@ -757,13 +758,13 @@ _libssh2_mbedtls_pub_priv_keyfile(LIBSSH2_SESSION *session, int _libssh2_mbedtls_pub_priv_keyfilememory(LIBSSH2_SESSION *session, - unsigned char **method, - size_t *method_len, - unsigned char **pubkeydata, - size_t *pubkeydata_len, - const char *privatekeydata, - size_t privatekeydata_len, - const char *passphrase) + unsigned char **method, + size_t *method_len, + unsigned char **pubkeydata, + size_t *pubkeydata_len, + const char *privatekeydata, + size_t privatekeydata_len, + const char *passphrase) { mbedtls_pk_context pkey; 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, - pubkeydata, pubkeydata_len, &pkey); + pubkeydata, pubkeydata_len, &pkey); mbedtls_pk_free(&pkey); diff --git a/src/misc.c b/src/misc.c index 74c7573f..47d9dc8f 100644 --- a/src/misc.c +++ b/src/misc.c @@ -162,7 +162,7 @@ _libssh2_recv(libssh2_socket_t sock, void *buffer, size_t length, { ssize_t rc; - (void) abstract; + (void)abstract; rc = recv(sock, buffer, length, flags); #ifdef WIN32 @@ -195,7 +195,7 @@ _libssh2_send(libssh2_socket_t sock, const void *buffer, size_t length, { ssize_t rc; - (void) abstract; + (void)abstract; rc = send(sock, buffer, length, flags); #ifdef WIN32 @@ -372,7 +372,7 @@ libssh2_base64_decode(LIBSSH2_SESSION *session, char **data, /* ---- Base64 Encoding/Decoding Table --- */ static const char table64[]= - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /* * _libssh2_base64_encode @@ -545,8 +545,8 @@ _libssh2_debug_low(LIBSSH2_SESSION * session, int context, const char *format, LIBSSH2_API int libssh2_trace(LIBSSH2_SESSION * session, int bitmask) { - (void) session; - (void) bitmask; + (void)session; + (void)bitmask; return 0; } @@ -554,9 +554,9 @@ LIBSSH2_API int libssh2_trace_sethandler(LIBSSH2_SESSION *session, void *handler_context, libssh2_trace_handler_func callback) { - (void) session; - (void) handler_context; - (void) callback; + (void)session; + (void)handler_context; + (void)callback; return 0; } #endif diff --git a/src/openssl.c b/src/openssl.c index af5fa6c1..23c8d53b 100644 --- a/src/openssl.c +++ b/src/openssl.c @@ -420,9 +420,9 @@ _libssh2_ecdsa_curve_name_with_octal_new(libssh2_ecdsa_ctx ** ec_ctx, int _libssh2_ecdsa_verify(libssh2_ecdsa_ctx * ctx, - const unsigned char *r, size_t r_len, - const unsigned char *s, size_t s_len, - const unsigned char *m, size_t m_len) + const unsigned char *r, size_t r_len, + const unsigned char *s, size_t s_len, + const unsigned char *m, size_t m_len) { int ret = 0; 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]; int ret; int rc = 1; - (void) algo; - (void) encrypt; + + (void)algo; + (void)encrypt; #ifdef HAVE_OPAQUE_STRUCTS 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) { int passphrase_len = (int) strlen(passphrase); - (void) rwflag; + + (void)rwflag; if(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(); 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; @@ -1298,9 +1303,10 @@ _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, - unsigned const char *passphrase) + LIBSSH2_SESSION * session, + 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; @@ -1333,7 +1341,7 @@ int _libssh2_ecdsa_new_private_frommemory_sk(libssh2_ecdsa_ctx ** ec_ctx, { int algorithm; return _libssh2_sk_pub_openssh_keyfilememory(session, - (void **)ec_ctx, + (void **)ec_ctx, "sk-ecdsa-sha2-nistp256@openssh.com", NULL, NULL, @@ -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,7 +2091,8 @@ _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx, const BIGNUM * r; const BIGNUM * s; int r_len, s_len; - (void) hash_len; + + (void)hash_len; sig = DSA_do_sign(hash, SHA_DIGEST_LENGTH, dsactx); if(!sig) { @@ -2121,8 +2131,8 @@ _libssh2_dsa_sha1_sign(libssh2_dsa_ctx * dsactx, int _libssh2_ecdsa_sign(LIBSSH2_SESSION * session, libssh2_ecdsa_ctx * ec_ctx, - const unsigned char *hash, unsigned long hash_len, - unsigned char **signature, size_t *signature_len) + const unsigned char *hash, unsigned long hash_len, + unsigned char **signature, size_t *signature_len) { int r_len, s_len; int rc = 0; @@ -2448,8 +2458,8 @@ gen_publickey_from_ec_evp(LIBSSH2_SESSION *session, libssh2_curve_type type; _libssh2_debug((session, - LIBSSH2_TRACE_AUTH, - "Computing public key from EC private key envelope")); + LIBSSH2_TRACE_AUTH, + "Computing public key from EC private key envelope")); bn_ctx = BN_CTX_new(); if(!bn_ctx) @@ -2473,7 +2483,7 @@ gen_publickey_from_ec_evp(LIBSSH2_SESSION *session, method_buf = LIBSSH2_ALLOC(session, *method_len); if(!method_buf) { return _libssh2_error(session, LIBSSH2_ERROR_ALLOC, - "out of memory"); + "out of memory"); } if(is_sk) @@ -2486,8 +2496,8 @@ gen_publickey_from_ec_evp(LIBSSH2_SESSION *session, memcpy(method_buf, "ecdsa-sha2-nistp521", *method_len); else { _libssh2_debug((session, - LIBSSH2_TRACE_ERROR, - "Unsupported EC private key type")); + LIBSSH2_TRACE_ERROR, + "Unsupported EC private key type")); rc = -1; goto clean_exit; } @@ -2805,7 +2815,7 @@ _libssh2_ecdsa_new_openssh_private(libssh2_ecdsa_ctx ** ec_ctx, if(!session) { _libssh2_error(session, LIBSSH2_ERROR_PROTO, - "Session is required"); + "Session is required"); return -1; } @@ -2867,7 +2877,7 @@ _libssh2_ecdsa_new_openssh_private_sk(libssh2_ecdsa_ctx ** ec_ctx, if(!session) { _libssh2_error(session, LIBSSH2_ERROR_PROTO, - "Session is required"); + "Session is required"); return -1; } @@ -3551,7 +3561,7 @@ _libssh2_pub_priv_openssh_keyfilememory(LIBSSH2_SESSION *session, method, method_len, pubkeydata, pubkeydata_len, - (libssh2_rsa_ctx**)key_ctx); + (libssh2_rsa_ctx**)key_ctx); } } #endif @@ -3559,10 +3569,10 @@ _libssh2_pub_priv_openssh_keyfilememory(LIBSSH2_SESSION *session, if(strcmp("ssh-dss", (const char *)buf) == 0) { if(!key_type || strcmp("ssh-dss", key_type) == 0) { rc = gen_publickey_from_dsa_openssh_priv_data(session, decrypted, - method, method_len, + method, method_len, pubkeydata, pubkeydata_len, - (libssh2_dsa_ctx**)key_ctx); + (libssh2_dsa_ctx**)key_ctx); } } #endif @@ -3578,7 +3588,7 @@ _libssh2_pub_priv_openssh_keyfilememory(LIBSSH2_SESSION *session, 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) == 0) { @@ -3588,7 +3598,7 @@ _libssh2_pub_priv_openssh_keyfilememory(LIBSSH2_SESSION *session, method, method_len, pubkeydata, 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, key_handle, handle_len, - (libssh2_ecdsa_ctx**)key_ctx); + (libssh2_ecdsa_ctx**)key_ctx); } } #endif @@ -3757,7 +3767,7 @@ _libssh2_pub_priv_keyfilememory(LIBSSH2_SESSION *session, pubkeydata_len, privatekeydata, privatekeydata_len, - (unsigned const char *)passphrase); + (unsigned const char *)passphrase); if(st) return st; return 0; diff --git a/src/packet.c b/src/packet.c index a5e32d17..3ce2e8cc 100644 --- a/src/packet.c +++ b/src/packet.c @@ -1240,8 +1240,8 @@ _libssh2_packet_require(LIBSSH2_SESSION * session, unsigned char packet_type, { if(state->start == 0) { if(_libssh2_packet_ask(session, packet_type, data, data_len, - match_ofs, match_buf, - match_len) == 0) { + match_ofs, match_buf, + match_len) == 0) { /* A packet was available in the packet brigade */ return 0; } @@ -1305,7 +1305,7 @@ _libssh2_packet_burn(LIBSSH2_SESSION * session, all_packets[254] = 0; if(_libssh2_packet_askv(session, all_packets, &data, &data_len, 0, - NULL, 0) == 0) { + NULL, 0) == 0) { i = data[0]; /* A packet was available in the packet brigade, burn it */ 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 */ if(0 == _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 */ LIBSSH2_FREE(session, data); *state = libssh2_NB_state_idle; @@ -1363,7 +1363,7 @@ _libssh2_packet_requirev(LIBSSH2_SESSION *session, packet_requirev_state_t * state) { 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 */ state->start = 0; return 0; diff --git a/src/pem.c b/src/pem.c index 69120e64..571d6e07 100644 --- a/src/pem.c +++ b/src/pem.c @@ -427,7 +427,7 @@ _libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session, if(_libssh2_get_string(&decoded, &kdfname, &tmp_len) || tmp_len == 0) { ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO, - "kdfname is missing"); + "kdfname is missing"); 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) { ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO, - "Private key data not found"); + "Private key data not found"); goto out; } @@ -505,7 +505,7 @@ _libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session, if(!method) { ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO, - "No supported cipher found"); + "No supported cipher found"); goto out; } } @@ -522,7 +522,7 @@ _libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session, key = LIBSSH2_CALLOC(session, total_len); if(!key) { ret = _libssh2_error(session, LIBSSH2_ERROR_PROTO, - "Could not alloc key"); + "Could not alloc key"); goto out; } @@ -547,7 +547,7 @@ _libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session, } else { ret = _libssh2_error(session, LIBSSH2_ERROR_KEYFILE_AUTH_FAILED, - "bcrypted without passphrase"); + "bcrypted without passphrase"); LIBSSH2_FREE(session, key); goto out; } @@ -574,7 +574,7 @@ _libssh2_openssh_pem_parse_data(LIBSSH2_SESSION * session, /* Initialize the decryption */ if(method->init(session, method, iv_part, &free_iv, key_part, - &free_secret, 0, &abstract)) { + &free_secret, 0, &abstract)) { ret = LIBSSH2_ERROR_DECRYPT; goto out; } diff --git a/src/scp.c b/src/scp.c index 24c70ac3..4fb81b92 100644 --- a/src/scp.c +++ b/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_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 = 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, session->scpRecv_command_len, - "scp -%sf ", sb?"p":""); + "scp -%sf ", sb ? "p" : ""); cmd_len = strlen((char *)session->scpRecv_command); 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) || (session->scpRecv_state == libssh2_NB_state_sent3)) { while(sb && (session->scpRecv_response_len < - LIBSSH2_SCP_RESPONSE_BUFLEN)) { + LIBSSH2_SCP_RESPONSE_BUFLEN)) { unsigned char *s, *p; 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) { session->scpSend_command_len = _libssh2_shell_quotedsize(path) + sizeof("scp -t ") + - ((mtime || atime)?1:0); + ((mtime || atime) ? 1 : 0); session->scpSend_command = 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, session->scpSend_command_len, - "scp -%st ", (mtime || atime)?"p":""); + "scp -%st ", (mtime || atime) ? "p" : ""); cmd_len = strlen((char *)session->scpSend_command); cmd_len += shell_quotearg(path, diff --git a/src/session.c b/src/session.c index c5800a36..eea239e2 100644 --- a/src/session.c +++ b/src/session.c @@ -75,7 +75,7 @@ static LIBSSH2_ALLOC_FUNC(libssh2_default_alloc) { - (void) abstract; + (void)abstract; return malloc(count); } @@ -84,7 +84,7 @@ LIBSSH2_ALLOC_FUNC(libssh2_default_alloc) static LIBSSH2_FREE_FUNC(libssh2_default_free) { - (void) abstract; + (void)abstract; free(ptr); } @@ -93,7 +93,7 @@ LIBSSH2_FREE_FUNC(libssh2_default_free) static LIBSSH2_REALLOC_FUNC(libssh2_default_realloc) { - (void) abstract; + (void)abstract; return realloc(ptr, count); } @@ -121,15 +121,15 @@ banner_receive(LIBSSH2_SESSION * session) } while((banner_len < sizeof(session->banner_TxRx_banner)) && - ((banner_len == 0) - || (session->banner_TxRx_banner[banner_len - 1] != '\n'))) { + ((banner_len == 0) + || (session->banner_TxRx_banner[banner_len - 1] != '\n'))) { char c = '\0'; /* no incoming block yet! */ session->socket_block_directions &= ~LIBSSH2_SESSION_BLOCK_INBOUND; ret = LIBSSH2_RECV(session, &c, 1, - LIBSSH2_SOCKET_RECV_FLAGS(session)); + LIBSSH2_SOCKET_RECV_FLAGS(session)); if(ret < 0) { if(session->api_block_mode || (ret != -EAGAIN)) /* ignore EAGAIN when non-blocking */ @@ -174,8 +174,8 @@ banner_receive(LIBSSH2_SESSION * session) } while(banner_len && - ((session->banner_TxRx_banner[banner_len - 1] == '\n') || - (session->banner_TxRx_banner[banner_len - 1] == '\r'))) { + ((session->banner_TxRx_banner[banner_len - 1] == '\n') || + (session->banner_TxRx_banner[banner_len - 1] == '\r'))) { banner_len--; } @@ -249,9 +249,9 @@ banner_send(LIBSSH2_SESSION * session) session->socket_block_directions &= ~LIBSSH2_SESSION_BLOCK_OUTBOUND; ret = LIBSSH2_SEND(session, - banner + session->banner_TxRx_total_send, - banner_len - session->banner_TxRx_total_send, - LIBSSH2_SOCKET_SEND_FLAGS(session)); + banner + session->banner_TxRx_total_send, + banner_len - session->banner_TxRx_total_send, + LIBSSH2_SOCKET_SEND_FLAGS(session)); if(ret < 0) _libssh2_debug((session, LIBSSH2_TRACE_SOCKET, "Error sending %d bytes: %d", @@ -414,7 +414,7 @@ get_socket_nonblocking(libssh2_socket_t sockfd) size_t size = sizeof(int); callstat = getsockopt(sockfd, SOL_SOCKET, SO_STATE, - (char *)&sockstat, &size); + (char *)&sockstat, &size); if(callstat == -1) { return 0; } @@ -1428,7 +1428,7 @@ _libssh2_session_set_blocking(LIBSSH2_SESSION *session, int blocking) { int bl = session->api_block_mode; _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; return bl; @@ -1442,7 +1442,7 @@ _libssh2_session_set_blocking(LIBSSH2_SESSION *session, int blocking) LIBSSH2_API void 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 diff --git a/src/sftp.c b/src/sftp.c index 37367812..a7c25cc8 100644 --- a/src/sftp.c +++ b/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) { for(i = 0; i < num_valid_responses; i++) { 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 * the timeout is not active @@ -741,8 +741,8 @@ LIBSSH2_CHANNEL_CLOSE_FUNC(libssh2_sftp_dtor) { LIBSSH2_SFTP *sftp = (LIBSSH2_SFTP *) (*channel_abstract); - (void) session_abstract; - (void) channel; + (void)session_abstract; + (void)channel; /* Free the partial packet storage for sftp_packet_read */ if(sftp->partial_packet) { @@ -971,7 +971,7 @@ static LIBSSH2_SFTP *sftp_init(LIBSSH2_SESSION *session) sftp_init_error: while(_libssh2_channel_free(session->sftpInit_channel) == - LIBSSH2_ERROR_EAGAIN); + LIBSSH2_ERROR_EAGAIN); session->sftpInit_channel = NULL; if(session->sftpInit_sftp) { LIBSSH2_FREE(session, session->sftpInit_sftp); @@ -1107,7 +1107,7 @@ sftp_open(LIBSSH2_SFTP *sftp, const char *filename, }; unsigned char *s; 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) { 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 get that data as well passed in here again. */ - already = (size_t) (handle->u.file.offset_sent - - handle->u.file.offset)+ + already = (size_t)(handle->u.file.offset_sent - + handle->u.file.offset)+ handle->u.file.acked; if(count >= already) { @@ -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; diff --git a/src/sftp.h b/src/sftp.h index 129b8f08..b0019b88 100644 --- a/src/sftp.h +++ b/src/sftp.h @@ -68,7 +68,7 @@ struct sftp_zombie_requests { }; #ifndef MIN -#define MIN(x,y) ((x)<(y)?(x):(y)) +#define MIN(x,y) ((x) < (y) ? (x) : (y)) #endif struct _LIBSSH2_SFTP_PACKET diff --git a/src/transport.c b/src/transport.c index f0e99848..19ad6ec2 100644 --- a/src/transport.c +++ b/src/transport.c @@ -141,7 +141,7 @@ decrypt(LIBSSH2_SESSION * session, unsigned char *source, while(len >= blocksize) { if(session->remote.crypt->crypt(session, source, blocksize, - &session->remote.crypt_abstract)) { + &session->remote.crypt_abstract)) { LIBSSH2_FREE(session, p->payload); return LIBSSH2_ERROR_DECRYPT; } @@ -201,11 +201,10 @@ 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 && - session->local.comp->compress && - ((session->state & LIBSSH2_STATE_AUTHENTICATED) || - session->local.comp->use_in_auth); + compressed = session->local.comp && + session->local.comp->compress && + ((session->state & LIBSSH2_STATE_AUTHENTICATED) || + session->local.comp->use_in_auth); 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 */ - nread = - LIBSSH2_RECV(session, &p->buf[remainbuf], - PACKETBUFSIZE - remainbuf, - LIBSSH2_SOCKET_RECV_FLAGS(session)); + nread = LIBSSH2_RECV(session, &p->buf[remainbuf], + PACKETBUFSIZE - remainbuf, + LIBSSH2_SOCKET_RECV_FLAGS(session)); if(nread <= 0) { /* check if this is due to EAGAIN and return the special 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 (5 bytes) packet length and padding length fields */ - total_num = - p->packet_length - 1 + - (encrypted ? session->remote.mac->mac_len : 0); + total_num = p->packet_length - 1 + + (encrypted ? session->remote.mac->mac_len : 0); /* 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; rc = LIBSSH2_SEND(session, &p->outbuf[p->osent], length, - LIBSSH2_SOCKET_SEND_FLAGS(session)); + LIBSSH2_SOCKET_SEND_FLAGS(session)); if(rc < 0) _libssh2_debug((session, LIBSSH2_TRACE_SOCKET, "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; - compressed = - session->local.comp && - session->local.comp->compress && - ((session->state & LIBSSH2_STATE_AUTHENTICATED) || - session->local.comp->use_in_auth); + compressed = session->local.comp && + session->local.comp->compress && + ((session->state & LIBSSH2_STATE_AUTHENTICATED) || + session->local.comp->use_in_auth); if(encrypted && compressed && session->local.comp_abstract) { /* 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) { unsigned char *ptr = &p->outbuf[i]; if(session->local.crypt->crypt(session, ptr, - session->local.crypt->blocksize, - &session->local.crypt_abstract)) + session->local.crypt->blocksize, + &session->local.crypt_abstract)) return LIBSSH2_ERROR_ENCRYPT; /* encryption failure */ } } @@ -901,7 +897,7 @@ int _libssh2_transport_send(LIBSSH2_SESSION *session, session->local.seqno++; ret = LIBSSH2_SEND(session, p->outbuf, total_length, - LIBSSH2_SOCKET_SEND_FLAGS(session)); + LIBSSH2_SOCKET_SEND_FLAGS(session)); if(ret < 0) _libssh2_debug((session, LIBSSH2_TRACE_SOCKET, "Error sending %d bytes: %d", total_length, -ret)); diff --git a/src/userauth.c b/src/userauth.c index 274fd0c3..3cf0138b 100644 --- a/src/userauth.c +++ b/src/userauth.c @@ -223,7 +223,7 @@ static char *userauth_list(LIBSSH2_SESSION *session, const char *username, } session->userauth_list_state = libssh2_NB_state_idle; - return (char *) session->userauth_list_data; + return (char *)session->userauth_list_data; } /* libssh2_userauth_list @@ -276,7 +276,7 @@ libssh2_userauth_banner(LIBSSH2_SESSION *session, char **banner) LIBSSH2_API int 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; } - if(libssh2_base64_decode(session, (char **) &tmp, &tmp_len, - (const char *) sp1, - (unsigned int)(sp2 - sp1))) { + if(libssh2_base64_decode(session, (char **)&tmp, &tmp_len, + (const char *)sp1, + (unsigned int)(sp2 - sp1))) { LIBSSH2_FREE(session, pubkey); return _libssh2_error(session, LIBSSH2_ERROR_FILE, "Invalid key data, not base64 encoded"); @@ -715,9 +715,9 @@ file_read_publickey(LIBSSH2_SESSION * session, unsigned char **method, sp2 = pubkey + pubkey_len; } - if(libssh2_base64_decode(session, (char **) &tmp, &tmp_len, - (const char *) sp1, - (unsigned int)(sp2 - sp1))) { + if(libssh2_base64_decode(session, (char **)&tmp, &tmp_len, + (const char *)sp1, + (unsigned int)(sp2 - sp1))) { LIBSSH2_FREE(session, pubkey); return _libssh2_error(session, LIBSSH2_ERROR_FILE, "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; if(privkeyobj->signv(session, sig, sig_len, 1, &datavec, - &hostkey_abstract)) { + &hostkey_abstract)) { if(privkeyobj->dtor) { 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; if(privkeyobj->signv(session, sig, sig_len, 1, &datavec, - &hostkey_abstract)) { + &hostkey_abstract)) { if(privkeyobj->dtor) { privkeyobj->dtor(session, &hostkey_abstract); } @@ -1106,8 +1106,8 @@ userauth_hostbased_fromfile(LIBSSH2_SESSION *session, datavec[2].iov_len = session->userauth_host_packet_len; if(privkeyobj && privkeyobj->signv && - privkeyobj->signv(session, &sig, &sig_len, 3, - datavec, &abstract)) { + privkeyobj->signv(session, &sig, &sig_len, 3, + datavec, &abstract)) { LIBSSH2_FREE(session, session->userauth_host_method); session->userauth_host_method = NULL; LIBSSH2_FREE(session, session->userauth_host_packet); @@ -1478,8 +1478,8 @@ _libssh2_userauth_publickey(LIBSSH2_SESSION *session, * the key default algo */ if(auth_attempts == 1) { rc = _libssh2_key_sign_algorithm(session, - &session->userauth_pblc_method, - &session->userauth_pblc_method_len); + &session->userauth_pblc_method, + &session->userauth_pblc_method_len); if(rc) return rc; @@ -1972,7 +1972,7 @@ libssh2_userauth_publickey(LIBSSH2_SESSION *session, const unsigned char *pubkeydata, size_t pubkeydata_len, LIBSSH2_USERAUTH_PUBLICKEY_SIGN_FUNC - ((*sign_callback)), + ((*sign_callback)), void **abstract) { int rc; @@ -1999,7 +1999,7 @@ userauth_keyboard_interactive(LIBSSH2_SESSION * session, const char *username, unsigned int username_len, LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC - ((*response_callback))) + ((*response_callback))) { unsigned char *s; @@ -2273,7 +2273,7 @@ libssh2_userauth_keyboard_interactive_ex(LIBSSH2_SESSION *session, const char *user, unsigned int user_len, LIBSSH2_USERAUTH_KBDINT_RESPONSE_FUNC - ((*response_callback))) + ((*response_callback))) { int rc; BLOCK_ADJUST(rc, session, @@ -2295,7 +2295,7 @@ libssh2_userauth_publickey_sk(LIBSSH2_SESSION *session, size_t privatekeydata_len, const char *passphrase, LIBSSH2_USERAUTH_SK_SIGN_FUNC - ((*sign_callback)), + ((*sign_callback)), void **abstract) { unsigned char *pubkeydata = NULL; diff --git a/src/wincng.c b/src/wincng.c index e35de113..ea9ba9e1 100644 --- a/src/wincng.c +++ b/src/wincng.c @@ -604,12 +604,12 @@ _libssh2_wincng_hmac_cleanup(_libssh2_wincng_hash_ctx *ctx) int _libssh2_wincng_key_sha_verify(_libssh2_wincng_key_ctx *ctx, - unsigned long hashlen, - const unsigned char *sig, - unsigned long sig_len, - const unsigned char *m, - unsigned long m_len, - unsigned long flags) + unsigned long hashlen, + const unsigned char *sig, + unsigned long sig_len, + const unsigned char *m, + unsigned long m_len, + unsigned long flags) { BCRYPT_PKCS1_PADDING_INFO paddingInfoPKCS1; BCRYPT_ALG_HANDLE hAlgHash; @@ -1267,11 +1267,11 @@ _libssh2_wincng_rsa_sha2_verify(libssh2_rsa_ctx* rsa, int _libssh2_wincng_rsa_sha_sign(LIBSSH2_SESSION *session, - libssh2_rsa_ctx *rsa, - const unsigned char *hash, - size_t hash_len, - unsigned char **signature, - size_t *signature_len) + libssh2_rsa_ctx *rsa, + const unsigned char *hash, + size_t hash_len, + unsigned char **signature, + size_t *signature_len) { BCRYPT_PKCS1_PADDING_INFO paddingInfo; unsigned char *data, *sig;