1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-27 13:21:11 +03:00

cleanup: use ssh_ prefix in the packet (non-static) functions

Having "ssh_" prefix in the functions' name will avoid possible clashes
when compiling libssh statically.

Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Fabiano Fidêncio
2015-09-17 14:11:08 +02:00
parent 310c41a89a
commit e368d01385
18 changed files with 86 additions and 86 deletions

View File

@@ -43,10 +43,10 @@ enum ssh_packet_state_e {
PACKET_STATE_PROCESSING PACKET_STATE_PROCESSING
}; };
int packet_send(ssh_session session); int ssh_packet_send(ssh_session session);
#ifdef WITH_SSH1 #ifdef WITH_SSH1
int packet_send1(ssh_session session) ; int ssh_packet_send1(ssh_session session) ;
void ssh_packet_set_default_callbacks1(ssh_session session); void ssh_packet_set_default_callbacks1(ssh_session session);
SSH_PACKET_CALLBACK(ssh_packet_disconnect1); SSH_PACKET_CALLBACK(ssh_packet_disconnect1);
@@ -78,12 +78,12 @@ void ssh_packet_set_default_callbacks(ssh_session session);
void ssh_packet_process(ssh_session session, uint8_t type); void ssh_packet_process(ssh_session session, uint8_t type);
/* PACKET CRYPT */ /* PACKET CRYPT */
uint32_t packet_decrypt_len(ssh_session session, char *crypted); uint32_t ssh_packet_decrypt_len(ssh_session session, char *crypted);
int packet_decrypt(ssh_session session, void *packet, unsigned int len); int ssh_packet_decrypt(ssh_session session, void *packet, unsigned int len);
unsigned char *packet_encrypt(ssh_session session, unsigned char *ssh_packet_encrypt(ssh_session session,
void *packet, void *packet,
unsigned int len); unsigned int len);
int packet_hmac_verify(ssh_session session,ssh_buffer buffer, int ssh_packet_hmac_verify(ssh_session session,ssh_buffer buffer,
unsigned char *mac, enum ssh_hmac_e type); unsigned char *mac, enum ssh_hmac_e type);
#endif /* PACKET_H_ */ #endif /* PACKET_H_ */

View File

