1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-08-13 04:42:23 +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:
Fabiano Fidêncio
2015-09-17 10:26:05 +02:00
parent 501faacf8e
commit c487f5db5b
7 changed files with 50 additions and 50 deletions

View File

@@ -25,27 +25,27 @@
#include "libssh/crypto.h" #include "libssh/crypto.h"
int dh_generate_e(ssh_session session); int ssh_dh_generate_e(ssh_session session);
int dh_generate_f(ssh_session session); int ssh_dh_generate_f(ssh_session session);
int dh_generate_x(ssh_session session); int ssh_dh_generate_x(ssh_session session);
int dh_generate_y(ssh_session session); int ssh_dh_generate_y(ssh_session session);
int ssh_crypto_init(void); int ssh_crypto_init(void);
void ssh_crypto_finalize(void); void ssh_crypto_finalize(void);
ssh_string dh_get_e(ssh_session session); ssh_string ssh_dh_get_e(ssh_session session);
ssh_string dh_get_f(ssh_session session); ssh_string ssh_dh_get_f(ssh_session session);
int dh_import_f(ssh_session session,ssh_string f_string); int ssh_dh_import_f(ssh_session session,ssh_string f_string);
int dh_import_e(ssh_session session, ssh_string e_string); int ssh_dh_import_e(ssh_session session, ssh_string e_string);
void dh_import_pubkey(ssh_session session,ssh_string pubkey_string); void ssh_dh_import_pubkey(ssh_session session,ssh_string pubkey_string);
int dh_build_k(ssh_session session); int ssh_dh_build_k(ssh_session session);
int ssh_client_dh_init(ssh_session session); int ssh_client_dh_init(ssh_session session);
int ssh_client_dh_reply(ssh_session session, ssh_buffer packet); 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 */ /* add data for the final cookie */
int hashbufin_add_cookie(ssh_session session, unsigned char *cookie); int ssh_hashbufin_add_cookie(ssh_session session, unsigned char *cookie);
int hashbufout_add_cookie(ssh_session session); int ssh_hashbufout_add_cookie(ssh_session session);
int generate_session_keys(ssh_session session); int ssh_generate_session_keys(ssh_session session);
#endif /* DH_H_ */ #endif /* DH_H_ */

View File

