Imported Upstream version 1.3.2 upstream/1.3.2
authorDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 23 Dec 2021 01:55:44 +0000 (10:55 +0900)
committerDongHun Kwak <dh0128.kwak@samsung.com>
Thu, 23 Dec 2021 01:55:44 +0000 (10:55 +0900)
22 files changed:
ChangeLog
Makefile.am
Makefile.in
NEWS
VERSION [deleted file]
autogen.sh
configure
configure.ac
doc/Makefile.in
doc/ksba.info
doc/stamp-vti
doc/version.texi
gl/Makefile.in
m4/Makefile.in
m4/gpg-error.m4
m4/libgcrypt.m4
src/Makefile.in
src/oid.c
tests/Makefile.am
tests/Makefile.in
tests/t-dnparser.c
tests/t-oid.c

index 33a97f3..6acaede 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2014-11-25  Werner Koch  <wk@gnupg.org>
+
+       Release 1.3.2.
+       * configure.ac: Set LT version to C19/A11/R3.
+
+       build: Update version number magic.
+       * autogen.sh: Update from gnupg master.
+       * configure.ac: Change for new init style.  Create VERSION.
+       * Makefile.am (dist-hook): Do no create VERSION
+
+       Fix buffer overflow in ksba_oid_to_str.
+       * src/oid.c (ksba_oid_to_str): Fix unsigned underflow.
+
+       * tests/Makefile.am (noinst_PROGRAMS): Move t-oid to ..
+       (TESTS): here.
+       * tests/t-oid.c (test_oid_to_str): New.
+       (main): Run the new tests by default.  The former functionality
+       requires the use of one of the new options.
+
+2014-09-25  Werner Koch  <wk@gnupg.org>
+
+       Strip CRs while building the oid translation table.
+       * tests/Makefile.am (oidtranstbl.h): Strip CRs
+
 2014-09-18  Werner Koch  <wk@gnupg.org>
 
        Release 1.3.1.
index c797e4f..1dc647d 100644 (file)
@@ -41,7 +41,6 @@ endif
 SUBDIRS = m4 gl src ${tests} doc
 
 dist-hook: gen-ChangeLog
-       @set -e; echo "$(VERSION)" > $(distdir)/VERSION
 
 
 gen_start_date = 2011-12-01T00:00:00
index 47618f9..2b4276f 100644 (file)
@@ -197,6 +197,8 @@ FGREP = @FGREP@
 GPG_ERROR_CFLAGS = @GPG_ERROR_CFLAGS@
 GPG_ERROR_CONFIG = @GPG_ERROR_CONFIG@
 GPG_ERROR_LIBS = @GPG_ERROR_LIBS@
+GPG_ERROR_MT_CFLAGS = @GPG_ERROR_MT_CFLAGS@
+GPG_ERROR_MT_LIBS = @GPG_ERROR_MT_LIBS@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -828,7 +830,6 @@ uninstall-am:
 
 
 dist-hook: gen-ChangeLog
-       @set -e; echo "$(VERSION)" > $(distdir)/VERSION
 .PHONY: gen-ChangeLog
 gen-ChangeLog:
        if test -d $(top_srcdir)/.git; then                             \
diff --git a/NEWS b/NEWS
index 4da0134..fad8554 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,9 @@
+Noteworthy changes in version 1.3.2 (2014-11-25) [C19/A11/R3]
+------------------------------------------------
+
+ * Fixed a buffer overflow in ksba_oid_to_str.
+
+
 Noteworthy changes in version 1.3.1 (2014-09-18)
 ------------------------------------------------
 
diff --git a/VERSION b/VERSION
deleted file mode 100644 (file)
index 3a3cd8c..0000000
--- a/VERSION
+++ /dev/null
@@ -1 +0,0 @@
-1.3.1
index ea3d5fc..7effd56 100755 (executable)
@@ -15,7 +15,7 @@
 # configure it for the respective package.  It is maintained as part of
 # GnuPG and source copied by other packages.
 #
-# Version: 2014-01-10
+# Version: 2014-06-06
 
 configure_ac="configure.ac"
 
@@ -41,7 +41,7 @@ fatal () {
 
 info () {
     if [ -z "${SILENT}" ]; then
-      echo "autogen.sh:" "$*"
+      echo "autogen.sh:" "$*" >&2
     fi
 }
 
@@ -70,8 +70,11 @@ MSGMERGE=${GETTEXT_PREFIX}${MSGMERGE:-msgmerge}${GETTEXT_SUFFIX}
 DIE=no
 FORCE=
 SILENT=
+PRINT_HOST=no
+PRINT_BUILD=no
 tmp=$(dirname "$0")
 tsdir=$(cd "${tmp}"; pwd)
+version_parts=3
 
 if [ -n "${AUTOGEN_SH_SILENT}" ]; then
   SILENT=" --silent"
@@ -88,6 +91,14 @@ if test x"$1" = x"--force"; then
   FORCE=" --force"
   shift
 fi
+if test x"$1" = x"--print-host"; then
+  PRINT_HOST=yes
+  shift
+fi
+if test x"$1" = x"--print-build"; then
+  PRINT_BUILD=yes
+  shift
+fi
 
 
 # Reject unsafe characters in $HOME, $tsdir and cwd.  We consider spaces
@@ -133,6 +144,11 @@ amd64_toolprefixes=
 myhost=""
 myhostsub=""
 case "$1" in
+    --find-version)
+        myhost="find-version"
+        SILENT=" --silent"
+        shift
+        ;;
     --build-w32)
         myhost="w32"
         shift
@@ -172,16 +188,74 @@ if [ -f "$HOME/.gnupg-autogen.rc" ]; then
     . "$HOME/.gnupg-autogen.rc"
 fi
 
