[svn] ksba - r290 - in trunk: . src tests

svn author wk cvs at cvs.gnupg.org
Mon Feb 25 13:58:56 CET 2008


Author: wk
Date: 2008-02-25 13:58:55 +0100 (Mon, 25 Feb 2008)
New Revision: 290

Added:
   trunk/src/visibility.c
   trunk/src/visibility.h
Modified:
   trunk/ChangeLog
   trunk/NEWS
   trunk/configure.ac
   trunk/src/ChangeLog
   trunk/src/Makefile.am
   trunk/src/asn1-func.c
   trunk/src/asn1-func2.c
   trunk/src/ber-decoder.c
   trunk/src/ber-dump.c
   trunk/src/keyinfo.c
   trunk/src/keyinfo.h
   trunk/src/util.h
   trunk/tests/cert-basic.c
Log:
Make use of the ELF visibility attribute.


[The diff below has been truncated]

Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2008-02-25 10:00:09 UTC (rev 289)
+++ trunk/ChangeLog	2008-02-25 12:58:55 UTC (rev 290)
@@ -1,3 +1,8 @@
+2008-02-25  Werner Koch  <wk at g10code.com>
+
+	* configure.ac (KSBA_USE_VISIBILITY): Define if system supports
+	the visibility attribute.
+
 2008-02-12  Werner Koch  <wk at g10code.com>
 
 	Released 1.0.3.

Modified: trunk/src/ChangeLog
===================================================================
--- trunk/src/ChangeLog	2008-02-25 10:00:09 UTC (rev 289)
+++ trunk/src/ChangeLog	2008-02-25 12:58:55 UTC (rev 290)
@@ -1,5 +1,8 @@
 2008-02-25  Werner Koch  <wk at g10code.com>
 
+	* visibility.h, visibility.c: New.
+	* util.h: Include visibility.h.
+
 	* keyinfo.c (pk_algo_table, sig_algo_table, enc_algo_table): Make
 	const.
 	(cryptval_to_sexp): Adjust for it.

Modified: trunk/NEWS
===================================================================
--- trunk/NEWS	2008-02-25 10:00:09 UTC (rev 289)
+++ trunk/NEWS	2008-02-25 12:58:55 UTC (rev 290)
@@ -5,7 +5,9 @@
 
  * Support DSA.
 
+ * The visibility attribute is now used if supported by the toolchain.
 
+
 Noteworthy changes in version 1.0.3 (2008-02-12)
 ------------------------------------------------
 

Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac	2008-02-25 10:00:09 UTC (rev 289)
+++ trunk/configure.ac	2008-02-25 12:58:55 UTC (rev 290)
@@ -168,8 +168,93 @@
 AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
 
 
