Yet another merge to beecrypt-3.0.0..
authorjbj <devnull@localhost>
Mon, 2 Jun 2003 15:58:04 +0000 (15:58 +0000)
committerjbj <devnull@localhost>
Mon, 2 Jun 2003 15:58:04 +0000 (15:58 +0000)
CVS patchset: 6881
CVS date: 2003/06/02 15:58:04

13 files changed:
beecrypt/README
beecrypt/base64.c
beecrypt/beecrypt.gnu.h.in
beecrypt/beecrypt.win.h
beecrypt/blowfish.c
beecrypt/configure.ac
beecrypt/endianness.c
beecrypt/gas/asmdefs.m4
beecrypt/gas/mpopt.x86_64.m4
beecrypt/java/.cvsignore [new file with mode: 0644]
beecrypt/mpbarrett.c
beecrypt/tests/Makefile.am
beecrypt/tests/testdsa.c

index 12221f1..ed9f487 100644 (file)
@@ -2,7 +2,7 @@ Welcome to the BeeCrypt crypto library!
 
 Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002 Virtual Unlimited B.V.
 
-Author: Bob Deblier <bob@virtualunlimited.com>
+Author: Bob Deblier <bob.deblier@pandora.be>
 
 This library is free software; you can redistribute it and/or
 modify it under the terms of the GNU Lesser General Public
@@ -23,12 +23,17 @@ this distribution.
 
 
 
-Welcome to version 2.2.0 of BeeCrypt:
+Welcome to version 3.0.0 of BeeCrypt:
 
 AES support has been added, and the library has been thoroughly debugged,
 with the addition of unit tests. Once you've built the library, you can
 verify the correct functioning with 'make check'.
 
+Multi-precision integer routines should now perform dramatically better 
+an 64-bit processors, especially Alpha and Itanium.
+
+Benchmarks can be obtained with 'make bench'.
+
 As usual, your comments are welcome.
 
 
@@ -93,8 +98,6 @@ Included in the library are:
     - DHAES encryption scheme
 
 Planned for the near future are:
-    - mp64 library for operation on 64-bit computers (and possibly also
-      on certain 32-bit platforms)
     - compliance with and compliance statements for IEEE P1363
     - more blockciphers (Twofish, ... )
        - more hash functions (RIPEMD-160, SHA-384, SHA-512, HAVAL, Tiger)
@@ -103,30 +106,28 @@ Planned for the near future are:
     - more blockcipher modes (OFB, ... )
 
 The library has been tested on the following platforms:
+       - AIX 5.1 ppc
+       - AIX 5.1 ppc64
     - FreeBSD 4.0 alpha
     - FreeBSD 4.0, 4.2 x86
-        - includes assembler optimization (tuned for Pentium and higher)
     - Linux glibc 2.x alpha
     - Linux glibc 2.x arm
-        - includes assembler optimization
+       - Linux glibc 2.x ia64
     - Linux glibc 2.x ppc
-        - includes assembler optimization for 32-bit PowerPC
-     - Linux glibc 2.x sparc
-        - includes assembler optimization for Sparc v8
+    - Linux glibc 2.x sparc
     - Linux glibc 2.x x86
-        - includes assembler optimization (tuned for Pentium and higher)
-    - Solaris 2.6/2.7/2.8 sparc (with Forte or gnu compilers)
-        - includes assembler optimization for Sparc v8, v8plus and v9
-    - Solaris 2.7/2.8 x86 (with Forte or gnu compilers)
-        - includes assembler optimization (tuned for Pentium and higher)
+    - Solaris 2.6/2.7/2.8/2.9 sparc (with Forte or gnu compilers)
+    - Solaris 2.7/2.8 x86 (with Forte or GNU compilers)
     - Tru64 Unix alpha
-    - Win32 (Windows 95, 98, NT 4.0, 2000)
-        - includes assembler optimization (tuned for Pentium and higher)
+    - Win32 (Windows 95, 98, NT 4.0, 2000, XP)
 
 The library is currently in the process of being ported to:
     - Darwin (apparently Apple has decided to change the PPC assembler format;
       this will need a fix)
