[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 02/24] 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@xxxxxxxxxx>
---
 include/libssh/bignum.h |  6 +++---
 src/bignum.c            |  6 +++---
 src/buffer.c            |  2 +-
 src/dh.c                | 10 +++++-----
 src/known_hosts.c       |  4 ++--
 src/pki_crypto.c        | 40 ++++++++++++++++++++--------------------
 6 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/include/libssh/bignum.h b/include/libssh/bignum.h
index 61786c8..df77ebe 100644
--- a/include/libssh/bignum.h
+++ b/include/libssh/bignum.h
@@ -24,9 +24,9 @@
 #include "libssh/libcrypto.h"
 #include "libssh/libgcrypt.h"
 
-bignum make_string_bn(ssh_string string);
-void make_string_bn_inplace(ssh_string string, bignum bnout);
-ssh_string make_bignum_string(bignum num);
+bignum ssh_make_string_bn(ssh_string string);
+void ssh_make_string_bn_inplace(ssh_string string, bignum bnout);
+ssh_string ssh_make_bignum_string(bignum num);
 void ssh_print_bignum(const char *which,bignum num);
 
 
diff --git a/src/bignum.c b/src/bignum.c
index e9c16dd..de21d6b 100644
--- a/src/bignum.c
+++ b/src/bignum.c
@@ -25,7 +25,7 @@
 #include "libssh/bignum.h"
 #include "libssh/string.h"
 