@@ -215,7 +215,7 @@ int ssh_server_curve25519_init(ssh_session session, ssh_buffer packet){
goto error; goto error;
} }
rc = make_sessionid(session); rc = ssh_make_sessionid(session);
if (rc != SSH_OK) { if (rc != SSH_OK) {
ssh_set_error(session, SSH_FATAL, "Could not create a session id"); ssh_set_error(session, SSH_FATAL, "Could not create a session id");
goto error; goto error;

View File

@@ -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(); session->next_crypto->x = bignum_new();
if (session->next_crypto->x == NULL) { if (session->next_crypto->x == NULL) {
return -1; return -1;
@@ -247,7 +247,7 @@ int dh_generate_x(ssh_session session) {
} }
/* used by server */ /* used by server */
int dh_generate_y(ssh_session session) { int ssh_dh_generate_y(ssh_session session) {
session->next_crypto->y = bignum_new(); session->next_crypto->y = bignum_new();
if (session->next_crypto->y == NULL) { if (session->next_crypto->y == NULL) {
return -1; return -1;
@@ -268,7 +268,7 @@ int dh_generate_y(ssh_session session) {
} }
/* used by server */ /* used by server */
int dh_generate_e(ssh_session session) { int ssh_dh_generate_e(ssh_session session) {
#ifdef HAVE_LIBCRYPTO #ifdef HAVE_LIBCRYPTO
bignum_CTX ctx = bignum_ctx_new(); bignum_CTX ctx = bignum_ctx_new();
if (ctx == NULL) { if (ctx == NULL) {
@@ -303,7 +303,7 @@ int dh_generate_e(ssh_session session) {
return 0; return 0;
} }
int dh_generate_f(ssh_session session) { int ssh_dh_generate_f(ssh_session session) {
#ifdef HAVE_LIBCRYPTO #ifdef HAVE_LIBCRYPTO
bignum_CTX ctx = bignum_ctx_new(); bignum_CTX ctx = bignum_ctx_new();
if (ctx == NULL) { if (ctx == NULL) {
@@ -338,20 +338,20 @@ int dh_generate_f(ssh_session session) {
return 0; 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); return ssh_make_bignum_string(session->next_crypto->e);
} }
/* used by server */ /* 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); 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; 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); session->next_crypto->f = ssh_make_string_bn(f_string);
if (session->next_crypto->f == NULL) { if (session->next_crypto->f == NULL) {
return -1; return -1;
@@ -365,7 +365,7 @@ int dh_import_f(ssh_session session, ssh_string f_string) {
} }
/* used by the server implementation */ /* 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); session->next_crypto->e = ssh_make_string_bn(e_string);
if (session->next_crypto->e == NULL) { if (session->next_crypto->e == NULL) {
return -1; return -1;
@@ -378,7 +378,7 @@ int dh_import_e(ssh_session session, ssh_string e_string) {
return 0; return 0;
} }
int dh_build_k(ssh_session session) { int ssh_dh_build_k(ssh_session session) {
#ifdef HAVE_LIBCRYPTO #ifdef HAVE_LIBCRYPTO
bignum_CTX ctx = bignum_ctx_new(); bignum_CTX ctx = bignum_ctx_new();
if (ctx == NULL) { if (ctx == NULL) {
@@ -435,14 +435,14 @@ int ssh_client_dh_init(ssh_session session){
ssh_string e = NULL; ssh_string e = NULL;
int rc; int rc;
if (dh_generate_x(session) < 0) { if (ssh_dh_generate_x(session) < 0) {
goto error; goto error;
} }
if (dh_generate_e(session) < 0) { if (ssh_dh_generate_e(session) < 0) {
goto error; goto error;
} }
e = dh_get_e(session); e = ssh_dh_get_e(session);
if (e == NULL) { if (e == NULL) {
goto error; 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"); ssh_set_error(session,SSH_FATAL, "No public key in packet");
goto error; goto error;
} }
dh_import_pubkey(session, pubkey); ssh_dh_import_pubkey(session, pubkey);
f = ssh_buffer_get_ssh_string(packet); f = ssh_buffer_get_ssh_string(packet);
if (f == NULL) { if (f == NULL) {
ssh_set_error(session,SSH_FATAL, "No F number in packet"); ssh_set_error(session,SSH_FATAL, "No F number in packet");
goto error; goto error;
} }
rc = dh_import_f(session, f); rc = ssh_dh_import_f(session, f);
ssh_string_burn(f); ssh_string_burn(f);
ssh_string_free(f); ssh_string_free(f);
if (rc < 0) { 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; session->next_crypto->dh_server_signature = signature;
signature=NULL; /* ownership changed */ 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"); ssh_set_error(session, SSH_FATAL, "Cannot build k number");
goto error; goto error;
} }
@@ -516,7 +516,7 @@ error:
return SSH_ERROR; return SSH_ERROR;
} }
int make_sessionid(ssh_session session) { int ssh_make_sessionid(ssh_session session) {
ssh_string num = NULL; ssh_string num = NULL;
ssh_buffer server_hash = NULL; ssh_buffer server_hash = NULL;
ssh_buffer client_hash = NULL; ssh_buffer client_hash = NULL;
@@ -692,7 +692,7 @@ error:
return rc; return rc;
} }
int hashbufout_add_cookie(ssh_session session) { int ssh_hashbufout_add_cookie(ssh_session session) {
session->out_hashbuf = ssh_buffer_new(); session->out_hashbuf = ssh_buffer_new();
if (session->out_hashbuf == NULL) { if (session->out_hashbuf == NULL) {
return -1; return -1;
@@ -720,7 +720,7 @@ int hashbufout_add_cookie(ssh_session session) {
return 0; 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(); session->in_hashbuf = ssh_buffer_new();
if (session->in_hashbuf == NULL) { if (session->in_hashbuf == NULL) {
return -1; return -1;
@@ -777,7 +777,7 @@ static int generate_one_key(ssh_string k,
return 0; return 0;
} }
int generate_session_keys(ssh_session session) { int ssh_generate_session_keys(ssh_session session) {
ssh_string k_string = NULL; ssh_string k_string = NULL;
struct ssh_crypto_struct *crypto = session->next_crypto; struct ssh_crypto_struct *crypto = session->next_crypto;
int rc = -1; int rc = -1;

View File

@@ -299,7 +299,7 @@ int ssh_server_ecdh_init(ssh_session session, ssh_buffer packet){
return SSH_ERROR; return SSH_ERROR;
} }
rc = make_sessionid(session); rc = ssh_make_sessionid(session);
if (rc != SSH_OK) { if (rc != SSH_OK) {
ssh_set_error(session, SSH_FATAL, "Could not create a session id"); ssh_set_error(session, SSH_FATAL, "Could not create a session id");
return SSH_ERROR; return SSH_ERROR;

View File

@@ -352,7 +352,7 @@ SSH_PACKET_CALLBACK(ssh_packet_kexinit){
goto error; 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) { if (rc < 0) {
ssh_set_error(session, SSH_FATAL, "ssh_packet_kexinit: adding cookie failed"); ssh_set_error(session, SSH_FATAL, "ssh_packet_kexinit: adding cookie failed");
goto error; goto error;
@@ -364,7 +364,7 @@ SSH_PACKET_CALLBACK(ssh_packet_kexinit){
goto error; 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) { if (rc < 0) {
ssh_set_error(session, SSH_FATAL, "ssh_packet_kexinit: adding cookie failed"); ssh_set_error(session, SSH_FATAL, "ssh_packet_kexinit: adding cookie failed");
goto error; goto error;
@@ -612,7 +612,7 @@ int ssh_send_kex(ssh_session session, int server_kex) {
kex->cookie); /* cookie */ kex->cookie); /* cookie */
if (rc != SSH_OK) if (rc != SSH_OK)
goto error; goto error;
if (hashbufout_add_cookie(session) < 0) { if (ssh_hashbufout_add_cookie(session) < 0) {
goto error; goto error;
} }

View File

@@ -154,20 +154,20 @@ SSH_PACKET_CALLBACK(ssh_packet_newkeys){
} else { } else {
ssh_key key; ssh_key key;
/* client */ /* client */
rc = make_sessionid(session); rc = ssh_make_sessionid(session);
if (rc != SSH_OK) { if (rc != SSH_OK) {
goto error; goto error;
} }
/* /*
* Set the cryptographic functions for the next crypto * 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*/ ) { if (crypt_set_algorithms(session, SSH_3DES) /* knows nothing about DES*/ ) {
goto error; goto error;
} }
if (generate_session_keys(session) < 0) { if (ssh_generate_session_keys(session) < 0) {
goto error; goto error;
} }

View File

@@ -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"); ssh_set_error(session, SSH_FATAL, "No e number in client request");
return -1; 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"); ssh_set_error(session, SSH_FATAL, "Cannot import e number");
session->session_state=SSH_SESSION_STATE_ERROR; session->session_state=SSH_SESSION_STATE_ERROR;
} else { } else {
@@ -258,7 +258,7 @@ int ssh_get_key_params(ssh_session session, ssh_key *privkey){
return -1; return -1;
} }
dh_import_pubkey(session, pubkey_blob); ssh_dh_import_pubkey(session, pubkey_blob);
return SSH_OK; return SSH_OK;
} }
@@ -268,16 +268,16 @@ static int dh_handshake_server(ssh_session session) {
ssh_string f; ssh_string f;
int rc; 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"); ssh_set_error(session, SSH_FATAL, "Could not create y number");
return -1; 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"); ssh_set_error(session, SSH_FATAL, "Could not create f number");
return -1; return -1;
} }
f = dh_get_f(session); f = ssh_dh_get_f(session);
if (f == NULL) { if (f == NULL) {
ssh_set_error(session, SSH_FATAL, "Could not get the f number"); ssh_set_error(session, SSH_FATAL, "Could not get the f number");
return -1; return -1;
@@ -288,13 +288,13 @@ static int dh_handshake_server(ssh_session session) {
return -1; 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_set_error(session, SSH_FATAL, "Could not import the public key");
ssh_string_free(f); ssh_string_free(f);
return -1; 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_set_error(session, SSH_FATAL, "Could not create a session id");
ssh_string_free(f); ssh_string_free(f);
return -1; return -1;
@@ -432,7 +432,7 @@ static void ssh_server_connection_callback(ssh_session session){
break; break;
case SSH_SESSION_STATE_DH: case SSH_SESSION_STATE_DH:
if(session->dh_handshake_state==DH_STATE_FINISHED){ if(session->dh_handshake_state==DH_STATE_FINISHED){
if (generate_session_keys(session) < 0) { if (ssh_generate_session_keys(session) < 0) {
goto error; goto error;
} }