+#            
+# Check for ELF visibility support.
+#
+AC_CACHE_CHECK(whether the visibility attribute is supported,
+       ksba_cv_visibility_attribute,
+       [ksba_cv_visibility_attribute=no
+        AC_LANG_CONFTEST([AC_LANG_SOURCE(
+          [[int foo __attribute__ ((visibility ("hidden"))) = 1;
+            int bar __attribute__ ((visibility ("protected"))) = 1;
+          ]])])
+        
+        if ${CC-cc} -Werror -S conftest.c -o conftest.s \
+                  1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
+            if grep '\.hidden.*foo' conftest.s >/dev/null 2>&1 ; then
+                if grep '\.protected.*bar' conftest.s >/dev/null 2>&1; then
+                    ksba_cv_visibility_attribute=yes
+                fi
+            fi  
+        fi  
+       ])
+if test "$ksba_cv_visibility_attribute" = "yes"; then
+    AC_CACHE_CHECK(for broken visibility attribute,
+       ksba_cv_broken_visibility_attribute,
+       [ksba_cv_broken_visibility_attribute=yes
+        AC_LANG_CONFTEST([AC_LANG_SOURCE(
+          [[int foo (int x);
+            int bar (int x) __asm__ ("foo")
+                            __attribute__ ((visibility ("hidden")));
+            int bar (int x) { return x; }
+          ]])])
+                  
+        if ${CC-cc} -Werror -S conftest.c -o conftest.s \
+                  1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
+           if grep '\.hidden@<:@ 	_@:>@foo' conftest.s >/dev/null 2>&1;
+            then
+               ksba_cv_broken_visibility_attribute=no
+           fi
+        fi
+       ])
+fi
+if test "$ksba_cv_visibility_attribute" = "yes"; then
+    AC_CACHE_CHECK(for broken alias attribute,
+       ksba_cv_broken_alias_attribute,
+       [ksba_cv_broken_alias_attribute=yes
+        AC_LANG_CONFTEST([AC_LANG_SOURCE(
+          [[extern int foo (int x) __asm ("xyzzy");
+            int bar (int x) { return x; }
+            extern __typeof (bar) foo __attribute ((weak, alias ("bar")));
+            extern int dfoo;
+            extern __typeof (dfoo) dfoo __asm ("abccb");
+            int dfoo = 1;
+          ]])])
+
+        if ${CC-cc} -Werror -S conftest.c -o conftest.s \
+                  1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
+           if grep 'xyzzy' conftest.s >/dev/null 2>&1 && \
+              grep 'abccb' conftest.s >/dev/null 2>&1; then
+              ksba_cv_broken_alias_attribute=no
+           fi
+        fi
+        ])
+fi
+if test "$ksba_cv_visibility_attribute" = "yes"; then
+    AC_CACHE_CHECK(if gcc supports -fvisibility=hidden,
+       ksba_cv_gcc_has_f_visibility,
+       [ksba_cv_gcc_has_f_visibility=no
+        _gcc_cflags_save=$CFLAGS
+        CFLAGS="-fvisibility=hidden"
+        AC_COMPILE_IFELSE(AC_LANG_PROGRAM([]),
+                          ksba_cv_gcc_has_f_visibility=yes)
+        CFLAGS=$_gcc_cflags_save;
+       ])
+fi
+if test "$ksba_cv_visibility_attribute" = "yes" \
+   && test "$ksba_cv_broken_visibility_attribute" != "yes" \
+   && test "$ksba_cv_broken_alias_attribute" != "yes" \
+   && test "$ksba_cv_gcc_has_f_visibility" = "yes"  
+ then
+   AC_DEFINE(KSBA_USE_VISIBILITY, 1,
+               [Define to use the GNU C visibility attribute.])
+   CFLAGS="$CFLAGS -fvisibility=hidden"
+fi
+
+
+#
 # Checks for libraries.
