gnutls-commit
[Top][All Lists]
Advanced

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

[SCM] GNU gnutls branch, master, updated. gnutls_3_0_5-18-g10cbbd5


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU gnutls branch, master, updated. gnutls_3_0_5-18-g10cbbd5
Date: Wed, 02 Nov 2011 09:57:39 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU gnutls".

http://git.savannah.gnu.org/cgit/gnutls.git/commit/?id=10cbbd52fba11ce69cd69641c7b4a176e673d23e

The branch, master has been updated
       via  10cbbd52fba11ce69cd69641c7b4a176e673d23e (commit)
      from  dad5a74138c9c202b9c4ed5b08be06c55bb95c9e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 10cbbd52fba11ce69cd69641c7b4a176e673d23e
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Wed Nov 2 10:56:03 2011 +0100

    removed duplicate code.

-----------------------------------------------------------------------

Summary of changes:
 lib/gnutls_str.c     |   38 ++++++++++++++++++
 lib/gnutls_str.h     |    5 ++
 lib/openpgp/output.c |   57 ++++-----------------------
 lib/x509/output.c    |  104 +++++++++++++++----------------------------------
 4 files changed, 84 insertions(+), 120 deletions(-)

diff --git a/lib/gnutls_str.c b/lib/gnutls_str.c
index c7c8e9d..9e8ed61 100644
--- a/lib/gnutls_str.c
+++ b/lib/gnutls_str.c
@@ -730,3 +730,41 @@ _gnutls_buffer_pop_data_prefix (gnutls_buffer_st * buf, 
void *data,
 
   return 0;
 }
+
+void _gnutls_buffer_hexprint (gnutls_buffer_st * str, const char *data, size_t 
len)
+{
+  size_t j;
+
+  if (len == 0)
+    _gnutls_buffer_append_str (str, "00");
+  else
+    {
+      for (j = 0; j < len; j++)
+        _gnutls_buffer_append_printf (str, "%.2x", (unsigned char) data[j]);
+    }
+}
+
+void
+_gnutls_buffer_hexdump (gnutls_buffer_st * str, const char *data, size_t len,
+         const char *spc)
+{
+  size_t j;
+
+  if (spc)
+    _gnutls_buffer_append_str (str, spc);
+  for (j = 0; j < len; j++)
+    {
+      if (((j + 1) % 16) == 0)
+        {
+          _gnutls_buffer_append_printf (str, "%.2x\n", (unsigned char) 
data[j]);
+          if (spc && j != (len - 1))
+            _gnutls_buffer_append_str (str, spc);
+        }
+      else if (j == (len - 1))
+        _gnutls_buffer_append_printf (str, "%.2x", (unsigned char) data[j]);
+      else
+        _gnutls_buffer_append_printf (str, "%.2x:", (unsigned char) data[j]);
+    }
+  if ((j % 16) != 0)
+    _gnutls_buffer_append_str (str, "\n");
+}
diff --git a/lib/gnutls_str.h b/lib/gnutls_str.h
index 3b6562e..3d1de00 100644
--- a/lib/gnutls_str.h
+++ b/lib/gnutls_str.h
@@ -92,6 +92,10 @@ int _gnutls_buffer_append_printf (gnutls_buffer_st * dest, 
const char *fmt,
                                   ...)
   __attribute__ ((format (printf, 2, 3)));
 
