mirror of
https://git.libssh.org/projects/libssh.git
synced 2025-11-29 01:03:57 +03:00
cleanup: use ssh_ prefix in the bignum (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:
@@ -24,9 +24,9 @@
|
|||||||
#include "libssh/libcrypto.h"
|
#include "libssh/libcrypto.h"
|
||||||
#include "libssh/libgcrypt.h"
|
#include "libssh/libgcrypt.h"
|
||||||
|
|
||||||
bignum make_string_bn(ssh_string string);
|
bignum ssh_make_string_bn(ssh_string string);
|
||||||
void make_string_bn_inplace(ssh_string string, bignum bnout);
|
void ssh_make_string_bn_inplace(ssh_string string, bignum bnout);
|
||||||
ssh_string make_bignum_string(bignum num);
|
ssh_string ssh_make_bignum_string(bignum num);
|
||||||
void ssh_print_bignum(const char *which,bignum num);
|
void ssh_print_bignum(const char *which,bignum num);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
#include "libssh/bignum.h"
|
#include "libssh/bignum.h"
|
||||||
#include "libssh/string.h"
|
#include "libssh/string.h"
|
||||||
|
|
||||||
ssh_string make_bignum_string(bignum num) {
|
ssh_string ssh_make_bignum_string(bignum num) {
|
||||||
ssh_string ptr = NULL;
|
ssh_string ptr = NULL;
|
||||||
int pad = 0;
|
int pad = 0;
|
||||||
unsigned int len = bignum_num_bytes(num);
|
unsigned int len = bignum_num_bytes(num);
|
||||||
@@ -63,7 +63,7 @@ ssh_string make_bignum_string(bignum num) {
|
|||||||
return ptr;
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bignum make_string_bn(ssh_string string){
|
bignum ssh_make_string_bn(ssh_string string){
|
||||||
bignum bn = NULL;
|
bignum bn = NULL;
|
||||||
unsigned int len = ssh_string_len(string);
|
unsigned int len = ssh_string_len(string);
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ bignum make_string_bn(ssh_string string){
|
|||||||
return bn;
|
return bn;
|
||||||
}
|
}
|
||||||
|
|
||||||
void make_string_bn_inplace(ssh_string string, bignum bnout) {
|
void ssh_make_string_bn_inplace(ssh_string string, bignum bnout) {
|
||||||
unsigned int len = ssh_string_len(string);
|
unsigned int len = ssh_string_len(string);
|
||||||
#ifdef HAVE_LIBGCRYPT
|
#ifdef HAVE_LIBGCRYPT
|
||||||
/* XXX: FIXME as needed for LIBGCRYPT ECDSA codepaths. */
|
/* XXX: FIXME as needed for LIBGCRYPT ECDSA codepaths. */
|
||||||
|
|||||||
@@ -767,7 +767,7 @@ int ssh_buffer_pack_va(struct ssh_buffer_struct *buffer,
|
|||||||
break;
|
break;
|
||||||
case 'B':
|
case 'B':
|
||||||
b = va_arg(ap, bignum);
|
b = va_arg(ap, bignum);
|
||||||
o.string = make_bignum_string(b);
|
o.string = ssh_make_bignum_string(b);
|
||||||
if(o.string == NULL){
|
if(o.string == NULL){
|
||||||
rc = SSH_ERROR;
|
rc = SSH_ERROR;
|
||||||
break;
|
break;
|
||||||
|
|||||||
10
src/dh.c
10
src/dh.c
@@ -339,12 +339,12 @@ int dh_generate_f(ssh_session session) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ssh_string dh_get_e(ssh_session session) {
|
ssh_string dh_get_e(ssh_session session) {
|
||||||
return 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 dh_get_f(ssh_session session) {
|
||||||
return 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 dh_import_pubkey(ssh_session session, ssh_string pubkey_string) {
|
||||||
@@ -352,7 +352,7 @@ void dh_import_pubkey(ssh_session session, ssh_string pubkey_string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int dh_import_f(ssh_session session, ssh_string f_string) {
|
int dh_import_f(ssh_session session, ssh_string f_string) {
|
||||||
session->next_crypto->f = 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;
|
||||||
}
|
}
|
||||||
@@ -366,7 +366,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 dh_import_e(ssh_session session, ssh_string e_string) {
|
||||||
session->next_crypto->e = 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;
|
||||||
}
|
}
|
||||||
@@ -782,7 +782,7 @@ int generate_session_keys(ssh_session session) {
|
|||||||
struct ssh_crypto_struct *crypto = session->next_crypto;
|
struct ssh_crypto_struct *crypto = session->next_crypto;
|
||||||
int rc = -1;
|
int rc = -1;
|
||||||
|
|
||||||
k_string = make_bignum_string(crypto->k);
|
k_string = ssh_make_bignum_string(crypto->k);
|
||||||
if (k_string == NULL) {
|
if (k_string == NULL) {
|
||||||
ssh_set_error_oom(session);
|
ssh_set_error_oom(session);
|
||||||
goto error;
|
goto error;
|
||||||
|
|||||||
@@ -225,9 +225,9 @@ static int check_public_key(ssh_session session, char **tokens) {
|
|||||||
ssh_buffer_free(pubkey_buffer);
|
ssh_buffer_free(pubkey_buffer);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* for some reason, make_bignum_string does not work
|
/* for some reason, ssh_make_bignum_string does not work
|
||||||
because of the padding which it does --kv */
|
because of the padding which it does --kv */
|
||||||
/* tmpstring = make_bignum_string(tmpbn); */
|
/* tmpstring = ssh_make_bignum_string(tmpbn); */
|
||||||
/* do it manually instead */
|
/* do it manually instead */
|
||||||
len = bignum_num_bytes(tmpbn);
|
len = bignum_num_bytes(tmpbn);
|
||||||
tmpstring = malloc(4 + len);
|
tmpstring = malloc(4 + len);
|
||||||
|
|||||||
@@ -831,10 +831,10 @@ int pki_pubkey_build_dss(ssh_key key,
|
|||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
key->dsa->p = make_string_bn(p);
|
key->dsa->p = ssh_make_string_bn(p);
|
||||||
key->dsa->q = make_string_bn(q);
|
key->dsa->q = ssh_make_string_bn(q);
|
||||||
key->dsa->g = make_string_bn(g);
|
key->dsa->g = ssh_make_string_bn(g);
|
||||||
key->dsa->pub_key = make_string_bn(pubkey);
|
key->dsa->pub_key = ssh_make_string_bn(pubkey);
|
||||||
if (key->dsa->p == NULL ||
|
if (key->dsa->p == NULL ||
|
||||||
key->dsa->q == NULL ||
|
key->dsa->q == NULL ||
|
||||||
key->dsa->g == NULL ||
|
key->dsa->g == NULL ||
|
||||||
@@ -854,8 +854,8 @@ int pki_pubkey_build_rsa(ssh_key key,
|
|||||||
return SSH_ERROR;
|
return SSH_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
key->rsa->e = make_string_bn(e);
|
key->rsa->e = ssh_make_string_bn(e);
|
||||||
key->rsa->n = make_string_bn(n);
|
key->rsa->n = ssh_make_string_bn(n);
|
||||||
if (key->rsa->e == NULL ||
|
if (key->rsa->e == NULL ||
|
||||||
key->rsa->n == NULL) {
|
key->rsa->n == NULL) {
|
||||||
RSA_free(key->rsa);
|
RSA_free(key->rsa);
|
||||||
@@ -897,22 +897,22 @@ ssh_string pki_publickey_to_blob(const ssh_key key)
|
|||||||
|
|
||||||
switch (key->type) {
|
switch (key->type) {
|
||||||
case SSH_KEYTYPE_DSS:
|
case SSH_KEYTYPE_DSS:
|
||||||
p = make_bignum_string(key->dsa->p);
|
p = ssh_make_bignum_string(key->dsa->p);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
q = make_bignum_string(key->dsa->q);
|
q = ssh_make_bignum_string(key->dsa->q);
|
||||||
if (q == NULL) {
|
if (q == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
g = make_bignum_string(key->dsa->g);
|
g = ssh_make_bignum_string(key->dsa->g);
|
||||||
if (g == NULL) {
|
if (g == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = make_bignum_string(key->dsa->pub_key);
|
n = ssh_make_bignum_string(key->dsa->pub_key);
|
||||||
if (n == NULL) {
|
if (n == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@@ -946,12 +946,12 @@ ssh_string pki_publickey_to_blob(const ssh_key key)
|
|||||||
break;
|
break;
|
||||||
case SSH_KEYTYPE_RSA:
|
case SSH_KEYTYPE_RSA:
|
||||||
case SSH_KEYTYPE_RSA1:
|
case SSH_KEYTYPE_RSA1:
|
||||||
e = make_bignum_string(key->rsa->e);
|
e = ssh_make_bignum_string(key->rsa->e);
|
||||||
if (e == NULL) {
|
if (e == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
n = make_bignum_string(key->rsa->n);
|
n = ssh_make_bignum_string(key->rsa->n);
|
||||||
if (n == NULL) {
|
if (n == NULL) {
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@@ -1150,12 +1150,12 @@ static ssh_string pki_dsa_signature_to_blob(const ssh_signature sig)
|
|||||||
ssh_string s;
|
ssh_string s;
|
||||||
int s_len, s_offset_in, s_offset_out;
|
int s_len, s_offset_in, s_offset_out;
|
||||||
|
|
||||||
r = make_bignum_string(sig->dsa_sig->r);
|
r = ssh_make_bignum_string(sig->dsa_sig->r);
|
||||||
if (r == NULL) {
|
if (r == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = make_bignum_string(sig->dsa_sig->s);
|
s = ssh_make_bignum_string(sig->dsa_sig->s);
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
ssh_string_free(r);
|
ssh_string_free(r);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1214,7 +1214,7 @@ ssh_string pki_signature_to_blob(const ssh_signature sig)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
r = make_bignum_string(sig->ecdsa_sig->r);
|
r = ssh_make_bignum_string(sig->ecdsa_sig->r);
|
||||||
if (r == NULL) {
|
if (r == NULL) {
|
||||||
ssh_buffer_free(b);
|
ssh_buffer_free(b);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1226,7 +1226,7 @@ ssh_string pki_signature_to_blob(const ssh_signature sig)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = make_bignum_string(sig->ecdsa_sig->s);
|
s = ssh_make_bignum_string(sig->ecdsa_sig->s);
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
ssh_buffer_free(b);
|
ssh_buffer_free(b);
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -1375,7 +1375,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
|
|||||||
}
|
}
|
||||||
ssh_string_fill(r, ssh_string_data(sig_blob), 20);
|
ssh_string_fill(r, ssh_string_data(sig_blob), 20);
|
||||||
|
|
||||||
sig->dsa_sig->r = make_string_bn(r);
|
sig->dsa_sig->r = ssh_make_string_bn(r);
|
||||||
ssh_string_free(r);
|
ssh_string_free(r);
|
||||||
if (sig->dsa_sig->r == NULL) {
|
if (sig->dsa_sig->r == NULL) {
|
||||||
ssh_signature_free(sig);
|
ssh_signature_free(sig);
|
||||||
@@ -1389,7 +1389,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
|
|||||||
}
|
}
|
||||||
ssh_string_fill(s, (char *)ssh_string_data(sig_blob) + 20, 20);
|
ssh_string_fill(s, (char *)ssh_string_data(sig_blob) + 20, 20);
|
||||||
|
|
||||||
sig->dsa_sig->s = make_string_bn(s);
|
sig->dsa_sig->s = ssh_make_string_bn(s);
|
||||||
ssh_string_free(s);
|
ssh_string_free(s);
|
||||||
if (sig->dsa_sig->s == NULL) {
|
if (sig->dsa_sig->s == NULL) {
|
||||||
ssh_signature_free(sig);
|
ssh_signature_free(sig);
|
||||||
@@ -1439,7 +1439,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
|
|||||||
ssh_print_hexa("r", ssh_string_data(r), ssh_string_len(r));
|
ssh_print_hexa("r", ssh_string_data(r), ssh_string_len(r));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
make_string_bn_inplace(r, sig->ecdsa_sig->r);
|
ssh_make_string_bn_inplace(r, sig->ecdsa_sig->r);
|
||||||
ssh_string_burn(r);
|
ssh_string_burn(r);
|
||||||
ssh_string_free(r);
|
ssh_string_free(r);
|
||||||
if (sig->ecdsa_sig->r == NULL) {
|
if (sig->ecdsa_sig->r == NULL) {
|
||||||
@@ -1460,7 +1460,7 @@ ssh_signature pki_signature_from_blob(const ssh_key pubkey,
|
|||||||
ssh_print_hexa("s", ssh_string_data(s), ssh_string_len(s));
|
ssh_print_hexa("s", ssh_string_data(s), ssh_string_len(s));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
make_string_bn_inplace(s, sig->ecdsa_sig->s);
|
ssh_make_string_bn_inplace(s, sig->ecdsa_sig->s);
|
||||||
ssh_string_burn(s);
|
ssh_string_burn(s);
|
||||||
ssh_string_free(s);
|
ssh_string_free(s);
|
||||||
if (sig->ecdsa_sig->s == NULL) {
|
if (sig->ecdsa_sig->s == NULL) {
|
||||||
|
|||||||
Reference in New Issue
Block a user