libtasn1-commit
[Top][All Lists]
Advanced

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

[SCM] GNU libtasn1 branch, master, updated. libtasn1_2_13-44-gc2ad9af


From: Nikos Mavrogiannopoulos
Subject: [SCM] GNU libtasn1 branch, master, updated. libtasn1_2_13-44-gc2ad9af
Date: Tue, 02 Oct 2012 18:21:19 +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 libtasn1".

http://git.savannah.gnu.org/cgit/libtasn1.git/commit/?id=c2ad9af33c54676d111331b32480978d67b9d8ca

The branch, master has been updated
       via  c2ad9af33c54676d111331b32480978d67b9d8ca (commit)
       via  663e96ae5bb3cc847b4208110a6fb8acbb8cf91f (commit)
       via  bb8628e071604d25b68cf3be2e22151b00ebbef5 (commit)
      from  0e0068c42896c411420da4d03166d54ea32694ee (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 c2ad9af33c54676d111331b32480978d67b9d8ca
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Tue Oct 2 20:20:49 2012 +0200

    removed unneeded variables and files.

commit 663e96ae5bb3cc847b4208110a6fb8acbb8cf91f
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Tue Oct 2 20:17:46 2012 +0200

    Updated gllib and added hash-pjw-bare.

commit bb8628e071604d25b68cf3be2e22151b00ebbef5
Author: Nikos Mavrogiannopoulos <address@hidden>
Date:   Tue Oct 2 20:11:01 2012 +0200

    Use hash-pjw-bare instead of asn1_bhash().

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

Summary of changes:
 lib/Makefile.am           |    3 +-
 lib/gllib/Makefile.am     |   14 ++--
 lib/gllib/dummy.c         |   42 --------
 lib/gllib/hash-pjw-bare.c |   42 ++++++++
 lib/gllib/hash-pjw-bare.h |   24 +++++
 lib/gllib/stdint.in.h     |    2 +-
 lib/glm4/extensions.m4    |    4 +-
 lib/glm4/gnulib-cache.m4  |    5 +-
 lib/glm4/gnulib-common.m4 |    4 +-
 lib/glm4/gnulib-comp.m4   |   28 +++---
 lib/glm4/multiarch.m4     |    4 +-
 lib/glm4/visibility.m4    |    4 +-
 lib/hash.c                |  235 ---------------------------------------------
 lib/int.h                 |    1 -
 lib/parser_aux.c          |   19 ++--
 15 files changed, 110 insertions(+), 321 deletions(-)
 delete mode 100644 lib/gllib/dummy.c
 create mode 100644 lib/gllib/hash-pjw-bare.c
 create mode 100644 lib/gllib/hash-pjw-bare.h
 delete mode 100644 lib/hash.c

diff --git a/lib/Makefile.am b/lib/Makefile.am
index 03b49f5..044f72d 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -44,8 +44,7 @@ libtasn1_la_SOURCES = \
        parser_aux.h    \
        structure.c     \
        structure.h     \
-       version.c       \
-       hash.c
+       version.c
 
 libtasn1_la_LIBADD = gllib/libgnu.la
 
diff --git a/lib/gllib/Makefile.am b/lib/gllib/Makefile.am
index 86fef38..519e32e 100644
--- a/lib/gllib/Makefile.am
+++ b/lib/gllib/Makefile.am
@@ -21,7 +21,7 @@
 # the same distribution terms as the rest of that program.
 #
 # Generated by gnulib-tool.
-# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu 
--source-base=lib/gllib --m4-base=lib/glm4 --doc-base=doc --tests-base=tests 
--aux-dir=build-aux --lgpl=2 --no-conditional-dependencies --libtool 
--macro-prefix=lgl --no-vc-files lib-symbol-versions lib-symbol-visibility 
stdint strverscmp
+# Reproduce by: gnulib-tool --import --dir=. --lib=libgnu 
--source-base=lib/gllib --m4-base=lib/glm4 --doc-base=doc --tests-base=tests 
--aux-dir=build-aux --lgpl=2 --no-conditional-dependencies --libtool 
--macro-prefix=lgl --no-vc-files hash-pjw-bare lib-symbol-versions 
lib-symbol-visibility stdint strverscmp
 
 AUTOMAKE_OPTIONS = 1.5 gnits
 
@@ -50,6 +50,12 @@ EXTRA_libgnu_la_SOURCES =
 libgnu_la_LDFLAGS = $(AM_LDFLAGS)
 libgnu_la_LDFLAGS += -no-undefined
 
+## begin gnulib module hash-pjw-bare
+
+libgnu_la_SOURCES += hash-pjw-bare.h hash-pjw-bare.c
+
+## end   gnulib module hash-pjw-bare
+
 ## begin gnulib module lib-symbol-visibility
 
 # The value of $(CFLAG_VISIBILITY) needs to be added to the CFLAGS for the
@@ -318,12 +324,6 @@ EXTRA_libgnu_la_SOURCES += strverscmp.c
 
 ## end   gnulib module strverscmp
 
-## begin gnulib module dummy
-
-libgnu_la_SOURCES += dummy.c
-
-## end   gnulib module dummy
-
 
 mostlyclean-local: mostlyclean-generic
        @for dir in '' $(MOSTLYCLEANDIRS); do \
diff --git a/lib/gllib/dummy.c b/lib/gllib/dummy.c
deleted file mode 100644
index ea1f46f..0000000
--- a/lib/gllib/dummy.c
+++ /dev/null
@@ -1,42 +0,0 @@
-/* A dummy file, to prevent empty libraries from breaking builds.
-   Copyright (C) 2004, 2007, 2009-2012 Free Software Foundation, Inc.
-
-   This program is free software: you can redistribute it and/or modify
-   it under the terms of the GNU Lesser General Public License as published by
-   the Free Software Foundation; either version 2.1 of the License, or
-   (at your option) any later version.
-
-   This program 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 Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public License
-   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
-
-/* Some systems, reportedly OpenBSD and Mac OS X, refuse to create
-   libraries without any object files.  You might get an error like:
-
-   > ar cru .libs/libgl.a
-   > ar: no archive members specified
-
-   Compiling this file, and adding its object file to the library, will
-   prevent the library from being empty.  */
-
-/* Some systems, such as Solaris with cc 5.0, refuse to work with libraries
-   that don't export any symbol.  You might get an error like:
-
-   > cc ... libgnu.a
-   > ild: (bad file) garbled symbol table in archive ../gllib/libgnu.a
-
-   Compiling this file, and adding its object file to the library, will
-   prevent the library from exporting no symbols.  */
-
-#ifdef __sun
-/* This declaration ensures that the library will export at least 1 symbol.  */
-int gl_dummy_symbol;
-#else
-/* This declaration is solely to ensure that after preprocessing
-   this file is never empty.  */
-typedef int dummy;
-#endif
diff --git a/lib/gllib/hash-pjw-bare.c b/lib/gllib/hash-pjw-bare.c
new file mode 100644
index 0000000..92101e3
--- /dev/null
+++ b/lib/gllib/hash-pjw-bare.c
@@ -0,0 +1,42 @@
+/* hash-pjw-bare.c -- compute a hash value from a provided buffer.
+
+   Copyright (C) 2012 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as published
+   by the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <config.h>
+
+#include "hash-pjw-bare.h"
+
+#include <limits.h>
+
+#define SIZE_BITS (sizeof (size_t) * CHAR_BIT)
+
+/* Return a hash of the N bytes of X using the method described by
+   Bruno Haible in http://www.haible.de/bruno/hashfunc.html.
+   Note that while many hash functions reduce their result via modulo
+   to a 0..table_size-1 range, this function does not do that.  */
+
+size_t
+hash_pjw_bare (const void *x, size_t n)
+{
+  const unsigned char *s = x;
+  size_t h = 0;
+  unsigned i;
+
+  for (i = 0; i < n; i++)
+    h = s[i] + ((h << 9) | (h >> (SIZE_BITS - 9)));
+
+  return h;
+}
diff --git a/lib/gllib/hash-pjw-bare.h b/lib/gllib/hash-pjw-bare.h
new file mode 100644
index 0000000..60852d1
--- /dev/null
+++ b/lib/gllib/hash-pjw-bare.h
@@ -0,0 +1,24 @@
+/* hash-pjw-bare.h -- declaration for a simple hash function
+   Copyright (C) 2012 Free Software Foundation, Inc.
+
+   This program is free software: you can redistribute it and/or modify it
+   under the terms of the GNU Lesser General Public License as published
+   by the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
+
+#include <stddef.h>
+
+/* Compute a hash code for a buffer starting at X and of size N,
+   and return the hash code.  Note that unlike hash_pjw(), it does not
+   return it modulo a table size.
+   The result is platform dependent: it depends on the size of the 'size_t'
+   type and on the signedness of the 'char' type.  */
+extern size_t hash_pjw_bare (const void *x, size_t n) _GL_ATTRIBUTE_PURE;
diff --git a/lib/gllib/stdint.in.h b/lib/gllib/stdint.in.h
index 3475dbe..4f61f95 100644
--- a/lib/gllib/stdint.in.h
+++ b/lib/gllib/stdint.in.h
@@ -83,7 +83,7 @@
 /* <sys/types.h> defines some of the stdint.h types as well, on glibc,
    IRIX 6.5, and OpenBSD 3.8 (via <machine/types.h>).
    AIX 5.2 <sys/types.h> isn't needed and causes troubles.
-   MacOS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
+   Mac OS X 10.4.6 <sys/types.h> includes <stdint.h> (which is us), but
    relies on the system <stdint.h> definitions, so include
    <sys/types.h> after @address@hidden  */
 #if @HAVE_SYS_TYPES_H@ && ! defined _AIX
diff --git a/lib/glm4/extensions.m4 b/lib/glm4/extensions.m4
index 0bfaef6..6d17d8a 100644
--- a/lib/glm4/extensions.m4
+++ b/lib/glm4/extensions.m4
@@ -1,4 +1,4 @@
-# serial 11  -*- Autoconf -*-
+# serial 12  -*- Autoconf -*-
 # Enable extensions on systems that normally disable them.
 
 # Copyright (C) 2003, 2006-2012 Free Software Foundation, Inc.
@@ -67,7 +67,7 @@ AC_BEFORE([$0], [AC_RUN_IFELSE])dnl
 #ifndef _ALL_SOURCE
 # undef _ALL_SOURCE
 #endif
-/* Enable general extensions on MacOS X.  */
+/* Enable general extensions on Mac OS X.  */
 #ifndef _DARWIN_C_SOURCE
 # undef _DARWIN_C_SOURCE
 #endif
diff --git a/lib/glm4/gnulib-cache.m4 b/lib/glm4/gnulib-cache.m4
index d0e6acb..1037f83 100644
--- a/lib/glm4/gnulib-cache.m4
+++ b/lib/glm4/gnulib-cache.m4
@@ -27,11 +27,12 @@
 
 
 # Specification in the form of a command-line invocation:
-#   gnulib-tool --import --dir=. --lib=libgnu --source-base=lib/gllib 
--m4-base=lib/glm4 --doc-base=doc --tests-base=tests --aux-dir=build-aux 
--lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=lgl 
--no-vc-files lib-symbol-versions lib-symbol-visibility stdint strverscmp
+#   gnulib-tool --import --dir=. --lib=libgnu --source-base=lib/gllib 
--m4-base=lib/glm4 --doc-base=doc --tests-base=tests --aux-dir=build-aux 
--lgpl=2 --no-conditional-dependencies --libtool --macro-prefix=lgl 
--no-vc-files hash-pjw-bare lib-symbol-versions lib-symbol-visibility stdint 
strverscmp
 
 # Specification in the form of a few gnulib-tool.m4 macro invocations:
 gl_LOCAL_DIR([])
 gl_MODULES([
+  hash-pjw-bare
   lib-symbol-versions
   lib-symbol-visibility
   stdint
@@ -49,5 +50,5 @@ gl_MAKEFILE_NAME([])
 gl_LIBTOOL
 gl_MACRO_PREFIX([lgl])
 gl_PO_DOMAIN([])
-gl_WITNESS_C_DOMAIN([])
+gl_WITNESS_C_MACRO([])
 gl_VC_FILES([false])
diff --git a/lib/glm4/gnulib-common.m4 b/lib/glm4/gnulib-common.m4
index d62b767..15d2b2b 100644
--- a/lib/glm4/gnulib-common.m4
+++ b/lib/glm4/gnulib-common.m4
@@ -1,4 +1,4 @@
-# gnulib-common.m4 serial 32
+# gnulib-common.m4 serial 33
 dnl Copyright (C) 2007-2012 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -30,7 +30,7 @@ AC_DEFUN([gl_COMMON_BODY], [
 [/* Work around a bug in Apple GCC 4.0.1 build 5465: In C99 mode, it supports
    the ISO C 99 semantics of 'extern inline' (unlike the GNU C semantics of
    earlier versions), but does not display it by setting __GNUC_STDC_INLINE__.
-   __APPLE__ && __MACH__ test for MacOS X.
+   __APPLE__ && __MACH__ test for Mac OS X.
    __APPLE_CC__ tests for the Apple compiler and its version.
    __STDC_VERSION__ tests for the C99 mode.  */
 #if defined __APPLE__ && defined __MACH__ && __APPLE_CC__ >= 5465 && !defined 
__cplusplus && __STDC_VERSION__ >= 199901L && !defined __GNUC_STDC_INLINE__
diff --git a/lib/glm4/gnulib-comp.m4 b/lib/glm4/gnulib-comp.m4
index b1d2854..6badef8 100644
--- a/lib/glm4/gnulib-comp.m4
+++ b/lib/glm4/gnulib-comp.m4
@@ -40,6 +40,7 @@ AC_DEFUN([lgl_EARLY],
   AC_REQUIRE([gl_PROG_AR_RANLIB])
   # Code from module extensions:
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
+  # Code from module hash-pjw-bare:
   # Code from module include_next:
   # Code from module lib-symbol-versions:
   # Code from module lib-symbol-visibility:
@@ -67,18 +68,18 @@ AC_DEFUN([lgl_INIT],
   m4_pushdef([lgl_LIBSOURCES_DIR], [])
   gl_COMMON
   gl_source_base='lib/gllib'
-gl_LD_VERSION_SCRIPT
-gl_VISIBILITY
-gl_MULTIARCH
-gl_STDDEF_H
-gl_STDINT_H
-gl_HEADER_STRING_H
-gl_FUNC_STRVERSCMP
-if test $HAVE_STRVERSCMP = 0; then
-  AC_LIBOBJ([strverscmp])
-  gl_PREREQ_STRVERSCMP
-fi
-gl_STRING_MODULE_INDICATOR([strverscmp])
+  gl_LD_VERSION_SCRIPT
+  gl_VISIBILITY
+  gl_MULTIARCH
+  gl_STDDEF_H
+  gl_STDINT_H
+  gl_HEADER_STRING_H
+  gl_FUNC_STRVERSCMP
+  if test $HAVE_STRVERSCMP = 0; then
+    AC_LIBOBJ([strverscmp])
+    gl_PREREQ_STRVERSCMP
+  fi
+  gl_STRING_MODULE_INDICATOR([strverscmp])
   # End of code from modules
   m4_ifval(lgl_LIBSOURCES_LIST, [
     m4_syscmd([test ! -d ]m4_defn([lgl_LIBSOURCES_DIR])[ ||
@@ -218,7 +219,8 @@ AC_DEFUN([lgl_FILE_LIST], [
   build-aux/snippet/arg-nonnull.h
   build-aux/snippet/c++defs.h
   build-aux/snippet/warn-on-use.h
-  lib/dummy.c
+  lib/hash-pjw-bare.c
+  lib/hash-pjw-bare.h
   lib/stddef.in.h
   lib/stdint.in.h
   lib/string.in.h
diff --git a/lib/glm4/multiarch.m4 b/lib/glm4/multiarch.m4
index b424dce..0c288b8 100644
--- a/lib/glm4/multiarch.m4
+++ b/lib/glm4/multiarch.m4
@@ -1,4 +1,4 @@
-# multiarch.m4 serial 6
+# multiarch.m4 serial 7
 dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -6,7 +6,7 @@ dnl with or without modifications, as long as this notice is 
preserved.
 
 # Determine whether the compiler is or may be producing universal binaries.
 #
-# On MacOS X 10.5 and later systems, the user can create libraries and
+# On Mac OS X 10.5 and later systems, the user can create libraries and
 # executables that work on multiple system types--known as "fat" or
 # "universal" binaries--by specifying multiple '-arch' options to the
 # compiler but only a single '-arch' option to the preprocessor.  Like
diff --git a/lib/glm4/visibility.m4 b/lib/glm4/visibility.m4
index 7b24d39..a7d4d8c 100644
--- a/lib/glm4/visibility.m4
+++ b/lib/glm4/visibility.m4
@@ -1,4 +1,4 @@
-# visibility.m4 serial 4 (gettext-0.18.2)
+# visibility.m4 serial 5 (gettext-0.18.2)
 dnl Copyright (C) 2005, 2008, 2010-2012 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -12,7 +12,7 @@ dnl __attribute__((__visibility__("hidden"))) and
 dnl __attribute__((__visibility__("default"))).
 dnl Does *not* test for __visibility__("protected") - which has tricky
 dnl semantics (see the 'vismain' test in glibc) and does not exist e.g. on
-dnl MacOS X.
+dnl Mac OS X.
 dnl Does *not* test for __visibility__("internal") - which has processor
 dnl dependent semantics.
 dnl Does *not* test for #pragma GCC visibility push(hidden) - which is
diff --git a/lib/hash.c b/lib/hash.c
deleted file mode 100644
index 50da70c..0000000
--- a/lib/hash.c
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * Copyright (C) 2011-2012 Free Software Foundation, Inc.
- *
- * Author: Nikos Mavrogiannopoulos
- *
- * This file is part of GnuTLS.
- *
- * The GnuTLS is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public License
- * as published by the Free Software Foundation; either version 3 of
- * the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-#include <int.h>
-
-#define INIT_VAL 0x33a1
-/*
--------------------------------------------------------------------------------
-lookup3.c, by Bob Jenkins, May 2006, Public Domain.
-
-These are functions for producing 32-bit hashes for hash table lookup.
-hashword(), hashlittle(), hashlittle2(), hashbig(), mix(), and final() 
-are externally useful functions.  Routines to test the hash are included 
-if SELF_TEST is defined.  You can use this free for any purpose.  It's in
-the public domain.  It has no warranty.
-
-You probably want to use hashlittle().  hashlittle() and hashbig()
-hash byte arrays.  hashlittle() is faster than hashbig() on
-little-endian machines.  Intel and AMD are little-endian machines.
-On second thought, you probably want hashlittle2(), which is identical to
-hashlittle() except it returns two 32-bit hashes for the price of one.  
-You could implement hashbig2() if you wanted but I haven't bothered here.
-
-If you want to find a hash of, say, exactly 7 integers, do
-  a = i1;  b = i2;  c = i3;
-  mix(a,b,c);
-  a += i4; b += i5; c += i6;
-  mix(a,b,c);
-  a += i7;
-  final(a,b,c);
-then use c as the hash value.  If you have a variable length array of
-4-byte integers to hash, use hashword().  If you have a byte array (like
-a character string), use hashlittle().  If you have several byte arrays, or
-a mix of things, see the comments above hashlittle().  
-
-Why is this so big?  I read 12 bytes at a time into 3 4-byte integers, 
-then mix those integers.  This is fast (you can do a lot more thorough
-mixing with 12*3 instructions on 3 integers than you can with 3 instructions
-on 1 byte), but shoehorning those bytes into integers efficiently is messy.
--------------------------------------------------------------------------------
-*/
-#define rot(x,k) (((x)<<(k)) | ((x)>>(32-(k))))
-
-/*
--------------------------------------------------------------------------------
-mix -- mix 3 32-bit values reversibly.
-
-This is reversible, so any information in (a,b,c) before mix() is
-still in (a,b,c) after mix().
-
-If four pairs of (a,b,c) inputs are run through mix(), or through
-mix() in reverse, there are at least 32 bits of the output that
-are sometimes the same for one pair and different for another pair.
-This was tested for:
-* pairs that differed by one bit, by two bits, in any combination
-  of top bits of (a,b,c), or in any combination of bottom bits of
-  (a,b,c).
-* "differ" is defined as +, -, ^, or ~^.  For + and -, I transformed
-  the output delta to a Gray code (a^(a>>1)) so a string of 1's (as
-  is commonly produced by subtraction) look like a single 1-bit
-  difference.
-* the base values were pseudorandom, all zero but one bit set, or 
-  all zero plus a counter that starts at zero.
-
-Some k values for my "a-=c; a^=rot(c,k); c+=b;" arrangement that
-satisfy this are
-    4  6  8 16 19  4
-    9 15  3 18 27 15
-   14  9  3  7 17  3
-Well, "9 15 3 18 27 15" didn't quite get 32 bits diffing
-for "differ" defined as + with a one-bit base and a two-bit delta.  I
-used http://burtleburtle.net/bob/hash/avalanche.html to choose 
-the operations, constants, and arrangements of the variables.
-
-This does not achieve avalanche.  There are input bits of (a,b,c)
-that fail to affect some output bits of (a,b,c), especially of a.  The
-most thoroughly mixed value is c, but it doesn't really even achieve
-avalanche in c.
-
-This allows some parallelism.  Read-after-writes are good at doubling
-the number of bits affected, so the goal of mixing pulls in the opposite
-direction as the goal of parallelism.  I did what I could.  Rotates
-seem to cost as much as shifts on every machine I could lay my hands
-on, and rotates are much kinder to the top and bottom bits, so I used
-rotates.
--------------------------------------------------------------------------------
-*/
-#define mix(a,b,c) \
-{ \
-  a -= c;  a ^= rot(c, 4);  c += b; \
-  b -= a;  b ^= rot(a, 6);  a += c; \
-  c -= b;  c ^= rot(b, 8);  b += a; \
-  a -= c;  a ^= rot(c,16);  c += b; \
-  b -= a;  b ^= rot(a,19);  a += c; \
-  c -= b;  c ^= rot(b, 4);  b += a; \
-}
-
-/*
--------------------------------------------------------------------------------
-final -- final mixing of 3 32-bit values (a,b,c) into c
-
-Pairs of (a,b,c) values differing in only a few bits will usually
-produce values of c that look totally different.  This was tested for
-* pairs that differed by one bit, by two bits, in any combination
-  of top bits of (a,b,c), or in any combination of bottom bits of
-  (a,b,c).
-* "differ" is defined as +, -, ^, or ~^.  For + and -, I transformed
-  the output delta to a Gray code (a^(a>>1)) so a string of 1's (as
-  is commonly produced by subtraction) look like a single 1-bit
-  difference.
-* the base values were pseudorandom, all zero but one bit set, or 
-  all zero plus a counter that starts at zero.
-
-These constants passed:
- 14 11 25 16 4 14 24
- 12 14 25 16 4 14 24
-and these came close:
-  4  8 15 26 3 22 24
- 10  8 15 26 3 22 24
- 11  8 15 26 3 22 24
--------------------------------------------------------------------------------
-*/
-#define final(a,b,c) \
-{ \
-  c ^= b; c -= rot(b,14); \
-  a ^= c; a -= rot(c,11); \
-  b ^= a; b -= rot(a,25); \
-  c ^= b; c -= rot(b,16); \
-  a ^= c; a -= rot(c,4);  \
-  b ^= a; b -= rot(a,14); \
-  c ^= b; c -= rot(b,24); \
-}
-
-
-/*
--------------------------------------------------------------------------------
-hashlittle() -- hash a variable-length key into a 32-bit value
-  k       : the key (the unaligned variable-length array of bytes)
-  length  : the length of the key, counting by bytes
-  initval : can be any 4-byte value
-Returns a 32-bit value.  Every bit of the key affects every bit of
-the return value.  Two keys differing by one or two bits will have
-totally different hash values.
-
-The best hash table sizes are powers of 2.  There is no need to do
-mod a prime (mod is sooo slow!).  If you need less than 32 bits,
-use a bitmask.  For example, if you need only 10 bits, do
-  h = (h & hashmask(10));
-In which case, the hash table should have hashsize(10) elements.
-
-If you are hashing n strings (uint8_t **)k, do it like this:
-  for (i=0, h=0; i<n; ++i) h = hashlittle( k[i], len[i], h);
-
-By Bob Jenkins, 2006.  address@hidden  You may use this
-code any way you wish, private, educational, or commercial.  It's free.
-
-Use for hash table lookup, or anything where one collision in 2^^32 is
-acceptable.  Do NOT use for cryptographic purposes.
--------------------------------------------------------------------------------
-*/
-
-uint32_t _asn1_bhash( const void *key, size_t length)
-{
-  uint32_t a,b,c;                                          /* internal state */
-  const uint8_t *k;
-
-  /* Set up the internal state */
-  a = b = c = 0xdeadbeef + ((uint32_t)length) + INIT_VAL;
-
-  k = (const uint8_t *)key;
-
-  /*--------------- all but the last block: affect some 32 bits of (a,b,c) */
-  while (length > 12)
-  {
-    a += k[0];
-    a += ((uint32_t)k[1])<<8;
-    a += ((uint32_t)k[2])<<16;
-    a += ((uint32_t)k[3])<<24;
-    b += k[4];
-    b += ((uint32_t)k[5])<<8;
-    b += ((uint32_t)k[6])<<16;
-    b += ((uint32_t)k[7])<<24;
-    c += k[8];
-    c += ((uint32_t)k[9])<<8;
-    c += ((uint32_t)k[10])<<16;
-    c += ((uint32_t)k[11])<<24;
-    mix(a,b,c);
-    length -= 12;
-    k += 12;
-  }
-
-  /*-------------------------------- last block: affect all 32 bits of (c) */
-  switch(length)                   /* all the case statements fall through */
-  {
-    case 12: c+=((uint32_t)k[11])<<24;
-    case 11: c+=((uint32_t)k[10])<<16;
-    case 10: c+=((uint32_t)k[9])<<8;
-    case 9 : c+=k[8];
-    case 8 : b+=((uint32_t)k[7])<<24;
-    case 7 : b+=((uint32_t)k[6])<<16;
-    case 6 : b+=((uint32_t)k[5])<<8;
-    case 5 : b+=k[4];
-    case 4 : a+=((uint32_t)k[3])<<24;
-    case 3 : a+=((uint32_t)k[2])<<16;
-    case 2 : a+=((uint32_t)k[1])<<8;
-    case 1 : a+=k[0];
-             break;
-    case 0 : return c;
-  }
-
-  final(a,b,c);
-  return c;
-}
-
-
-
diff --git a/lib/int.h b/lib/int.h
index 6643ffb..66d8a5c 100644
--- a/lib/int.h
+++ b/lib/int.h
@@ -64,7 +64,6 @@ struct asn_node_st
 #define _asn1_strcmp(a,b) strcmp((const char *)a, (const char *)b)
 #define _asn1_strcpy(a,b) strcpy((char *)a, (const char *)b)
 #define _asn1_strcat(a,b) strcat((char *)a, (const char *)b)
-uint32_t _asn1_bhash( const void *key, size_t length);
 
 #define MAX_LOG_SIZE 1024      /* maximum number of characters of a log 
message */
 
diff --git a/lib/parser_aux.c b/lib/parser_aux.c
index b52ad89..c9a1801 100644
--- a/lib/parser_aux.c
+++ b/lib/parser_aux.c
@@ -20,6 +20,7 @@
  */
 
 #include <int.h>
+#include <hash-pjw-bare.h>
 #include "parser_aux.h"
 #include "gstr.h"
 #include "structure.h"
@@ -118,12 +119,12 @@ asn1_find_node (asn_node_t pointer, const char *name)
          n_start = n_end;
          n_start++;
 
-          nhash = _asn1_bhash(n, nsize);
+          nhash = hash_pjw_bare(n, nsize);
        }
       else
        {
          nsize = _asn1_str_cpy (n, sizeof (n), n_start);
-          nhash = _asn1_bhash(n, nsize);
+          nhash = hash_pjw_bare(n, nsize);
 
          n_start = NULL;
        }
@@ -156,12 +157,12 @@ asn1_find_node (asn_node_t pointer, const char *name)
          n_start = n_end;
          n_start++;
 
-          nhash = _asn1_bhash(n, nsize);
+          nhash = hash_pjw_bare(n, nsize);
        }
       else
        {
          nsize = _asn1_str_cpy (n, sizeof (n), n_start);
-          nhash = _asn1_bhash(n, nsize);
+          nhash = hash_pjw_bare(n, nsize);
          n_start = NULL;
        }
 
@@ -365,12 +366,12 @@ unsigned int nsize;
   if (name == NULL)
     {
       node->name[0] = 0;
-      node->name_hash = _asn1_bhash(node->name, 0);
+      node->name_hash = hash_pjw_bare(node->name, 0);
       return node;
     }
 
   nsize = _asn1_str_cpy (node->name, sizeof (node->name), name);
-  node->name_hash = _asn1_bhash(node->name, nsize);
+  node->name_hash = hash_pjw_bare(node->name, nsize);
 
   return node;
 }
@@ -386,19 +387,17 @@ unsigned int nsize;
 asn_node_t
 _asn1_cpy_name (asn_node_t dst, asn_node_t src)
 {
-unsigned int nsize;
-
   if (dst == NULL)
     return dst;
 
   if (src == NULL)
     {
       dst->name[0] = 0;
-      dst->name_hash = _asn1_bhash(dst->name, 0);
+      dst->name_hash = hash_pjw_bare(dst->name, 0);
       return dst;
     }
 
-  nsize = _asn1_str_cpy (dst->name, sizeof (dst->name), src->name);
+  _asn1_str_cpy (dst->name, sizeof (dst->name), src->name);
   dst->name_hash = src->name_hash;
 
   return dst;


hooks/post-receive
-- 
GNU libtasn1



reply via email to

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