Yet another beecrypt-3.0.0 merge.
authorjbj <devnull@localhost>
Mon, 2 Jun 2003 17:01:41 +0000 (17:01 +0000)
committerjbj <devnull@localhost>
Mon, 2 Jun 2003 17:01:41 +0000 (17:01 +0000)
CVS patchset: 6882
CVS date: 2003/06/02 17:01:41

23 files changed:
beecrypt/BENCHMARKS
beecrypt/README
beecrypt/acinclude.m4
beecrypt/base64.c
beecrypt/beecrypt.gnu.h.in
beecrypt/beecrypt.h
beecrypt/beecrypt.win.h
beecrypt/blockpad.c
beecrypt/blowfish.c
beecrypt/configure.ac
beecrypt/dhaes.h
beecrypt/endianness.h
beecrypt/fips186.h
beecrypt/gas/aesopt.ppc.m4
beecrypt/gas/blowfishopt.ppc.m4
beecrypt/hmac.c
beecrypt/md5.c
beecrypt/md5.h
beecrypt/mp.c
beecrypt/sha1.c
beecrypt/sha1.h
beecrypt/sha256.c
beecrypt/sha256.h

index eee4b2a..9eed9b1 100644 (file)
@@ -1,4 +1,4 @@
-BeeCrypt 3.0.0 | gcc-3.3             | SuSE Linux 8.2       | Pentium 3      600 | 512 MB: 1447 (--with-arch=pentium3)
+Note: timings are average values and may vary under different conditions,
 i.e. the amount of free memory, swapped memory, amount of cpu cache, etc.
 I've tried to make them as accurate as possible, within limits.
 
@@ -10,30 +10,35 @@ Linux - I'm just a little cramped for space...
 
 BENCHmark Modular Exponentation (more is better):
 
-BeeCrypt 3.0.0 | gcc-3.2.2           | Debian Linux 3.0     | Itanium 2      900 |  12 GB: 7317 ()
-BeeCrypt 3.0.0 | gcc-3.3             | RedHat AS 2.1        | P4 Xeon       2400 |   4 GB: 6920 (--with-arch=pentium4)
-BeeCrypt 3.0.0 | gcc-2.95.4          | Debian Linux 3.0     | Alpha EV6.7    666 |   2 GB: 5742 ()
-BeeCrypt 3.0.0 | gcc-2.96            | RedHat AS 2.1        | P4 Xeon       2400 |   4 GB: 3280 (--with-arch=pentiumpro)
-BeeCrypt 3.0.0 | gcc-3.2.2           | AIX 5.1              | POWER3-II      333 | 512 MB: 1782 (--with-arch=powerpc64)
-BeeCrypt 3.0.0 | gcc-3.3             | SuSE Linux 8.2       | Pentium 3      600 | 512 MB: 1447 (--with-arch=pentium3)
-BeeCrypt 3.0.0 | gcc-3.2.2           | AIX 5.1              | POWER3-II      333 | 512 MB:  756 ()
-BeeCrypt 3.0.0 | Forte C 5.1         | Solaris 8            | UltraSparc II  400 |   4 GB:  425 (--with-arch=sparcv8plus)
-BeeCrypt 3.0.0 |                     | Debian Linux 3.0     | StrongARM 1110 128 |  32 MB:  341 ()
-BeeCrypt 3.0.0 | gcc-2.95.4          | Debian Linux 3.0r1   | M68030          25 |  36 MB:    8 ()
+BeeCrypt 3.0.0 | gcc-3.x             | RedHat Linux         | Opteron MP    1600 |       : 17230
+BeeCrypt 3.0.0 | gcc-3.2.2           | Debian Linux 3.0     | Itanium 2      900 |  12 GB:  7317
+BeeCrypt 3.0.0 | gcc-3.3             | RedHat AS 2.1        | P4 Xeon       2400 |   4 GB:  6920 [--with-arch=pentium4]
+BeeCrypt 3.0.0 | gcc-2.95.4          | Debian Linux 3.0     | Alpha EV6.7    666 |   2 GB:  5742
+BeeCrypt 3.0.0 | gcc-2.96            | RedHat AS 2.1        | P4 Xeon       2400 |   4 GB:  3280 [--with-arch=pentiumpro]
+BeeCrypt 3.0.0 | gcc-3.x             | RedHat Linux         | POWER4+       1200 |       :  2592
+BeeCrypt 3.0.0 | gcc-3.x             | RedHat Linux         | P3 Xeon        900 |       :  2169
+BeeCrypt 3.0.0 | gcc-3.2.2           | AIX 5.1              | POWER3-II      333 | 512 MB:  1782 [--with-arch=powerpc64]
+BeeCrypt 3.0.0 | gcc-3.x             | RedHat Linux         | zSeries 900        |       :  1687 (s390x)
+BeeCrypt 3.0.0 | gcc-3.3             | SuSE Linux 8.2       | Pentium 3      600 | 512 MB:  1447 [--with-arch=pentium3]
+BeeCrypt 3.0.0 | gcc-3.2.2           | AIX 5.1              | POWER3-II      333 | 512 MB:   756
+BeeCrypt 3.0.0 | Forte C 5.1         | Solaris 8            | UltraSparc II  400 |   4 GB:   425 [--with-arch=sparcv8plus]
+BeeCrypt 3.0.0 |                     | Debian Linux 3.0     | StrongARM 1110 128 |  32 MB:   341
+BeeCrypt 3.0.0 | gcc-2.95.4          | Debian Linux 3.0r1   | M68040          33 |  52 MB:    24
+BeeCrypt 3.0.0 | gcc-2.95.4          | Debian Linux 3.0r1   | M68030          25 |  36 MB:     8
 
 BENCHmark Hash Function (more is better):
 
 MD5