+
+# **** FIND VERSION ****
+# This is a helper for the configure.ac M4 magic
+# Called
+#   ./autogen.sh --find-version PACKAGE MAJOR MINOR [MICRO]
+# returns a complete version string with automatic beta numbering.
+if [ "$myhost" = "find-version" ]; then
+    package="$1"
+    major="$2"
+    minor="$3"
+    micro="$4"
+
+    case "$version_parts" in
+      2)
+        matchstr1="$package-$major.[0-9]*"
+        matchstr2="$package-$major-base"
+        vers="$major.$minor"
+        ;;
+      *)
+        matchstr1="$package-$major.$minor.[0-9]*"
+        matchstr2="$package-$major.$minor-base"
+        vers="$major.$minor.$micro"
+        ;;
+    esac
+
+    beta=no
+    if [ -d .git ]; then
+      ingit=yes
+      tmp=$(git describe --match "${matchstr1}" --long 2>/dev/null)
+      if [ -n "$tmp" ]; then
+          tmp=$(echo "$tmp"|awk -F- '$3!=0 && $3 !~ /^beta/ {print"-beta"$3}')
+      else
+          tmp=$(git describe --match "${matchstr2}" --long 2>/dev/null \
+                | awk -F- '$4!=0{print"-beta"$4}')
+      fi
+      [ -n "$tmp" ] && beta=yes
+      rev=$(git rev-parse --short HEAD | tr -d '\n\r')
+      rvd=$((0x$(echo ${rev} | head -c 4)))
+    else
+      ingit=no
+      beta=yes
+      tmp="-unknown"
+      rev="0000000"
+      rvd="0"
+    fi
+
+    echo "$package-$vers$tmp:$beta:$ingit:$vers$tmp:$vers:$tmp:$rev:$rvd:"
+    exit 0
+fi
+# **** end FIND VERSION ****
+
+
+if [ ! -f "$tsdir/build-aux/config.guess" ]; then
+    fatal "$tsdir/build-aux/config.guess not found"
+    exit 1
+fi
+build=`$tsdir/build-aux/config.guess`
+if [ $PRINT_BUILD = yes ]; then
+    echo "$build"
+    exit 0
+fi
+
+
+
 # ******************
 #  W32 build script
 # ******************
 if [ "$myhost" = "w32" ]; then
-    if [ ! -f "$tsdir/build-aux/config.guess" ]; then
-        fatal "$tsdir/build-aux/config.guess not found"
-        exit 1
-    fi
-    build=`$tsdir/build-aux/config.guess`
-
     case $myhostsub in
         ce)
           w32root="$w32ce_root"
@@ -189,6 +263,12 @@ if [ "$myhost" = "w32" ]; then
           toolprefixes="$w32ce_toolprefixes arm-mingw32ce"
           extraoptions="$extraoptions $w32ce_extraoptions"
           ;;
+        64)
+          w32root="$w64root"
+          [ -z "$w32root" ] && w32root="$HOME/w64root"
+          toolprefixes="$w64_toolprefixes x86_64-w64-mingw32"
+          extraoptions="$extraoptions $w64_extraoptions"
+          ;;
         *)
           [ -z "$w32root" ] && w32root="$HOME/w32root"
           toolprefixes="$w32_toolprefixes i686-w64-mingw32 i586-mingw32msvc"
@@ -216,6 +296,10 @@ if [ "$myhost" = "w32" ]; then
         fi
         die_p
     fi
+    if [ $PRINT_HOST = yes ]; then
+        echo "$host"
+        exit 0
+    fi
 
     if [ -f "$tsdir/config.log" ]; then
         if ! head $tsdir/config.log | grep "$host" >/dev/null; then
@@ -226,7 +310,7 @@ if [ "$myhost" = "w32" ]; then
 
     $tsdir/configure --enable-maintainer-mode ${SILENT} \
              --prefix=${w32root}  \
-             --host=${host} --build=${build} \
+             --host=${host} --build=${build} SYSROOT=${w32root} \
              ${configure_opts} ${extraoptions} "$@"
     rc=$?
     exit $rc
@@ -236,13 +320,6 @@ fi
 # ***** AMD64 cross build script *******
 # Used to cross-compile for AMD64 (for testing)
 if [ "$myhost" = "amd64" ]; then
-    shift
-    if [ ! -f $tsdir/build-aux/config.guess ]; then
-        echo "$tsdir/build-aux/config.guess not found" >&2
-        exit 1
-    fi
-    build=`$tsdir/build-aux/config.guess`
-
     [ -z "$amd64root" ] && amd64root="$HOME/amd64root"
     info "Using $amd64root as standard install directory"
     replace_sysroot
@@ -263,6 +340,10 @@ if [ "$myhost" = "amd64" ]; then
         echo "Stop." >&2
         exit 1
     fi
+    if [ $PRINT_HOST = yes ]; then
+        echo "$host"
+        exit 0
+    fi
 
     if [ -f "$tsdir/config.log" ]; then
         if ! head $tsdir/config.log | grep "$host" >/dev/null; then
index b7e7dfc..70f1dea 100755 (executable)
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for libksba 1.3.1.
+# Generated by GNU Autoconf 2.69 for libksba 1.3.2.
 #
 # Report bugs to <http://bugs.gnupg.org>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='libksba'
 PACKAGE_TARNAME='libksba'
-PACKAGE_VERSION='1.3.1'
-PACKAGE_STRING='libksba 1.3.1'
+PACKAGE_VERSION='1.3.2'
+PACKAGE_STRING='libksba 1.3.2'
 PACKAGE_BUGREPORT='http://bugs.gnupg.org'
 PACKAGE_URL=''
 