-    - Cygwin (Can't seem to get the DLL to build properly with the current version of the autotools)
+    - Cygwin (Can't seem to get the DLL to build properly with the current
+      version of the autotools)
+    - HP/UX is a pain in the backside; I'll try getting it working, but the
+      configure script doesn't seem capable of properly detecting gettimeofday.
 
 For more information, refer to the HTML documentation in the docs directory.
 
@@ -135,7 +136,7 @@ enhancements, please see the beecrypt-specific website:
 
 http://beecrypt.virtualunlimited.com/
 
-or contact me at mailto:beecrypt@virtualunlimited.com
+or contact me at mailto:bob.deblier@pandora.be
 
 Sincerely,
 
index 44eb3c4..4628d5b 100644 (file)
 
 /*!\file base64.c
  * \brief Base64 encoding and decoding.
- * \author Bob Deblier <bob@virtualunlimited.com>
+ * \author Bob Deblier <bob.deblier@pandora.be>
  */
 
 #include "system.h"
 #include "base64.h"
-#include "endianness.h"                /* XXX swapu32 for crc */
+#include "endianness.h"
 #include "debug.h"
 
 /*@unchecked@*/
index b09a68a..824fd0d 100644 (file)
@@ -24,6 +24,9 @@
 @INCLUDE_STDINT_H@
 @INCLUDE_SYNCH_H@
 @INCLUDE_PTHREAD_H@
+@INCLUDE_STDLIB_H@ 
+@INCLUDE_MALLOC_H@
+@INCLUDE_STRING_H@
 
 @TYPEDEF_BC_LOCK_T@
 
index 82ca262..a3f97bb 100644 (file)
 #endif
 
 #if defined(_MSC_VER) || __MWERKS__
+#include <stdlib.h>
+#include <string.h>
+
 #define HAVE_ERRNO_H                   1
-#define HAVE_STRING_H                  1
-#define HAVE_STDLIB_H                  1
 #define HAVE_CTYPE_H                   1
 #define HAVE_FCNTL_H                   1
 #define HAVE_TIME_H                            1
@@ -87,9 +88,6 @@
 #endif
 
 #if __MWERKS__
-#define HAVE_UNISTD_H                  1
-#define HAVE_MALLOC_H                  1
-
 #define HAVE_SYS_STAT_H                        0
 
 #define HAVE_LONG_LONG                 1
@@ -109,9 +107,6 @@ typedef unsigned long               uint32_t;
 typedef unsigned long long     uint64_t;
 
 #elif defined(_MSC_VER)
-#define HAVE_UNISTD_H                  0
-#define HAVE_MALLOC_H                  1
-
 #define HAVE_SYS_STAT_H                        1
 
 #define HAVE_LONG_LONG                 0
index b61474b..b7cb73e 100644 (file)
@@ -391,6 +391,20 @@ int blowfishSetIV(blowfishParam* bp, const byte* iv)
 }
 #endif
 