+void _gnutls_buffer_hexprint (gnutls_buffer_st * str, const char *data, size_t 
len);
+void _gnutls_buffer_hexdump (gnutls_buffer_st * str, const char *data, size_t 
len,
+         const char *spc);
+
 char *_gnutls_bin2hex (const void *old, size_t oldlen, char *buffer,
                        size_t buffer_size, const char *separator);
 int _gnutls_hex2bin (const opaque * hex_data, int hex_size, opaque * bin_data,
@@ -99,6 +103,7 @@ int _gnutls_hex2bin (const opaque * hex_data, int hex_size, 
opaque * bin_data,
 
 int _gnutls_hostname_compare (const char *certname, size_t certnamesize,
                               const char *hostname, int level);
+
 #define MAX_CN 256
 #define MAX_DN 1024
 
diff --git a/lib/openpgp/output.c b/lib/openpgp/output.c
index d3a9405..2b5f12d 100644
--- a/lib/openpgp/output.c
+++ b/lib/openpgp/output.c
@@ -35,45 +35,6 @@
 #define adds _gnutls_buffer_append_str
 
 static void
-hexdump (gnutls_buffer_st * str, const char *data, size_t len,
-         const char *spc)
-{
-  size_t j;
-
-  if (spc)
-    adds (str, spc);
-  for (j = 0; j < len; j++)
-    {
-      if (((j + 1) % 16) == 0)
-        {
-          addf (str, "%.2x\n", (unsigned char) data[j]);
-          if (spc && j != (len - 1))
-            adds (str, spc);
-        }
-      else if (j == (len - 1))
-        addf (str, "%.2x", (unsigned char) data[j]);
-      else
-        addf (str, "%.2x:", (unsigned char) data[j]);
-    }
-  if ((j % 16) != 0)
-    adds (str, "\n");
-}
-
-static void
-hexprint (gnutls_buffer_st * str, const char *data, size_t len)
-{
-  size_t j;
-
-  if (len == 0)
-    adds (str, "00");
-  else
-    {
-      for (j = 0; j < len; j++)
-        addf (str, "%.2x", (unsigned char) data[j]);
-    }
-}
-
-static void
 print_key_usage (gnutls_buffer_st * str, gnutls_openpgp_crt_t cert,
                  unsigned int idx)
 {
@@ -124,7 +85,7 @@ print_key_id (gnutls_buffer_st * str, gnutls_openpgp_crt_t 
cert, int idx)
   else
     {
       adds (str, _("\tID (hex): "));
-      hexprint (str, id, sizeof (id));
+      _gnutls_buffer_hexprint (str, id, sizeof (id));
       addf (str, "\n");
     }
 }
@@ -145,7 +106,7 @@ print_key_fingerprint (gnutls_buffer_st * str, 
gnutls_openpgp_crt_t cert)
   else
     {
       adds (str, _("\tFingerprint (hex): "));
-      hexprint (str, fpr, fpr_size);
+      _gnutls_buffer_hexprint (str, fpr, fpr_size);
       addf (str, "\n");
     }
 }
@@ -258,9 +219,9 @@ print_key_info (gnutls_buffer_st * str, 
gnutls_openpgp_crt_t cert, int idx)
             else
               {
                 addf (str, _("\t\tModulus (bits %d):\n"), bits);
-                hexdump (str, m.data, m.size, "\t\t\t");
+                _gnutls_buffer_hexdump (str, m.data, m.size, "\t\t\t");
                 adds (str, _("\t\tExponent:\n"));
-                hexdump (str, e.data, e.size, "\t\t\t");
+                _gnutls_buffer_hexdump (str, e.data, e.size, "\t\t\t");
 
                 gnutls_free (m.data);
                 gnutls_free (e.data);
@@ -285,13 +246,13 @@ print_key_info (gnutls_buffer_st * str, 
gnutls_openpgp_crt_t cert, int idx)
             else
               {
                 addf (str, _("\t\tPublic key (bits %d):\n"), bits);
-                hexdump (str, y.data, y.size, "\t\t\t");
+                _gnutls_buffer_hexdump (str, y.data, y.size, "\t\t\t");
                 adds (str, _("\t\tP:\n"));
-                hexdump (str, p.data, p.size, "\t\t\t");
+                _gnutls_buffer_hexdump (str, p.data, p.size, "\t\t\t");
                 adds (str, _("\t\tQ:\n"));
-                hexdump (str, q.data, q.size, "\t\t\t");
+                _gnutls_buffer_hexdump (str, q.data, q.size, "\t\t\t");
                 adds (str, _("\t\tG:\n"));
-                hexdump (str, g.data, g.size, "\t\t\t");
+                _gnutls_buffer_hexdump (str, g.data, g.size, "\t\t\t");
 
                 gnutls_free (p.data);
                 gnutls_free (q.data);
@@ -440,7 +401,7 @@ print_oneline (gnutls_buffer_st * str, gnutls_openpgp_crt_t 
cert)
     else
       {
         adds (str, _("fingerprint: "));
-        hexprint (str, fpr, fpr_size);
+        _gnutls_buffer_hexprint (str, fpr, fpr_size);
         addf (str, ", ");
       }
   }
diff --git a/lib/x509/output.c b/lib/x509/output.c
index 6bf02ce..0f326a6 100644
--- a/lib/x509/output.c
+++ b/lib/x509/output.c
@@ -41,46 +41,6 @@
 #define ERROR_STR (char*) "(error)"
 
 static void
-hexdump (gnutls_buffer_st * str, const char *data, size_t len,
-         const char *spc)
-{
-  size_t j;
-
-  if (spc)
-    adds (str, spc);
-  for (j = 0; j < len; j++)
-    {
-      if (((j + 1) % 16) == 0)
-        {
-          addf (str, "%.2x\n", (unsigned char) data[j]);
-          if (spc && j != (len - 1))
-            adds (str, spc);
-        }
-      else if (j == (len - 1))
-        addf (str, "%.2x", (unsigned char) data[j]);
-      else
-        addf (str, "%.2x:", (unsigned char) data[j]);
-    }
-  if ((j % 16) != 0)
-    adds (str, "\n");
-}
-
-static void
-hexprint (gnutls_buffer_st * str, const char *data, size_t len)
-{
-  size_t j;
-
-  if (len == 0)
-    adds (str, "00");
-  else
-    {
-      for (j = 0; j < len; j++)
-        addf (str, "%.2x", (unsigned char) data[j]);
-    }
-}
-
-
-static void
 asciiprint (gnutls_buffer_st * str, const char *data, size_t len)
 {
   size_t j;
@@ -165,7 +125,7 @@ print_proxy (gnutls_buffer_st * str, gnutls_x509_crt_t cert)
       adds (str, _("\t\t\tPolicy:\n\t\t\t\tASCII: "));
       asciiprint (str, policy, npolicy);
       adds (str, _("\n\t\t\t\tHexdump: "));
-      hexprint (str, policy, npolicy);
+      _gnutls_buffer_hexprint (str, policy, npolicy);
       adds (str, "\n");
     }
 }
@@ -258,7 +218,7 @@ print_ski (gnutls_buffer_st * str, gnutls_x509_crt_t cert)
     }
 
   adds (str, "\t\t\t");