@@ -649,6 +649,8 @@ VALGRIND
 ALLOCA_H
 ALLOCA
 LTALLOCA
+GPG_ERROR_MT_LIBS
+GPG_ERROR_MT_CFLAGS
 GPG_ERROR_LIBS
 GPG_ERROR_CFLAGS
 GPG_ERROR_CONFIG
@@ -1352,7 +1354,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures libksba 1.3.1 to adapt to many kinds of systems.
+\`configure' configures libksba 1.3.2 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1422,7 +1424,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of libksba 1.3.1:";;
+     short | recursive ) echo "Configuration of libksba 1.3.2:";;
    esac
   cat <<\_ACEOF
 
@@ -1543,7 +1545,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-libksba configure 1.3.1
+libksba configure 1.3.2
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2149,7 +2151,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by libksba $as_me 1.3.1, which was
+It was created by libksba $as_me 1.3.2, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2505,7 +2507,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 # Please remember to document interface changes in the NEWS file.
 LIBKSBA_LT_CURRENT=19
 LIBKSBA_LT_AGE=11
-LIBKSBA_LT_REVISION=2
+LIBKSBA_LT_REVISION=3
 #-------------------
 # If the API is changed in an incompatible way: increment the next counter.
 KSBA_CONFIG_API_VERSION=1
 # Checks for libraries.
 #
 
+  gpg_error_config_prefix=""
 
 # Check whether --with-libgpg-error-prefix was given.
 if test "${with_libgpg_error_prefix+set}" = set; then :
   withval=$with_libgpg_error_prefix; gpg_error_config_prefix="$withval"
-else
-  gpg_error_config_prefix=""
 fi
 
 
 # Check whether --with-gpg-error-prefix was given.
 if test "${with_gpg_error_prefix+set}" = set; then :
   withval=$with_gpg_error_prefix; gpg_error_config_prefix="$withval"
-else
-  gpg_error_config_prefix=""
 fi
 
 
-  if test x$gpg_error_config_prefix != x ; then
-     if test x${GPG_ERROR_CONFIG+set} != xset ; then
-        GPG_ERROR_CONFIG=$gpg_error_config_prefix/bin/gpg-error-config
+  if test x"${GPG_ERROR_CONFIG}" = x ; then
+     if test x"${gpg_error_config_prefix}" != x ; then
+        GPG_ERROR_CONFIG="${gpg_error_config_prefix}/bin/gpg-error-config"
+     else
+       case "${SYSROOT}" in
+         /*)
+           if test -x "${SYSROOT}/bin/gpg-error-config" ; then
+             GPG_ERROR_CONFIG="${SYSROOT}/bin/gpg-error-config"
+           fi
+           ;;
+         '')
+           ;;
+          *)
+           { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring \$SYSROOT as it is not an absolute path." >&5
+$as_echo "$as_me: WARNING: Ignoring \$SYSROOT as it is not an absolute path." >&2;}
+           ;;
+       esac
      fi
   fi
 
-  if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}gpg-error-config", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gpg-error-config; ac_word=$2
+  # Extract the first word of "gpg-error-config", so it can be a program name with args.
+set dummy gpg-error-config; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
 if ${ac_cv_path_GPG_ERROR_CONFIG+:} false; then :
@@ -13801,6 +13813,7 @@ done
   done
 IFS=$as_save_IFS
 
+  test -z "$ac_cv_path_GPG_ERROR_CONFIG" && ac_cv_path_GPG_ERROR_CONFIG="no"
   ;;
 esac
 fi
@@ -13814,68 +13827,12 @@ $as_echo "no" >&6; }
 fi
 
 
-fi
-if test -z "$ac_cv_path_GPG_ERROR_CONFIG"; then
-  ac_pt_GPG_ERROR_CONFIG=$GPG_ERROR_CONFIG
-  # Extract the first word of "gpg-error-config", so it can be a program name with args.
-set dummy gpg-error-config; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_ac_pt_GPG_ERROR_CONFIG+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $ac_pt_GPG_ERROR_CONFIG in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_ac_pt_GPG_ERROR_CONFIG="$ac_pt_GPG_ERROR_CONFIG" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_ac_pt_GPG_ERROR_CONFIG="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  ;;
-esac
-fi
-ac_pt_GPG_ERROR_CONFIG=$ac_cv_path_ac_pt_GPG_ERROR_CONFIG
-if test -n "$ac_pt_GPG_ERROR_CONFIG"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_GPG_ERROR_CONFIG" >&5
-$as_echo "$ac_pt_GPG_ERROR_CONFIG" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_pt_GPG_ERROR_CONFIG" = x; then
-    GPG_ERROR_CONFIG="no"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    GPG_ERROR_CONFIG=$ac_pt_GPG_ERROR_CONFIG
-  fi
-else
-  GPG_ERROR_CONFIG="$ac_cv_path_GPG_ERROR_CONFIG"
-fi
-
   min_gpg_error_version="$NEED_GPG_ERROR_VERSION"
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GPG Error - version >= $min_gpg_error_version" >&5
 $as_echo_n "checking for GPG Error - version >= $min_gpg_error_version... " >&6; }
   ok=no
-  if test "$GPG_ERROR_CONFIG" != "no" ; then
+  if test "$GPG_ERROR_CONFIG" != "no" \
+     && test -f "$GPG_ERROR_CONFIG" ; then
     req_major=`echo $min_gpg_error_version | \
                sed 's/\([0-9]*\)\.\([0-9]*\)/\1/'`
     req_minor=`echo $min_gpg_error_version | \
@@ -13898,6 +13855,8 @@ $as_echo_n "checking for GPG Error - version >= $min_gpg_error_version... " >&6;
   if test $ok = yes; then
     GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags`
     GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs`