+int blowfishBlowit(blowfishParam* bp, uint32_t* dst, const uint32_t* src)
+{
+       register uint32_t xl = src[0], xr = src[1];
+       register uint32_t* p = bp->p;
+       register uint32_t* s = bp->s;
+
+       EROUND(xl, xr); EROUND(xr, xl);
+
+       dst[1] = xr;
+       dst[0] = xl;
+
+       return 0;
+}
+
 #ifndef ASM_BLOWFISHENCRYPT
 int blowfishEncrypt(blowfishParam* bp, uint32_t* dst, const uint32_t* src)
 {
index 555ac65..1e49aca 100644 (file)
@@ -166,7 +166,7 @@ AC_ARG_WITH(mtmalloc,[  --with-mtmalloc         links against the mtmalloc libra
   fi
   ],[ac_with_mtmalloc=no])
 
-AC_ARG_WITH(java,[  --with-java             creates the java glue code [default=no]],[
+AC_ARG_WITH(java,[  --with-java         creates the java glue code [default=no]],[
   if test "$withval" = no; then
     ac_with_java=no
   else
@@ -360,12 +360,30 @@ AC_HEADER_TIME
 AC_CHECK_HEADERS([ctype.h errno.h fcntl.h malloc.h termio.h termios.h])
 AC_CHECK_HEADERS([sys/ioctl sys/audioio.h sys/soundcard.h])
 
-if test "$ac_enable_threads" = yes; then
-  AC_CHECK_HEADERS([thread.h pthread.h synch.h semaphore.h])
+bc_include_stdlib_h=
+bc_include_malloc_h=
+bc_include_string_h=
+if test "$ac_cv_header_stdlib_h" = yes; then
+  bc_include_stdlib_h="#include <stdlib.h>"
+elif test "$ac_cv_header_malloc_h" = yes; then
+  bc_include_malloc_h="#include <malloc.h>"
 fi
-
 if test "$ac_with_mtmalloc" = yes; then
   AC_CHECK_HEADERS(mtmalloc.h)
+  if test "$ac_cv_header_mtmalloc_h" = yes; then
+    bc_include_stdlib_h=
+    bc_include_malloc_h="#include <mtmalloc.h>"
+  fi
+fi
+if test "$ac_cv_header_string_h" = yes; then
+  bc_include_string_h="#include <string.h>"
+fi
+AC_SUBST(INCLUDE_STDLIB_H,$bc_include_stdlib_h)
+AC_SUBST(INCLUDE_MALLOC_H,$bc_include_malloc_h)
+AC_SUBST(INCLUDE_STRING_H,$bc_include_string_h)
+
+if test "$ac_enable_threads" = yes; then
+  AC_CHECK_HEADERS([thread.h pthread.h synch.h semaphore.h])
 fi
 
 # Checks for libraries.
@@ -389,9 +407,9 @@ if test "$ac_enable_threads" = yes; then
     AC_MSG_WARN([Don't know which thread library to check for])
   fi
 fi
-AC_SUBST(INCLUDE_SYNCH_H, $bc_include_synch_h)
-AC_SUBST(INCLUDE_PTHREAD_H, $bc_include_pthread_h)
-AC_SUBST(TYPEDEF_BC_LOCK_T, $bc_typedef_bc_lock_t)
+AC_SUBST(INCLUDE_SYNCH_H,$bc_include_synch_h)
+AC_SUBST(INCLUDE_PTHREAD_H,$bc_include_pthread_h)
+AC_SUBST(TYPEDEF_BC_LOCK_T,$bc_typedef_bc_lock_t)
 
 if test "$ac_enable_aio" = yes; then
   BEECRYPT_WORKING_AIO
@@ -458,7 +476,7 @@ EOF
           ac_cv_java_include="$ac_cv_java_include -I$gcjpath/include"
         fi
       else
-        AC_MSG_WARN([java headers not found, disabling java])
+        AC_MSG_WARN([java headers not found, disabling java glue])
         ac_cv_java_headers=no
         ac_cv_java_include=
         ac_with_java=no
@@ -466,12 +484,12 @@ EOF
       rm -fr conftest*
     ])
   else
-  AC_CHECK_PROG(ac_cv_have_java, java, yes, no)
-  if test "$ac_cv_have_java" = yes; then
-    AC_CHECK_PROG(ac_cv_have_javac, javac, yes, no)
-    if test "$ac_cv_have_javac" = yes; then
-      AC_CACHE_CHECK([for java native interface headers],ac_cv_java_include,[
-        cat > conftest.java << EOF
+    AC_CHECK_PROG(ac_cv_have_java, java, yes, no)
+    if test "$ac_cv_have_java" = yes; then
+      AC_CHECK_PROG(ac_cv_have_javac, javac, yes, no)
+      if test "$ac_cv_have_javac" = yes; then
+        AC_CACHE_CHECK([for java native interface headers],ac_cv_java_include,[
+          cat > conftest.java << EOF
 public class conftest
 {
   public static void main(String[[]] argv)
@@ -480,20 +498,20 @@ public class conftest
   }
 }
 EOF
-        java_home=`javac conftest.java; java -classpath . conftest`
-        case $target_os in
-        cygwin*)
-          java_home=`cygpath -u -p "$java_home"` ;;
-        esac
-       if test -d "$java_home"; then
+          java_home=`javac conftest.java; java -classpath . conftest`
           case $target_os in
-          darwin*)
-           java_include="$java_home/../../../Headers" ;;
-          *)
-           java_include="$java_home"/../include ;;
+          cygwin*)
+            java_home=`cygpath -u -p "$java_home"` ;;
           esac
-         if test -d "$java_include"; then
-            ac_cv_java_headers=yes
+          if test -d "$java_home"; then
+            case $target_os in
+            darwin*)
+              java_include="$java_home/../../../Headers" ;;
+            *)
+              java_include="$java_home"/../include ;;
+            esac
+            if test -d "$java_include"; then
+              ac_cv_java_headers=yes
               ac_cv_java_include="-I$java_include"
               case $target_os in
               aix*)
@@ -511,28 +529,28 @@ EOF
                 AC_MSG_WARN([please add appropriate -I$java_include/<operating system> flag])
                 ac_cv_java_include="-I$java_include" ;;
               esac
-          else
-            AC_MSG_WARN([java headers not found, disabling java])
-            ac_cv_java_headers=no
+            else
+              AC_MSG_WARN([java headers not found, disabling java])
+              ac_cv_java_headers=no
               ac_cv_java_include=
-            ac_with_java=no
+              ac_with_java=no
+            fi
           fi
-        fi
-        rm -fr conftest*
-      ])
-    else
-      AC_MSG_WARN([javac not found, disabling java])
-      ac_cv_java_headers=no
+          rm -fr conftest*
+        ])
+      else
+        AC_MSG_WARN([javac not found, disabling java])
+        ac_cv_java_headers=no
         ac_cv_java_include=
         ac_with_java=no