-  hexprint (str, buffer, size);
+  _gnutls_buffer_hexprint (str, buffer, size);
   adds (str, "\n");
 
   gnutls_free (buffer);
@@ -327,7 +287,7 @@ print_aki (gnutls_buffer_st * str, int type, cert_type_t 
cert)
     }
 
   adds (str, "\t\t\t");
-  hexprint (str, buffer, size);
+  _gnutls_buffer_hexprint (str, buffer, size);
   adds (str, "\n");
 
   gnutls_free (buffer);
@@ -744,7 +704,7 @@ print_altname (gnutls_buffer_st * str, const char *prefix, 
int altname_type,
                 addf (str, _("%s\t\t\totherName OID: %.*s\n"), prefix,
                       (int) oidsize, oid);
                 addf (str, _("%s\t\t\totherName DER: "), prefix);
-                hexprint (str, buffer, size);
+                _gnutls_buffer_hexprint (str, buffer, size);
                 addf (str, _("\n%s\t\t\totherName ASCII: "), prefix);
                 asciiprint (str, buffer, size);
                 addf (str, "\n");
@@ -803,7 +763,7 @@ print_unique_ids (gnutls_buffer_st * str, const 
gnutls_x509_crt_t cert)
   if (result >= 0)
     {
       addf (str, ("\t\tIssuer Unique ID:\n"));
-      hexdump (str, buf, buf_size, "\t\t\t");
+      _gnutls_buffer_hexdump (str, buf, buf_size, "\t\t\t");
       if (buf_size == 16)
         {                       /* this could be a GUID */
           guiddump (str, buf, buf_size, "\t\t\t");
@@ -815,7 +775,7 @@ print_unique_ids (gnutls_buffer_st * str, const 
gnutls_x509_crt_t cert)
   if (result >= 0)
     {
       addf (str, ("\t\tSubject Unique ID:\n"));
-      hexdump (str, buf, buf_size, "\t\t\t");
+      _gnutls_buffer_hexdump (str, buf, buf_size, "\t\t\t");
       if (buf_size == 16)
         {                       /* this could be a GUID */
           guiddump (str, buf, buf_size, "\t\t\t");
@@ -1081,7 +1041,7 @@ print_extensions (gnutls_buffer_st * str, const char 
*prefix, int type,
           addf (str, "\n");
 
           addf (str, _("%s\t\t\tHexdump: "), prefix);
-          hexprint (str, buffer, extlen);
+          _gnutls_buffer_hexprint (str, buffer, extlen);
           adds (str, "\n");
 
           gnutls_free (buffer);
@@ -1113,7 +1073,7 @@ print_cert (gnutls_buffer_st * str, gnutls_x509_crt_t 
cert, int notsigned)
     else
       {
         adds (str, _("\tSerial Number (hex): "));
-        hexprint (str, serial, serial_size);
+        _gnutls_buffer_hexprint (str, serial, serial_size);
         adds (str, "\n");
       }
   }
@@ -1258,9 +1218,9 @@ print_cert (gnutls_buffer_st * str, gnutls_x509_crt_t 
cert, int notsigned)
               else
                 {
                   addf (str, _("\t\tModulus (bits %d):\n"), bits);
-                  hexdump (str, m.data, m.size, "\t\t\t");
+                  _gnutls_buffer_hexdump (str, m.data, m.size, "\t\t\t");
                   addf (str, _("\t\tExponent (bits %d):\n"), e.size * 8);
-                  hexdump (str, e.data, e.size, "\t\t\t");
+                  _gnutls_buffer_hexdump (str, e.data, e.size, "\t\t\t");
 
                   gnutls_free (m.data);
                   gnutls_free (e.data);
@@ -1282,9 +1242,9 @@ print_cert (gnutls_buffer_st * str, gnutls_x509_crt_t 
cert, int notsigned)
                 {
                   addf (str, _("\t\tCurve:\t%s\n"), 
gnutls_ecc_curve_get_name(curve));
                   addf (str, _("\t\tX:\n"));
-                  hexdump (str, x.data, x.size, "\t\t\t");
+                  _gnutls_buffer_hexdump (str, x.data, x.size, "\t\t\t");
                   adds (str, _("\t\tY:\n"));
-                  hexdump (str, y.data, y.size, "\t\t\t");
+                  _gnutls_buffer_hexdump (str, y.data, y.size, "\t\t\t");
 
                   gnutls_free (x.data);
                   gnutls_free (y.data);
@@ -1303,13 +1263,13 @@ print_cert (gnutls_buffer_st * str, gnutls_x509_crt_t 
cert, int notsigned)
               else
                 {
                   addf (str, _("\t\tPublic key (bits %d):\n"), bits);
-                  hexdump (str, y.data, y.size, "\t\t\t");
+                  _gnutls_buffer_hexdump (str, y.data, y.size, "\t\t\t");
                   adds (str, _("\t\tP:\n"));
-                  hexdump (str, p.data, p.size, "\t\t\t");
+                  _gnutls_buffer_hexdump (str, p.data, p.size, "\t\t\t");
                   adds (str, _("\t\tQ:\n"));
-                  hexdump (str, q.data, q.size, "\t\t\t");
+                  _gnutls_buffer_hexdump (str, q.data, q.size, "\t\t\t");
                   adds (str, _("\t\tG:\n"));
-                  hexdump (str, g.data, g.size, "\t\t\t");
+                  _gnutls_buffer_hexdump (str, g.data, g.size, "\t\t\t");
 
                   gnutls_free (p.data);
                   gnutls_free (q.data);
@@ -1388,7 +1348,7 @@ print_cert (gnutls_buffer_st * str, gnutls_x509_crt_t 
cert, int notsigned)
         }
 
       adds (str, _("\tSignature:\n"));
-      hexdump (str, buffer, size, "\t\t");
+      _gnutls_buffer_hexdump (str, buffer, size, "\t\t");
 
       gnutls_free (buffer);
     }
@@ -1413,7 +1373,7 @@ print_fingerprint (gnutls_buffer_st * str, 
gnutls_x509_crt_t cert,
     adds (str, _("\tMD5 fingerprint:\n\t\t"));
   else
     adds (str, _("\tSHA-1 fingerprint:\n\t\t"));
-  hexprint (str, buffer, size);
+  _gnutls_buffer_hexprint (str, buffer, size);
   adds (str, "\n");
 }
 
@@ -1432,7 +1392,7 @@ print_keyid (gnutls_buffer_st * str, gnutls_x509_crt_t 
cert)
     }
 
   adds (str, _("\tPublic Key Id:\n\t\t"));
-  hexprint (str, buffer, size);
+  _gnutls_buffer_hexprint (str, buffer, size);
   adds (str, "\n");
 }
 
@@ -1604,7 +1564,7 @@ print_oneline (gnutls_buffer_st * str, gnutls_x509_crt_t 
cert)
     else
       {
         addf (str, "SHA-1 fingerprint `");
-        hexprint (str, buffer, size);
+        _gnutls_buffer_hexprint (str, buffer, size);
         adds (str, "'");
       }
   }
@@ -1804,7 +1764,7 @@ print_crl (gnutls_buffer_st * str, gnutls_x509_crl_t crl, 
int notsigned)
                 addf (str, "error: get_number: %s\n", gnutls_strerror (err));
               else
                 {
-                  hexprint (str, nr, nr_size);
+                  _gnutls_buffer_hexprint (str, nr, nr_size);
                   addf (str, "\n");
                 }
 
@@ -1868,7 +1828,7 @@ print_crl (gnutls_buffer_st * str, gnutls_x509_crl_t crl, 
int notsigned)
               adds (str, "\n");
 
               adds (str, _("\t\t\tHexdump: "));
-              hexprint (str, buffer, extlen);
+              _gnutls_buffer_hexprint (str, buffer, extlen);
               adds (str, "\n");
 
               gnutls_free (buffer);
@@ -1905,7 +1865,7 @@ print_crl (gnutls_buffer_st * str, gnutls_x509_crl_t crl, 
int notsigned)
             struct tm t;
 
             adds (str, _("\t\tSerial Number (hex): "));
-            hexprint (str, serial, serial_size);
+            _gnutls_buffer_hexprint (str, serial, serial_size);
             adds (str, "\n");
 
             if (gmtime_r (&tim, &t) == NULL)
@@ -1966,7 +1926,7 @@ print_crl (gnutls_buffer_st * str, gnutls_x509_crl_t crl, 
int notsigned)
         }
 
       adds (str, _("\tSignature:\n"));
-      hexdump (str, buffer, size, "\t\t");
+      _gnutls_buffer_hexdump (str, buffer, size, "\t\t");
 
       gnutls_free (buffer);
     }
@@ -2074,9 +2034,9 @@ print_crq (gnutls_buffer_st * str, gnutls_x509_crq_t cert)
               else
                 {
                   addf (str, _("\t\tModulus (bits %d):\n"), bits);
-                  hexdump (str, m.data, m.size, "\t\t\t");
+                  _gnutls_buffer_hexdump (str, m.data, m.size, "\t\t\t");
                   adds (str, _("\t\tExponent:\n"));
-                  hexdump (str, e.data, e.size, "\t\t\t");
+                  _gnutls_buffer_hexdump (str, e.data, e.size, "\t\t\t");
 
                   gnutls_free (m.data);
                   gnutls_free (e.data);
@@ -2096,13 +2056,13 @@ print_crq (gnutls_buffer_st * str, gnutls_x509_crq_t 
cert)
               else
                 {
                   addf (str, _("\t\tPublic key (bits %d):\n"), bits);
-                  hexdump (str, y.data, y.size, "\t\t\t");
+                  _gnutls_buffer_hexdump (str, y.data, y.size, "\t\t\t");
                   addf (str, _("\t\tP:\n"));
-                  hexdump (str, p.data, p.size, "\t\t\t");
+                  _gnutls_buffer_hexdump (str, p.data, p.size, "\t\t\t");
                   addf (str, _("\t\tQ:\n"));
-                  hexdump (str, q.data, q.size, "\t\t\t");
+                  _gnutls_buffer_hexdump (str, q.data, q.size, "\t\t\t");
                   addf (str, _("\t\tG:\n"));
-                  hexdump (str, g.data, g.size, "\t\t\t");
+                  _gnutls_buffer_hexdump (str, g.data, g.size, "\t\t\t");
 
                   gnutls_free (p.data);
                   gnutls_free (q.data);
@@ -2238,7 +2198,7 @@ print_crq (gnutls_buffer_st * str, gnutls_x509_crq_t cert)
             adds (str, "\n");
 
             adds (str, _("\t\t\tHexdump: "));
-            hexprint (str, buffer, extlen);
+            _gnutls_buffer_hexprint (str, buffer, extlen);
             adds (str, "\n");
 
             gnutls_free (buffer);
@@ -2278,7 +2238,7 @@ print_crq_other (gnutls_buffer_st * str, 
gnutls_x509_crq_t crq)
     }
 
   adds (str, _("\tPublic Key Id:\n\t\t"));
-  hexprint (str, buffer, size);
+  _gnutls_buffer_hexprint (str, buffer, size);
   adds (str, "\n");
 
   gnutls_free (buffer);


hooks/post-receive
-- 
GNU gnutls



reply via email to

[Prev in Thread] Current Thread [Next in Thread]