-
+#
 AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION")
 if test "x$GPG_ERROR_LIBS" = "x"; then
   AC_MSG_ERROR([libgpg-error is needed.

Modified: trunk/src/Makefile.am
===================================================================
--- trunk/src/Makefile.am	2008-02-25 10:00:09 UTC (rev 289)
+++ trunk/src/Makefile.am	2008-02-25 12:58:55 UTC (rev 290)
@@ -86,6 +86,7 @@
 
 libksba_la_SOURCES = \
 	ksba.h \
+        visibility.c visibility.h \
 	reader.c reader.h \
 	writer.c writer.h \
 	asn1-parse.y asn1-parse.h \

Modified: trunk/src/asn1-func.c
===================================================================
--- trunk/src/asn1-func.c	2008-02-25 10:00:09 UTC (rev 289)
+++ trunk/src/asn1-func.c	2008-02-25 12:58:55 UTC (rev 290)
@@ -27,9 +27,9 @@
 
 #include <alloca.h>
 
+#include "util.h"
 #include "ksba.h"
 #include "asn1-func.h"
-#include "util.h"
 
 
 static AsnNode

Modified: trunk/src/asn1-func2.c
===================================================================
--- trunk/src/asn1-func2.c	2008-02-25 10:00:09 UTC (rev 289)
+++ trunk/src/asn1-func2.c	2008-02-25 12:58:55 UTC (rev 290)
@@ -1,6 +1,7 @@
 /* asn1-func2.c - More ASN.1 definitions
  *      Copyright (C) 2000, 2001 Fabio Fiorina
- *      Copyright (C) 2001, 2008 Free Software Foundation, Inc.
+ *      Copyright (C) 2001 Free Software Foundation, Inc.
+ *      Copyright (C) 2008 g10 Code GmbH
  *
  * This file is part of GNUTLS.
  *
@@ -31,9 +32,9 @@
 #include <ctype.h>
 #include <assert.h>
 
+#include "util.h"
 #include "ksba.h"
 #include "asn1-func.h"
-#include "util.h"
 
 
 static AsnNode 

Modified: trunk/src/ber-decoder.c
===================================================================
--- trunk/src/ber-decoder.c	2008-02-25 10:00:09 UTC (rev 289)
+++ trunk/src/ber-decoder.c	2008-02-25 12:58:55 UTC (rev 290)
@@ -24,6 +24,7 @@
 #include <assert.h>
 #include "util.h"
 
+#include "util.h"
 #include "ksba.h"
 #include "asn1-func.h"
 #include "ber-decoder.h"

Modified: trunk/src/ber-dump.c
===================================================================
--- trunk/src/ber-dump.c	2008-02-25 10:00:09 UTC (rev 289)
+++ trunk/src/ber-dump.c	2008-02-25 12:58:55 UTC (rev 290)
@@ -24,6 +24,7 @@
 #include <errno.h>
 #include <stdarg.h>
 
+#include "visibility.h"
 #include "ksba.h"
 #include "ber-decoder.h"
 

Modified: trunk/src/keyinfo.c
===================================================================
--- trunk/src/keyinfo.c	2008-02-25 10:00:09 UTC (rev 289)
+++ trunk/src/keyinfo.c	2008-02-25 12:58:55 UTC (rev 290)
@@ -27,7 +27,6 @@
 #include <string.h>
 #include <assert.h>
 
-#include "ksba.h"
 #include "util.h"
 #include "asn1-func.h"
 #include "keyinfo.h"

Modified: trunk/src/keyinfo.h
===================================================================
--- trunk/src/keyinfo.h	2008-02-25 10:00:09 UTC (rev 289)
+++ trunk/src/keyinfo.h	2008-02-25 12:58:55 UTC (rev 290)
@@ -35,10 +35,12 @@
 
 
 gpg_error_t _ksba_keyinfo_to_sexp (const unsigned char *der, size_t derlen,
-                                 ksba_sexp_t *r_string);
+                                   ksba_sexp_t *r_string)
+     _KSBA_VISIBILITY_DEFAULT;
 
 gpg_error_t _ksba_keyinfo_from_sexp (ksba_const_sexp_t sexp,
-                                   unsigned char **r_der, size_t *r_derlen);
+                                     unsigned char **r_der, size_t *r_derlen)
+     _KSBA_VISIBILITY_DEFAULT;
 
 gpg_error_t _ksba_sigval_to_sexp (const unsigned char *der, size_t derlen,
                                 ksba_sexp_t *r_string);

Modified: trunk/src/util.h
===================================================================
--- trunk/src/util.h	2008-02-25 10:00:09 UTC (rev 289)
+++ trunk/src/util.h	2008-02-25 12:58:55 UTC (rev 290)
@@ -20,8 +20,9 @@
 #ifndef UTIL_H
 #define UTIL_H
 
-#include "ksba.h"  /* ksba_malloc() etc. */
+#include "visibility.h"
 
+
 gpg_error_t _ksba_hash_buffer (const char *oid,
                                const void *buffer, size_t length,
                                size_t resultsize,

Added: trunk/src/visibility.c
===================================================================
--- trunk/src/visibility.c	2008-02-25 10:00:09 UTC (rev 289)
+++ trunk/src/visibility.c	2008-02-25 12:58:55 UTC (rev 290)
@@ -0,0 +1,1193 @@
+/* visibility.c - Wrapper for all public functions
+ *      Copyright (C) 2008 g10 Code GmbH
+ *
+ * This file is part of KSBA.
+ *
+ * KSBA is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * KSBA is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+#include <stdarg.h>
+
+#define _KSBA_INCLUDED_BY_VISIBILITY_C 
+#include "util.h"
+
+/*--version.c --*/
+const char *
+ksba_check_version (const char *req_version)
+{
+  return _ksba_check_version (req_version);
+}
+
+
+/*-- util.c --*/
+void 
+ksba_set_malloc_hooks ( void *(*new_alloc_func)(size_t n),
+                        void *(*new_realloc_func)(void *p, size_t n),
+                        void (*new_free_func)(void*) )
+{
+  _ksba_set_malloc_hooks (new_alloc_func, new_realloc_func, new_free_func);
+}
+
+
+void 
+ksba_set_hash_buffer_function ( gpg_error_t (*fnc)
+                                (void *arg, const char *oid,
+                                 const void *buffer, size_t length,
+                                 size_t resultsize,
+                                 unsigned char *result,
+                                 size_t *resultlen),
+                                void *fnc_arg)
+{
+  _ksba_set_hash_buffer_function (fnc, fnc_arg);
+}
+
+void *
+ksba_malloc (size_t n )
+{
+  return _ksba_malloc (n);
+}
+
+void *
+ksba_calloc (size_t n, size_t m )
+{
+  return _ksba_calloc (n, m);
+}
+
+void *
+ksba_realloc (void *p, size_t n)
+{
+  return _ksba_realloc (p, n);
+}
+
+char *
+ksba_strdup (const char *p)
+{
+  return _ksba_strdup (p);
+}
+
+void
+ksba_free ( void *a )
+{
+  if (a)
+    _ksba_free (a);
+}
+
+
+/*-- cert.c --*/
+gpg_error_t 
+ksba_cert_new (ksba_cert_t *acert)
+{
+  return _ksba_cert_new (acert);
+}
+
+
+void
+ksba_cert_ref (ksba_cert_t cert)
+{
+  _ksba_cert_ref (cert);
+}
+
+
+void
+ksba_cert_release (ksba_cert_t cert)
+{
+  _ksba_cert_release (cert);
+}
+
+
+gpg_error_t
+ksba_cert_set_user_data (ksba_cert_t cert, const char *key,
+                         const void *data, size_t datalen)
+{
+  return _ksba_cert_set_user_data (cert, key, data, datalen);
+}
+
+
+gpg_error_t
+ksba_cert_get_user_data (ksba_cert_t cert, const char *key,
+                         void *buffer, size_t bufferlen,
+                         size_t *datalen)
+{
+  return _ksba_cert_get_user_data (cert, key, buffer, bufferlen, datalen);
+}
+
+
+
+gpg_error_t
+ksba_cert_read_der (ksba_cert_t cert, ksba_reader_t reader)
+{
+  return _ksba_cert_read_der (cert, reader);
+}
+
+
+gpg_error_t
+ksba_cert_init_from_mem (ksba_cert_t cert,
+                         const void *buffer, size_t length)
+{
+  return _ksba_cert_init_from_mem (cert, buffer, length);
+}
+
+
+const unsigned char *
+ksba_cert_get_image (ksba_cert_t cert, size_t *r_length)
+{
+  return _ksba_cert_get_image (cert, r_length);
+}
+
+
+gpg_error_t
+ksba_cert_hash (ksba_cert_t cert,
+                int what,
+                void (*hasher)(void *,
+                               const void *,
+                               size_t length), 
+                void *hasher_arg)
+{
+  return _ksba_cert_hash (cert, what, hasher, hasher_arg);
+}
+
+
+const char *
+ksba_cert_get_digest_algo (ksba_cert_t cert)
+{
+  return _ksba_cert_get_digest_algo (cert);
+}
+
+
+ksba_sexp_t
+ksba_cert_get_serial (ksba_cert_t cert)
+{
+  return _ksba_cert_get_serial (cert);
+}
+
+
+char *
+ksba_cert_get_issuer (ksba_cert_t cert, int idx)
+{
+  return _ksba_cert_get_issuer (cert, idx);
+}
+
+
+gpg_error_t 
+ksba_cert_get_validity (ksba_cert_t cert, int what,
+                        ksba_isotime_t r_time)
+{
+  return _ksba_cert_get_validity (cert, what, r_time);
+}
+
+
+char *
+ksba_cert_get_subject (ksba_cert_t cert, int idx)
+{
+  return _ksba_cert_get_subject (cert, idx);
+}
+
+
+ksba_sexp_t 
+ksba_cert_get_public_key (ksba_cert_t cert)
+{
+  return _ksba_cert_get_public_key (cert);
+}
+
+
+ksba_sexp_t
+ksba_cert_get_sig_val (ksba_cert_t cert)
+{
+  return _ksba_cert_get_sig_val (cert);
+}
+
+
+
+gpg_error_t 
+ksba_cert_get_extension (ksba_cert_t cert, int idx,
+                         char const **r_oid, int *r_crit,
+                         size_t *r_deroff, size_t *r_derlen)
+{
+  return _ksba_cert_get_extension (cert, idx, r_oid, r_crit, 
+                                   r_deroff, r_derlen);
+}
+
+
+
+gpg_error_t
+ksba_cert_is_ca (ksba_cert_t cert, int *r_ca, int *r_pathlen)
+{
+  return _ksba_cert_is_ca (cert, r_ca, r_pathlen);
+}
+
+
+gpg_error_t
+ksba_cert_get_key_usage (ksba_cert_t cert, unsigned int *r_flags)
+{
+  return _ksba_cert_get_key_usage (cert, r_flags);
+}
+
+
+gpg_error_t
+ksba_cert_get_cert_policies (ksba_cert_t cert, char **r_policies)
+{
+  return _ksba_cert_get_cert_policies (cert, r_policies);
+}
+
+
+gpg_error_t
+ksba_cert_get_ext_key_usages (ksba_cert_t cert, char **result)
+{
+  return _ksba_cert_get_ext_key_usages (cert, result);
+}
+
+




More information about the Gnupg-commits mailing list