+      fi
+    else
+      AC_MSG_WARN([java not found, disabling java])
+      ac_cv_java_headers=no
+      ac_with_java=no
     fi
-  else
-    AC_MSG_WARN([java not found, disabling java])
-    ac_cv_java_headers=no
-    ac_with_java=no
   fi
 fi
-fi
 
 if test "$ac_with_java" = yes ; then
   AC_DEFINE([JAVAGLUE],1)
@@ -689,8 +707,8 @@ if test "$ac_enable_debug" != yes; then
   BEECRYPT_ASM_ALIGN
 fi
 
-  # generate assembler source files from m4 files
-  BEECRYPT_ASM_SOURCES
+# generate assembler source files from m4 files
+BEECRYPT_ASM_SOURCES
 
 # Check for standard types and integers of specific sizes
 BEECRYPT_INT_TYPES
index 85a5654..4ba7cb6 100644 (file)
  * \brief Endian-dependant encoding/decoding.
  * \author Bob Deblier <bob.deblier@pandora.be>
  */
+
 #include "system.h"
 #include "endianness.h"
 #include "debug.h"
 
-/*@-bitwisesigned -shiftimplementation@*/
 int16_t swap16(int16_t n)
 {
        return (    ((n & 0xff) << 8) |
@@ -66,4 +65,3 @@ int64_t swap64(int64_t n)
                                ((n & ((int64_t) 0xff) << 48) >> 40) |
                                ((n & ((int64_t) 0xff) << 56) >> 56) );
 }
