A variety of small tweaks and fixes. Make mpmont etc. return errors
[u/mdw/catacomb] / Makefile.m4
index ea3daa5..b269aee 100644 (file)
@@ -1,6 +1,6 @@
 ## -*-m4-*-
 ##
-## $Id: Makefile.m4,v 1.72 2004/03/27 17:55:11 mdw Exp $
+## $Id$
 ##
 ## Makefile for Catacomb
 ##
 ## Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
 ## MA 02111-1307, USA.
 
-##----- Revision history ----------------------------------------------------
-##
-## $Log: Makefile.m4,v $
-## Revision 1.72  2004/03/27 17:55:11  mdw
-## Run ec-info test.
-##
-## Revision 1.71  2004/03/27 17:54:11  mdw
-## Standard curves and curve checking.
-##
-## Revision 1.70  2004/03/27 00:04:46  mdw
-## Implement efficient reduction for pleasant-looking primes.
-##
-## Revision 1.69  2004/03/23 15:19:32  mdw
-## Test elliptic curves more thoroughly.
-##
-## Revision 1.68  2004/03/21 23:03:30  mdw
-## Distribute headers properly.
-##
-## Revision 1.67  2004/03/21 22:52:06  mdw
-## Merge and close elliptic curve branch.
-##
-##   Revision 1.60.2.2  2004/03/21 22:39:46  mdw
-##   Elliptic curves on binary fields work.
-##
-##   Revision 1.60.2.1  2003/06/10 13:43:53  mdw
-##   Simple (non-projective) curves over prime fields now seem to work.
-##
-## Revision 1.66  2004/03/21 22:43:50  mdw
-## New hash variant SHA224.
-##
-## Revision 1.65  2003/11/29 23:39:36  mdw
-## Debianization.
-##
-## Revision 1.64  2003/11/10 22:18:30  mdw
-## Build fixes.
-##
-## Revision 1.63  2003/10/17 16:30:46  mdw
-## Report errors if key files don't exist!
-##
-## Revision 1.62  2003/10/12 15:02:09  mdw
-## Reliability fixes.
-##
-## Revision 1.61  2003/10/11 21:02:33  mdw
-## Import buf stuff from tripe.
-##
-## Revision 1.60  2003/05/16 01:12:37  mdw
-## Ship `rc2-tab.h' and `skipjack-tab.h'.
-##
-## Revision 1.59  2003/05/16 00:54:50  mdw
-## Install pixie to fake root if wanted.  Ship `desx-tab.h'
-##
-## Revision 1.58  2002/10/19 17:56:50  mdw
-## Fix bit operations.  Test them (a bit) better.
-##
-## Revision 1.57  2002/10/15 22:58:29  mdw
-## Fast estimation of number representation lengths.
-##
-## Revision 1.56  2001/06/16 13:01:10  mdw
-## New source files and tests.
-##
-## Revision 1.55  2001/05/08 22:17:41  mdw
-## New cipher Noekeon added.
-##
-## Revision 1.54  2001/05/07 17:32:52  mdw
-## New Rijndael block sizes.
-##
-## Revision 1.53  2001/04/29 18:11:19  mdw
-## New block cipher MARS.
-##
-## Revision 1.52  2001/04/29 17:37:35  mdw
-## Added SAFER block cipher.
-##
-## Revision 1.51  2001/04/19 18:26:32  mdw
-## Add CRC as another hash function.
-##
-## Revision 1.50  2001/04/06 22:05:10  mdw
-## Add support for SSL pseudo-random function.
-##
-## Revision 1.49  2001/04/04 20:10:52  mdw
-## Add support for the TLS pseudo-random function.
-##
-## Revision 1.48  2001/04/03 19:36:50  mdw
-## New block cipher DESX added.
-##
-## Revision 1.47  2001/03/03 13:14:13  mdw
-## Distribute md2-tab.h
-##
-## Revision 1.46  2001/02/21 20:03:22  mdw
-## Added support for MD2 hash function.
-##
-## Revision 1.45  2001/02/03 16:09:41  mdw
-## New files added.
-##
-## Revision 1.44  2000/10/15 17:49:00  mdw
-## New SHA variants with longer outputs.
-##
-## Revision 1.43  2000/10/08 16:01:26  mdw
-## Add binary poly arithmetic.  Tidy table generation stuff.  Distribute
-## calc prototypes.
-##
-## Revision 1.42  2000/10/08 12:16:06  mdw
-## Remove vestiges of @primorial@.
-##
-## Revision 1.41  2000/08/15 21:46:20  mdw
-## Set up the dependencies on primetab.[ch] and mptypes.h properly.
-## There's some m4 hacking, but it's worth it not to have to recompile all
-## the cipher modes.
-##
-## Revision 1.40  2000/08/06 10:50:55  mdw
-## (mkphrase): New program for generating random passphrases with measured
-## strength.
-##
-## Revision 1.39  2000/07/29 21:55:32  mdw
-## Make sure the pixie is installed setuid-root (workaround for an Automake
-## bug).  Install new manpages.
-##
-## Revision 1.38  2000/07/29 10:54:55  mdw
-## Further fixing to support building using normal `make' again. ;-)  I
-## think we're there now.
-##
-## Revision 1.37  2000/07/29 10:02:36  mdw
-## Lots of fixing to support `make -j' building.
-##
-## Revision 1.36  2000/07/20 20:13:38  mdw
-## Added Bellare and Rogaway's PSS encoding for RSA signatures.
-##
-## Revision 1.35  2000/07/16 20:00:46  mdw
-## Bug fixes to distribution.
-##
-## Revision 1.34  2000/07/15 20:55:32  mdw
-## More hashes and ciphers.  An extra tool.
-##
-## Revision 1.33  2000/07/09 21:34:15  mdw
-## New hash functions and other stuff.
-##
-## Revision 1.32  2000/07/01 11:27:32  mdw
-## Name changes and new files.
-##
-## Revision 1.31  2000/06/25 13:02:07  mdw
-## Fix cleaning of generated files.
-##
-## Revision 1.30  2000/06/22 19:10:33  mdw
-## Fix Makefile to test mp-sqrt.c.
-##
-## Revision 1.29  2000/06/22 19:04:19  mdw
-## More new functions to be added.
-##
-## Revision 1.28  2000/06/18 23:31:18  mdw
-## Rearrange build order to ensure that `mptypes.h' exists by the time it's
-## needed.
-##
-## Revision 1.27  2000/06/17 13:28:50  mdw
-## Minor tidying and fixing.
-##
-## Revision 1.26  2000/06/17 10:33:43  mdw
-## Lots of new ciphers and other files.
-##
-## Revision 1.25  2000/02/12 18:55:40  mdw
-## Make it all compile properly.
-##
-## Revision 1.24  2000/02/12 18:22:26  mdw
-## Missed a file.  Whoops.
-##
-## Revision 1.23  2000/02/12 18:21:01  mdw
-## Overhaul of key management (again).
-##
-## Revision 1.22  1999/12/22 16:04:06  mdw
-## Lots of new files.
-##
-## Revision 1.21  1999/12/13 15:47:58  mdw
-## Fix a couple of minor bugs in the distribution set.
-##
-## Revision 1.19  1999/12/11 10:58:24  mdw
-## Fix bug in test rig link flags.  Add Karatsuba squaring.
-##
-## Revision 1.18  1999/12/10 23:30:01  mdw
-## Lots of new files.
-##
-## Revision 1.17  1999/11/25 11:38:31  mdw
-## Support for conversions between MPs and C integers.
-##
-## Revision 1.16  1999/11/22 20:51:33  mdw
-## Add yet more source files.
-##
-## Revision 1.15  1999/11/22 14:08:30  mdw
-## Improve dependencies for test programs.
-##
-## Revision 1.14  1999/11/22 00:17:09  mdw
-## Create object files for test programs so that rebuilding doesn't take so
-## long.
-##
-## Revision 1.12  1999/11/20 22:36:26  mdw
-## Improve dependencies.  Move mpx testing into mpx.c.
-##
-## Revision 1.11  1999/11/20 22:24:53  mdw
-## Add Diffie-Hellman support.
-##
-## Revision 1.10  1999/11/19 19:28:24  mdw
-## Add DSA files and tests.
-##
-## Revision 1.9  1999/11/17 18:05:35  mdw
-## Many new files and test cases for multiprecision arithmetic.
-##
-## Revision 1.8  1999/11/13 01:56:07  mdw
-## Include multiprecision maths stuff.
-##
-## Revision 1.7  1999/11/11 19:01:02  mdw
-## Use `libtool' to generate a shared library.
-##
-## Revision 1.6  1999/11/11 17:47:34  mdw
-## Updates for new configuration system, and `mptypes' generator.
-##
-## Revision 1.5  1999/11/11 00:59:17  mdw
-## Minor reformatting.
-##
-## Revision 1.4  1999/10/24 10:20:36  mdw
-## Modify for standalone distribution.  The library's getting far too large
-## to be sensibly embedded in other programs.
-##
-## Revision 1.3  1999/10/24 10:04:26  mdw
-## Install headers in the right directory.
-##
-## Revision 1.2  1999/10/23 12:55:35  mdw
-## The `CVS' directory can't be hardlinked.  Don't worry about this
-## overmuch.
-##
-## Revision 1.1  1999/09/03 08:41:11  mdw
-## Initial import.
-##
-
 AUTOMAKE_OPTIONS = foreign
 
 SUBDIRS = tests