@@ -391,7 +391,7 @@ int ssh_userauth_none(ssh_session session, const char *username) {
session->auth_state = SSH_AUTH_STATE_NONE; session->auth_state = SSH_AUTH_STATE_NONE;
session->pending_call_state = SSH_PENDING_CALL_AUTH_NONE; session->pending_call_state = SSH_PENDING_CALL_AUTH_NONE;
rc = packet_send(session); rc = ssh_packet_send(session);
if (rc == SSH_ERROR) { if (rc == SSH_ERROR) {
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
} }
@@ -503,7 +503,7 @@ int ssh_userauth_try_publickey(ssh_session session,
session->auth_state = SSH_AUTH_STATE_NONE; session->auth_state = SSH_AUTH_STATE_NONE;
session->pending_call_state = SSH_PENDING_CALL_AUTH_OFFER_PUBKEY; session->pending_call_state = SSH_PENDING_CALL_AUTH_OFFER_PUBKEY;
rc = packet_send(session); rc = ssh_packet_send(session);
if (rc == SSH_ERROR) { if (rc == SSH_ERROR) {
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
} }
@@ -623,7 +623,7 @@ int ssh_userauth_publickey(ssh_session session,
session->auth_state = SSH_AUTH_STATE_NONE; session->auth_state = SSH_AUTH_STATE_NONE;
session->pending_call_state = SSH_PENDING_CALL_AUTH_PUBKEY; session->pending_call_state = SSH_PENDING_CALL_AUTH_PUBKEY;
rc = packet_send(session); rc = ssh_packet_send(session);
if (rc == SSH_ERROR) { if (rc == SSH_ERROR) {
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
} }
@@ -707,7 +707,7 @@ static int ssh_userauth_agent_publickey(ssh_session session,
session->auth_state = SSH_AUTH_STATE_NONE; session->auth_state = SSH_AUTH_STATE_NONE;
session->pending_call_state = SSH_PENDING_CALL_AUTH_AGENT; session->pending_call_state = SSH_PENDING_CALL_AUTH_AGENT;
rc = packet_send(session); rc = ssh_packet_send(session);
if (rc == SSH_ERROR) { if (rc == SSH_ERROR) {
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
} }
@@ -1151,7 +1151,7 @@ int ssh_userauth_password(ssh_session session,
session->auth_state = SSH_AUTH_STATE_NONE; session->auth_state = SSH_AUTH_STATE_NONE;
session->pending_call_state = SSH_PENDING_CALL_AUTH_OFFER_PUBKEY; session->pending_call_state = SSH_PENDING_CALL_AUTH_OFFER_PUBKEY;
rc = packet_send(session); rc = ssh_packet_send(session);
if (rc == SSH_ERROR) { if (rc == SSH_ERROR) {
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
} }
@@ -1320,7 +1320,7 @@ static int ssh_userauth_kbdint_init(ssh_session session,
SSH_LOG(SSH_LOG_DEBUG, SSH_LOG(SSH_LOG_DEBUG,
"Sending keyboard-interactive init request"); "Sending keyboard-interactive init request");
rc = packet_send(session); rc = ssh_packet_send(session);
if (rc == SSH_ERROR) { if (rc == SSH_ERROR) {
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
} }
@@ -1381,7 +1381,7 @@ static int ssh_userauth_kbdint_send(ssh_session session)
SSH_LOG(SSH_LOG_DEBUG, SSH_LOG(SSH_LOG_DEBUG,
"Sending keyboard-interactive response packet"); "Sending keyboard-interactive response packet");
rc = packet_send(session); rc = ssh_packet_send(session);
if (rc == SSH_ERROR) { if (rc == SSH_ERROR) {
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
} }

View File

@@ -114,7 +114,7 @@ static int send_username(ssh_session session, const char *username) {
ssh_string_free(user); ssh_string_free(user);
session->auth_state=SSH_AUTH_STATE_NONE; session->auth_state=SSH_AUTH_STATE_NONE;
session->auth_service_state = SSH_AUTH_SERVICE_SENT; session->auth_service_state = SSH_AUTH_SERVICE_SENT;
if (packet_send(session) == SSH_ERROR) { if (ssh_packet_send(session) == SSH_ERROR) {
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
} }
pending: pending:
@@ -214,7 +214,7 @@ int ssh_userauth1_password(ssh_session session, const char *username,
ssh_string_free(pwd); ssh_string_free(pwd);
session->auth_state=SSH_AUTH_STATE_NONE; session->auth_state=SSH_AUTH_STATE_NONE;
session->pending_call_state = SSH_PENDING_CALL_AUTH_PASSWORD; session->pending_call_state = SSH_PENDING_CALL_AUTH_PASSWORD;
if (packet_send(session) == SSH_ERROR) { if (ssh_packet_send(session) == SSH_ERROR) {
return SSH_AUTH_ERROR; return SSH_AUTH_ERROR;
} }
pending: pending:

View File

@@ -293,7 +293,7 @@ static int channel_open(ssh_channel channel, const char *type, int window,
} }
} }
channel->state = SSH_CHANNEL_STATE_OPENING; channel->state = SSH_CHANNEL_STATE_OPENING;
if (packet_send(session) == SSH_ERROR) { if (ssh_packet_send(session) == SSH_ERROR) {
return err; return err;
} }
@@ -374,7 +374,7 @@ static int grow_window(ssh_session session, ssh_channel channel, int minimumsize
goto error; goto error;
} }
if (packet_send(session) == SSH_ERROR) { if (ssh_packet_send(session) == SSH_ERROR) {
goto error; goto error;
} }
@@ -752,7 +752,7 @@ SSH_PACKET_CALLBACK(channel_rcv_request) {
if (rc != SSH_OK) { if (rc != SSH_OK) {
return SSH_PACKET_USED; return SSH_PACKET_USED;
} }
packet_send(session); ssh_packet_send(session);
return SSH_PACKET_USED; return SSH_PACKET_USED;
} }
@@ -1082,7 +1082,7 @@ int ssh_channel_send_eof(ssh_channel channel){
goto error; goto error;
} }
rc = packet_send(session); rc = ssh_packet_send(session);
SSH_LOG(SSH_LOG_PACKET, SSH_LOG(SSH_LOG_PACKET,
"Sent a EOF on client channel (%d:%d)", "Sent a EOF on client channel (%d:%d)",
channel->local_channel, channel->local_channel,
@@ -1141,7 +1141,7 @@ int ssh_channel_close(ssh_channel channel){
goto error; goto error;
} }
rc = packet_send(session); rc = ssh_packet_send(session);
SSH_LOG(SSH_LOG_PACKET, SSH_LOG(SSH_LOG_PACKET,
"Sent a close on client channel (%d:%d)", "Sent a close on client channel (%d:%d)",
channel->local_channel, channel->local_channel,
@@ -1318,7 +1318,7 @@ static int channel_write_common(ssh_channel channel,
goto error; goto error;
} }
rc = packet_send(session); rc = ssh_packet_send(session);
if (rc == SSH_ERROR) { if (rc == SSH_ERROR) {
return SSH_ERROR; return SSH_ERROR;
} }
@@ -1547,7 +1547,7 @@ static int channel_request(ssh_channel channel, const char *request,
} }
} }
channel->request_state = SSH_CHANNEL_REQ_STATE_PENDING; channel->request_state = SSH_CHANNEL_REQ_STATE_PENDING;
if (packet_send(session) == SSH_ERROR) { if (ssh_packet_send(session) == SSH_ERROR) {
return rc; return rc;
} }
@@ -2109,7 +2109,7 @@ static int global_request(ssh_session session, const char *request,
} }
session->global_req_state = SSH_CHANNEL_REQ_STATE_PENDING; session->global_req_state = SSH_CHANNEL_REQ_STATE_PENDING;
rc = packet_send(session); rc = ssh_packet_send(session);
if (rc == SSH_ERROR) { if (rc == SSH_ERROR) {
return rc; return rc;
} }