-/*@=bitwisesigned =shiftimplementation@*/
index 7b4146f..e41a9cb 100644 (file)
@@ -20,21 +20,39 @@ dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
 ifelse(substr(ASM_OS,0,5),linux,`
 define(USE_SIZE_DIRECTIVE,yes)
+define(USE_TYPE_DIRECTIVE,yes)
 ')
 
 define(SYMNAME,`GSYM_PREFIX`$1'')
 define(LOCAL,`LSYM_PREFIX`$1'')
 
-ifdef(ALIGN,,`
-define(ALIGN)
-')
+ifdef(`ALIGN',,`define(`ALIGN',`')')
 
+ifelse(USE_TYPE_DIRECTIVE,yes,`
+ifelse(SUBSTR(ASM_ARCH,0,3),arm,`
+define(FUNCTION_TYPE,`function')
+',`
+ifelse(SUBSTR(ASM_ARCH,0,5),sparc,`
+define(FUNCTION_TYPE,`#function')
+',`
+define(FUNCTION_TYPE,`@function')
+')
+')
 define(C_FUNCTION_BEGIN,`
        TEXTSEG
        ALIGN
        GLOBL SYMNAME($1)
+       .type SYMNAME($1),FUNCTION_TYPE
 SYMNAME($1):
 ')
+',`
+define(C_FUNCTION_BEGIN,`
+       TEXTSEG
+       ALIGN
+       GLOBL SYMNAME($1)
+SYMNAME($1):
+')
+')
 
 ifelse(USE_SIZE_DIRECTIVE,yes,`
 define(C_FUNCTION_END,`
index 2fa8a18..5a50661 100644 (file)
@@ -21,7 +21,7 @@ dnl  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
        .file "mpopt.s"
 
 include(config.m4)
-include(ARM_SRCDIR/x86_64.m4)
+include(ASM_SRCDIR/x86_64.m4)
 
 
 C_FUNCTION_BEGIN(mpzero)
diff --git a/beecrypt/java/.cvsignore b/beecrypt/java/.cvsignore
new file mode 100644 (file)
index 0000000..da7b481
--- /dev/null
@@ -0,0 +1,5 @@
+.deps
+.libs
+Makefile
+Makefile.in
+*.lo
index c83bca2..ad56494 100644 (file)
@@ -23,7 +23,7 @@
  *        "Handbook of Applied Cryptography", Chapter 14.3.3
  *        Menezes, van Oorschot, Vanstone
  *        CRC Press
- * \author Bob Deblier <bob@virtualunlimited.com>
+ * \author Bob Deblier <bob.deblier@pandora.be>
  * \ingroup MP__m
  */
 
index 2920abe..9f04620 100644 (file)
@@ -25,9 +25,9 @@ AUTOMAKE_OPTIONS = gnu no-dependencies
 INCLUDES = -I$(top_srcdir)
 LDADD = $(top_builddir)/libbeecrypt.la
 
-TESTS = testmd5 testsha1 testsha256 testhmacmd5 testhmacsha1 testaes testblowfish testmp testmpinv testrsa testdldp
+TESTS = testmd5 testsha1 testsha256 testhmacmd5 testhmacsha1 testaes testblowfish testmp testmpinv testdsa testrsa testdldp
 
-check_PROGRAMS = testmd5 testsha1 testsha256 testhmacmd5 testhmacsha1 testaes testblowfish testmp testmpinv testrsa testdldp
+check_PROGRAMS = testmd5 testsha1 testsha256 testhmacmd5 testhmacsha1 testaes testblowfish testmp testmpinv testdsa testrsa testdldp
 
 testmd5_SOURCES = testmd5.c
 
@@ -47,6 +47,8 @@ testmp_SOURCES = testmp.c
 
 testmpinv_SOURCES = testmpinv.c
 
+testdsa_SOURCES = testdsa.c
+
 testrsa_SOURCES = testrsa.c
 
 testdldp_SOURCES = testdldp.c
index d42c431..c252ad8 100644 (file)
@@ -42,46 +42,12 @@ static const char* dsa_hm = "a9993e364706816aba3e25717850c26c9cd0d89d";
 static const char* expect_r = "8bac1ab66410435cb7181f95b16ab97c92b341c0";
 static const char* expect_s = "41e2345f1f56df2458f426d155b4ba2db6dcd8c8";
 
-/* we need to fake a random generator to pass k into the signing algorithm */
-
-int fake_setup(randomGeneratorParam* p)
-{
-       return 0;
-}
-
-int fake_seed(randomGeneratorParam* p, const byte* data, size_t size)
-{
-       return 0;
-}
-
-int fake_next(randomGeneratorParam* p, byte* data, size_t size)
-{
-       mpnumber tmp;
-
-       mpnzero(&tmp);
-       mpnsethex(&tmp, dsa_k);
-
-       memcpy(data, tmp.data, size);
-
-       mpnfree(&tmp);
-
-       return 0;
-}
-
-int fake_cleanup(randomGeneratorParam* p)
-{
-       return 0;
-}
-
-const randomGenerator fakeprng = { "fake", 4, fake_setup, fake_seed, fake_next, fake_cleanup };
-
 int main()
 {
        int failures = 0;
 
        dlkp_p keypair;
-       mpnumber hm, r, s, e_r, e_s;
-       randomGeneratorContext rngc;
+       mpnumber hm, r, s, k, e_r, e_s;
 
        dlkp_pInit(&keypair);
 
@@ -93,57 +59,20 @@ int main()
 
        mpnzero(&e_r);
        mpnzero(&e_s);
+
        mpnsethex(&e_r, expect_r);
        mpnsethex(&e_s, expect_s);
 
        mpnzero(&hm);
        mpnsethex(&hm, dsa_hm);
 
-       /* first test, from NIST FIPS 186-1 */
        mpnzero(&r);
        mpnzero(&s);
 
-       if (randomGeneratorContextInit(&rngc, &fakeprng))
-               return -1;
-
-       if (dsasign(&keypair.param.p, &keypair.param.q, &keypair.param.g, &rngc, &hm, &keypair.x, &r, &s))
-               return -1;
-
-       if (mpnex(e_r.size, e_r.data, r.size, r.data) || mpnex(e_s.size, e_s.data, s.size, s.data))
-       {
-               printf("failed test vector 1\n");
-               failures++;
-       }
-       else
-               printf("ok\n");
-
-       if (randomGeneratorContextFree(&rngc))
-               return -1;
-
-       mpnfree(&s);
-       mpnfree(&r);
-
-       /* second test, sign a hash and verify the signature */
-       mpnzero(&s);
-       mpnzero(&r);
-
-       if (randomGeneratorContextInit(&rngc, randomGeneratorDefault()))
-               return -1;
-
-       if (dsasign(&keypair.param.p, &keypair.param.q, &keypair.param.g, &rngc, &hm, &keypair.x, &r, &s))
-               return -1;
-
-       if (!dsavrfy(&keypair.param.p, &keypair.param.q, &keypair.param.g, &hm, &keypair.y, &r, &s))
-       {
-               printf("failed test vector 2\n");
+       /* first test, verify the signature result from NIST FIPS 186-1 */
+       if (!dsavrfy(&keypair.param.p, &keypair.param.q, &keypair.param.g, &hm, &keypair.y, &e_r, &e_s))
                failures++;
-       }
-       else
-               printf("ok\n");
 
-       if (randomGeneratorContextFree(&rngc))
-               return -1;
-               
        mpnfree(&s);
        mpnfree(&r);