From b8772cff2dffaacf21fa91c07c1968f39bee3d59 Mon Sep 17 00:00:00 2001 From: jbj Date: Wed, 28 May 2003 17:18:56 +0000 Subject: [PATCH] Spliddles and diddles. CVS patchset: 6877 CVS date: 2003/05/28 17:18:56 --- beecrypt/BUGS | 3 + beecrypt/Doxyheader | 60 +++++++++------ beecrypt/Makefile.am | 2 +- beecrypt/autogen.sh | 2 +- beecrypt/beecrypt.c | 8 +- beecrypt/beecrypt.win.h | 5 +- beecrypt/configure.ac | 10 ++- beecrypt/docs/Makefile.am | 2 - beecrypt/docs/api.html | 133 -------------------------------- beecrypt/docs/developing.html | 13 ---- beecrypt/docs/index.html | 39 ---------- beecrypt/docs/installing.html | 139 ---------------------------------- beecrypt/docs/manual.css | 25 ------ beecrypt/docs/using.html | 11 --- beecrypt/entropy.c | 2 +- beecrypt/memchunk.c | 8 +- beecrypt/memchunk.h | 8 +- beecrypt/mp.c | 17 ++--- beecrypt/mpbarrett.c | 4 +- beecrypt/python/Makefile.am | 8 +- beecrypt/python/mpw-py.c | 4 +- beecrypt/python/rng-py.c | 4 +- beecrypt/tests/Makefile.am | 1 + 23 files changed, 78 insertions(+), 430 deletions(-) delete mode 100644 beecrypt/docs/api.html delete mode 100644 beecrypt/docs/developing.html delete mode 100644 beecrypt/docs/index.html delete mode 100644 beecrypt/docs/installing.html delete mode 100644 beecrypt/docs/manual.css delete mode 100644 beecrypt/docs/using.html diff --git a/beecrypt/BUGS b/beecrypt/BUGS index 367149a53..dcdbe0d83 100644 --- a/beecrypt/BUGS +++ b/beecrypt/BUGS @@ -6,6 +6,9 @@ Legend: - Intel icc can't cope with gcj headers; there's also a problem in combination with aio.h. Solution should be to not test gcj when using this compiler. As a workaround, you can specify --without-javaglue. + - GCC 3.3 produces faster output for Blowfish than the included assembler + source; try coding two Blowfish rounds (without swap) in C and compile + to assembler to see how GCC accomplishes this. 2.3.0pre: * bug in certain instances of computing modular inverse. diff --git a/beecrypt/Doxyheader b/beecrypt/Doxyheader index b72eae52f..2f3835564 100644 --- a/beecrypt/Doxyheader +++ b/beecrypt/Doxyheader @@ -1,5 +1,30 @@ /*! \mainpage BeeCrypt API Documentation. +BeeCrypt started its life when the need for a portable and fast cryptography +library arose at Virtual Unlimited in 1997. I'm still trying to make it +faster, easier to use and more portable, in addition to providing better +documentation. + +BeeCrypt is released under the following license: + +This library 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 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 library; if not, write to the Free Software +Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Legal disclaimer: note that depending on where you are, the use of +cryptography may be limited or forbidden by law. Before using this library, +make sure you are legally entitled to do so. + Included in the library are: - entropy sources for initializing pseudo-random generators - pseudo-random generators @@ -17,20 +42,19 @@ Included in the library are: - HMAC-SHA-1 - HMAC-SHA-256 - multi-precision integer library, with assembler-optimized routines - for several processors + for a range of processors; optimized to perform well on both 32-bit + and 64-bit machines - probabilistic primality testing, with optimized small prime trial division - discrete logarithm parameter generation over a prime field - Diffie-Hellman key agreement + - DHAES encryption scheme - DSA signature scheme - ElGamal signature scheme (two variants) - RSA keypair generation with chinese remainder theorem variables - RSA public & private key operations - - 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) @@ -39,30 +63,20 @@ Planned for the near future are: - more blockcipher modes (OFB, ... ) The library has been tested on the following platforms: - - FreeBSD 4.0 alpha - - FreeBSD 4.0, 4.2 x86 - - includes assembler optimization (tuned for Pentium and higher) - - HP-UX 11a PA-RISC - Linux glibc 2.x alpha - Linux glibc 2.x arm - - includes assembler optimization + - Linux glibc 2.x ia64 + - Linux glibc 2.x m68k - 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 s390x + - Linux glibc 2.x sparc - Linux glibc 2.x x86 - - includes assembler optimization (tuned for Pentium and higher) - - Solaris 2.[6789] sparc (with Forte or gnu compilers) - - includes assembler optimization for Sparc v8, v8plus and v9 - - Solaris 2.[78] x86 (with Forte or gnu compilers) - - includes assembler optimization (tuned for Pentium and higher) + - Solaris 2.[6789] sparc (with Forte or GNU compilers) + - Solaris 2.[78] 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) - -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) + - Win32 (Windows 95, 98, NT 4.0, 2000, XP) + - AIX (shared libraries don't seem to work in 64-bit mode) + - Darwin (javaglue doesn't compile yet) - Cygwin (the DLL builds now, but needs to be tested) The structures in the library are geared towards exchange with Java diff --git a/beecrypt/Makefile.am b/beecrypt/Makefile.am index 9b5eb9fa4..0e58fc335 100644 --- a/beecrypt/Makefile.am +++ b/beecrypt/Makefile.am @@ -36,7 +36,7 @@ AUTOMAKE_OPTIONS = gnu check-news no-dependencies LINT = splint -SUBDIRS = . docs gas masm python tests $(MAYBE_OPT) +SUBDIRS = . docs gas masm tests $(MAYBE_OPT) SUFFIXES = .s diff --git a/beecrypt/autogen.sh b/beecrypt/autogen.sh index 13965a12e..71bf7a4c9 100755 --- a/beecrypt/autogen.sh +++ b/beecrypt/autogen.sh @@ -38,7 +38,7 @@ if [ X"$@" = X -a "X`uname -s`" = "XLinux" ]; then mandir=/usr/man infodir=/usr/info fi - CPPFLAGS="-Wall -g" ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --infodir=${infodir} --mandir=${mandir} --enable-static "$@" + CPPFLAGS="-Wall -g" ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --infodir=${infodir} --mandir=${mandir} --enable-static --with-python "$@" else ./configure "$@" fi diff --git a/beecrypt/beecrypt.c b/beecrypt/beecrypt.c index a10c565c7..68102d6b3 100644 --- a/beecrypt/beecrypt.c +++ b/beecrypt/beecrypt.c @@ -48,8 +48,8 @@ static entropySource entropySourceList[] = { #if WIN32 { "wincrypt", entropy_wincrypt }, - { "wavein", entropy_wavein }, { "console", entropy_console }, + { "wavein", entropy_wavein }, #else # if HAVE_DEV_URANDOM { "urandom", entropy_dev_urandom }, @@ -394,7 +394,6 @@ int hashFunctionContextUpdateMP(hashFunctionContext* ctxt, const mpnumber* n) if (tmp == (byte*) 0) return -1; - /*@-nullpass -nullderef -nullptrarith @*/ /* FIX: temp may be NULL */ if (mpmsbset(n->size, n->data)) { tmp[0] = 0; @@ -407,7 +406,6 @@ int hashFunctionContextUpdateMP(hashFunctionContext* ctxt, const mpnumber* n) rc = ctxt->algo->update(ctxt->param, tmp, MP_WORDS_TO_BYTES(n->size)); } free(tmp); - /*@=nullpass =nullderef =nullptrarith @*/ return rc; } @@ -656,8 +654,9 @@ int keyedHashFunctionContextUpdateMP(keyedHashFunctionContext* ctxt, const mpnum { register int rc; register byte* temp = (byte*) malloc(MP_WORDS_TO_BYTES(n->size)+1); + if (temp == (byte*) 0) + return -1; - /*@-nullpass -nullderef -nullptrarith @*/ /* FIX: temp may be NULL */ if (mpmsbset(n->size, n->data)) { temp[0] = 0; @@ -670,7 +669,6 @@ int keyedHashFunctionContextUpdateMP(keyedHashFunctionContext* ctxt, const mpnum rc = ctxt->algo->update(ctxt->param, temp, MP_WORDS_TO_BYTES(n->size)); } free(temp); - /*@=nullpass =nullderef =nullptrarith @*/ return rc; } diff --git a/beecrypt/beecrypt.win.h b/beecrypt/beecrypt.win.h index 98d23ef9f..82ca2624e 100644 --- a/beecrypt/beecrypt.win.h +++ b/beecrypt/beecrypt.win.h @@ -132,9 +132,6 @@ typedef unsigned __int64 uint64_t; #endif -#define MP_WBITS 32 - -typedef float float4; -typedef double double8; +#define MP_WBITS 32U #endif diff --git a/beecrypt/configure.ac b/beecrypt/configure.ac index d26408cc7..dda6b301a 100644 --- a/beecrypt/configure.ac +++ b/beecrypt/configure.ac @@ -85,6 +85,9 @@ AC_ARG_WITH(arch,[ --with-arch optimize for specific architecture ( i[[3456]]86 | \ pentium | pentium-mmx | pentiumpro | pentium[[234]] | \ athlon | athlon-tbird | athlon-4 | athlon-xp | athlon-mp) + if test "$ac_with_cpu" != yes; then + bc_target_cpu=$withval + fi ;; esac ;; @@ -373,8 +376,8 @@ if test "$ac_enable_threads" = yes; then if test "$ac_cv_header_thread_h" = yes -a "$ac_cv_header_synch_h" = yes; then AC_SEARCH_LIBS([mutex_lock],[thread],[ AC_DEFINE([ENABLE_THREADS],1) - bc_include_synch_h="#include " - bc_typedef_bc_lock_t="typedef pthread_mutex_t bc_lock_t;" + bc_include_synch_h="#include " + bc_typedef_bc_lock_t="typedef mutex_t bc_lock_t;" ]) elif test "$ac_cv_header_pthread_h" = yes; then AC_SEARCH_LIBS([pthread_mutex_lock],[pthread],[ @@ -489,7 +492,7 @@ EOF *) java_include="$java_home"/../include ;; esac - if test -d "$java_include" -a -f "$java_include/jni.h"; then + if test -d "$java_include"; then ac_cv_java_headers=yes ac_cv_java_include="-I$java_include" case $target_os in @@ -718,7 +721,6 @@ AC_CONFIG_FILES([Makefile gas/Makefile java/Makefile masm/Makefile - mwerks/Makefile python/Makefile python/test/Makefile tests/Makefile]) diff --git a/beecrypt/docs/Makefile.am b/beecrypt/docs/Makefile.am index 8a50295ed..797486c24 100644 --- a/beecrypt/docs/Makefile.am +++ b/beecrypt/docs/Makefile.am @@ -21,5 +21,3 @@ # AUTOMAKE_OPTIONS = gnu no-dependencies - -EXTRA_DIST = index.html installing.html using.html developing.html api.html manual.css diff --git a/beecrypt/docs/api.html b/beecrypt/docs/api.html deleted file mode 100644 index 2a9f24216..000000000 --- a/beecrypt/docs/api.html +++ /dev/null @@ -1,133 +0,0 @@ - - - - - -The BeeCrypt API - - -
-
Entropy Sources
-
-
-
-
-
Random Generators
-
-

The following structure is used to hold information describing a -specific random generator implementation: -


-typedef struct
-{
-  const char*                  name;
-  const unsigned int           paramsize;
-  const randomGeneratorSetup   setup;
-  const randomGeneratorSeed    seed;
-  const randomGeneratorNext    next;
-  const randomGeneratorCleanup cleanup;
-} randomGenerator;
-
-

The following structure is used to work with a specific random -generator implementation: -


-typedef struct
-{
-  const randomGenerator* rng;
-  randomGeneratorparam*  param;
-} randomGeneratorContext;
-
-

The following functions will operate on this structure: -

-
-void randomGeneratorContextInit(randomGeneratorContext* ctxt, const randomGenerator* rng); -
-
This function initializes ctxt by allocating and -initializing parameters appropriate for rng. -
-
-void randomGeneratorContextFree(randomGeneratorContext* ctxt); -
-
This function cleans up ctxt and frees its -allocated parameters. -
-
-
-
-
Hash Functions
-
-
-
-
-
Keyed Hash Functions
-
-
-
-
-
Block Ciphers
-
-
-
-
-
Multi-Precision Integer routines
-
-

The following structure is used to hold a multi-precision integer: -


-typedef struct
-{
-  uint32  size;
-  uint32* data;
-} mp32number;
-
-

The following structure is used for barrett modular reduction operations on multi-precision integers: -


-typedef struct
-{
-  uint32  size;
-  uint32* modl;
-  uint32* mu;
-} mp32barrett;
-
-
-
-
-
Discrete Logarithm Public Key Primitives
-
-

Discrete logarithm operations can be performed in a variety of fields. This API implements discrete logarithms over a prime field, conform with IEEE P1363. -

You can find the exact mathematics in: -

-"Handbook of Applied Cryptography"
-Alfred J. Menezes, Paul C. van Oorschot, Scott A. Vanstone
-CRC Press -
-

The domain parameters are defined by a prime P, a prime factor Q of (P-1), and a group generator G. -

The following struct is used to hold the discrete logarithm domain parameters: -


-typedef struct
-{
-  mp32barrett p;
-  mp32barrett q;
-  mp32number  r;
-  mp32number  g;
-  mp32barrett n;
-} dldp_p;
-
-

The struct holds more than the three domain parameters required by IEEE P1363. Some discrete logarithm operations call for a reduction modulo (P-1). Hence we've defined N as (P-1). R is the cofactor of (P-1), so that P-1=N=Q*R, where P and Q are (probable) primes. -

If you save the domain parameters, you don't need to save N, and R, since they can be trivially recomputed. -

The following functions will operate on this structure: -

-
-void dldp_pInit(dldp_p* domain); -
-
-void dldp_pFree(dldp_p* domain); -
-
-void dldp_pCopy(dldp_p* dest, const dldp_p* source); -
-
-
-
-
-
- - diff --git a/beecrypt/docs/developing.html b/beecrypt/docs/developing.html deleted file mode 100644 index 06edb4e09..000000000 --- a/beecrypt/docs/developing.html +++ /dev/null @@ -1,13 +0,0 @@ - - - - - -Developing Applications with BeeCrypt - - -To be completed. -

API -

Examples - - diff --git a/beecrypt/docs/index.html b/beecrypt/docs/index.html deleted file mode 100644 index a2c4a0f19..000000000 --- a/beecrypt/docs/index.html +++ /dev/null @@ -1,39 +0,0 @@ - - - - - -The BeeCrypt Cryptography Library - - -

The BeeCrypt Cryptography Library

-

Copyright © 1997, 1998, 1999, 2000, 2001 Virtual Unlimited, B.V.
-

Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.1 or any -later version published by the Free Software Foundation; -with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover -Texts. -

For the specifics of this license, see file 'COPYING.DOC', included in this -distribution. -

About BeeCrypt

-

BeeCrypt is an open source cryptography library that contains highly -optimized C and assembler implementations of many well-known algorithms -including Blowfish, MD5, SHA-1, SHA-256, Diffie-Hellman, and ElGamal. -

The goal of the library is to offer a wide range of low-level cryptographic -primitives. -

BeeCrypt is licensed under the GNU Lesser Public General License (LGPL), -which means it can be used for free in both open and closed source commercial -products. -
-

About the documentation

-

This is the first attempt to write a manual for the BeeCrypt Cryptography -Library. Eventually this will become a full-blown manual, with all the jingles -and bells. -

Contents

-
    -
  1. Installing BeeCrypt -
  2. Using BeeCrypt -
  3. Developing with BeeCrypt -
- - diff --git a/beecrypt/docs/installing.html b/beecrypt/docs/installing.html deleted file mode 100644 index 6cd21b2b1..000000000 --- a/beecrypt/docs/installing.html +++ /dev/null @@ -1,139 +0,0 @@ - - - - -Installing the BeeCrypt Cryptography Library - - -

Installing the BeeCrypt Cryptography Library

-

When it comes to installing BeeCrypt you basically have the following -alternatives: -

    -
  1. Installing from the source code - aka roll your own
  2. -
      -
    • Getting the source code
    • -

      The primary download location for the source tarball is through - -Virtual Unlimited's download page. Alternatively you can download from -SourceForge. -

    • Unpacking
    • -

      Once you have the source tarball, unpack it with GNU -tar (if you have it); on Windows you can use -WinRAR. -

    • Configuring, building and installing
    • -

      The library can be built on a variety of platforms, and we will illustrate -the two most common ways: -

      Using the GNU toolchain -

      The source tarball contains a configure script produced with -GNU autoconf; -on most platforms you will want to use this. -

      As with most configure scripts, there are a few options you can use: -

      -
      --prefix
      -
      Use this option to indicate where you want the shared library and header -files installed. By default this is set to /usr/local. Another -suggested location is the /usr directory.
      -
      --target
      -
      Use this option to indicate that you want the library built for a -processor other than the one which is normally detected. Some examples of -useful combinations are: -
      -
      --target=sparcv8plus-sun-solaris2.8
      -
      --target=i686-pc-freebsd4.3
      -
      -
      --enable-debug
      -
      will build the library with debug symbols, and without assembler -optimization, and instead just use plain C code. -
      --disable-optimized
      -
      will build the library without any processor-specific assembler -optimization, and instead just use plain C code.
      -
      --without-javaglue
      -
      will build the library without code which allows BeeCrypt for Java -to employ the native code in the library (automatic if you don't -have a JDK installed).
      -
      --disable-threads
      -
      will build the library without thread-safe code; useful on platforms -such as NetBSD (automatic if configure can't find threads).
      -
      --disable-aio
      -
      will build the library without asynchronous I/O on entropy devices -(automatic if configure can't find POSIX-compliant asynchronous I/O -routines).
      -
      --with-mtmalloc
      -
      will build the library with multi-thread optimized malloc routines -(available on Solaris 8). There is a tradeoff in speed versus the amount -of memory allocated.
      -
      -

      To build, run:

      make -

      To install, run:

      make install - -

      Using Visual C++ for Win32 -

      Microsoft Visual C++ is currently the preferred platform for compiling -the library, as it seems faster and more stable than other platforms. -

      The prerequisites for compiling are: -

      -
      Visual C++ 6.0
      -
      At the time of writing, it is recommended to install the latest service -pack for Visual Studio. You can find it through Microsoft's -download page.
      -
      Visual C++ Processor Pack
      -
      You will need this package to support compilation of the assembler source -code. You can download it - -here.
      - -

      Before going on, make sure the following Visual C++ tools are found on -your PATH: cl.exe, (the compiler), ml.exe (the assembler), link.exe (the -linker) and nmake.exe (the make utility). -

      For the Win32 platform, there is a Makefile.mak for Visual C++ included; -if you have a Pentium class processor, you won't have to configure the source -tree. -

      This Makefile.mak is set up to compile Java support into the library. If -you don't have JDK 1.2 or later installed, you'll need to edit this file. -

      To build, run:

      nmake /f Makefile.mak -

      Using Metrowerks CodeWarrior for Win32 -

      The prerequisites for compiling are: -

      -
      CodeWarrior Pro
      -
      Use version 5 or later.
      -
      CodeWarrior Pro Assembler Plugin
      -
      This tool isn't officially support by MetroWerks, but it functions fine -in conjunction with the project file included in the library.
      -
      -

      To build, start the CodeWarrior IDE, open project file 'beecrypt.mcp' -and make the BeeCrypt DLL by pressing the [F7] key. -

      Installing the BeeCrypt DLL -

      To install, either copy file 'beecrypt.dll' to your Windows System -directory (on Windows 95/98/Millenium), or to your Windows System 32 -directory (on Windows NT/2000). -

      If you don't need the BeeCrypt DLL globallly available, copy it into the same -directory as the application which is going to use it. If you intend to develop -software with BeeCrypt, you'll need file 'beecrypt.lib'. Either copy it into -project directory, or point your Makefile or project to it. -

      -
    -
    -
  3. Installing precompiled versions
  4. -

    Several different flavors of precompiled versions exist. -

    -
    Win32 BeeCrypt DLLs
    -
    Virtual Unlimited makes precompiled BeeCrypt DLL and LIB files, usable on -Pentium class processors. If you want to develop your own software with these -files, you will also need the header files from the source tarball. See -'Getting the source code'.
    -
    RedHat RPMS
    -
    Virtual Unlimited makes BeeCrypt RPM packages for every release for at -least the following platforms: i386, i586, i686, powerpc. As we get access to -more platforms, we will try to make more RPMS available; until then it -shouldn't be too hard to get the BeeCrypt SRPM file, install it and compile -your own RPMS from it. Note that RPM packages originating at Virtual -Unlimited will contain a signature, which you can verify with - -this key.
    -
    Debian Packages
    -
    Thanks to Luca Filipozzi there are Debian packages available for BeeCrypt. -You can find these packages on various Debian mirror sites.
    -
    -

    -

- - diff --git a/beecrypt/docs/manual.css b/beecrypt/docs/manual.css deleted file mode 100644 index 63f1bb065..000000000 --- a/beecrypt/docs/manual.css +++ /dev/null @@ -1,25 +0,0 @@ -BODY { background: #fff } - -A:link { color: #0D45AC } -A:visited { color: #936 } - -H1 { font: bold 170% verdana,arial,sans-serif } - -H2 { -font: bold 100% verdana,arial,sans-serif; -margin-bottom: .5em -} - -H3 { -font: bold 90% verdana,arial,sans-serif; -margin-bottom: .5em -} - -A.index { font: normal 70% Verdana,Arial,Helvetica,sans-serif } -A.index { color: #0D45AC } -A.index:visited { color: #936 } - -.crumbtrail { font: normal 70% Verdana,Arial,Helvetica,sans-serif } -A.crumblink { color: #0D45AC } -A.crumblink:visited { color: #936 } - diff --git a/beecrypt/docs/using.html b/beecrypt/docs/using.html deleted file mode 100644 index 9bc2db617..000000000 --- a/beecrypt/docs/using.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - -Using BeeCrypt - - -To be completed. - - diff --git a/beecrypt/entropy.c b/beecrypt/entropy.c index a36fec155..5dc3f0ba1 100644 --- a/beecrypt/entropy.c +++ b/beecrypt/entropy.c @@ -526,7 +526,7 @@ static int entropy_noise_gather(int fd, int samplesize, int channels, int swap, temp <<= 1; temp |= samples[i]; randombits--; - if (!(randombits & 0x1f)) + if (!(randombits & 0x7)) *(data++) = temp; } } diff --git a/beecrypt/memchunk.c b/beecrypt/memchunk.c index 3239ebcee..a6dc139dd 100644 --- a/beecrypt/memchunk.c +++ b/beecrypt/memchunk.c @@ -1,12 +1,8 @@ /* * memchunk.c * - * BeeCrypt memory block handling, code - * * Copyright (c) 2001 Virtual Unlimited B.V. * - * Author: Bob Deblier - * * This library 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 @@ -23,6 +19,10 @@ * */ +/*!\file memchunk.c + * \author Bob Deblier + */ + #include "system.h" #include "memchunk.h" #include "debug.h" diff --git a/beecrypt/memchunk.h b/beecrypt/memchunk.h index 86f668378..75e4f8fd6 100644 --- a/beecrypt/memchunk.h +++ b/beecrypt/memchunk.h @@ -1,8 +1,4 @@ /* - * memchunk.h - * - * Beecrypt memory block handling, header - * * Copyright (c) 2001 Virtual Unlimited B.V. * * This library is free software; you can redistribute it and/or @@ -20,6 +16,10 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +/*!\file memchunk.h + * \author Bob Deblier + */ + #ifndef _MEMCHUNK_H #define _MEMCHUNK_H diff --git a/beecrypt/mp.c b/beecrypt/mp.c index 4fd0571f8..b4685f055 100644 --- a/beecrypt/mp.c +++ b/beecrypt/mp.c @@ -395,14 +395,6 @@ void mpand(size_t size, mpw* xdata, const mpw* ydata) } #endif -#ifndef ASM_MPXOR -void mpxor(size_t size, mpw* xdata, const mpw* ydata) -{ - while (size--) - xdata[size] ^= ydata[size]; -} -#endif - #ifndef ASM_MPOR void mpor(size_t size, mpw* xdata, const mpw* ydata) { @@ -411,6 +403,14 @@ void mpor(size_t size, mpw* xdata, const mpw* ydata) } #endif +#ifndef ASM_MPXOR +void mpxor(size_t size, mpw* xdata, const mpw* ydata) +{ + while (size--) + xdata[size] ^= ydata[size]; +} +#endif + #ifndef ASM_MPNOT void mpnot(size_t size, mpw* data) { @@ -1016,7 +1016,6 @@ void mprshift(size_t size, mpw* data, size_t count) #endif #ifndef ASM_MPRSHIFTLSZ -/* x must be != 0 */ size_t mprshiftlsz(size_t size, mpw* data) { register mpw* slide = data+size-1; diff --git a/beecrypt/mpbarrett.c b/beecrypt/mpbarrett.c index 3c18c0595..c83bca221 100644 --- a/beecrypt/mpbarrett.c +++ b/beecrypt/mpbarrett.c @@ -134,14 +134,13 @@ void mpbset(mpbarrett* b, size_t size, const mpw* data) { mpw* temp = (mpw*) malloc((6*size+4) * sizeof(*temp)); + assert(temp != NULL); b->size = size; b->mu = b->modl+size; mpcopy(size, b->modl, data); - /*@-nullpass@*/ /* temp may be NULL */ mpbmu_w(b, temp); free(temp); - /*@=nullpass@*/ } else { @@ -340,6 +339,7 @@ void mpbmod_w(const mpbarrett* b, const mpw* data, mpw* result, mpw* wksp) while (mpgex(b->size+1, wksp, b->size, b->modl)) (void) mpsubx(b->size+1, wksp, b->size, b->modl); + mpcopy(b->size, result, wksp+1); } diff --git a/beecrypt/python/Makefile.am b/beecrypt/python/Makefile.am index c72d2477a..50be8434d 100644 --- a/beecrypt/python/Makefile.am +++ b/beecrypt/python/Makefile.am @@ -26,14 +26,14 @@ LDADD = pythondir = $(pylibdir)/site-packages python_PROGRAMS = _bc.so -_bc_so_SOURCES = _bc-py.c +_bc_so_SOURCES = _bc_so_LDFLAGS = $(mylibs) $(LIBS) -shared -Wl,-soname,_bc.so noinst_LTLIBRARIES = libbc.la -libbc_la_SOURCES = mpw-py.c rng-py.c +libbc_la_SOURCES = _bc-py.c mpw-py.c rng-py.c -_bc.so$(EXEEXT): $(_bc_so_OBJECTS) $(libbc_la_OBJECTS) - $(CC) -o $@ $(_bc_so_OBJECTS) $(libbc_la_OBJECTS) $(_bc_so_LDFLAGS) +_bc.so$(EXEEXT): $(libbc_la_OBJECTS) + $(CC) -o $@ $(libbc_la_OBJECTS) $(_bc_so_LDFLAGS) splint_srcs = _bc-py.c $(libbc_la_sources) diff --git a/beecrypt/python/mpw-py.c b/beecrypt/python/mpw-py.c index bd910bffb..651478d60 100644 --- a/beecrypt/python/mpw-py.c +++ b/beecrypt/python/mpw-py.c @@ -4,7 +4,7 @@ #define _REENTRANT 1 /* XXX config.h collides with pyconfig.h */ #define _GNU_SOURCE /* XXX pick up stpcpy et al */ -#include "system.h" +#include "config.h" #include "Python.h" #include "longintrepr.h" @@ -19,8 +19,6 @@ #include "debug-py.c" -#include "debug.h" - #define ABS(_x) ((_x) < 0 ? -(_x) : (_x)) #if !defined(MAX) #define MAX(x, y) ((x) < (y) ? (y) : (x)) diff --git a/beecrypt/python/rng-py.c b/beecrypt/python/rng-py.c index a5b2a8608..1a9173dc3 100644 --- a/beecrypt/python/rng-py.c +++ b/beecrypt/python/rng-py.c @@ -3,7 +3,7 @@ */ #define _REENTRANT 1 /* XXX config.h collides with pyconfig.h */ -#include "system.h" +#include "config.h" #include "Python.h" #ifdef __LCLINT__ @@ -15,8 +15,6 @@ #include "debug-py.c" -#include "debug.h" - /*@unchecked@*/ static int _rng_debug = 0; diff --git a/beecrypt/tests/Makefile.am b/beecrypt/tests/Makefile.am index 1a23de484..2920abefe 100644 --- a/beecrypt/tests/Makefile.am +++ b/beecrypt/tests/Makefile.am @@ -73,3 +73,4 @@ bench: benchme benchhf benchbc ./benchbc AES 128 ./benchbc Blowfish 128 ./benchbc Blowfish 128 +