View File

@@ -129,7 +129,7 @@ int ssh_channel_request_pty_size1(ssh_channel channel, const char *terminal, int
SSH_LOG(SSH_LOG_FUNCTIONS, "Opening a ssh1 pty"); SSH_LOG(SSH_LOG_FUNCTIONS, "Opening a ssh1 pty");
channel->request_state = SSH_CHANNEL_REQ_STATE_PENDING; channel->request_state = SSH_CHANNEL_REQ_STATE_PENDING;
if (packet_send(session) == SSH_ERROR) { if (ssh_packet_send(session) == SSH_ERROR) {
return -1; return -1;
} }
@@ -178,7 +178,7 @@ int ssh_channel_change_pty_size1(ssh_channel channel, int cols, int rows) {
return SSH_ERROR; return SSH_ERROR;
} }
channel->request_state=SSH_CHANNEL_REQ_STATE_PENDING; channel->request_state=SSH_CHANNEL_REQ_STATE_PENDING;
if (packet_send(session) == SSH_ERROR) { if (ssh_packet_send(session) == SSH_ERROR) {
return SSH_ERROR; return SSH_ERROR;
} }
@@ -219,7 +219,7 @@ int ssh_channel_request_shell1(ssh_channel channel) {
return -1; return -1;
} }
if (packet_send(session) == SSH_ERROR) { if (ssh_packet_send(session) == SSH_ERROR) {
return -1; return -1;
} }
@@ -249,7 +249,7 @@ int ssh_channel_request_exec1(ssh_channel channel, const char *cmd) {
} }
ssh_string_free(command); ssh_string_free(command);
if(packet_send(session) == SSH_ERROR) { if(ssh_packet_send(session) == SSH_ERROR) {
return -1; return -1;
} }
@@ -314,7 +314,7 @@ SSH_PACKET_CALLBACK(ssh_packet_close1){
if (rc < 0) { if (rc < 0) {
return SSH_PACKET_NOT_USED; return SSH_PACKET_NOT_USED;
} }
packet_send(session); ssh_packet_send(session);
return SSH_PACKET_USED; return SSH_PACKET_USED;
} }
@@ -364,7 +364,7 @@ int ssh_channel_write1(ssh_channel channel, const void *data, int len) {
ptr += effectivelen; ptr += effectivelen;
len -= effectivelen; len -= effectivelen;
if (packet_send(session) == SSH_ERROR) { if (ssh_packet_send(session) == SSH_ERROR) {
return -1; return -1;
} }
ssh_handle_packets(session, SSH_TIMEOUT_NONBLOCKING); ssh_handle_packets(session, SSH_TIMEOUT_NONBLOCKING);

View File

@@ -283,7 +283,7 @@ int ssh_service_request(ssh_session session, const char *service) {
return SSH_ERROR; return SSH_ERROR;
} }
session->auth_service_state=SSH_AUTH_SERVICE_SENT; session->auth_service_state=SSH_AUTH_SERVICE_SENT;
if (packet_send(session) == SSH_ERROR) { if (ssh_packet_send(session) == SSH_ERROR) {
ssh_set_error(session, SSH_FATAL, ssh_set_error(session, SSH_FATAL,
"Sending SSH2_MSG_SERVICE_REQUEST failed."); "Sending SSH2_MSG_SERVICE_REQUEST failed.");
return SSH_ERROR; return SSH_ERROR;
@@ -643,7 +643,7 @@ void ssh_disconnect(ssh_session session) {
goto error; goto error;
} }
packet_send(session); ssh_packet_send(session);
ssh_socket_close(session->socket); ssh_socket_close(session->socket);
} }
error: error:

View File

@@ -64,7 +64,7 @@ int ssh_client_curve25519_init(ssh_session session){
return SSH_ERROR; return SSH_ERROR;
} }
rc = packet_send(session); rc = ssh_packet_send(session);
return rc; return rc;
} }
@@ -147,7 +147,7 @@ int ssh_client_curve25519_reply(ssh_session session, ssh_buffer packet){
goto error; goto error;
} }
rc=packet_send(session); rc=ssh_packet_send(session);
SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent"); SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent");
return rc; return rc;
error: error:
@@ -260,7 +260,7 @@ int ssh_server_curve25519_init(ssh_session session, ssh_buffer packet){
} }
SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_KEX_ECDH_REPLY sent"); SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_KEX_ECDH_REPLY sent");
rc = packet_send(session); rc = ssh_packet_send(session);
if (rc == SSH_ERROR) { if (rc == SSH_ERROR) {
return SSH_ERROR; return SSH_ERROR;
} }
@@ -272,7 +272,7 @@ int ssh_server_curve25519_init(ssh_session session, ssh_buffer packet){
} }
session->dh_handshake_state = DH_STATE_NEWKEYS_SENT; session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
rc = packet_send(session); rc = ssh_packet_send(session);
SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent"); SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent");
return rc; return rc;

View File

@@ -456,7 +456,7 @@ int ssh_client_dh_init(ssh_session session){
ssh_string_free(e); ssh_string_free(e);
e=NULL; e=NULL;
rc = packet_send(session); rc = ssh_packet_send(session);
return rc; return rc;
error: error:
if(e != NULL){ if(e != NULL){
@@ -509,7 +509,7 @@ int ssh_client_dh_reply(ssh_session session, ssh_buffer packet){
goto error; goto error;
} }
rc=packet_send(session); rc=ssh_packet_send(session);
SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent"); SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent");
return rc; return rc;
error: error:

View File

@@ -87,7 +87,7 @@ int ssh_client_ecdh_init(ssh_session session){
session->next_crypto->ecdh_privkey = key; session->next_crypto->ecdh_privkey = key;
session->next_crypto->ecdh_client_pubkey = client_pubkey; session->next_crypto->ecdh_client_pubkey = client_pubkey;
rc = packet_send(session); rc = ssh_packet_send(session);
return rc; return rc;
} }
@@ -212,7 +212,7 @@ int ssh_client_ecdh_reply(ssh_session session, ssh_buffer packet){
goto error; goto error;
} }
rc=packet_send(session); rc=ssh_packet_send(session);
SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent"); SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent");
return rc; return rc;
error: error:
@@ -326,7 +326,7 @@ int ssh_server_ecdh_init(ssh_session session, ssh_buffer packet){
} }
SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_KEXDH_REPLY sent"); SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_KEXDH_REPLY sent");
rc = packet_send(session); rc = ssh_packet_send(session);
if (rc == SSH_ERROR) { if (rc == SSH_ERROR) {
return SSH_ERROR; return SSH_ERROR;
} }
@@ -338,7 +338,7 @@ int ssh_server_ecdh_init(ssh_session session, ssh_buffer packet){
} }
session->dh_handshake_state = DH_STATE_NEWKEYS_SENT; session->dh_handshake_state = DH_STATE_NEWKEYS_SENT;
rc = packet_send(session); rc = ssh_packet_send(session);
SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent"); SSH_LOG(SSH_LOG_PROTOCOL, "SSH_MSG_NEWKEYS sent");
return rc; return rc;

View File