-BeeCrypt 3.0.0 | gcc-2.96            | RedHat AS 2.1        | P4 Xeon       2400 |   4 GB: 137.0 MB/s (--with-arch=pentiumpro)
+BeeCrypt 3.0.0 | gcc-2.96            | RedHat AS 2.1        | P4 Xeon       2400 |   4 GB: 137.0 MB/s [--with-arch=pentiumpro]
 
 SHA-1
-BeeCrypt 3.0.0 | gcc-2.96            | RedHat AS 2.1        | P4 Xeon       2400 |   4 GB:  77.0 MB/s (--with-arch=pentiumpro)
+BeeCrypt 3.0.0 | gcc-2.96            | RedHat AS 2.1        | P4 Xeon       2400 |   4 GB:  77.0 MB/s [--with-arch=pentiumpro]
 
 SHA-256
-BeeCrypt 3.0.0 | gcc-2.96            | RedHat AS 2.1        | P4 Xeon       2400 |   4 GB:  37.8 MB/s (--with-arch=pentiumpro)
+BeeCrypt 3.0.0 | gcc-2.96            | RedHat AS 2.1        | P4 Xeon       2400 |   4 GB:  37.8 MB/s [--with-arch=pentiumpro]
 
 BENCHmark Block Cipher (more is better):
 
 AES, 128 bits
 
-BLowfish, 128 bits
+Blowfish, 128 bits
index ed9f487..affc428 100644 (file)
@@ -1,6 +1,7 @@
 Welcome to the BeeCrypt crypto library!
 
-Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002 Virtual Unlimited B.V.
+Copyright (c) 1997, 1998, 1999, 2000, 2001 Virtual Unlimited B.V.
+Copyright (c) 2002, 2003, Bob Deblier (for certain parts)
 
 Author: Bob Deblier <bob.deblier@pandora.be>
 
