Support subgroups of binary fields.
[u/mdw/catacomb] / Makefile.m4
CommitLineData
f9984d11 1## -*-m4-*-
d03ab969 2##
c65df279 3## $Id$
d03ab969 4##
5## Makefile for Catacomb
6##
7## (c) 1999 Straylight/Edgeware
8##
9
10##----- Licensing notice ----------------------------------------------------
11##
12## This file is part of Catacomb.
13##
14## Catacomb is free software; you can redistribute it and/or modify
15## it under the terms of the GNU Library General Public License as
16## published by the Free Software Foundation; either version 2 of the
17## License, or (at your option) any later version.
18##
19## Catacomb is distributed in the hope that it will be useful,
20## but WITHOUT ANY WARRANTY; without even the implied warranty of
21## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22## GNU Library General Public License for more details.
23##
24## You should have received a copy of the GNU Library General Public
25## License along with Catacomb; if not, write to the Free
26## Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
27## MA 02111-1307, USA.
28
d03ab969 29AUTOMAKE_OPTIONS = foreign
30
cc44d54e 31SUBDIRS = tests
32
d03ab969 33archincludedir = $(libdir)/catacomb/include
34
35## --- List handling macros ---
36##
37## List handling is nice, usually. Unfortunately, I based this design on
38## TeX list macros rather than anything sensible...
39
40define(`_', `define(`_item', $1)define(`_item_2', $2)emit`'')
41define(`adorn', `pushdef(`emit', `$1`'_item`'$3')$2`'popdef(`emit')')
42define(`join',
43`pushdef(`emit', `adorn(``_(''_item`$2', `$3', ``)'')`'')$1`'popdef(`emit')')
44define(`addsuffix', `adorn(`', `$1', `$2')')
45define(`lit', `adorn(`', `$1', `')')
46define(`nl', `
47')
48
49define(`allwithsuffix',
50`addsuffix(`$1', `$3') addsuffix(`$2', `$3') dnl
51addsuffix(join(`$1', `-', `$2'), `$3')')
52
53## --- Autogenerated source files ---
54
cc44d54e 55define(`ciphers', `dnl
3bef8c14 56_(des) _(desx) _(des3) _(mars) dnl
621468d8 57_(idea) _(safer) _(safersk) dnl
cc44d54e 58_(blowfish) _(twofish) dnl
a16cc8cf 59_(tea) _(xtea) dnl
cc44d54e 60_(rc2) _(rc5) dnl
a16cc8cf 61_(skipjack) dnl
cc44d54e 62_(cast128) _(cast256) dnl
2e8eb64a 63_(square) _(rijndael) _(rijndael192) _(rijndael256) dnl
0ba18b90 64_(serpent) _(noekeon)')
cc44d54e 65define(`cipher_modes', `_(ecb) _(cbc) _(cfb) _(ofb) _(counter)')
d03ab969 66
817d0432 67define(`hashes', `dnl
e9026a0a 68_(md5) _(md4) _(md2) _(tiger) _(has160) dnl
5b69c389 69_(sha) _(sha224) _(sha256) _(sha384) _(sha512) dnl
817d0432 70_(rmd128) _(rmd160) _(rmd256) _(rmd320)')
cc44d54e 71define(`hash_modes', `_(mgf) _(hmac)')
d03ab969 72
73MODES = \
74 adorn(`$(srcdir)/', join(`ciphers', `-', `cipher_modes'), `.c') \
75 adorn(`$(srcdir)/', join(`ciphers', `-', `cipher_modes'), `.h') \
76 adorn(`$(srcdir)/', join(`hashes', `-', `hash_modes'), `.c') \
77 adorn(`$(srcdir)/', join(`hashes', `-', `hash_modes'), `.h')
78
5a1a3a89 79$(MODES): modes-stamp
80modes-stamp: genmodes
a7557fb1 81 cd $(srcdir); ./genmodes "lit(`ciphers')" "lit(`cipher_modes')"
82 cd $(srcdir); ./genmodes "lit(`hashes')" "lit(`hash_modes')"
5a1a3a89 83 echo datestamp >modes-stamp
84
bc981076 85define(`gen_tables', `dnl
2e8eb64a 86_(des) _(blowfish) _(twofish) dnl
87_(square) _(rijndael) dnl
3bef8c14 88_(safer) _(mars) _(tiger) dnl
7c0acba6 89_(gfshare) _(gfx-sqr)')
a7557fb1 90
bc981076 91autoheaders: addsuffix(`gen_tables', `-tab.h') primetab.h mptypes.h
5a1a3a89 92define(`emit', `
93_item`'-tab.h: _item`'-mktab
f21119d7 94 ./_item`'-mktab >_item`'-tab.h.new
95 mv _item`'-tab.h.new _item`'-tab.h')dnl
bc981076 96gen_tables
5a1a3a89 97
98primetab.h: primetab.c
99primetab.c: genprimes
34e4f738 100 ./genprimes -h primetab.h -c primetab.c \
101 -s CATACOMB_PRIMETAB_H -n 256 \
3fe3eae5 102 -t "unsigned short" -i primetab
d03ab969 103archinclude_HEADERS = mptypes.h
d03ab969 104mptypes.h: mptypes
f21119d7 105 ./mptypes >mptypes.h.new
106 mv mptypes.h.new mptypes.h
d03ab969 107
4edc47b8 108ectab.c: ectab.in ec-gentab.awk mpdump
109 $(srcdir)/ec-gentab.awk <$(srcdir)/ectab.in >ectab.c.new
432c4e18 110 mv ectab.c.new ectab.c
111
4edc47b8 112ptab.c: ptab.in p-gentab.awk mpdump
113 $(srcdir)/p-gentab.awk <$(srcdir)/ptab.in >ptab.c.new
34e4f738 114 mv ptab.c.new ptab.c
115
3688eb75 116bintab.c: bintab.in bin-gentab.awk mpdump
117 $(srcdir)/bin-gentab.awk <$(srcdir)/bintab.in >bintab.c.new
118 mv bintab.c.new bintab.c
119
e9026a0a 120gciphertab.c: gengctab
121 $(srcdir)/gengctab gccipher gcipher >gciphertab.c.new \
122 "lit(join(`ciphers', `-', `cipher_modes')) \
b817bfc6 123 lit(join(`hashes', `-', `_(mgf)')) \
e9026a0a 124 rc4 seal"
125 mv gciphertab.c.new gciphertab.c
126
127gmactab.c: gengctab
128 $(srcdir)/gengctab gcmac gmac >gmactab.c.new \
129 "lit(join(`hashes', `-', `_(hmac)'))"
130 mv gmactab.c.new gmactab.c
131
132ghashtab.c: gengctab
133 $(srcdir)/gengctab gchash ghash >ghashtab.c.new \
b817bfc6 134 "lit(`hashes') \
135 crc32=gcrc32"
e9026a0a 136 mv ghashtab.c.new ghashtab.c
137
d03ab969 138BUILT_SOURCES = \
e9026a0a 139 getdate.c modes-stamp gciphertab.c gmactab.c ghashtab.c \
d03ab969 140 addsuffix(join(`ciphers', `-', `cipher_modes'), `.c') \
141 addsuffix(join(`ciphers', `-', `cipher_modes'), `.h') \
d03ab969 142 addsuffix(join(`hashes', `-', `hash_modes'), `.c') \
143 addsuffix(join(`hashes', `-', `hash_modes'), `.h')
ffc086db 144
145## --- Building the main library ---
8582bb3b 146
ffc086db 147lib_LTLIBRARIES = libcatacomb.la
148
dbfee00a 149libcatacomb_la_LDFLAGS = -version-info 3:0:1
d03ab969 150## Middle number is the patchlevel. Final number is the minor version. The
151## difference between the first and last numbers is major version.
152
d03ab969 153pkginclude_HEADERS = \
432c4e18 154 arena.h paranoia.h buf.h qdparse.h \
5a1a3a89 155 blkc.h hash.h gcipher.h ghash.h gmac.h grand.h ghash-def.h \
156 lcrand.h fibrand.h rc4.h seal.h rand.h noise.h fipstest.h maurer.h \
876b4f53 157 key.h key-data.h passphrase.h pixie.h lmem.h \
75263f25 158 mpx.h bitops.h mpw.h mpscan.h mparena.h mp.h mptext.h mpint.h \
f46efa79 159 exp.h mpbarrett.h mpmont.h mpreduce.h \
dbfee00a 160 mpcrt.h mprand.h mpmul.h \
4edc47b8 161 gfx.h gf.h gfreduce.h gfn.h \
9312c71f 162 primetab.h pfilt.h rabin.h \
f2ec324f 163 pgen.h prim.h strongprime.h limlee.h keycheck.h \
e9026a0a 164 bbs.h rsa.h dh.h dsarand.h dsa.h gdsa.h gkcdsa.h \
b817bfc6 165 tlsprf.h sslprf.h \
cc44d54e 166 gfshare.h share.h \
817d0432 167 rho.h \
f94b972d 168 field.h field-guts.h \
169 ec.h ec-guts.h ec-exp.h ec-test.h ectab.h ec-keys.h ec-raw.h \
170 ptab.h group.h group-guts.h \
d03ab969 171 allwithsuffix(`ciphers', `cipher_modes', `.h') \
bba24c1d 172 allwithsuffix(`hashes', `hash_modes', `.h') \
173 addsuffix(`cipher_modes', `-def.h') \
e7dc130f 174 addsuffix(`hash_modes', `-def.h') crc32.h
d03ab969 175
3fe3eae5 176define(`MP_SOURCES',
8ef0c733 177 `mpx.c mpx-kmul.c mpx-ksqr.c mpscan.c mparena.c qdparse.c \
a7557fb1 178 mp-misc.c mp-mem.c mp-const.c mp-io.c mp-arith.c mp-test.c \
338b4cd3 179 mp-sqrt.c mp-gcd.c mp-jacobi.c mp-modsqrt.c \
5a1a3a89 180 mpint.c mptext.c mptext-file.c mptext-string.c mptext-dstr.c \
0cbfe12e 181 mptext-len.c \
aacf9080 182 exp.c mpcrt.c mpmul.c mprand.c \
34e4f738 183 mpbarrett.c mpbarrett-exp.c mpbarrett-mexp.c mpbarrett-exp.h \
184 mpmont.c mpmont-exp.c mpmont-mexp.c mpmont-exp.h \
f46efa79 185 mpreduce.c mpreduce-exp.h \
3688eb75 186 group-stdops.c group-exp.c group-exp.h g-prime.c g-bin.c \
187 group-parse.c \
34e4f738 188 group-string.c group-file.c group-dstr.c \
3688eb75 189 rho.c buf.c ptab.c bintab.c \
dbfee00a 190 GF_SOURCES PGEN_SOURCES EC_SOURCES')
7c0acba6 191
192define(`GF_SOURCES',
f46efa79 193 `gfx.c gfx-kmul.c gfx-sqr.c gf-arith.c gf-gcd.c \
4edc47b8 194 gfreduce.c gfreduce-exp.h gfn.c')
3fe3eae5 195
dbfee00a 196define(`EC_SOURCES',
432c4e18 197 `field.c field-parse.c f-prime.c f-niceprime.c f-binpoly.c \
34e4f738 198 ec.c ec-exp.c ec-prime.c ec-bin.c ec-test.c ec-info.c ectab.c \
0f3faccd 199 ec-fetch.c ec-raw.c g-ec.c')
3fe3eae5 200
201define(`PGEN_SOURCES',
9312c71f 202 `pfilt.c rabin.c \
cc44d54e 203 pgen.c pgen-stdev.c pgen-safe.c pgen-gcd.c prim.c strongprime.c \
817d0432 204 limlee.c \
f2ec324f 205 keycheck.c keycheck-mp.c keycheck-report.c \
cc44d54e 206 bbs-rand.c bbs-gen.c bbs-jump.c bbs-fetch.c \
d3325040 207 rsa-priv.c rsa-pub.c rsa-gen.c rsa-recover.c rsa-fetch.c \
53cbeae3 208 oaep.c pkcs1.c pss.c \
34e4f738 209 dh-gen.c dh-limlee.c dh-check.c dh-fetch.c dh-param.c \
f2ec324f 210 dsarand.c dsa-sign.c dsa-verify.c dsa-gen.c dsa-check.c \
e9026a0a 211 gdsa.c gkcdsa.c \
ad47fc73 212 key-data.c key-flags.c key-text.c key-binary.c key-pass.c \
5a1a3a89 213 key-pack.c key-misc.c key-file.c key-attr.c key-io.c key-moan.c \
bc981076 214 key-error.c key-fetch.c \
3fe3eae5 215 primetab.c share.c')
216
217libcatacomb_la_SOURCES = \
218 grand.c keysz.c \
219 lcrand.c fibrand.c rc4.c seal.c rand.c noise.c fipstest.c maurer.c \
8ef0c733 220 arena.c \
3fe3eae5 221 passphrase.c pixie-client.c pixie-common.c lmem.c \
53cbeae3 222 tlsprf.c sslprf.c \
3fe3eae5 223 gfshare.c \
7c0acba6 224 MP_SOURCES karatsuba.h \
e9026a0a 225 gciphertab.c ghashtab.c gmactab.c \
3fe3eae5 226 des-base.c des-base.h \
0798f682 227 desx-tab.h \
a297c216 228 rc2-tab.h \
229 skipjack-tab.h \
3fe3eae5 230 cast-s.c cast-sk.c cast-base.h cast-tab.h \
2e8eb64a 231 rijndael-base.c rijndael-base.h \
abef5380 232 md2-tab.h \
3fe3eae5 233 serpent-sbox.h skipjack-tab.h tiger-base.h \
234 daftstory.h \
d03ab969 235 addsuffix(join(`ciphers', `-', `cipher_modes'), `.c') \
ce79f967 236 addsuffix(join(`hashes', `-', `hash_modes'), `.c') \
e7dc130f 237 addsuffix(`ciphers', `.c') addsuffix(`hashes', `.c') crc32.c
76f32ed2 238
cc44d54e 239des-base.lo: des-tab.h
240blowfish.lo: blowfish-tab.h
241twofish.lo: twofish-tab.h
a16cc8cf 242square.lo: square-tab.h
2e8eb64a 243rijndael-base.lo: rijndael-tab.h
244safer.lo: safer-tab.h
245mars.lo: mars-tab.h
a16cc8cf 246tiger.lo: tiger-tab.h
5a1a3a89 247gfshare.lo: gfshare-tab.h
7c0acba6 248gfx-sqr.lo: gfx-sqr-tab.h
748ed8dc 249
d03ab969 250## --- Utility programs ---
a7557fb1 251
e2edda68 252bin_PROGRAMS = \
c65df279 253 dsig key pixie cookie rspit factorial hashsum mkphrase catcrypt
254noinst_LIBRARIES = libcatcrypt.a
de5585f8 255bin_SCRIPTS = catacomb-config xpixie
cc44d54e 256noinst_PROGRAMS = \
432c4e18 257 genprimes mptypes serpent-check bittest mpdump \
e2edda68 258 perftest \
7c0acba6 259 addsuffix(`gen_tables', `-mktab')
c65df279 260LDADD = libcatacomb.la libcatcrypt.a
261
4b09da23 262define(`LIBCAT_SRC', `cc.h getdate.h dnl
263 cc-sig.c cc-subcmd.c cc-enc.c cc-kem.c cc-list.c')
264libcatcrypt_a_SOURCES = LIBCAT_SRC getdate.y
265
266patsubst(MP_SOURCES, `\.c\>', `.lo') dsig.o keyutil.o rspit.o \
267 patsubst(LIBCAT_SRC, `\.c\>', `.o'): \
268 mptypes.h primetab.h
c65df279 269
270dsig_SOURCES = dsig.c
271cookie_SOURCES = cookie.c
272catcrypt_SOURCES = catcrypt.c
273key_SOURCES = keyutil.c
a16cc8cf 274hashsum_SOURCES = hashsum.c
bba24c1d 275rspit_SOURCES = rspit.c
817d0432 276factorial_SOURCES = factorial.c
e2edda68 277perftest_SOURCES = perftest.c
a16cc8cf 278pixie_SOURCES = pixie.c pixie-common.c lmem.c arena.c
279pixie_LDADD =
b55540f6 280mkphrase_SOURCES = mkphrase.c
75263f25 281bittest_SOURCES = bittest.c
282bittest_LDADD =
817d0432 283
7c0acba6 284define(`emit', `
285patsubst(_item, `[^a-zA-Z0-9]', `_')_mktab_SOURCES = _item`'-mktab.c
286patsubst(_item, `[^a-zA-Z0-9]', `_')_mktab_LDADD =')dnl
287gen_tables
288
cc44d54e 289serpent_check_SOURCES = serpent-check.c
290serpent_check_LDADD =
cc44d54e 291
d03ab969 292genprimes_SOURCES = genprimes.c
293genprimes_LDADD =
294
295mptypes_SOURCES = mptypes.c
296mptypes_LDADD =
297
432c4e18 298mpdump_SOURCES = \
299 mpdump.c \
300 mpx.c mpx-kmul.c mpx-ksqr.c mpscan.c mparena.c \
301 mp-misc.c mp-mem.c mp-const.c mp-arith.c mp-io.c \
302 mptext.c mptext-string.c
303mpdump_LDADD =
304
de5585f8 305## --- Install the pixie setuid-root if we can ---
525af7b8 306##
307## Bodge around a bug in Automake: it doesn't call `install-exec-hook' from
308## `install' if there are subdirectories.
de5585f8 309
310changequote(<, >)
525af7b8 311install: install-exec-hook
de5585f8 312install-exec-hook:
0798f682 313 @pixie="$(DESTDIR)$(bindir)/`echo pixie|sed $(transform)`"; \
de5585f8 314 if chown root $$pixie && chmod 4755 $$pixie; then \
315 echo "chown root $$pixie"; \
316 echo "chmod 4755 $$pixie"; \
317 else \
318 echo "***"; \
319 echo "*** You should probably install $$pixie setuid-root."; \
320 echo "***"; \
321 fi
322changequote(`, ')
323
d03ab969 324## --- Documentation ---
325
c65df279 326man_MANS = key.1 dsig.1 cookie.1 catcrypt.1 hashsum.1 keyring.5 pixie.1
d03ab969 327
328## --- Other handy definitions ---
9183ab7b 329
6f51228e 330EXTRA_DIST = \
b817bfc6 331 Makefile.m4 genmodes gengctab $(man_MANS) xpixie \
332 group-test.c rsa-test.c \
3688eb75 333 ectab.in ec-gentab.awk ptab.in p-gentab.awk bin-gentab.awk \
2ee993fe 334 README.cipher README.hash README.random README.mp \
335 debian/rules debian/copyright debian/control debian/changelog \
336 debian/catacomb-bin.postinst debian/catacomb-bin.config \
337 debian/catacomb-bin.prerm debian/catacomb-bin.templates
d03ab969 338
339dist-hook:
e9026a0a 340 @for i in getdate.c gciphertab.c ghashtab.c gmactab.c; do \
341 ln $$i $(distdir) || ln $(srcdir)/$$i $(distdir) || true; \
342 done
5a1a3a89 343 @echo datestamp >$(distdir)/modes-stamp || true
7c0acba6 344 @for i in calc tests; do \
345 mkdir $(distdir)/$$i; \
346 ln $(srcdir)/$$i/*[!~] $(distdir)/$$i; \
347 done || true
cc44d54e 348# kr=$$HOME/.catacomb/dsig-keyring; \
349# if [ -r $$kr ]; then \
350# cd $(distdir); \
351# ../key -k $$kr extract -f -secret KEYRING; \
352# find . -type f -print0 | ../dsig -k $$kr sign -0 -oMANIFEST; \
353# fi
471db039 354
a094cab7 355## --- Testing ---
d03ab969 356
471db039 357define(`testprogs', `')
358
359define(`CTESTRIG',
ffc086db 360`define(`testprogs', testprogs \
d03ab969 361 $1.t)dnl
8b6cedcc 362$1.to: $1.c
363 $(COMPILE) -c -DTEST_RIG -DSRCDIR=\"$(srcdir)\" $(srcdir)/$1.c -o $1.to
34e4f738 364$1.t: $1.to libcatacomb.la
b6f2c5a0 365 $(CC) $(CFLAGS) $(LDFLAGS) $1.to .libs/libcatacomb.a $(LIBS) -o $1.t')
a7557fb1 366
367CTESTRIG(rc4)
cc44d54e 368CTESTRIG(seal)
a7557fb1 369adorn(`nl`'CTESTRIG(', `ciphers', `)')
ce79f967 370adorn(`nl`'CTESTRIG(', `hashes', `)')
471db039 371adorn(`nl`'CTESTRIG(', join(`ciphers', `-', `cipher_modes'), `)')
372adorn(`nl`'CTESTRIG(', join(`hashes', `-', `hash_modes'), `)')
bba24c1d 373CTESTRIG(lcrand)
d83a82be 374CTESTRIG(tlsprf)
51a0f805 375CTESTRIG(sslprf)
471db039 376CTESTRIG(mpx)
bba24c1d 377CTESTRIG(mpx-kmul)
b6f2c5a0 378CTESTRIG(mpx-ksqr)
a7557fb1 379CTESTRIG(mp-arith)
1cf8e9fb 380CTESTRIG(mp-modsqrt)
a7557fb1 381CTESTRIG(mp-gcd)
9fc256e8 382CTESTRIG(mp-jacobi)
1cf8e9fb 383CTESTRIG(mp-sqrt)
bba24c1d 384CTESTRIG(mptext)
70b904c5 385CTESTRIG(mpint)
bba24c1d 386CTESTRIG(mpbarrett)
34e4f738 387CTESTRIG(mpbarrett-exp)
aacf9080 388CTESTRIG(mpbarrett-mexp)
a7557fb1 389CTESTRIG(mpmont)
34e4f738 390CTESTRIG(mpmont-exp)
a7557fb1 391CTESTRIG(mpmont-mexp)
f46efa79 392CTESTRIG(mpreduce)
9fc256e8 393CTESTRIG(mpcrt)
817d0432 394CTESTRIG(mpmul)
b817bfc6 395CTESTRIG(rsa-test)
7c0acba6 396CTESTRIG(gfx)
ceb3f0c0 397CTESTRIG(gfx-sqr)
7c0acba6 398CTESTRIG(gfx-kmul)
ceb3f0c0 399CTESTRIG(gf-arith)
400CTESTRIG(gf-gcd)
401CTESTRIG(gfreduce)
4edc47b8 402CTESTRIG(gfn)
dbfee00a 403CTESTRIG(ec-prime)
ceb3f0c0 404CTESTRIG(ec-bin)
bc985cef 405CTESTRIG(ec-test)
fb83f882 406CTESTRIG(ec-info)
34e4f738 407CTESTRIG(dh-param)
408CTESTRIG(group-test)
e9026a0a 409CTESTRIG(gdsa)
410CTESTRIG(gkcdsa)
a7557fb1 411CTESTRIG(pgen)
471db039 412CTESTRIG(dsa-gen)
413CTESTRIG(dsa-sign)
d03ab969 414CTESTRIG(dsa-verify)
bba24c1d 415CTESTRIG(bbs-rand)
416CTESTRIG(bbs-jump)
cc44d54e 417CTESTRIG(gfshare)
418CTESTRIG(share)
817d0432 419CTESTRIG(rho)
a7557fb1 420
75263f25 421TESTS = serpent-check bittest testprogs
d03ab969 422
cc44d54e 423CLEANFILES = \
424 *.t *.to \
ba17f3e5 425 mptypes.h primetab.c primetab.h ectab.c \
bc981076 426 addsuffix(`gen_tables', `-tab.h')
d03ab969 427
428## --- Makefile building (haha!) ---
429
430$(srcdir)/Makefile.am: $(srcdir)/Makefile.m4
f21119d7 431 m4 $(srcdir)/Makefile.m4 >$(srcdir)/Makefile.am.new
432 mv $(srcdir)/Makefile.am.new $(srcdir)/Makefile.am
a7557fb1 433
9312c71f 434DISTCLEANFILES = libtool
435
a7557fb1 436MAINTAINERCLEANFILES = \
d03ab969 437 $(srcdir)/Makefile.am \
438 $(srcdir)/getdate.c getdate.c \
5a1a3a89 439 $(MODES) modes-stamp $(srcdir)/modes-stamp
d03ab969 440
441##----- That's all, folks ---------------------------------------------------