@@ -121,7 +121,7 @@ static int ssh_gssapi_send_response(ssh_session session, ssh_string oid){
return SSH_ERROR; return SSH_ERROR;
} }
packet_send(session); ssh_packet_send(session);
SSH_LOG(SSH_LOG_PACKET, SSH_LOG(SSH_LOG_PACKET,
"Sent SSH_MSG_USERAUTH_GSSAPI_RESPONSE"); "Sent SSH_MSG_USERAUTH_GSSAPI_RESPONSE");
return SSH_OK; return SSH_OK;
@@ -319,7 +319,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server){
ssh_set_error_oom(session); ssh_set_error_oom(session);
return SSH_PACKET_USED; return SSH_PACKET_USED;
} }
packet_send(session); ssh_packet_send(session);
ssh_string_free(out_token); ssh_string_free(out_token);
} else { } else {
session->gssapi->state = SSH_GSSAPI_STATE_RCV_MIC; session->gssapi->state = SSH_GSSAPI_STATE_RCV_MIC;
@@ -358,7 +358,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_server){
SSH2_MSG_USERAUTH_GSSAPI_TOKEN, SSH2_MSG_USERAUTH_GSSAPI_TOKEN,
output_token.length, output_token.length,
(size_t)output_token.length, output_token.value); (size_t)output_token.length, output_token.value);
packet_send(session); ssh_packet_send(session);
} }
if(maj_stat == GSS_S_COMPLETE){ if(maj_stat == GSS_S_COMPLETE){
session->gssapi->state = SSH_GSSAPI_STATE_RCV_MIC; session->gssapi->state = SSH_GSSAPI_STATE_RCV_MIC;
@@ -540,7 +540,7 @@ static int ssh_gssapi_send_auth_mic(ssh_session session, ssh_string *oid_set, in
} }
session->auth_state = SSH_AUTH_STATE_GSSAPI_REQUEST_SENT; session->auth_state = SSH_AUTH_STATE_GSSAPI_REQUEST_SENT;
return packet_send(session); return ssh_packet_send(session);
fail: fail:
ssh_buffer_reinit(session->out_buffer); ssh_buffer_reinit(session->out_buffer);
return SSH_ERROR; return SSH_ERROR;
@@ -771,7 +771,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_response){
SSH2_MSG_USERAUTH_GSSAPI_TOKEN, SSH2_MSG_USERAUTH_GSSAPI_TOKEN,
output_token.length, output_token.length,
(size_t)output_token.length, output_token.value); (size_t)output_token.length, output_token.value);
packet_send(session); ssh_packet_send(session);
session->auth_state = SSH_AUTH_STATE_GSSAPI_TOKEN; session->auth_state = SSH_AUTH_STATE_GSSAPI_TOKEN;
} }
return SSH_PACKET_USED; return SSH_PACKET_USED;
@@ -812,7 +812,7 @@ static int ssh_gssapi_send_mic(ssh_session session){
return SSH_ERROR; return SSH_ERROR;
} }
return packet_send(session); return ssh_packet_send(session);
} }
SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_client){ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_client){
@@ -866,7 +866,7 @@ SSH_PACKET_CALLBACK(ssh_packet_userauth_gssapi_token_client){
SSH2_MSG_USERAUTH_GSSAPI_TOKEN, SSH2_MSG_USERAUTH_GSSAPI_TOKEN,
output_token.length, output_token.length,
(size_t)output_token.length, output_token.value); (size_t)output_token.length, output_token.value);
packet_send(session); ssh_packet_send(session);
} }
if(maj_stat == GSS_S_COMPLETE){ if(maj_stat == GSS_S_COMPLETE){
session->auth_state = SSH_AUTH_STATE_NONE; session->auth_state = SSH_AUTH_STATE_NONE;

View File

@@ -642,7 +642,7 @@ int ssh_send_kex(ssh_session session, int server_kex) {
goto error; goto error;
} }
if (packet_send(session) == SSH_ERROR) { if (ssh_packet_send(session) == SSH_ERROR) {
return -1; return -1;
} }

View File

@@ -443,7 +443,7 @@ SSH_PACKET_CALLBACK(ssh_packet_publickey1){
goto error; goto error;
} }
session->session_state=SSH_SESSION_STATE_KEXINIT_RECEIVED; session->session_state=SSH_SESSION_STATE_KEXINIT_RECEIVED;
if (packet_send(session) == SSH_ERROR) { if (ssh_packet_send(session) == SSH_ERROR) {
goto error; goto error;
} }

View File