+    GPG_ERROR_MT_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --mt --cflags 2>/dev/null`
+    GPG_ERROR_MT_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --mt --libs 2>/dev/null`
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes ($gpg_error_config_version)" >&5
 $as_echo "yes ($gpg_error_config_version)" >&6; }
     :
@@ -13910,7 +13869,7 @@ $as_echo "yes ($gpg_error_config_version)" >&6; }
 *** built for $gpg_error_config_host and thus may not match the
 *** used host $host.
 *** You may want to use the configure option --with-gpg-error-prefix
-*** to specify a matching config script.
+*** to specify a matching config script or use \$SYSROOT.
 ***" >&5
 $as_echo "$as_me: WARNING:
 ***
@@ -13918,13 +13877,16 @@ $as_echo "$as_me: WARNING:
 *** built for $gpg_error_config_host and thus may not match the
 *** used host $host.
 *** You may want to use the configure option --with-gpg-error-prefix
-*** to specify a matching config script.
+*** to specify a matching config script or use \$SYSROOT.
 ***" >&2;}
+        gpg_config_script_warn="$gpg_config_script_warn libgpg-error"
       fi
     fi
   else
     GPG_ERROR_CFLAGS=""
     GPG_ERROR_LIBS=""
+    GPG_ERROR_MT_CFLAGS=""
+    GPG_ERROR_MT_LIBS=""
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
     :
@@ -13932,6 +13894,8 @@ $as_echo "no" >&6; }
 
 
 
+
+
 if test "x$GPG_ERROR_LIBS" = "x"; then
   as_fn_error $? "libgpg-error is needed.
                 See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ ." "$LINENO" 5
 if test "$have_w32_system" = yes; then
    BUILD_TIMESTAMP=`date --iso-8601=minutes`
       BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'`
-      BUILD_FILEVERSION="${BUILD_FILEVERSION}17527"
+      BUILD_FILEVERSION="${BUILD_FILEVERSION}519"
 fi
 
 
 
-BUILD_REVISION="447784c"
+BUILD_REVISION="02079b5"
 
 
 cat >>confdefs.h <<_ACEOF
@@ -15399,7 +15363,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by libksba $as_me 1.3.1, which was
+This file was extended by libksba $as_me 1.3.2, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -15465,7 +15429,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-libksba config.status 1.3.1
+libksba config.status 1.3.2
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
@@ -17463,7 +17427,7 @@ fi
 echo "
         Libksba v${VERSION} has been configured as follows:
 
-        Revision:  447784c  (17527)
+        Revision:  02079b5  (519)
         Platform:  $host
 
 "
index f556319..1ca825b 100644 (file)
@@ -27,23 +27,23 @@ min_automake_version="1.10"
 # bump the version number immediately after the release and do another
 # commit and push so that the git magic is able to work.  See below
 # for the LT versions.