@@ -295,7 +65,7 @@ _(serpent) _(noekeon)')
 define(`cipher_modes', `_(ecb) _(cbc) _(cfb) _(ofb) _(counter)')
 
 define(`hashes', `dnl
-_(md5) _(md4) _(md2) _(tiger) dnl
+_(md5) _(md4) _(md2) _(tiger) _(has160) dnl
 _(sha) _(sha224) _(sha256) _(sha384) _(sha512) dnl
 _(rmd128) _(rmd160) _(rmd256) _(rmd320)')
 define(`hash_modes', `_(mgf) _(hmac)')
@@ -327,19 +97,46 @@ gen_tables
 
 primetab.h: primetab.c
 primetab.c: genprimes
-       ./genprimes -h primetab.h -c primetab.c -n 256 \
+       ./genprimes -h primetab.h -c primetab.c \
+               -s CATACOMB_PRIMETAB_H -n 256 \
                -t "unsigned short" -i primetab
 archinclude_HEADERS = mptypes.h
 mptypes.h: mptypes
        ./mptypes >mptypes.h.new
        mv mptypes.h.new mptypes.h
 
-ectab.c: ectab.in ec-gentab.sh mpdump
-       $(srcdir)/ec-gentab.sh <$(srcdir)/ectab.in >ectab.c.new
+ectab.c: ectab.in ec-gentab.awk mpdump
+       $(srcdir)/ec-gentab.awk <$(srcdir)/ectab.in >ectab.c.new
        mv ectab.c.new ectab.c
 
+ptab.c: ptab.in p-gentab.awk mpdump
+       $(srcdir)/p-gentab.awk <$(srcdir)/ptab.in >ptab.c.new
+       mv ptab.c.new ptab.c
+
+bintab.c: bintab.in bin-gentab.awk mpdump
+       $(srcdir)/bin-gentab.awk <$(srcdir)/bintab.in >bintab.c.new
+       mv bintab.c.new bintab.c
+
+gciphertab.c: gengctab
+       $(srcdir)/gengctab gccipher gcipher >gciphertab.c.new \
+               "lit(join(`ciphers', `-', `cipher_modes')) \
+               lit(join(`hashes', `-', `_(mgf)')) \
+               rc4 seal" 
+       mv gciphertab.c.new gciphertab.c
+
+gmactab.c: gengctab
+       $(srcdir)/gengctab gcmac gmac >gmactab.c.new \
+               "lit(join(`hashes', `-', `_(hmac)'))" 
+       mv gmactab.c.new gmactab.c
+
+ghashtab.c: gengctab
+       $(srcdir)/gengctab gchash ghash >ghashtab.c.new \
+               "lit(`hashes') \
+               crc32=gcrc32"
+       mv ghashtab.c.new ghashtab.c
+
 BUILT_SOURCES = \
-       getdate.c modes-stamp \
+       getdate.c modes-stamp gciphertab.c gmactab.c ghashtab.c \
        addsuffix(join(`ciphers', `-', `cipher_modes'), `.c') \
        addsuffix(join(`ciphers', `-', `cipher_modes'), `.h') \
        addsuffix(join(`hashes', `-', `hash_modes'), `.c') \
@@ -359,41 +156,47 @@ pkginclude_HEADERS = \
        lcrand.h fibrand.h rc4.h seal.h rand.h noise.h fipstest.h maurer.h \
        key.h key-data.h passphrase.h pixie.h lmem.h \
        mpx.h bitops.h mpw.h mpscan.h mparena.h mp.h mptext.h mpint.h \
-       exp.h mpbarrett.h mpmont.h mpreduce.h \
+       exp.h mpbarrett.h mpmont.h mpreduce.h mp-exp.h \
        mpcrt.h mprand.h mpmul.h \
-       gfx.h gf.h gfreduce.h \
+       gfx.h gf.h gfreduce.h gfn.h gf-exp.h \
        primetab.h pfilt.h rabin.h \
        pgen.h prim.h strongprime.h limlee.h keycheck.h \
-       bbs.h rsa.h dh.h dsarand.h dsa.h \
-       oaep.h pkcs1.h pss.h tlsprf.h sslprf.h \
+       bbs.h rsa.h dh.h dsarand.h dsa.h gdsa.h gkcdsa.h \
+       tlsprf.h sslprf.h \
        gfshare.h share.h \
        rho.h \
-       field.h ec.h ec-exp.h ec-test.h \
+       field.h field-guts.h \
+       ec.h ec-guts.h ec-exp.h ec-test.h ectab.h ec-keys.h ec-raw.h \
+       ptab.h bintab.h group.h group-guts.h \
        allwithsuffix(`ciphers', `cipher_modes', `.h') \
        allwithsuffix(`hashes', `hash_modes', `.h') \
        addsuffix(`cipher_modes', `-def.h') \
        addsuffix(`hash_modes', `-def.h') crc32.h
 
 define(`MP_SOURCES',
-       `mpx.c mpx-kmul.c mpx-ksqr.c mpscan.c mparena.c \
+       `mpx.c mpx-kmul.c mpx-ksqr.c mpscan.c mparena.c qdparse.c \
        mp-misc.c mp-mem.c mp-const.c mp-io.c mp-arith.c mp-test.c \
-       mp-sqrt.c mp-gcd.c mp-jacobi.c mp-modsqrt.c \
+       mp-sqrt.c mp-gcd.c mp-jacobi.c mp-modsqrt.c mp-exp.c \
        mpint.c mptext.c mptext-file.c mptext-string.c mptext-dstr.c \
        mptext-len.c \
        exp.c mpcrt.c mpmul.c mprand.c \
-       mpbarrett.c mpbarrett-mexp.c mpbarrett-exp.h \
-       mpmont.c mpmont-mexp.c mpmont-exp.h \
+       mpbarrett.c mpbarrett-exp.c mpbarrett-mexp.c mpbarrett-exp.h \
+       mpmont.c mpmont-exp.c mpmont-mexp.c mpmont-exp.h \
        mpreduce.c mpreduce-exp.h \
-       rho.c buf.c \
+       group-stdops.c group-exp.c group-exp.h g-prime.c g-bin.c \
+         group-parse.c \
+       group-string.c group-file.c group-dstr.c \
+       rho.c buf.c ptab.c bintab.c \
        GF_SOURCES PGEN_SOURCES EC_SOURCES')
 
 define(`GF_SOURCES',
-       `gfx.c gfx-kmul.c gfx-sqr.c gf-arith.c gf-gcd.c \
-       gfreduce.c gfreduce-exp.h ')
+       `gfx.c gfx-kmul.c gfx-sqr.c gf-arith.c gf-exp.c gf-gcd.c \
+       gfreduce.c gfreduce-exp.h gfn.c')
 
 define(`EC_SOURCES',
        `field.c field-parse.c f-prime.c f-niceprime.c f-binpoly.c \
-       ec.c ec-prime.c ec-bin.c ec-test.c ec-info.c ectab.c')
+       ec.c ec-exp.c ec-prime.c ec-bin.c ec-test.c ec-info.c ectab.c \
+       ec-fetch.c ec-raw.c g-ec.c')
 
 define(`PGEN_SOURCES',
        `pfilt.c rabin.c \
@@ -402,8 +205,10 @@ define(`PGEN_SOURCES',
        keycheck.c keycheck-mp.c keycheck-report.c \
        bbs-rand.c bbs-gen.c bbs-jump.c bbs-fetch.c \
        rsa-priv.c rsa-pub.c rsa-gen.c rsa-recover.c rsa-fetch.c \
-       dh-gen.c dh-limlee.c dh-check.c dh-fetch.c \
+       oaep.c pkcs1.c pss.c \
+       dh-gen.c dh-limlee.c dh-check.c dh-fetch.c dh-param.c \
        dsarand.c dsa-sign.c dsa-verify.c dsa-gen.c dsa-check.c \
+       gdsa.c gkcdsa.c \
        key-data.c key-flags.c key-text.c key-binary.c key-pass.c \
        key-pack.c key-misc.c key-file.c key-attr.c key-io.c key-moan.c \
        key-error.c key-fetch.c \
@@ -412,11 +217,12 @@ define(`PGEN_SOURCES',
 libcatacomb_la_SOURCES = \
        grand.c keysz.c \
        lcrand.c fibrand.c rc4.c seal.c rand.c noise.c fipstest.c maurer.c \
-       arena.c qdparse.c \
+       arena.c \
        passphrase.c pixie-client.c pixie-common.c lmem.c \
-       oaep.c pkcs1.c pss.c tlsprf.c sslprf.c \
+       tlsprf.c sslprf.c \
        gfshare.c \
        MP_SOURCES karatsuba.h \
+       gciphertab.c ghashtab.c gmactab.c \
        des-base.c des-base.h \
        desx-tab.h \
        rc2-tab.h \
@@ -440,23 +246,35 @@ mars.lo: mars-tab.h
 tiger.lo: tiger-tab.h
 gfshare.lo: gfshare-tab.h
 gfx-sqr.lo: gfx-sqr-tab.h
-patsubst(MP_SOURCES, `\.c\>', `.lo') dsig.o keyutil.o rspit.o: mptypes.h
-patsubst(PGEN_SOURCES, `\.c\>', `.lo') dsig.o keyutil.o rspit.o: primetab.h
 
 ## --- Utility programs ---
 
-bin_PROGRAMS = dsig key pixie rspit factorial hashsum mkphrase
+bin_PROGRAMS = \
+       dsig key pixie cookie rspit factorial hashsum mkphrase catcrypt
+noinst_LIBRARIES = libcatcrypt.a
 bin_SCRIPTS = catacomb-config xpixie
 noinst_PROGRAMS = \
        genprimes mptypes serpent-check bittest mpdump \
+       perftest \
        addsuffix(`gen_tables', `-mktab')
-LDADD = libcatacomb.la
-
-dsig_SOURCES = dsig.c getdate.y getdate.h
-key_SOURCES = keyutil.c getdate.y getdate.h
+LDADD = libcatacomb.la libcatcrypt.a
+
+define(`LIBCAT_SRC', `cc.h getdate.h dnl
+       cc-sig.c cc-subcmd.c cc-enc.c cc-kem.c cc-list.c')
+libcatcrypt_a_SOURCES = LIBCAT_SRC getdate.y
+
+patsubst(MP_SOURCES, `\.c\>', `.lo') dsig.o keyutil.o rspit.o \
+       patsubst(LIBCAT_SRC, `\.c\>', `.o'): \
+       mptypes.h primetab.h
+       
+dsig_SOURCES = dsig.c
+cookie_SOURCES = cookie.c
+catcrypt_SOURCES = catcrypt.c
+key_SOURCES = keyutil.c
 hashsum_SOURCES = hashsum.c
 rspit_SOURCES = rspit.c
 factorial_SOURCES = factorial.c
+perftest_SOURCES = perftest.c
 pixie_SOURCES = pixie.c pixie-common.c lmem.c arena.c
 pixie_LDADD =
 mkphrase_SOURCES = mkphrase.c
@@ -505,19 +323,23 @@ changequote(`, ')
 
 ## --- Documentation ---
 
-man_MANS = key.1 hashsum.1 keyring.5 pixie.1
+man_MANS = key.1 dsig.1 cookie.1 catcrypt.1 hashsum.1 keyring.5 pixie.1
 
 ## --- Other handy definitions ---
 
 EXTRA_DIST = \
-       Makefile.m4 genmodes $(man_MANS) xpixie \
+       Makefile.m4 genmodes gengctab $(man_MANS) xpixie \
+       group-test.c rsa-test.c \
+       ectab.in ec-gentab.awk ptab.in p-gentab.awk bin-gentab.awk \
        README.cipher README.hash README.random README.mp \
        debian/rules debian/copyright debian/control debian/changelog \
        debian/catacomb-bin.postinst debian/catacomb-bin.config \
        debian/catacomb-bin.prerm debian/catacomb-bin.templates
 
 dist-hook:
-       @ln getdate.c $(distdir) || ln $(srcdir)/getdate.c $(distdir) || true
+       @for i in getdate.c gciphertab.c ghashtab.c gmactab.c; do \
+         ln $$i $(distdir) || ln $(srcdir)/$$i $(distdir) || true; \
+       done
        @echo datestamp >$(distdir)/modes-stamp || true
        @for i in calc tests; do \
          mkdir $(distdir)/$$i; \
@@ -539,7 +361,7 @@ define(`CTESTRIG',
        $1.t)dnl
 $1.to: $1.c
        $(COMPILE) -c -DTEST_RIG -DSRCDIR=\"$(srcdir)\" $(srcdir)/$1.c -o $1.to
-$1.t: $1.to $1.o libcatacomb.la
+$1.t: $1.to libcatacomb.la
        $(CC) $(CFLAGS) $(LDFLAGS) $1.to .libs/libcatacomb.a $(LIBS) -o $1.t')
 
 CTESTRIG(rc4)
@@ -549,7 +371,6 @@ adorn(`nl`'CTESTRIG(', `hashes', `)')
 adorn(`nl`'CTESTRIG(', join(`ciphers', `-', `cipher_modes'), `)')
 adorn(`nl`'CTESTRIG(', join(`hashes', `-', `hash_modes'), `)')
 CTESTRIG(lcrand)
-CTESTRIG(oaep)
 CTESTRIG(tlsprf)
 CTESTRIG(sslprf)
 CTESTRIG(mpx)
@@ -563,22 +384,30 @@ CTESTRIG(mp-sqrt)
 CTESTRIG(mptext)
 CTESTRIG(mpint)
 CTESTRIG(mpbarrett)
+CTESTRIG(mpbarrett-exp)
 CTESTRIG(mpbarrett-mexp)
 CTESTRIG(mpmont)
+CTESTRIG(mpmont-exp)
 CTESTRIG(mpmont-mexp)
 CTESTRIG(mpreduce)
 CTESTRIG(mpcrt)
 CTESTRIG(mpmul)
+CTESTRIG(rsa-test)
 CTESTRIG(gfx)
 CTESTRIG(gfx-sqr)
 CTESTRIG(gfx-kmul)
 CTESTRIG(gf-arith)
 CTESTRIG(gf-gcd)
 CTESTRIG(gfreduce)
+CTESTRIG(gfn)
 CTESTRIG(ec-prime)
 CTESTRIG(ec-bin)
 CTESTRIG(ec-test)
 CTESTRIG(ec-info)
+CTESTRIG(dh-param)
+CTESTRIG(group-test)
+CTESTRIG(gdsa)
+CTESTRIG(gkcdsa)
 CTESTRIG(pgen)
 CTESTRIG(dsa-gen)
 CTESTRIG(dsa-sign)
@@ -593,7 +422,7 @@ TESTS = serpent-check bittest testprogs
 
 CLEANFILES = \
        *.t *.to \
-       mptypes.h primetab.c primetab.h \
+       mptypes.h primetab.c primetab.h ectab.c \
        addsuffix(`gen_tables', `-tab.h')
 
 ## --- Makefile building (haha!) ---