index ae46b17..0de192d 100644 (file)
@@ -280,7 +280,7 @@ AC_DEFUN(BEECRYPT_GNU_CC,[
   fi
   if test "$ac_enable_debug" = yes; then
     BEECRYPT_CFLAGS_REM([-O2])
-    CFLAGS="$CFLAGS -Wall"
+    CFLAGS="$CFLAGS -Wall -pedantic"
   else
     # Generic optimizations, including cpu tuning
     BEECRYPT_CFLAGS_REM([-g])
index 4628d5b..ba5334b 100644 (file)
@@ -252,7 +252,7 @@ char * b64encode (const void * data, size_t ns)
     if (s == NULL)     return NULL;
     if (*s == '\0')    return calloc(1, sizeof(*t));
 
-    if (ns == 0) ns = strlen(s);
+    if (ns == 0) ns = strlen((const char*) s);
     nt = ((ns + 2) / 3) * 4;
 
     /* Add additional bytes necessary for eol string(s). */
@@ -316,7 +316,7 @@ fprintf(stderr, "%7u %02x %02x %02x -> %02x %02x %02x %02x\n",
     }
 
     /*@-mustfree -compdef @*/
-    return t;
+    return (char *) t;
     /*@=mustfree =compdef @*/
 }
 /*@=globs =internalglobs =modfilesys @*/
index 824fd0d..0b1afee 100644 (file)
 @INCLUDE_STDINT_H@
 @INCLUDE_SYNCH_H@
 @INCLUDE_PTHREAD_H@
+@INCLUDE_STDIO_H@
 @INCLUDE_STDLIB_H@ 
 @INCLUDE_MALLOC_H@
 @INCLUDE_STRING_H@
+@INCLUDE_UNISTD_H@
 
 @TYPEDEF_BC_LOCK_T@
 
index e7f0bae..c0bb34c 100644 (file)
@@ -187,7 +187,7 @@ typedef struct
 {
 /*@observer@*/
     const char* name;                  /*!< random generator name */
-    const unsigned int paramsize;
+    const size_t paramsize;
     const randomGeneratorSetup setup;
     const randomGeneratorSeed seed;
     const randomGeneratorNext next;
@@ -334,9 +334,9 @@ typedef struct
 {
 /*@observer@*/
     const char* name;                  /*!< hash function name */
-    const unsigned int paramsize;      /*!< in bytes */
-    const unsigned int blocksize;      /*!< in bytes */
-    const unsigned int digestsize;     /*!< in bytes */
+    const size_t paramsize;            /*!< in bytes */
+    const size_t blocksize;            /*!< in bytes */
+    const size_t digestsize;           /*!< in bytes */
     const hashFunctionReset reset;
     const hashFunctionUpdate update;
     const hashFunctionDigest digest;
@@ -535,12 +535,12 @@ typedef struct
 {
 /*@observer@*/
     const char* name;                  /*!< keyed hash function name */
-    const unsigned int paramsize;      /*!< in bytes */
-    const unsigned int blocksize;      /*!< in bytes */
-    const unsigned int digestsize;     /*!< in bytes */
-    const unsigned int keybitsmin;     /*!< min keysize in bits */
-    const unsigned int keybitsmax;     /*!< max keysize in bits */
-    const unsigned int keybitsinc;     /*!< keysize increment in bits */
+    const size_t paramsize;            /*!< in bytes */
+    const size_t blocksize;            /*!< in bytes */
+    const size_t digestsize;           /*!< in bytes */
+    const size_t keybitsmin;           /*!< min keysize in bits */
+    const size_t keybitsmax;           /*!< max keysize in bits */
+    const size_t keybitsinc;           /*!< keysize increment in bits */
     const keyedHashFunctionSetup setup;
     const keyedHashFunctionReset reset;
     const keyedHashFunctionUpdate update;
@@ -750,16 +750,16 @@ typedef struct
 {
 /*@observer@*/
     const char* name;                  /*!< block cipher name */
-    const unsigned int paramsize;      /*!< in bytes */
-    const unsigned int blocksize;      /*!< in bytes */
-    const unsigned int keybitsmin;     /*!< min keysize in bits */
-    const unsigned int keybitsmax;     /*!< max keysize in bits */
-    const unsigned int keybitsinc;     /*!< keysize increment in bits */
+    const size_t paramsize;            /*!< in bytes */
+    const size_t blocksize;            /*!< in bytes */
+    const size_t keybitsmin;           /*!< min keysize in bits */
+    const size_t keybitsmax;           /*!< max keysize in bits */
+    const size_t keybitsinc;           /*!< keysize increment in bits */
     const blockCipherSetup setup;
     const blockCipherSetIV setiv;
     const blockCipherEncrypt encrypt;
     const blockCipherDecrypt decrypt;
-    const blockCipherFeedback   getfb;
+    const blockCipherFeedback getfb;
 } blockCipher;
 
 #ifdef __cplusplus
index a3f97bb..234384d 100644 (file)
@@ -52,6 +52,7 @@
 #endif
 
 #if defined(_MSC_VER) || __MWERKS__
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
index 429de13..3e2fe73 100644 (file)
@@ -47,7 +47,7 @@ memchunk* pkcs5Unpad(size_t blockbytes, memchunk* tmp)
        if (tmp)
        {
                byte padvalue;
-               int i;
+               unsigned int i;
 
 /*@-usedef@*/ /* LCL: tmp->{data,size} not initialized? */
                if (tmp->data == (byte*) 0)
@@ -95,7 +95,7 @@ memchunk* pkcs5UnpadCopy(/*@unused@*/ size_t blockbytes, const memchunk* src)
 {
        memchunk* tmp;
        byte padvalue;
-       int i;
+       unsigned int i;
 
        if (src == (memchunk*) 0)
                return (memchunk*) 0;
index b7cb73e..45cb62f 100644 (file)
@@ -323,7 +323,7 @@ int blowfishSetup(blowfishParam* bp, const byte* key, size_t keybits, cipherOper
        {
                register uint32_t* p = bp->p;
                register uint32_t* s = bp->s;
-               register int i, j, k;
+               register unsigned int i, j, k;
 
                uint32_t tmp, work[2];
 
index 1e49aca..21e960f 100644 (file)
@@ -309,13 +309,9 @@ esac
 AH_TEMPLATE([HAVE_CTYPE_H],[.])
 AH_TEMPLATE([HAVE_ERRNO_H],[.])
 AH_TEMPLATE([HAVE_FCNTL_H],[.])
-AH_TEMPLATE([HAVE_MALLOC_H],[.])
-AH_TEMPLATE([HAVE_STDLIB_H],[.])
-AH_TEMPLATE([HAVE_STRING_H],[.])
 AH_TEMPLATE([HAVE_TERMIO_H],[.])
 AH_TEMPLATE([HAVE_TERMIOS_H],[.])
 AH_TEMPLATE([HAVE_TIME_H],[.])
-AH_TEMPLATE([HAVE_UNISTD_H],[.])
 
 AH_TEMPLATE([HAVE_SYS_AUDIOIO_H],[.])
 AH_TEMPLATE([HAVE_SYS_IOCTL_H],[.])
@@ -330,7 +326,6 @@ AH_TEMPLATE([HAVE_SYNCH_H],[.])
 AH_TEMPLATE([HAVE_SEMAPHORE_H],[.])
 
 AH_TEMPLATE([HAVE_AIO_H],[.])
-AH_TEMPLATE([HAVE_MTMALLOC_H],[.])
 
 AH_TEMPLATE([HAVE_DEV_AUDIO],[Define to 1 if your system has device /dev/audio])
 AH_TEMPLATE([HAVE_DEV_DSP],[Define to 1 if your system has device /dev/dsp])
@@ -357,12 +352,17 @@ AH_BOTTOM([
 AC_HEADER_STDC
 AC_CHECK_HEADERS([time.h sys/time.h])
 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])
+AC_CHECK_HEADERS([stdio.h ctype.h errno.h fcntl.h malloc.h termio.h termios.h])
+AC_CHECK_HEADERS([sys/ioctl.h sys/audioio.h sys/soundcard.h])
 
+bc_include_stdio_h=
 bc_include_stdlib_h=
 bc_include_malloc_h=
 bc_include_string_h=
+bc_include_unistd_h=
+if test "$ac_cv_header_stdio_h" = yes; then
+  bc_include_stdio_h="#include <stdio.h>"
+fi
 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
@@ -378,9 +378,14 @@ fi
 if test "$ac_cv_header_string_h" = yes; then
   bc_include_string_h="#include <string.h>"
 fi
+if test "$ac_cv_header_unistd_h" = yes; then
+  bc_include_unistd_h="#include <unistd.h>"
+fi
+AC_SUBST(INCLUDE_STDIO_H,$bc_include_stdio_h)
 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)
+AC_SUBST(INCLUDE_UNISTD_H,$bc_include_unistd_h)
 
 if test "$ac_enable_threads" = yes; then
   AC_CHECK_HEADERS([thread.h pthread.h synch.h semaphore.h])
index aca8da2..5ae3683 100644 (file)
@@ -44,8 +44,8 @@ typedef struct
        const hashFunction*             hash;
        const blockCipher*              cipher;
        const keyedHashFunction*        mac;
-       int                             cipherkeybits;
-       int                             mackeybits;
+       size_t                          cipherkeybits;
+       size_t                          mackeybits;
 } dhaes_pParameters;
 
 /**
@@ -58,8 +58,8 @@ typedef struct
        hashFunctionContext             hash;
        blockCipherContext              cipher;
        keyedHashFunctionContext        mac;
-       int                             cipherkeybits;
-       int                             mackeybits;
+       size_t                          cipherkeybits;
+       size_t                          mackeybits;
 } dhaes_pContext;
 
 #ifdef __cplusplus
index 1fa2418..df9942e 100644 (file)
@@ -26,8 +26,6 @@
 
 #include "beecrypt.h"
 
-#include <stdio.h>
-
 #ifdef __cplusplus
 inline int16_t swap16(int16_t n)
 {
index 46dfcd8..423e097 100644 (file)
@@ -51,7 +51,7 @@ typedef struct
        sha1Param       param;
        mpw             state[FIPS186_STATE_SIZE];
        byte            digest[20];
-       int             digestremain;
+       unsigned char   digestremain;
 } fips186Param;
 
 #ifdef __cplusplus
index f81f3a5..9299405 100644 (file)
@@ -1,6 +1,6 @@
 dnl  aesopt.ppc.m4
 dnl
-dnl  NOTE: Only works for big-endian PowerPC!
+dnl  NOTE: Only tested for big-endian PowerPC!
 dnl
 dnl  Copyright (c) 2003 Bob Deblier
 dnl 
index 74214aa..09c64e6 100644 (file)
@@ -1,5 +1,7 @@
 dnl  blowfishopt.ppc.m4
 dnl
+dnl  Note: Only tested on big-endian PowerPC!
+dnl
 dnl  Copyright (c) 2003 Bob Deblier
 dnl 
 dnl  Author: Bob Deblier <bob.deblier@pandora.be>
@@ -101,7 +103,7 @@ ifelse(ASM_BIGENDIAN,yes,`
        li r0,0
        lwbrx r7,r5,r0
        li r0,4
-       lwbrx r7,r5,r0
+       lwbrx r8,r5,r0
 ')
        
        eblock
@@ -113,7 +115,7 @@ ifelse(ASM_BIGENDIAN,yes,`
        li r0,4
        stwbrx r7,r4,r0
        li r0,0
-       stwbrx r7,r4,r0
+       stwbrx r8,r4,r0
 ')
 
        li r3,0
index c8934d7..448d86f 100644 (file)
@@ -42,7 +42,7 @@
 
 int hmacSetup(byte* kxi, byte* kxo, const hashFunction* hash, hashFunctionParam* param, const byte* key, size_t keybits)
 {
-       register unsigned i;
+       register unsigned int i;
        size_t keybytes = keybits >> 3;
 
        /* if the key is too large, hash it first */
index 73f2e55..ecef23f 100644 (file)
@@ -174,7 +174,7 @@ void md5Process(md5Param* mp)
 
 int md5Update(md5Param* mp, const byte* data, size_t size)
 {
-       register int proclength;
+       register unsigned short proclength;
 
        #if (MP_WBITS == 64)
        mpw add[1];
@@ -193,13 +193,13 @@ int md5Update(md5Param* mp, const byte* data, size_t size)
 /*@-type@*/
        while (size > 0)
        {
-               proclength = ((mp->offset + size) > 64) ? (64 - mp->offset) : size;
+               proclength = ((mp->offset + size) > 64U) ? (64U - mp->offset) : size;
                memmove(((byte *) mp->data) + mp->offset, data, proclength);
                size -= proclength;
                data += proclength;
                mp->offset += proclength;
 
-               if (mp->offset == 64)
+               if (mp->offset == 64U)
                {
                        md5Process(mp);
                        mp->offset = 0;
index 40dcf41..1205ea9 100644 (file)
@@ -41,7 +41,7 @@ typedef struct
        #else
        # error
        #endif
-       short offset;
+       unsigned short offset;
 } md5Param;
 
 #ifdef __cplusplus
index b4685f0..03c0945 100644 (file)
@@ -1028,7 +1028,7 @@ size_t mprshiftlsz(size_t size, mpw* data)
        /* count 'all zero' words and move src pointer */
        while (size--)
        {
-               /* test if we a non-zero word */
+               /* test if we have a non-zero word */
                if ((carry = *(slide--)))
                {
                        /* count 'least signification zero bits and set zbits counter */
@@ -1042,6 +1042,9 @@ size_t mprshiftlsz(size_t size, mpw* data)
                zwords++;
        }
 
+       if ((rbits == 0) && (zwords == 0))
+               return 0;
+
        /* shouldn't happen, but let's test anyway */
        if (size == 0)
                return 0;
@@ -1096,7 +1099,6 @@ void mpgcd_w(size_t size, const mpw* xdata, const mpw* ydata, mpw* result, mpw*
        /* get the smallest returned values, and set shift to that */
 
        shift = mprshiftlsz(size, wksp);
-
        temp = mprshiftlsz(size, result);
 
        if (shift > temp)
index 69ccbf6..8af1c8d 100644 (file)
@@ -201,7 +201,7 @@ void sha1Process(sha1Param* sp)
 
 int sha1Update(sha1Param* sp, const byte* data, size_t size)
 {
-       register int proclength;
+       register unsigned short proclength;
 
        #if (MP_WBITS == 64)
        mpw add[1];
@@ -220,13 +220,13 @@ int sha1Update(sha1Param* sp, const byte* data, size_t size)
 /*@-type@*/
        while (size > 0)
        {
-               proclength = ((sp->offset + size) > 64) ? (64 - sp->offset) : size;
+               proclength = ((sp->offset + size) > 64U) ? (64U - sp->offset) : size;
                memmove(((byte *) sp->data) + sp->offset, data, proclength);
                size -= proclength;
                data += proclength;
                sp->offset += proclength;
 
-               if (sp->offset == 64)
+               if (sp->offset == 64U)
                {
                        sha1Process(sp);
                        sp->offset = 0;
index 0e6c7bc..1729e66 100644 (file)
@@ -41,7 +41,7 @@ typedef struct
        #else
        # error
        #endif
-       short offset;
+       unsigned short offset;
 } sha1Param;
 
 #ifdef __cplusplus
index c96ca78..574d023 100644 (file)
@@ -191,7 +191,7 @@ void sha256Process(sha256Param* sp)
 
 int sha256Update(sha256Param* sp, const byte* data, size_t size)
 {
-       register int proclength;
+       register unsigned short proclength;
 
        #if (MP_WBITS == 64)
        mpw add[1];
@@ -210,13 +210,13 @@ int sha256Update(sha256Param* sp, const byte* data, size_t size)
 /*@-type@*/
        while (size > 0)
        {
-               proclength = ((sp->offset + size) > 64) ? (64 - sp->offset) : size;
+               proclength = ((sp->offset + size) > 64U) ? (64U - sp->offset) : size;
                memmove(((byte *) sp->data) + sp->offset, data, proclength);
                size -= proclength;
                data += proclength;
                sp->offset += proclength;
 
-               if (sp->offset == 64)
+               if (sp->offset == 64U)
                {
                        sha256Process(sp);
                        sp->offset = 0;
index 390d228..e2d83e7 100644 (file)
@@ -41,7 +41,7 @@ typedef struct
        #else
        # error
        #endif
-       short offset;
+       unsigned short offset;
 } sha256Param;
 
 #ifdef __cplusplus