[git] GCRYPT - branch, master, updated. libgcrypt-1.5.0-275-gd2076f2

by Werner Koch cvs at cvs.gnupg.org
Mon Sep 30 10:51:08 CEST 2013


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 "The GNU crypto library".

The branch, master has been updated
       via  d2076f27bb7c5d505abf25fc622d21794c4a5df3 (commit)
      from  db60d828137c4f3682ca4ca2a54fe3d96d3db5f9 (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 d2076f27bb7c5d505abf25fc622d21794c4a5df3
Author: Werner Koch <wk at gnupg.org>
Date:   Mon Sep 30 10:18:25 2013 +0200

    Add logging functions to the API.
    
    * src/gcrypt.h.in (_GCRY_GCC_ATTR_PRINTF): New.
    (gcry_log_debug, gcry_log_debughex, gcry_log_debugmpi): New.
    (gcry_log_debugpnt, gcry_log_debugsxp): New.
    * src/visibility.c (gcry_log_debug): New.
    (gcry_log_debughex, gcry_log_debugmpi, gcry_log_debugpnt): New.
    (gcry_log_debugsxp): New.
    * src/libgcrypt.def, src/libgcrypt.vers: Add new functions.
    * src/misc.c (_gcry_logv): Make public.
    (_gcry_log_printsxp): New.
    * src/g10lib.h (log_printsxp): New macro.
    --
    
    For debugging applications it is often required to dump certain data
    structures.  Libgcrypt uses several internal functions for this.  To
    avoid re-implementing everything in the caller, we now provide access
    to some of those functions.
    
    Signed-off-by: Werner Koch <wk at gnupg.org>

diff --git a/NEWS b/NEWS
index 1e84cbe..c232a99 100644
--- a/NEWS
+++ b/NEWS
@@ -107,6 +107,10 @@ Noteworthy changes in version 1.6.0 (unreleased)
  GCRY_MD_STRIBOG512              NEW.
  GCRYCTL_DISABLE_ALGO            CHANGED: Not anymore thread-safe.
  GCRY_PK_ECC                     NEW.
+ gcry_log_debug                  NEW.
+ gcry_log_debughex               NEW.
+ gcry_log_debugmpi               NEW.
+ gcry_log_debugpnt               NEW.
 
 
 Noteworthy changes in version 1.5.0 (2011-06-29)
diff --git a/src/g10lib.h b/src/g10lib.h
index 73ba683..ff7f4b3 100644
--- a/src/g10lib.h
+++ b/src/g10lib.h
@@ -115,6 +115,8 @@ void _gcry_divide_by_zero (void) JNLIB_GCC_A_NR;
 
 const char *_gcry_gettext (const char *key) GCC_ATTR_FORMAT_ARG(1);
 void _gcry_fatal_error(int rc, const char *text ) JNLIB_GCC_A_NR;
+void _gcry_logv (int level,
+                 const char *fmt, va_list arg_ptr) JNLIB_GCC_A_PRINTF(2,0);
 void _gcry_log( int level, const char *fmt, ... ) JNLIB_GCC_A_PRINTF(2,3);
 void _gcry_log_bug( const char *fmt, ... )   JNLIB_GCC_A_NR_PRINTF(1,2);
 void _gcry_log_fatal( const char *fmt, ... ) JNLIB_GCC_A_NR_PRINTF(1,2);
@@ -126,6 +128,7 @@ void _gcry_log_debug( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2);
 void _gcry_log_printf ( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2);
 void _gcry_log_printhex (const char *text, const void *buffer, size_t length);
 void _gcry_log_printmpi (const char *text, gcry_mpi_t mpi);
+void _gcry_log_printsxp (const char *text, gcry_sexp_t sexp);
 
 void _gcry_set_log_verbosity( int level );
 int _gcry_log_verbosity( int level );
@@ -153,6 +156,7 @@ int _gcry_log_verbosity( int level );
 #define log_printf  _gcry_log_printf
 #define log_printhex _gcry_log_printhex
 #define log_printmpi _gcry_log_printmpi
+#define log_printsxp _gcry_log_printsxp
 
 /* Compatibility macro.  */
 #define log_mpidump _gcry_log_printmpi
diff --git a/src/gcrypt.h.in b/src/gcrypt.h.in
index 5f49edc..8fca52e 100644
--- a/src/gcrypt.h.in
+++ b/src/gcrypt.h.in
@@ -100,6 +100,8 @@ extern "C" {
 #define _GCRY_GCC_ATTR_MALLOC  __attribute__ ((__malloc__))
 #endif
 
+#define _GCRY_GCC_ATTR_PRINTF(f,a)  __attribute__ ((format (printf,f,a)))
+
 #endif /*__GNUC__*/
 
 #ifndef _GCRY_GCC_ATTR_DEPRECATED
@@ -111,6 +113,9 @@ extern "C" {
 #ifndef _GCRY_GCC_ATTR_MALLOC
 #define _GCRY_GCC_ATTR_MALLOC
 #endif
+#ifndef _GCRY_GCC_ATTR_PRINTF
+#define _GCRY_GCC_ATTR_PRINTF
+#endif
 
 /* Make up an attribute to mark functions and types as deprecated but
    allow internal use by Libgcrypt.  */
@@ -1405,6 +1410,15 @@ gcry_error_t gcry_prime_check (gcry_mpi_t x, unsigned int flags);
 /* Release the context object CTX.  */
 void gcry_ctx_release (gcry_ctx_t ctx);
 
+/* Log data using Libgcrypt's own log interface.  */
+void gcry_log_debug (const char *fmt, ...) _GCRY_GCC_ATTR_PRINTF(1,2);
+void gcry_log_debughex (const char *text, const void *buffer, size_t length);
+void gcry_log_debugmpi (const char *text, gcry_mpi_t mpi);
+void gcry_log_debugpnt (const char *text,
+                        gcry_mpi_point_t point, gcry_ctx_t ctx);
+void gcry_log_debugsxp (const char *text, gcry_sexp_t sexp);
+
+
 /* Log levels used by the internal logging facility. */
 enum gcry_log_levels
   {
diff --git a/src/libgcrypt.def b/src/libgcrypt.def
index 9fa4245..7efb3b9 100644
--- a/src/libgcrypt.def
+++ b/src/libgcrypt.def
@@ -247,5 +247,11 @@ EXPORTS
 
       gcry_md_hash_buffers      @219
 
+      gcry_log_debug            @220
+      gcry_log_debughex         @221
+      gcry_log_debugmpi         @222
+      gcry_log_debugpnt         @223
+      gcry_log_debugsxp         @224
+
 
 ;; end of file with public symbols for Windows.
diff --git a/src/libgcrypt.vers b/src/libgcrypt.vers
index 904ab41..b1669fd 100644
--- a/src/libgcrypt.vers
+++ b/src/libgcrypt.vers
@@ -101,6 +101,9 @@ GCRYPT_1.6 {
     gcry_mpi_ec_dup; gcry_mpi_ec_add; gcry_mpi_ec_mul;
     gcry_mpi_ec_curve_point;
 
+    gcry_log_debug;
+    gcry_log_debughex; gcry_log_debugmpi; gcry_log_debugpnt; gcry_log_debugsxp;
+
     _gcry_mpi_get_const;
 
     gcry_ctx_release;
diff --git a/src/misc.c b/src/misc.c
index a19e1e4..d9b85cb 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -115,7 +115,7 @@ _gcry_log_verbosity( int level )
  * This is our log function which prints all log messages to stderr or
  * using the function defined with gcry_set_log_handler().
  */
-static void
+void
 _gcry_logv( int level, const char *fmt, va_list arg_ptr )
 {
   if (log_handler)
@@ -361,6 +361,55 @@ _gcry_log_printmpi (const char *text, gcry_mpi_t mpi)
     }
 }
 
+/* Print SEXP in human readabale format.  With TEXT of NULL print just the raw
+   dump without any wrappping, with TEXT an empty string, print a
+   trailing linefeed, otherwise print the full debug output. */
+void
+_gcry_log_printsxp (const char *text, gcry_sexp_t sexp)
+{
+  int with_lf = 0;
+
+  if (text && *text)
+    {
+      if ((with_lf = strchr (text, '\n')))
+        log_debug ("%s", text);
+      else
+        log_debug ("%s: ", text);
+    }
+  if (sexp)
+    {
+      int any = 0;
+      char *buf, *p, *pend;
+      size_t size;
+
+      size = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_ADVANCED, NULL, 0);
+      p = buf = gcry_xmalloc (size);
+      gcry_sexp_sprint (sexp, GCRYSEXP_FMT_ADVANCED, buf, size);
+
+      do
+        {
+          if (any && !with_lf)
+            log_debug ("%*s  ", (int)strlen(text), "");
+          else
+            any = 1;
+          pend = strchr (p, '\n');
+          size = pend? (pend - p) : strlen (p);
+          if (with_lf)
+            log_debug ("%.*s\n", (int)size, p);
+          else
+            log_printf ("%.*s\n", (int)size, p);
+          if (pend)
+            p = pend + 1;
+          else
+            p += size;
+        }
+      while (*p);
+      gcry_free (buf);
+    }
+  if (text)
+    log_printf ("\n");
+}
+
 
 void
 _gcry_burn_stack (unsigned int bytes)
diff --git a/src/visibility.c b/src/visibility.c
index cfb159f..6e3c755 100644
--- a/src/visibility.c
+++ b/src/visibility.c
@@ -1209,6 +1209,42 @@ gcry_ctx_release (gcry_ctx_t ctx)
 }
 
 void
+gcry_log_debug (const char *fmt, ...)
+{
+  va_list arg_ptr ;
+
+  va_start( arg_ptr, fmt ) ;
+  _gcry_logv (GCRY_LOG_DEBUG, fmt, arg_ptr);
+  va_end (arg_ptr);
+}
+
+void
+gcry_log_debughex (const char *text, const void *buffer, size_t length)
+{
+  _gcry_log_printhex (text, buffer, length);
+}
+
+void
+gcry_log_debugmpi (const char *text, gcry_mpi_t mpi)
+{
+  _gcry_log_printmpi (text, mpi);
+}
+
+void
+gcry_log_debugpnt (const char *text, mpi_point_t point, gcry_ctx_t ctx)
+{
+  mpi_ec_t ec = ctx? _gcry_ctx_get_pointer (ctx, CONTEXT_TYPE_EC) : NULL;
+
+  _gcry_mpi_point_log (text, point, ec);
+}
+
+void
+gcry_log_debugsxp (const char *text, gcry_sexp_t sexp)
+{
+  _gcry_log_printsxp (text, sexp);
+}
+
+void
 gcry_set_progress_handler (gcry_handler_progress_t cb, void *cb_data)
 {
   _gcry_set_progress_handler (cb, cb_data);
diff --git a/src/visibility.h b/src/visibility.h
index 5e3556c..7e7793b 100644
--- a/src/visibility.h
+++ b/src/visibility.h
@@ -604,6 +604,12 @@ MARK_VISIBLE (gcry_mpi_test_bit)
 
 MARK_VISIBLE (gcry_ctx_release)
 
+MARK_VISIBLEX(gcry_log_debug)
+MARK_VISIBLEX(gcry_log_debughex)
+MARK_VISIBLEX(gcry_log_debugmpi)
+MARK_VISIBLEX(gcry_log_debugpnt)
+MARK_VISIBLEX(gcry_log_debugsxp)
+
 /* Functions used to implement macros.  */
 MARK_VISIBLEX(_gcry_mpi_get_const)
 

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

Summary of changes:
 NEWS               |    4 ++++
 src/g10lib.h       |    4 ++++
 src/gcrypt.h.in    |   14 ++++++++++++++
 src/libgcrypt.def  |    6 ++++++
 src/libgcrypt.vers |    3 +++
 src/misc.c         |   51 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/visibility.c   |   36 ++++++++++++++++++++++++++++++++++++
 src/visibility.h   |    6 ++++++
 8 files changed, 123 insertions(+), 1 deletions(-)


hooks/post-receive
-- 
The GNU crypto library
http://git.gnupg.org


_______________________________________________
Gnupg-commits mailing list
Gnupg-commits at gnupg.org
http://lists.gnupg.org/mailman/listinfo/gnupg-commits




More information about the Gcrypt-devel mailing list