@@ -86,7 +86,7 @@ static int ssh_message_reply_default(ssh_message msg) {
if (ssh_buffer_add_u32(msg->session->out_buffer, if (ssh_buffer_add_u32(msg->session->out_buffer,
htonl(msg->session->recv_seq-1)) < 0) htonl(msg->session->recv_seq-1)) < 0)
goto error; goto error;
return packet_send(msg->session); return ssh_packet_send(msg->session);
error: error:
return SSH_ERROR; return SSH_ERROR;
} }
@@ -1138,7 +1138,7 @@ int ssh_message_channel_request_open_reply_accept_channel(ssh_message msg, ssh_c
"Accepting a channel request_open for chan %d", "Accepting a channel request_open for chan %d",
chan->remote_channel); chan->remote_channel);
rc = packet_send(session); rc = ssh_packet_send(session);
return rc; return rc;
} }
@@ -1319,7 +1319,7 @@ int ssh_message_channel_request_reply_success(ssh_message msg) {
return SSH_ERROR; return SSH_ERROR;
} }
return packet_send(msg->session); return ssh_packet_send(msg->session);
} }
SSH_LOG(SSH_LOG_PACKET, SSH_LOG(SSH_LOG_PACKET,

View File

@@ -192,7 +192,7 @@ int ssh_packet_socket_callback(const void *data, size_t receivedlen, void *user)
memcpy(buffer, data, blocksize); memcpy(buffer, data, blocksize);
processed += blocksize; processed += blocksize;
len = packet_decrypt_len(session, buffer); len = ssh_packet_decrypt_len(session, buffer);
rc = ssh_buffer_add_data(session->in_buffer, buffer, blocksize); rc = ssh_buffer_add_data(session->in_buffer, buffer, blocksize);
if (rc < 0) { if (rc < 0) {
@@ -260,7 +260,7 @@ int ssh_packet_socket_callback(const void *data, size_t receivedlen, void *user)
uint8_t *payload = ((uint8_t*)ssh_buffer_get_rest(session->in_buffer) + blocksize); uint8_t *payload = ((uint8_t*)ssh_buffer_get_rest(session->in_buffer) + blocksize);
uint32_t plen = buffer_len - blocksize; uint32_t plen = buffer_len - blocksize;
rc = packet_decrypt(session, payload, plen); rc = ssh_packet_decrypt(session, payload, plen);
if (rc < 0) { if (rc < 0) {
ssh_set_error(session, SSH_FATAL, "Decrypt error"); ssh_set_error(session, SSH_FATAL, "Decrypt error");
goto error; goto error;
@@ -271,7 +271,7 @@ int ssh_packet_socket_callback(const void *data, size_t receivedlen, void *user)
packet = ((uint8_t *)data) + processed; packet = ((uint8_t *)data) + processed;
memcpy(mac, packet, current_macsize); memcpy(mac, packet, current_macsize);
rc = packet_hmac_verify(session, session->in_buffer, mac, session->current_crypto->in_hmac); rc = ssh_packet_hmac_verify(session, session->in_buffer, mac, session->current_crypto->in_hmac);
if (rc < 0) { if (rc < 0) {
ssh_set_error(session, SSH_FATAL, "HMAC error"); ssh_set_error(session, SSH_FATAL, "HMAC error");
goto error; goto error;
@@ -452,7 +452,7 @@ int ssh_packet_send_unimplemented(ssh_session session, uint32_t seqnum){
ssh_set_error_oom(session); ssh_set_error_oom(session);
return SSH_ERROR; return SSH_ERROR;
} }
rc = packet_send(session); rc = ssh_packet_send(session);
return rc; return rc;
} }
@@ -567,7 +567,7 @@ static int packet_send2(ssh_session session) {
,ssh_buffer_get_rest_len(session->out_buffer)); ,ssh_buffer_get_rest_len(session->out_buffer));
} }
#endif #endif
hmac = packet_encrypt(session, ssh_buffer_get_rest(session->out_buffer), hmac = ssh_packet_encrypt(session, ssh_buffer_get_rest(session->out_buffer),
ssh_buffer_get_rest_len(session->out_buffer)); ssh_buffer_get_rest_len(session->out_buffer));
if (hmac) { if (hmac) {
rc = ssh_buffer_add_data(session->out_buffer, hmac, hmac_digest_len(hmac_type)); rc = ssh_buffer_add_data(session->out_buffer, hmac, hmac_digest_len(hmac_type));
@@ -595,10 +595,10 @@ error:
} }
int packet_send(ssh_session session) { int ssh_packet_send(ssh_session session) {
#ifdef WITH_SSH1 #ifdef WITH_SSH1
if (session->version == 1) { if (session->version == 1) {
return packet_send1(session); return ssh_packet_send1(session);
} }
#endif #endif
return packet_send2(session); return packet_send2(session);

View File

@@ -171,7 +171,7 @@ int ssh_packet_socket_callback1(const void *data, size_t receivedlen, void *user
buffer_len = ssh_buffer_get_len(session->in_buffer); buffer_len = ssh_buffer_get_len(session->in_buffer);
if (buffer_len > 0) { if (buffer_len > 0) {
int rc; int rc;
rc = packet_decrypt(session, rc = ssh_packet_decrypt(session,
ssh_buffer_get_begin(session->in_buffer), ssh_buffer_get_begin(session->in_buffer),
buffer_len); buffer_len);
if (rc < 0) { if (rc < 0) {
@@ -252,7 +252,7 @@ error:
} }
int packet_send1(ssh_session session) { int ssh_packet_send1(ssh_session session) {
unsigned int blocksize = (session->current_crypto ? unsigned int blocksize = (session->current_crypto ?
session->current_crypto->out_cipher->blocksize : 8); session->current_crypto->out_cipher->blocksize : 8);
uint32_t currentlen = ssh_buffer_get_len(session->out_buffer) + sizeof(uint32_t); uint32_t currentlen = ssh_buffer_get_len(session->out_buffer) + sizeof(uint32_t);
@@ -306,8 +306,8 @@ int packet_send1(ssh_session session) {
#endif #endif
/* session->out_buffer should have more than sizeof(uint32_t) bytes /* session->out_buffer should have more than sizeof(uint32_t) bytes
in it as required for packet_encrypt */ in it as required for ssh_packet_encrypt */
packet_encrypt(session, (unsigned char *)ssh_buffer_get_begin(session->out_buffer) + sizeof(uint32_t), ssh_packet_encrypt(session, (unsigned char *)ssh_buffer_get_begin(session->out_buffer) + sizeof(uint32_t),
ssh_buffer_get_len(session->out_buffer) - sizeof(uint32_t)); ssh_buffer_get_len(session->out_buffer) - sizeof(uint32_t));
#ifdef DEBUG_CRYPTO #ifdef DEBUG_CRYPTO

View File

@@ -44,11 +44,11 @@
#include "libssh/crypto.h" #include "libssh/crypto.h"
#include "libssh/buffer.h" #include "libssh/buffer.h"
uint32_t packet_decrypt_len(ssh_session session, char *crypted){ uint32_t ssh_packet_decrypt_len(ssh_session session, char *crypted){
uint32_t decrypted; uint32_t decrypted;
if (session->current_crypto) { if (session->current_crypto) {
if (packet_decrypt(session, crypted, if (ssh_packet_decrypt(session, crypted,
session->current_crypto->in_cipher->blocksize) < 0) { session->current_crypto->in_cipher->blocksize) < 0) {
return 0; return 0;
} }
@@ -57,7 +57,7 @@ uint32_t packet_decrypt_len(ssh_session session, char *crypted){
return ntohl(decrypted); return ntohl(decrypted);
} }
int packet_decrypt(ssh_session session, void *data,uint32_t len) { int ssh_packet_decrypt(ssh_session session, void *data,uint32_t len) {
struct ssh_cipher_struct *crypto = session->current_crypto->in_cipher; struct ssh_cipher_struct *crypto = session->current_crypto->in_cipher;
char *out = NULL; char *out = NULL;
@@ -80,7 +80,7 @@ int packet_decrypt(ssh_session session, void *data,uint32_t len) {
return 0; return 0;
} }
unsigned char *packet_encrypt(ssh_session session, void *data, uint32_t len) { unsigned char *ssh_packet_encrypt(ssh_session session, void *data, uint32_t len) {
struct ssh_cipher_struct *crypto = NULL; struct ssh_cipher_struct *crypto = NULL;
HMACCTX ctx = NULL; HMACCTX ctx = NULL;
char *out = NULL; char *out = NULL;
@@ -149,7 +149,7 @@ unsigned char *packet_encrypt(ssh_session session, void *data, uint32_t len) {
* @return 0 if hmac and mac are equal, < 0 if not or an error * @return 0 if hmac and mac are equal, < 0 if not or an error
* occurred. * occurred.
*/ */
int packet_hmac_verify(ssh_session session, ssh_buffer buffer, int ssh_packet_hmac_verify(ssh_session session, ssh_buffer buffer,
unsigned char *mac, enum ssh_hmac_e type) { unsigned char *mac, enum ssh_hmac_e type) {
unsigned char hmacbuf[DIGEST_MAX_LEN] = {0}; unsigned char hmacbuf[DIGEST_MAX_LEN] = {0};
HMACCTX ctx; HMACCTX ctx;

View File

@@ -321,7 +321,7 @@ static int dh_handshake_server(ssh_session session) {
return -1; return -1;
} }
if (packet_send(session) == SSH_ERROR) { if (ssh_packet_send(session) == SSH_ERROR) {
return -1; return -1;
} }
@@ -330,7 +330,7 @@ static int dh_handshake_server(ssh_session session) {
return -1; return -1;
} }
if (packet_send(session) == SSH_ERROR) { if (ssh_packet_send(session) == SSH_ERROR) {
return -1; return -1;
} }
SSH_LOG(SSH_LOG_PACKET, "SSH_MSG_NEWKEYS sent"); SSH_LOG(SSH_LOG_PACKET, "SSH_MSG_NEWKEYS sent");
@@ -659,7 +659,7 @@ int ssh_auth_reply_default(ssh_session session,int partial) {
ssh_set_error_oom(session); ssh_set_error_oom(session);
return SSH_ERROR; return SSH_ERROR;
} }
rc = packet_send(session); rc = ssh_packet_send(session);
return rc; return rc;
} }
@@ -680,7 +680,7 @@ static int ssh_message_channel_request_open_reply_default(ssh_message msg) {
return SSH_ERROR; return SSH_ERROR;
} }
rc = packet_send(msg->session); rc = ssh_packet_send(msg->session);
return rc; return rc;
} }
@@ -702,7 +702,7 @@ static int ssh_message_channel_request_reply_default(ssh_message msg) {
ssh_set_error_oom(msg->session); ssh_set_error_oom(msg->session);
return SSH_ERROR; return SSH_ERROR;
} }
return packet_send(msg->session); return ssh_packet_send(msg->session);
} }
SSH_LOG(SSH_LOG_PACKET, SSH_LOG(SSH_LOG_PACKET,
@@ -736,7 +736,7 @@ int ssh_message_service_reply_success(ssh_message msg) {
ssh_set_error_oom(session); ssh_set_error_oom(session);
return SSH_ERROR; return SSH_ERROR;
} }
rc = packet_send(msg->session); rc = ssh_packet_send(msg->session);
return rc; return rc;
} }
@@ -760,7 +760,7 @@ int ssh_message_global_request_reply_success(ssh_message msg, uint16_t bound_por
} }
} }
return packet_send(msg->session); return ssh_packet_send(msg->session);
} }
if(msg->global_request.type == SSH_GLOBAL_REQUEST_TCPIP_FORWARD if(msg->global_request.type == SSH_GLOBAL_REQUEST_TCPIP_FORWARD
@@ -782,7 +782,7 @@ static int ssh_message_global_request_reply_default(ssh_message msg) {
, SSH2_MSG_REQUEST_FAILURE) < 0) { , SSH2_MSG_REQUEST_FAILURE) < 0) {
goto error; goto error;
} }
return packet_send(msg->session); return ssh_packet_send(msg->session);
} }
SSH_LOG(SSH_LOG_PACKET, SSH_LOG(SSH_LOG_PACKET,
"The client doesn't want to know the request failed!"); "The client doesn't want to know the request failed!");
@@ -919,7 +919,7 @@ int ssh_message_auth_interactive_request(ssh_message msg, const char *name,
} }
} }
rc = packet_send(msg->session); rc = ssh_packet_send(msg->session);
/* fill in the kbdint structure */ /* fill in the kbdint structure */
if (msg->session->kbdint == NULL) { if (msg->session->kbdint == NULL) {
@@ -1006,7 +1006,7 @@ int ssh_auth_reply_success(ssh_session session, int partial) {
return SSH_ERROR; return SSH_ERROR;
} }
r = packet_send(session); r = ssh_packet_send(session);
if(session->current_crypto && session->current_crypto->delayed_compress_out){ if(session->current_crypto && session->current_crypto->delayed_compress_out){
SSH_LOG(SSH_LOG_PROTOCOL,"Enabling delayed compression OUT"); SSH_LOG(SSH_LOG_PROTOCOL,"Enabling delayed compression OUT");
session->current_crypto->do_compress_out=1; session->current_crypto->do_compress_out=1;
@@ -1041,7 +1041,7 @@ int ssh_message_auth_reply_pk_ok(ssh_message msg, ssh_string algo, ssh_string pu
return SSH_ERROR; return SSH_ERROR;
} }
rc = packet_send(msg->session); rc = ssh_packet_send(msg->session);
return rc; return rc;
} }
@@ -1208,7 +1208,7 @@ int ssh_send_keepalive(ssh_session session)
goto err; goto err;
} }
if (packet_send(session) == SSH_ERROR) { if (ssh_packet_send(session) == SSH_ERROR) {
goto err; goto err;
} }

View File

@@ -828,7 +828,7 @@ int ssh_send_ignore (ssh_session session, const char *data) {
ssh_set_error_oom(session); ssh_set_error_oom(session);
goto error; goto error;
} }
packet_send(session); ssh_packet_send(session);
ssh_handle_packets(session, 0); ssh_handle_packets(session, 0);
} }
@@ -864,7 +864,7 @@ int ssh_send_debug (ssh_session session, const char *message, int always_display
ssh_set_error_oom(session); ssh_set_error_oom(session);
goto error; goto error;
} }
packet_send(session); ssh_packet_send(session);
ssh_handle_packets(session, 0); ssh_handle_packets(session, 0);
} }