mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-08-10 06:23:01 +03:00
cleanup: use ssh_ prefix in the dh (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:
@@ -25,27 +25,27 @@
|
||||
|
||||
#include "libssh/crypto.h"
|
||||
|
||||
int dh_generate_e(ssh_session session);
|
||||
int dh_generate_f(ssh_session session);
|
||||
int dh_generate_x(ssh_session session);
|
||||
int dh_generate_y(ssh_session session);
|
||||
int ssh_dh_generate_e(ssh_session session);
|
||||
int ssh_dh_generate_f(ssh_session session);
|
||||
int ssh_dh_generate_x(ssh_session session);
|
||||
int ssh_dh_generate_y(ssh_session session);
|
||||
|
||||
int ssh_crypto_init(void);
|
||||
void ssh_crypto_finalize(void);
|
||||
|
||||
ssh_string dh_get_e(ssh_session session);
|
||||
ssh_string dh_get_f(ssh_session session);
|
||||
int dh_import_f(ssh_session session,ssh_string f_string);
|
||||
int dh_import_e(ssh_session session, ssh_string e_string);
|
||||
void dh_import_pubkey(ssh_session session,ssh_string pubkey_string);
|
||||
int dh_build_k(ssh_session session);
|
||||
ssh_string ssh_dh_get_e(ssh_session session);
|
||||
ssh_string ssh_dh_get_f(ssh_session session);
|
||||
int ssh_dh_import_f(ssh_session session,ssh_string f_string);
|
||||
int ssh_dh_import_e(ssh_session session, ssh_string e_string);
|
||||
void ssh_dh_import_pubkey(ssh_session session,ssh_string pubkey_string);
|
||||
int ssh_dh_build_k(ssh_session session);
|
||||
int ssh_client_dh_init(ssh_session session);
|
||||
int ssh_client_dh_reply(ssh_session session, ssh_buffer packet);
|
||||
|
||||
int make_sessionid(ssh_session session);
|
||||
int ssh_make_sessionid(ssh_session session);
|
||||
/* add data for the final cookie */
|
||||
int hashbufin_add_cookie(ssh_session session, unsigned char *cookie);
|
||||
int hashbufout_add_cookie(ssh_session session);
|
||||
int generate_session_keys(ssh_session session);
|
||||
int ssh_hashbufin_add_cookie(ssh_session session, unsigned char *cookie);
|
||||
int ssh_hashbufout_add_cookie(ssh_session session);
|
||||
int ssh_generate_session_keys(ssh_session session);
|
||||
|
||||
#endif /* DH_H_ */
|
||||
|
@@ -215,7 +215,7 @@ int ssh_server_curve25519_init(ssh_session session, ssh_buffer packet){
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = make_sessionid(session);
|
||||
rc = ssh_make_sessionid(session);
|
||||
if (rc != SSH_OK) {
|
||||
ssh_set_error(session, SSH_FATAL, "Could not create a session id");
|
||||
goto error;
|
||||
|
40
src/dh.c
40
src/dh.c
@@ -226,7 +226,7 @@ void ssh_crypto_finalize(void) {
|
||||
}
|
||||
}
|
||||
|
||||
int dh_generate_x(ssh_session session) {
|
||||
int ssh_dh_generate_x(ssh_session session) {
|
||||
session->next_crypto->x = bignum_new();
|
||||
if (session->next_crypto->x == NULL) {
|
||||
return -1;
|
||||
@@ -247,7 +247,7 @@ int dh_generate_x(ssh_session session) {
|
||||
}
|
||||
|
||||
/* used by server */
|
||||
int dh_generate_y(ssh_session session) {
|
||||
int ssh_dh_generate_y(ssh_session session) {
|
||||
session->next_crypto->y = bignum_new();
|
||||
if (session->next_crypto->y == NULL) {
|
||||
return -1;
|
||||
@@ -268,7 +268,7 @@ int dh_generate_y(ssh_session session) {
|
||||
}
|
||||
|
||||
/* used by server */
|
||||
int dh_generate_e(ssh_session session) {
|
||||
int ssh_dh_generate_e(ssh_session session) {
|
||||
#ifdef HAVE_LIBCRYPTO
|
||||
bignum_CTX ctx = bignum_ctx_new();
|
||||
if (ctx == NULL) {
|
||||
@@ -303,7 +303,7 @@ int dh_generate_e(ssh_session session) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dh_generate_f(ssh_session session) {
|
||||
int ssh_dh_generate_f(ssh_session session) {
|
||||
#ifdef HAVE_LIBCRYPTO
|
||||
bignum_CTX ctx = bignum_ctx_new();
|
||||
if (ctx == NULL) {
|
||||
@@ -338,20 +338,20 @@ int dh_generate_f(ssh_session session) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
ssh_string dh_get_e(ssh_session session) {
|
||||
ssh_string ssh_dh_get_e(ssh_session session) {
|
||||
return ssh_make_bignum_string(session->next_crypto->e);
|
||||
}
|
||||
|
||||
/* used by server */
|
||||
ssh_string dh_get_f(ssh_session session) {
|
||||
ssh_string ssh_dh_get_f(ssh_session session) {
|
||||
return ssh_make_bignum_string(session->next_crypto->f);
|
||||
}
|
||||
|
||||
void dh_import_pubkey(ssh_session session, ssh_string pubkey_string) {
|
||||
void ssh_dh_import_pubkey(ssh_session session, ssh_string pubkey_string) {
|
||||
session->next_crypto->server_pubkey = pubkey_string;
|
||||
}
|
||||
|
||||
int dh_import_f(ssh_session session, ssh_string f_string) {
|
||||
int ssh_dh_import_f(ssh_session session, ssh_string f_string) {
|
||||
session->next_crypto->f = ssh_make_string_bn(f_string);
|
||||
if (session->next_crypto->f == NULL) {
|
||||
return -1;
|
||||
@@ -365,7 +365,7 @@ int dh_import_f(ssh_session session, ssh_string f_string) {
|
||||
}
|
||||
|
||||
/* used by the server implementation */
|
||||
int dh_import_e(ssh_session session, ssh_string e_string) {
|
||||
int ssh_dh_import_e(ssh_session session, ssh_string e_string) {
|
||||
session->next_crypto->e = ssh_make_string_bn(e_string);
|
||||
if (session->next_crypto->e == NULL) {
|
||||
return -1;
|
||||
@@ -378,7 +378,7 @@ int dh_import_e(ssh_session session, ssh_string e_string) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dh_build_k(ssh_session session) {
|
||||
int ssh_dh_build_k(ssh_session session) {
|
||||
#ifdef HAVE_LIBCRYPTO
|
||||
bignum_CTX ctx = bignum_ctx_new();
|
||||
if (ctx == NULL) {
|
||||
@@ -435,14 +435,14 @@ int ssh_client_dh_init(ssh_session session){
|
||||
ssh_string e = NULL;
|
||||
int rc;
|
||||
|
||||
if (dh_generate_x(session) < 0) {
|
||||
if (ssh_dh_generate_x(session) < 0) {
|
||||
goto error;
|
||||
}
|
||||
if (dh_generate_e(session) < 0) {
|
||||
if (ssh_dh_generate_e(session) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
e = dh_get_e(session);
|
||||
e = ssh_dh_get_e(session);
|
||||
if (e == NULL) {
|
||||
goto error;
|
||||
}
|
||||
@@ -477,14 +477,14 @@ int ssh_client_dh_reply(ssh_session session, ssh_buffer packet){
|
||||
ssh_set_error(session,SSH_FATAL, "No public key in packet");
|
||||
goto error;
|
||||
}
|
||||
dh_import_pubkey(session, pubkey);
|
||||
ssh_dh_import_pubkey(session, pubkey);
|
||||
|
||||
f = ssh_buffer_get_ssh_string(packet);
|
||||
if (f == NULL) {
|
||||
ssh_set_error(session,SSH_FATAL, "No F number in packet");
|
||||
goto error;
|
||||
}
|
||||
rc = dh_import_f(session, f);
|
||||
rc = ssh_dh_import_f(session, f);
|
||||
ssh_string_burn(f);
|
||||
ssh_string_free(f);
|
||||
if (rc < 0) {
|
||||
@@ -499,7 +499,7 @@ int ssh_client_dh_reply(ssh_session session, ssh_buffer packet){
|
||||
}
|
||||
session->next_crypto->dh_server_signature = signature;
|
||||
signature=NULL; /* ownership changed */
|
||||
if (dh_build_k(session) < 0) {
|
||||
if (ssh_dh_build_k(session) < 0) {
|
||||
ssh_set_error(session, SSH_FATAL, "Cannot build k number");
|
||||
goto error;
|
||||
}
|
||||
@@ -516,7 +516,7 @@ error:
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
||||
int make_sessionid(ssh_session session) {
|
||||
int ssh_make_sessionid(ssh_session session) {
|
||||
ssh_string num = NULL;
|
||||
ssh_buffer server_hash = NULL;
|
||||
ssh_buffer client_hash = NULL;
|
||||
@@ -692,7 +692,7 @@ error:
|
||||
return rc;
|
||||
}
|
||||
|
||||
int hashbufout_add_cookie(ssh_session session) {
|
||||
int ssh_hashbufout_add_cookie(ssh_session session) {
|
||||
session->out_hashbuf = ssh_buffer_new();
|
||||
if (session->out_hashbuf == NULL) {
|
||||
return -1;
|
||||
@@ -720,7 +720,7 @@ int hashbufout_add_cookie(ssh_session session) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int hashbufin_add_cookie(ssh_session session, unsigned char *cookie) {
|
||||
int ssh_hashbufin_add_cookie(ssh_session session, unsigned char *cookie) {
|
||||
session->in_hashbuf = ssh_buffer_new();
|
||||
if (session->in_hashbuf == NULL) {
|
||||
return -1;
|
||||
@@ -777,7 +777,7 @@ static int generate_one_key(ssh_string k,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int generate_session_keys(ssh_session session) {
|
||||
int ssh_generate_session_keys(ssh_session session) {
|
||||
ssh_string k_string = NULL;
|
||||
struct ssh_crypto_struct *crypto = session->next_crypto;
|
||||
int rc = -1;
|
||||
|
@@ -299,7 +299,7 @@ int ssh_server_ecdh_init(ssh_session session, ssh_buffer packet){
|
||||
return SSH_ERROR;
|
||||
}
|
||||
|
||||
rc = make_sessionid(session);
|
||||
rc = ssh_make_sessionid(session);
|
||||
if (rc != SSH_OK) {
|
||||
ssh_set_error(session, SSH_FATAL, "Could not create a session id");
|
||||
return SSH_ERROR;
|
||||
|
@@ -352,7 +352,7 @@ SSH_PACKET_CALLBACK(ssh_packet_kexinit){
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = hashbufin_add_cookie(session, session->next_crypto->client_kex.cookie);
|
||||
rc = ssh_hashbufin_add_cookie(session, session->next_crypto->client_kex.cookie);
|
||||
if (rc < 0) {
|
||||
ssh_set_error(session, SSH_FATAL, "ssh_packet_kexinit: adding cookie failed");
|
||||
goto error;
|
||||
@@ -364,7 +364,7 @@ SSH_PACKET_CALLBACK(ssh_packet_kexinit){
|
||||
goto error;
|
||||
}
|
||||
|
||||
rc = hashbufin_add_cookie(session, session->next_crypto->server_kex.cookie);
|
||||
rc = ssh_hashbufin_add_cookie(session, session->next_crypto->server_kex.cookie);
|
||||
if (rc < 0) {
|
||||
ssh_set_error(session, SSH_FATAL, "ssh_packet_kexinit: adding cookie failed");
|
||||
goto error;
|
||||
@@ -612,7 +612,7 @@ int ssh_send_kex(ssh_session session, int server_kex) {
|
||||
kex->cookie); /* cookie */
|
||||
if (rc != SSH_OK)
|
||||
goto error;
|
||||
if (hashbufout_add_cookie(session) < 0) {
|
||||
if (ssh_hashbufout_add_cookie(session) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@@ -154,20 +154,20 @@ SSH_PACKET_CALLBACK(ssh_packet_newkeys){
|
||||
} else {
|
||||
ssh_key key;
|
||||
/* client */
|
||||
rc = make_sessionid(session);
|
||||
rc = ssh_make_sessionid(session);
|
||||
if (rc != SSH_OK) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the cryptographic functions for the next crypto
|
||||
* (it is needed for generate_session_keys for key lengths)
|
||||
* (it is needed for ssh_generate_session_keys for key lengths)
|
||||
*/
|
||||
if (crypt_set_algorithms(session, SSH_3DES) /* knows nothing about DES*/ ) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (generate_session_keys(session) < 0) {
|
||||
if (ssh_generate_session_keys(session) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
16
src/server.c
16
src/server.c
@@ -160,7 +160,7 @@ static int ssh_server_kexdh_init(ssh_session session, ssh_buffer packet){
|
||||
ssh_set_error(session, SSH_FATAL, "No e number in client request");
|
||||
return -1;
|
||||
}
|
||||
if (dh_import_e(session, e) < 0) {
|
||||
if (ssh_dh_import_e(session, e) < 0) {
|
||||
ssh_set_error(session, SSH_FATAL, "Cannot import e number");
|
||||
session->session_state=SSH_SESSION_STATE_ERROR;
|
||||
} else {
|
||||
@@ -258,7 +258,7 @@ int ssh_get_key_params(ssh_session session, ssh_key *privkey){
|
||||
return -1;
|
||||
}
|
||||
|
||||
dh_import_pubkey(session, pubkey_blob);
|
||||
ssh_dh_import_pubkey(session, pubkey_blob);
|
||||
return SSH_OK;
|
||||
}
|
||||
|
||||
@@ -268,16 +268,16 @@ static int dh_handshake_server(ssh_session session) {
|
||||
ssh_string f;
|
||||
int rc;
|
||||
|
||||
if (dh_generate_y(session) < 0) {
|
||||
if (ssh_dh_generate_y(session) < 0) {
|
||||
ssh_set_error(session, SSH_FATAL, "Could not create y number");
|
||||
return -1;
|
||||
}
|
||||
if (dh_generate_f(session) < 0) {
|
||||
if (ssh_dh_generate_f(session) < 0) {
|
||||
ssh_set_error(session, SSH_FATAL, "Could not create f number");
|
||||
return -1;
|
||||
}
|
||||
|
||||
f = dh_get_f(session);
|
||||
f = ssh_dh_get_f(session);
|
||||
if (f == NULL) {
|
||||
ssh_set_error(session, SSH_FATAL, "Could not get the f number");
|
||||
return -1;
|
||||
@@ -288,13 +288,13 @@ static int dh_handshake_server(ssh_session session) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (dh_build_k(session) < 0) {
|
||||
if (ssh_dh_build_k(session) < 0) {
|
||||
ssh_set_error(session, SSH_FATAL, "Could not import the public key");
|
||||
ssh_string_free(f);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (make_sessionid(session) != SSH_OK) {
|
||||
if (ssh_make_sessionid(session) != SSH_OK) {
|
||||
ssh_set_error(session, SSH_FATAL, "Could not create a session id");
|
||||
ssh_string_free(f);
|
||||
return -1;
|
||||
@@ -432,7 +432,7 @@ static void ssh_server_connection_callback(ssh_session session){
|
||||
break;
|
||||
case SSH_SESSION_STATE_DH:
|
||||
if(session->dh_handshake_state==DH_STATE_FINISHED){
|
||||
if (generate_session_keys(session) < 0) {
|
||||
if (ssh_generate_session_keys(session) < 0) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user