-ssh_string make_bignum_string(bignum num) {
+ssh_string ssh_make_bignum_string(bignum num) {
   ssh_string ptr = NULL;
   int pad = 0;
   unsigned int len = bignum_num_bytes(num);
@@ -63,7 +63,7 @@ ssh_string make_bignum_string(bignum num) {
   return ptr;
 }
 
-bignum make_string_bn(ssh_string string){
+bignum ssh_make_string_bn(ssh_string string){
   bignum bn = NULL;
   unsigned int len = ssh_string_len(string);
 
@@ -81,7 +81,7 @@ bignum make_string_bn(ssh_string string){
   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);
 #ifdef HAVE_LIBGCRYPT
   /* XXX: FIXME as needed for LIBGCRYPT ECDSA codepaths. */
diff --git a/src/buffer.c b/src/buffer.c
index 0bffdfd..0a33ae3 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -767,7 +767,7 @@ int ssh_buffer_pack_va(struct ssh_buffer_struct *buffer,
             break;
         case 'B':
             b = va_arg(ap, bignum);
-            o.string = make_bignum_string(b);
+            o.string = ssh_make_bignum_string(b);
             if(o.string == NULL){
                 rc = SSH_ERROR;
                 break;
diff --git a/src/dh.c b/src/dh.c
index e489a1d..b372b2c 100644
--- a/src/dh.c
+++ b/src/dh.c
@@ -339,12 +339,12 @@ int dh_generate_f(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 */
 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) {
@@ -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) {
-  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) {
     return -1;
   }
@@ -366,7 +366,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) {
-  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) {
     return -1;
   }
@@ -782,7 +782,7 @@ int generate_session_keys(ssh_session session) {
   struct ssh_crypto_struct *crypto = session->next_crypto;
   int rc = -1;
 
-  k_string = make_bignum_string(crypto->k);
+  k_string = ssh_make_bignum_string(crypto->k);
   if (k_string == NULL) {
     ssh_set_error_oom(session);
     goto error;
diff --git a/src/known_hosts.c b/src/known_hosts.c
index f7828d5..d87af43 100644
--- a/src/known_hosts.c
+++ b/src/known_hosts.c
@@ -225,9 +225,9 @@ static int check_public_key(ssh_session session, char **tokens) {
         ssh_buffer_free(pubkey_buffer);
         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 */
-      /* tmpstring = make_bignum_string(tmpbn); */
+      /* tmpstring = ssh_make_bignum_string(tmpbn); */
       /* do it manually instead */
       len = bignum_num_bytes(tmpbn);
       tmpstring = malloc(4 + len);
diff --git a/src/pki_crypto.c b/src/pki_crypto.c
index d656e35..7a3caba 100644
--- a/src/pki_crypto.c
+++ b/src/pki_crypto.c
@@ -831,10 +831,10 @@ int pki_pubkey_build_dss(ssh_key key,
         return SSH_ERROR;
     }
 
-    key->dsa->p = make_string_bn(p);
-    key->dsa->q = make_string_bn(q);
-    key->dsa->g = make_string_bn(g);
-    key->dsa->pub_key = make_string_bn(pubkey);
+    key->dsa->p = ssh_make_string_bn(p);
+    key->dsa->q = ssh_make_string_bn(q);
+    key->dsa->g = ssh_make_string_bn(g);
+    key->dsa->pub_key = ssh_make_string_bn(pubkey);
     if (key->dsa->p == NULL ||
         key->dsa->q == NULL ||
         key->dsa->g == NULL ||
@@ -854,8 +854,8 @@ int pki_pubkey_build_rsa(ssh_key key,
         return SSH_ERROR;
     }
 
-    key->rsa->e = make_string_bn(e);
-    key->rsa->n = make_string_bn(n);
+    key->rsa->e = ssh_make_string_bn(e);
+    key->rsa->n = ssh_make_string_bn(n);
     if (key->rsa->e == NULL ||
         key->rsa->n == NULL) {
         RSA_free(key->rsa);
@@ -897,22 +897,22 @@ ssh_string pki_publickey_to_blob(const ssh_key key)
 
     switch (key->type) {
         case SSH_KEYTYPE_DSS:
-            p = make_bignum_string(key->dsa->p);
+            p = ssh_make_bignum_string(key->dsa->p);
             if (p == NULL) {
                 goto fail;
             }
 
-            q = make_bignum_string(key->dsa->q);
+            q = ssh_make_bignum_string(key->dsa->q);
             if (q == NULL) {
                 goto fail;
             }
 
-            g = make_bignum_string(key->dsa->g);
+            g = ssh_make_bignum_string(key->dsa->g);
             if (g == NULL) {
                 goto fail;
             }
 
-            n = make_bignum_string(key->dsa->pub_key);
+            n = ssh_make_bignum_string(key->dsa->pub_key);
             if (n == NULL) {
                 goto fail;
             }
@@ -946,12 +946,12 @@ ssh_string pki_publickey_to_blob(const ssh_key key)
             break;
         case SSH_KEYTYPE_RSA:
         case SSH_KEYTYPE_RSA1:
-            e = make_bignum_string(key->rsa->e);
+            e = ssh_make_bignum_string(key->rsa->e);
             if (e == NULL) {
                 goto fail;
             }
 
-            n = make_bignum_string(key->rsa->n);
+            n = ssh_make_bignum_string(key->rsa->n);
             if (n == NULL) {
                 goto fail;
             }
@@ -1150,12 +1150,12 @@ static ssh_string pki_dsa_signature_to_blob(const ssh_signature sig)
     ssh_string s;
     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) {
         return NULL;
     }
 
-    s = make_bignum_string(sig->dsa_sig->s);
+    s = ssh_make_bignum_string(sig->dsa_sig->s);
     if (s == NULL) {
         ssh_string_free(r);
         return NULL;
@@ -1214,7 +1214,7 @@ ssh_string pki_signature_to_blob(const ssh_signature sig)
                 return NULL;
             }
 
-            r = make_bignum_string(sig->ecdsa_sig->r);
+            r = ssh_make_bignum_string(sig->ecdsa_sig->r);
             if (r == NULL) {
                 ssh_buffer_free(b);
                 return NULL;
@@ -1226,7 +1226,7 @@ ssh_string pki_signature_to_blob(const ssh_signature sig)
                 return NULL;
             }
 
-            s = make_bignum_string(sig->ecdsa_sig->s);
+            s = ssh_make_bignum_string(sig->ecdsa_sig->s);
             if (s == NULL) {
                 ssh_buffer_free(b);
                 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);
 
-            sig->dsa_sig->r = make_string_bn(r);
+            sig->dsa_sig->r = ssh_make_string_bn(r);
             ssh_string_free(r);
             if (sig->dsa_sig->r == NULL) {
                 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);
 
-            sig->dsa_sig->s = make_string_bn(s);
+            sig->dsa_sig->s = ssh_make_string_bn(s);
             ssh_string_free(s);
             if (sig->dsa_sig->s == NULL) {
                 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));
 #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_free(r);
                 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));
 #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_free(s);
                 if (sig->ecdsa_sig->s == NULL) {
-- 
2.5.0


Archive administrator: postmaster@lists.cynapses.org