-m4_define(mym4_version, [1.3.1])
-
-# Below is m4 magic to extract and compute the revision number, the
-# decimalized short revision number, a beta version string, and a flag
-# indicating a development version (mym4_isgit). Note that the m4
-# processing is done by autoconf and not during the configure run.
-m4_define([mym4_revision],
-          m4_esyscmd([git rev-parse --short HEAD | tr -d '\n\r']))
-m4_define([mym4_revision_dec],
-          m4_esyscmd_s([echo $((0x$(echo ]mym4_revision[|head -c 4)))]))
-m4_define([mym4_betastring],
-          m4_esyscmd_s([git describe --match 'libksba-[0-9].*[0-9]' --long|\
-                        awk -F- '$3!=0{print"-beta"$3}']))
-m4_define([mym4_isgit],m4_if(mym4_betastring,[],[no],[yes]))
-m4_define([mym4_full_version],[mym4_version[]mym4_betastring])
-
-AC_INIT([libksba],[mym4_full_version],[http://bugs.gnupg.org])
+m4_define([mym4_package],[libksba])
+m4_define([mym4_major], [1])
+m4_define([mym4_minor], [3])
+m4_define([mym4_micro], [2])
+
+# Below is m4 magic to extract and compute the git revision number,
+# the decimalized short revision number, a beta version string and a
+# flag indicating a development version (mym4_isbeta).  Note that the
+# m4 processing is done by autoconf and not during the configure run.
+m4_define([mym4_verslist], m4_split(m4_esyscmd([./autogen.sh --find-version] \
+                           mym4_package mym4_major mym4_minor mym4_micro),[:]))
+m4_define([mym4_isbeta],       m4_argn(2, mym4_verslist))
+m4_define([mym4_version],      m4_argn(4, mym4_verslist))
+m4_define([mym4_revision],     m4_argn(7, mym4_verslist))
+m4_define([mym4_revision_dec], m4_argn(8, mym4_verslist))
+m4_esyscmd([echo ]mym4_version[>VERSION])
+AC_INIT([mym4_package],[mym4_version], [http://bugs.gnupg.org])
 
 # LT Version numbers: Remember to change them just *before* a release.
 #   (Interfaces removed:    CURRENT++, AGE=0, REVISION=0)
@@ -52,7 +52,7 @@ AC_INIT([libksba],[mym4_full_version],[http://bugs.gnupg.org])
 # Please remember to document interface changes in the NEWS file.
 LIBKSBA_LT_CURRENT=19
 LIBKSBA_LT_AGE=11
-LIBKSBA_LT_REVISION=2
+LIBKSBA_LT_REVISION=3
 #-------------------
 # If the API is changed in an incompatible way: increment the next counter.
 KSBA_CONFIG_API_VERSION=1
index 92aad6c..5f59bce 100644 (file)
@@ -178,6 +178,8 @@ FGREP = @FGREP@
 GPG_ERROR_CFLAGS = @GPG_ERROR_CFLAGS@
 GPG_ERROR_CONFIG = @GPG_ERROR_CONFIG@
 GPG_ERROR_LIBS = @GPG_ERROR_LIBS@
+GPG_ERROR_MT_CFLAGS = @GPG_ERROR_MT_CFLAGS@
+GPG_ERROR_MT_LIBS = @GPG_ERROR_MT_LIBS@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
index 07176ba..62719b0 100644 (file)
@@ -9,8 +9,8 @@ END-INFO-DIR-ENTRY
    This file documents the KSBA library to access X.509 and CMS data
 structures.
 
-   This is edition 1.3.1, last updated 15 March 2013, of `The KSBA
-Reference Manual', for Version 1.3.1.
+   This is edition 1.3.2, last updated 15 March 2013, of `The KSBA
+Reference Manual', for Version 1.3.2.
 
    Copyright (C) 2002, 2003, 2004 g10 Code GmbH
 
@@ -26,8 +26,8 @@ File: ksba.info,  Node: Top,  Next: Introduction,  Up: (dir)
 Main Menu
 *********
 
-This is edition 1.3.1, last updated 15 March 2013, of `The KSBA
-Reference Manual', for Version 1.3.1 of the KSBA library.
+This is edition 1.3.2, last updated 15 March 2013, of `The KSBA
+Reference Manual', for Version 1.3.2 of the KSBA library.
 
    Copyright (C) 2002, 2003, 2004 g10 Code GmbH
 
index 0bc4e0e..9d2083c 100644 (file)
@@ -1,4 +1,4 @@
 @set UPDATED 15 March 2013
 @set UPDATED-MONTH March 2013
-@set EDITION 1.3.1
-@set VERSION 1.3.1
+@set EDITION 1.3.2
+@set VERSION 1.3.2
index 0bc4e0e..9d2083c 100644 (file)
@@ -1,4 +1,4 @@
 @set UPDATED 15 March 2013
 @set UPDATED-MONTH March 2013
-@set EDITION 1.3.1
-@set VERSION 1.3.1
+@set EDITION 1.3.2
+@set VERSION 1.3.2
index 2cf5302..dee5b17 100644 (file)
@@ -158,6 +158,8 @@ FGREP = @FGREP@
 GPG_ERROR_CFLAGS = @GPG_ERROR_CFLAGS@
 GPG_ERROR_CONFIG = @GPG_ERROR_CONFIG@
 GPG_ERROR_LIBS = @GPG_ERROR_LIBS@
+GPG_ERROR_MT_CFLAGS = @GPG_ERROR_MT_CFLAGS@
+GPG_ERROR_MT_LIBS = @GPG_ERROR_MT_LIBS@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
index 5e05e41..56895a1 100644 (file)
@@ -117,6 +117,8 @@ FGREP = @FGREP@
 GPG_ERROR_CFLAGS = @GPG_ERROR_CFLAGS@
 GPG_ERROR_CONFIG = @GPG_ERROR_CONFIG@
 GPG_ERROR_LIBS = @GPG_ERROR_LIBS@
+GPG_ERROR_MT_CFLAGS = @GPG_ERROR_MT_CFLAGS@
+GPG_ERROR_MT_LIBS = @GPG_ERROR_MT_LIBS@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
index 35cbc78..1661204 100644 (file)
@@ -1,5 +1,5 @@
 # gpg-error.m4 - autoconf macro to detect libgpg-error.
-# Copyright (C) 2002, 2003, 2004, 2011 g10 Code GmbH
+# Copyright (C) 2002, 2003, 2004, 2011, 2014 g10 Code GmbH
 #
 # This file is free software; as a special exception the author gives
 # unlimited permission to copy and/or distribute it, with or without
@@ -8,38 +8,64 @@
 # This file is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# Last-changed: 2014-10-02
+
 
 dnl AM_PATH_GPG_ERROR([MINIMUM-VERSION,
 dnl                   [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
-dnl Test for libgpg-error and define GPG_ERROR_CFLAGS and GPG_ERROR_LIBS
+dnl
+dnl Test for libgpg-error and define GPG_ERROR_CFLAGS, GPG_ERROR_LIBS,
+dnl GPG_ERROR_MT_CFLAGS, and GPG_ERROR_MT_LIBS.  The _MT_ variants are
+dnl used for programs requireing real multi thread support.
+dnl
+dnl If a prefix option is not used, the config script is first
+dnl searched in $SYSROOT/bin and then along $PATH.  If the used
+dnl config script does not match the host specification the script
+dnl is added to the gpg_config_script_warn variable.
 dnl
 AC_DEFUN([AM_PATH_GPG_ERROR],
 [ AC_REQUIRE([AC_CANONICAL_HOST])
+  gpg_error_config_prefix=""
   dnl --with-libgpg-error-prefix=PFX is the preferred name for this option,
   dnl since that is consistent with how our three siblings use the directory/
   dnl package name in --with-$dir_name-prefix=PFX.
   AC_ARG_WITH(libgpg-error-prefix,
-            AC_HELP_STRING([--with-libgpg-error-prefix=PFX],
-                           [prefix where GPG Error is installed (optional)]),
-     gpg_error_config_prefix="$withval", gpg_error_config_prefix="")
+              AC_HELP_STRING([--with-libgpg-error-prefix=PFX],
+                             [prefix where GPG Error is installed (optional)]),
+              [gpg_error_config_prefix="$withval"])
 
   dnl Accept --with-gpg-error-prefix and make it work the same as
   dnl --with-libgpg-error-prefix above, for backwards compatibility,
   dnl but do not document this old, inconsistently-named option.
   AC_ARG_WITH(gpg-error-prefix,,
-     gpg_error_config_prefix="$withval", gpg_error_config_prefix="")
+              [gpg_error_config_prefix="$withval"])
 
-  if test x$gpg_error_config_prefix != x ; then
-     if test x${GPG_ERROR_CONFIG+set} != xset ; then
-        GPG_ERROR_CONFIG=$gpg_error_config_prefix/bin/gpg-error-config
+  if test x"${GPG_ERROR_CONFIG}" = x ; then
+     if test x"${gpg_error_config_prefix}" != x ; then
+        GPG_ERROR_CONFIG="${gpg_error_config_prefix}/bin/gpg-error-config"
+     else
+       case "${SYSROOT}" in
+         /*)
+           if test -x "${SYSROOT}/bin/gpg-error-config" ; then
+             GPG_ERROR_CONFIG="${SYSROOT}/bin/gpg-error-config"
+           fi
+           ;;
+         '')
+           ;;
+          *)
+           AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.])
+           ;;
+       esac
      fi
   fi
 
-  AC_PATH_TOOL(GPG_ERROR_CONFIG, gpg-error-config, no)
+  AC_PATH_PROG(GPG_ERROR_CONFIG, gpg-error-config, no)
   min_gpg_error_version=ifelse([$1], ,0.0,$1)
   AC_MSG_CHECKING(for GPG Error - version >= $min_gpg_error_version)
   ok=no
-  if test "$GPG_ERROR_CONFIG" != "no" ; then
+  if test "$GPG_ERROR_CONFIG" != "no" \
+     && test -f "$GPG_ERROR_CONFIG" ; then
     req_major=`echo $min_gpg_error_version | \
                sed 's/\([[0-9]]*\)\.\([[0-9]]*\)/\1/'`
     req_minor=`echo $min_gpg_error_version | \
@@ -62,6 +88,8 @@ AC_DEFUN([AM_PATH_GPG_ERROR],
   if test $ok = yes; then
     GPG_ERROR_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --cflags`
     GPG_ERROR_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --libs`
+    GPG_ERROR_MT_CFLAGS=`$GPG_ERROR_CONFIG $gpg_error_config_args --mt --cflags 2>/dev/null`
+    GPG_ERROR_MT_LIBS=`$GPG_ERROR_CONFIG $gpg_error_config_args --mt --libs 2>/dev/null`
     AC_MSG_RESULT([yes ($gpg_error_config_version)])
     ifelse([$2], , :, [$2])
     gpg_error_config_host=`$GPG_ERROR_CONFIG $gpg_error_config_args --host 2>/dev/null || echo none`
@@ -73,16 +101,21 @@ AC_DEFUN([AM_PATH_GPG_ERROR],
 *** built for $gpg_error_config_host and thus may not match the
 *** used host $host.
 *** You may want to use the configure option --with-gpg-error-prefix
-*** to specify a matching config script.
+*** to specify a matching config script or use \$SYSROOT.
 ***]])
+        gpg_config_script_warn="$gpg_config_script_warn libgpg-error"
       fi
     fi
   else
     GPG_ERROR_CFLAGS=""
     GPG_ERROR_LIBS=""
+    GPG_ERROR_MT_CFLAGS=""
+    GPG_ERROR_MT_LIBS=""
     AC_MSG_RESULT(no)
     ifelse([$3], , :, [$3])
   fi
   AC_SUBST(GPG_ERROR_CFLAGS)
   AC_SUBST(GPG_ERROR_LIBS)
+  AC_SUBST(GPG_ERROR_MT_CFLAGS)
+  AC_SUBST(GPG_ERROR_MT_LIBS)
 ])
index 6cf482f..c67cfec 100644 (file)
@@ -1,13 +1,15 @@
-dnl Autoconf macros for libgcrypt
-dnl       Copyright (C) 2002, 2004, 2011 Free Software Foundation, Inc.
-dnl
-dnl This file is free software; as a special exception the author gives
-dnl unlimited permission to copy and/or distribute it, with or without
-dnl modifications, as long as this notice is preserved.
-dnl
-dnl This file is distributed in the hope that it will be useful, but
-dnl WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
-dnl implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# libgcrypt.m4 - Autoconf macros to detect libgcrypt
+# Copyright (C) 2002, 2003, 2004, 2011, 2014 g10 Code GmbH
+#
+# This file is free software; as a special exception the author gives
+# unlimited permission to copy and/or distribute it, with or without
+# modifications, as long as this notice is preserved.
+#
+# This file is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+#
+# Last-changed: 2014-10-02
 
 
 dnl AM_PATH_LIBGCRYPT([MINIMUM-VERSION,
@@ -20,19 +22,37 @@ dnl version of libgcrypt is at least 1.2.5 *and* the API number is 1.  Using
 dnl this features allows to prevent build against newer versions of libgcrypt
 dnl with a changed API.
 dnl
+dnl If a prefix option is not used, the config script is first
+dnl searched in $SYSROOT/bin and then along $PATH.  If the used
+dnl config script does not match the host specification the script
+dnl is added to the gpg_config_script_warn variable.
+dnl
 AC_DEFUN([AM_PATH_LIBGCRYPT],
 [ AC_REQUIRE([AC_CANONICAL_HOST])
   AC_ARG_WITH(libgcrypt-prefix,
             AC_HELP_STRING([--with-libgcrypt-prefix=PFX],
                            [prefix where LIBGCRYPT is installed (optional)]),
      libgcrypt_config_prefix="$withval", libgcrypt_config_prefix="")
-  if test x$libgcrypt_config_prefix != x ; then
-     if test x${LIBGCRYPT_CONFIG+set} != xset ; then
-        LIBGCRYPT_CONFIG=$libgcrypt_config_prefix/bin/libgcrypt-config
+  if test x"${LIBGCRYPT_CONFIG}" = x ; then
+     if test x"${libgcrypt_config_prefix}" != x ; then
+        LIBGCRYPT_CONFIG="${libgcrypt_config_prefix}/bin/libgcrypt-config"
+     else
+       case "${SYSROOT}" in
+         /*)
+           if test -x "${SYSROOT}/bin/libgcrypt-config" ; then
+             LIBGCRYPT_CONFIG="${SYSROOT}/bin/libgcrypt-config"
+           fi
+           ;;
+         '')
+           ;;
+          *)
+           AC_MSG_WARN([Ignoring \$SYSROOT as it is not an absolute path.])
+           ;;
+       esac
      fi
   fi
 
-  AC_PATH_TOOL(LIBGCRYPT_CONFIG, libgcrypt-config, no)
+  AC_PATH_PROG(LIBGCRYPT_CONFIG, libgcrypt-config, no)
   tmp=ifelse([$1], ,1:1.2.0,$1)
   if echo "$tmp" | grep ':' >/dev/null 2>/dev/null ; then
      req_libgcrypt_api=`echo "$tmp"     | sed 's/\(.*\):\(.*\)/\1/'`
@@ -108,8 +128,9 @@ AC_DEFUN([AM_PATH_LIBGCRYPT],
 *** built for $libgcrypt_config_host and thus may not match the
 *** used host $host.
 *** You may want to use the configure option --with-libgcrypt-prefix
-*** to specify a matching config script.
+*** to specify a matching config script or use \$SYSROOT.
 ***]])
+        gpg_config_script_warn="$gpg_config_script_warn libgcrypt"
       fi
     fi
   else
index bae5094..f0fe66c 100644 (file)
@@ -231,6 +231,8 @@ FGREP = @FGREP@
 GPG_ERROR_CFLAGS = @GPG_ERROR_CFLAGS@
 GPG_ERROR_CONFIG = @GPG_ERROR_CONFIG@
 GPG_ERROR_LIBS = @GPG_ERROR_LIBS@
+GPG_ERROR_MT_CFLAGS = @GPG_ERROR_MT_CFLAGS@
+GPG_ERROR_MT_LIBS = @GPG_ERROR_MT_LIBS@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
index d98f740..9061a4a 100644 (file)
--- a/src/oid.c
+++ b/src/oid.c
@@ -94,6 +94,8 @@ ksba_oid_to_str (const char *buffer, size_t length)
         val <<= 7;
         val |= buf[n] & 0x7f;
       }
+    if (val < 80)
+      goto badoid;
     val -= 80;
     sprintf (p, "2.%lu", val);
     p += strlen (p);
index ae2ad4e..759b626 100644 (file)
@@ -39,13 +39,13 @@ EXTRA_DIST = $(test_certs) samples/README mkoidtbl.awk
 BUILT_SOURCES = oidtranstbl.h
 CLEANFILES = oidtranstbl.h
 
-TESTS = cert-basic t-crl-parser t-dnparser
+TESTS = cert-basic t-crl-parser t-dnparser t-oid
 
 AM_CFLAGS = $(GPG_ERROR_CFLAGS)
 AM_LDFLAGS = -no-install
 
 noinst_HEADERS = t-common.h
-noinst_PROGRAMS = $(TESTS) t-cms-parser t-crl-parser t-dnparser t-ocsp t-oid
+noinst_PROGRAMS = $(TESTS) t-cms-parser t-crl-parser t-dnparser t-ocsp
 LDADD = ../src/libksba.la $(GPG_ERROR_LIBS)
 
 t_ocsp_SOURCES = t-ocsp.c sha1.c
@@ -59,6 +59,6 @@ oidtranstbl.h: Makefile mkoidtbl.awk
         for i in /etc/dumpasn1 /usr/local/bin /usr/local/share /usr/bin \
                  /usr/share ; do \
           if test -f $$i/dumpasn1.cfg; then f=$$i/dumpasn1.cfg; break; fi; \
-        done; $(AWK) -f $(srcdir)/mkoidtbl.awk $$f >$@
+        done; tr -d '\r' <$$f | $(AWK) -f $(srcdir)/mkoidtbl.awk >$@
 
 LOG_COMPILER = $(VALGRIND)
index b2e1709..a018c43 100644 (file)
@@ -70,10 +70,10 @@ PRE_UNINSTALL = :
 POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
-TESTS = cert-basic$(EXEEXT) t-crl-parser$(EXEEXT) t-dnparser$(EXEEXT)
-noinst_PROGRAMS = $(am__EXEEXT_1) t-cms-parser$(EXEEXT) \
-       t-crl-parser$(EXEEXT) t-dnparser$(EXEEXT) t-ocsp$(EXEEXT) \
+TESTS = cert-basic$(EXEEXT) t-crl-parser$(EXEEXT) t-dnparser$(EXEEXT) \
        t-oid$(EXEEXT)
+noinst_PROGRAMS = $(am__EXEEXT_1) t-cms-parser$(EXEEXT) \
+       t-crl-parser$(EXEEXT) t-dnparser$(EXEEXT) t-ocsp$(EXEEXT)
 subdir = tests
 DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \
        $(srcdir)/Makefile.in
@@ -94,7 +94,7 @@ CONFIG_HEADER = $(top_builddir)/config.h
 CONFIG_CLEAN_FILES =
 CONFIG_CLEAN_VPATH_FILES =
 am__EXEEXT_1 = cert-basic$(EXEEXT) t-crl-parser$(EXEEXT) \
-       t-dnparser$(EXEEXT)
+       t-dnparser$(EXEEXT) t-oid$(EXEEXT)
 PROGRAMS = $(noinst_PROGRAMS)
 cert_basic_SOURCES = cert-basic.c
 cert_basic_OBJECTS = cert-basic.$(OBJEXT)
@@ -200,6 +200,8 @@ FGREP = @FGREP@
 GPG_ERROR_CFLAGS = @GPG_ERROR_CFLAGS@
 GPG_ERROR_CONFIG = @GPG_ERROR_CONFIG@
 GPG_ERROR_LIBS = @GPG_ERROR_LIBS@
+GPG_ERROR_MT_CFLAGS = @GPG_ERROR_MT_CFLAGS@
+GPG_ERROR_MT_LIBS = @GPG_ERROR_MT_LIBS@
 GREP = @GREP@
 INSTALL = @INSTALL@
 INSTALL_DATA = @INSTALL_DATA@
@@ -740,7 +742,7 @@ oidtranstbl.h: Makefile mkoidtbl.awk
         for i in /etc/dumpasn1 /usr/local/bin /usr/local/share /usr/bin \
                  /usr/share ; do \
           if test -f $$i/dumpasn1.cfg; then f=$$i/dumpasn1.cfg; break; fi; \
-        done; $(AWK) -f $(srcdir)/mkoidtbl.awk $$f >$@
+        done; tr -d '\r' <$$f | $(AWK) -f $(srcdir)/mkoidtbl.awk >$@
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
index c8d4b0d..ef4ab5d 100644 (file)
@@ -143,7 +143,7 @@ main (int argc, char **argv)
       if (!feof (stdin))
         fail ("read error or input too large");
 
-      fail ("no yet implemented");
+      fail ("not yet implemented");
 
     }
   else if (argc == 2 && !strcmp (argv[1], "--to-der") )
index 95fc7f5..be68d52 100644 (file)
@@ -27,6 +27,9 @@
 
 #include "../src/ksba.h"
 
+#define PGM "t-oid"
+#define BADOID "1.3.6.1.4.1.11591.2.12242973"
+
 
 static void *
 read_into_buffer (FILE *fp, size_t *r_length)
@@ -68,23 +71,104 @@ read_into_buffer (FILE *fp, size_t *r_length)
 }
 
 
+static void
+test_oid_to_str (void)
+{
+  struct {
+    unsigned int binlen;
+    unsigned char *bin;
+    char *str;
+  } tests[] = {
+
+    {  7, "\x02\x82\x06\x01\x0A\x0C\x00",
+       "0.2.262.1.10.12.0"
+    },
+    {  7, "\x02\x82\x06\x01\x0A\x0C\x01",
+       "0.2.262.1.10.12.1"
+    },
+    {  7, "\x2A\x86\x48\xCE\x38\x04\x01",
+       "1.2.840.10040.4.1"
+    },
+    {  7, "\x2A\x86\x48\xCE\x38\x04\x03",
+       "1.2.840.10040.4.3"
+    },
+    { 10, "\x2B\x06\x01\x04\x01\xDA\x47\x02\x01\x01",
+      "1.3.6.1.4.1.11591.2.1.1"
+    },
+    {  3, "\x55\x1D\x0E",
+       "2.5.29.14"
+    },
+    {  9, "\x80\x02\x70\x50\x25\x46\xfd\x0c\xc0",
+       BADOID
+    },
+    {  1, "\x80",
+       BADOID
+    },
+    {  2, "\x81\x00",
+       "2.48"
+    },
+    {  2, "\x81\x01",
+       "2.49"
+    },
+    {  2, "\x81\x7f",
+       "2.175"
+    },
+    {  2, "\x81\x80",  /* legal encoding? */
+       "2.48"
+    },
+    {  2, "\x81\x81\x01",  /* legal encoding? */
+       "2.49"
+    },
+    {  0, "",
+       ""
+    },
+
+    { 0, NULL, NULL }
+  };
+  int tidx;
+  char *str;
+
+  for (tidx=0; tests[tidx].bin; tidx++)
+    {
+      str = ksba_oid_to_str (tests[tidx].bin, tests[tidx].binlen);
+      if (!str)
+        {
+          perror ("ksba_oid_to_str failed");
+          exit (1);
+        }
+      if (strcmp (tests[tidx].str, str))
+        {
+          fprintf (stderr, "ksba_oid_to_str test %d failed\n", tidx);
+          fprintf (stderr, "  got=%s\n", str);
+          fprintf (stderr, " want=%s\n", tests[tidx].str);
+          exit (1);
+        }
+    }
+}
+
 
 int
 main (int argc, char **argv)
 {
   gpg_error_t err;
+
   if (argc)
     {
       argc--;
       argv++;
     }
 
-  if (argc)
+
+  if (!argc)
+    {
+      test_oid_to_str ();
+    }
+  else if (!strcmp (*argv, "--from-str"))
     {
       unsigned char *buffer;
       size_t n, buflen;
 
-      for ( ;argc ; argc--, argv++)
+      for (argv++,argc-- ; argc; argc--, argv++)
         {
           err = ksba_oid_from_str (*argv, &buffer, &buflen);
           if (err)
@@ -100,18 +184,25 @@ main (int argc, char **argv)
           free (buffer);
         }
     }
-  else
+  else if (!strcmp (*argv, "--to-str"))
     {
       char *buffer;
       size_t buflen;
       char *result;
 
+      argv++;argc--;
+
       buffer = read_into_buffer (stdin, &buflen);
       result = ksba_oid_to_str (buffer, buflen);
       free (buffer);
       printf ("%s\n", result? result:"[malloc failed]");
       free (result);
     }
+  else
+    {
+      fputs ("usage: "PGM" [--from-str|--to-str]\n", stderr);
+      return 1;
+    }
 
   return 0;
 }