chiark / gitweb /
modexp: Implement simple mp_modexp function.
[catacomb] / Makefile.m4
1 ## -*-m4-*-
2 ##
3 ## $Id$
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
29 AUTOMAKE_OPTIONS = foreign
30
31 SUBDIRS = tests
32
33 archincludedir = $(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
40 define(`_', `define(`_item', $1)define(`_item_2', $2)emit`'')
41 define(`adorn', `pushdef(`emit', `$1`'_item`'$3')$2`'popdef(`emit')')
42 define(`join',
43 `pushdef(`emit', `adorn(``_(''_item`$2', `$3', ``)'')`'')$1`'popdef(`emit')')
44 define(`addsuffix', `adorn(`', `$1', `$2')')
45 define(`lit', `adorn(`', `$1', `')')
46 define(`nl', `
47 ')
48
49 define(`allwithsuffix',
50 `addsuffix(`$1', `$3') addsuffix(`$2', `$3') dnl
51 addsuffix(join(`$1', `-', `$2'), `$3')')
52
53 ## --- Autogenerated source files ---
54
55 define(`ciphers', `dnl
56 _(des) _(desx) _(des3) _(mars) dnl
57 _(idea) _(safer) _(safersk) dnl
58 _(blowfish) _(twofish) dnl
59 _(tea) _(xtea) dnl
60 _(rc2) _(rc5) dnl
61 _(skipjack) dnl
62 _(cast128) _(cast256) dnl
63 _(square) _(rijndael) _(rijndael192) _(rijndael256) dnl
64 _(serpent) _(noekeon)')
65 define(`cipher_modes', `_(ecb) _(cbc) _(cfb) _(ofb) _(counter)')
66
67 define(`hashes', `dnl
68 _(md5) _(md4) _(md2) _(tiger) _(has160) dnl
69 _(sha) _(sha224) _(sha256) _(sha384) _(sha512) dnl
70 _(whirlpool) _(whirlpool256) dnl
71 _(rmd128) _(rmd160) _(rmd256) _(rmd320)')
72 define(`hash_modes', `_(mgf) _(hmac)')
73
74 MODES = \
75         adorn(`$(srcdir)/', join(`ciphers', `-', `cipher_modes'), `.c') \
76         adorn(`$(srcdir)/', join(`ciphers', `-', `cipher_modes'), `.h') \
77         adorn(`$(srcdir)/', join(`hashes', `-', `hash_modes'), `.c') \
78         adorn(`$(srcdir)/', join(`hashes', `-', `hash_modes'), `.h')
79
80 $(MODES): modes-stamp
81 modes-stamp: genmodes
82         cd $(srcdir); ./genmodes "lit(`ciphers')" "lit(`cipher_modes')"
83         cd $(srcdir); ./genmodes "lit(`hashes')" "lit(`hash_modes')"
84         echo datestamp >modes-stamp
85
86 define(`gen_tables', `dnl
87 _(des) _(blowfish) _(twofish) dnl
88 _(square) _(rijndael) _(whirlpool) dnl
89 _(safer) _(mars) _(tiger) dnl
90 _(gfshare) _(gfx-sqr)')
91
92 autoheaders: \
93   addsuffix(`gen_tables', `-tab.h') primetab.h mptypes.h mplimits.h
94 define(`emit', `
95 _item`'-tab.h: _item`'-mktab$(EXEEXT)
96         ./_item`'-mktab >_item`'-tab.h.new
97         mv _item`'-tab.h.new _item`'-tab.h')dnl
98 gen_tables
99
100 primetab.h: primetab.c
101 primetab.c: genprimes$(EXEEXT)
102         ./genprimes -h primetab.h -c primetab.c \
103                 -s CATACOMB_PRIMETAB_H -n 256 \
104                 -t "unsigned short" -i primetab
105 archinclude_HEADERS = mptypes.h mplimits.h
106 mptypes.h: mptypes$(EXEEXT)
107         ./mptypes >mptypes.h.new
108         mv mptypes.h.new mptypes.h
109
110 mplimits.h: genlimits$(EXEEXT)
111         ./genlimits h >mplimits.h.new
112         mv mplimits.h.new mplimits.h
113 mplimits.c: genlimits$(EXEEXT)
114         ./genlimits c >mplimits.c.new
115         mv mplimits.c.new mplimits.c
116
117 ectab.c: ectab.in ec-gentab.awk mpdump$(EXEEXT)
118         $(srcdir)/ec-gentab.awk <$(srcdir)/ectab.in >ectab.c.new
119         mv ectab.c.new ectab.c
120
121 ptab.c: ptab.in p-gentab.awk mpdump$(EXEEXT)
122         $(srcdir)/p-gentab.awk <$(srcdir)/ptab.in >ptab.c.new
123         mv ptab.c.new ptab.c
124
125 bintab.c: bintab.in bin-gentab.awk mpdump$(EXEEXT)
126         $(srcdir)/bin-gentab.awk <$(srcdir)/bintab.in >bintab.c.new
127         mv bintab.c.new bintab.c
128
129 gciphertab.c: gengctab
130         $(srcdir)/gengctab gccipher gcipher >gciphertab.c.new \
131                 "lit(join(`ciphers', `-', `cipher_modes')) \
132                 lit(join(`hashes', `-', `_(mgf)')) \
133                 rc4 seal" 
134         mv gciphertab.c.new gciphertab.c
135
136 gmactab.c: gengctab
137         $(srcdir)/gengctab gcmac gmac >gmactab.c.new \
138                 "lit(join(`hashes', `-', `_(hmac)'))" 
139         mv gmactab.c.new gmactab.c
140
141 ghashtab.c: gengctab
142         $(srcdir)/gengctab gchash ghash >ghashtab.c.new \
143                 "lit(`hashes') \
144                 crc32=gcrc32"
145         mv ghashtab.c.new ghashtab.c
146
147 BUILT_SOURCES = \
148         getdate.c modes-stamp gciphertab.c gmactab.c ghashtab.c \
149         addsuffix(join(`ciphers', `-', `cipher_modes'), `.c') \
150         addsuffix(join(`ciphers', `-', `cipher_modes'), `.h') \
151         addsuffix(join(`hashes', `-', `hash_modes'), `.c') \
152         addsuffix(join(`hashes', `-', `hash_modes'), `.h')
153
154 ## --- Building the main library ---
155
156 lib_LTLIBRARIES = libcatacomb.la
157
158 libcatacomb_la_LDFLAGS = -version-info 3:0:1
159 ## Middle number is the patchlevel.  Final number is the minor version.  The
160 ## difference between the first and last numbers is major version.
161
162 pkginclude_HEADERS = \
163         arena.h paranoia.h buf.h qdparse.h \
164         blkc.h hash.h gcipher.h ghash.h gmac.h grand.h ghash-def.h \
165         lcrand.h fibrand.h rc4.h seal.h rand.h noise.h fipstest.h maurer.h \
166         key.h key-error.h key-data.h passphrase.h pixie.h lmem.h \
167         mpx.h bitops.h mpw.h mpscan.h mparena.h mp.h mptext.h mpint.h \
168         exp.h mpbarrett.h mpmont.h mpreduce.h mp-exp.h \
169         mpcrt.h mprand.h mpmul.h \
170         gfx.h gf.h gfreduce.h gfn.h gf-exp.h \
171         primetab.h pfilt.h rabin.h \
172         pgen.h prim.h strongprime.h limlee.h keycheck.h \
173         bbs.h rsa.h dh.h dsarand.h dsa.h gdsa.h gkcdsa.h \
174         tlsprf.h sslprf.h \
175         gfshare.h share.h \
176         rho.h \
177         field.h field-guts.h field-exp.h \
178         ec.h ec-guts.h ec-exp.h ec-test.h ectab.h ec-keys.h ec-raw.h \
179         ptab.h bintab.h group.h group-guts.h \
180         allwithsuffix(`ciphers', `cipher_modes', `.h') \
181         allwithsuffix(`hashes', `hash_modes', `.h') \
182         addsuffix(`cipher_modes', `-def.h') \
183         addsuffix(`hash_modes', `-def.h') crc32.h
184
185 define(`MP_BASE',
186         `mpx.c mpx-kmul.c mpx-ksqr.c mpscan.c mparena.c \
187         mp-misc.c mp-mem.c mp-const.c mp-arith.c mp-io.c \
188         mptext.c mptext-string.c')
189
190 define(`MP_SOURCES',
191         `qdparse.c \
192         mp-test.c mplimits.c \
193         mp-sqrt.c mp-gcd.c mp-jacobi.c mp-modsqrt.c mp-exp.c mp-modexp.c \
194         mpint.c mptext-file.c mptext-dstr.c \
195         mptext-len.c \
196         exp.c mpcrt.c mpmul.c mprand.c \
197         mpbarrett.c mpbarrett-exp.c mpbarrett-mexp.c mpbarrett-exp.h \
198         mpmont.c mpmont-exp.c mpmont-mexp.c mpmont-exp.h \
199         mpreduce.c mpreduce-exp.h \
200         group-stdops.c group-exp.c group-exp.h g-prime.c g-bin.c \
201           group-parse.c \
202         group-string.c group-file.c group-dstr.c \
203         rho.c buf.c ptab.c bintab.c \
204         GF_SOURCES PGEN_SOURCES EC_SOURCES')
205
206 define(`GF_SOURCES',
207         `gfx.c gfx-kmul.c gfx-sqr.c gf-arith.c gf-exp.c gf-gcd.c \
208         gfreduce.c gfreduce-exp.h gfn.c')
209
210 define(`EC_SOURCES',
211         `field.c field-parse.c field-exp.c \
212         f-prime.c f-niceprime.c f-binpoly.c \
213         ec.c ec-exp.c ec-prime.c ec-bin.c ec-test.c ec-info.c ectab.c \
214         ec-fetch.c ec-raw.c g-ec.c')
215
216 define(`PGEN_SOURCES',
217         `pfilt.c rabin.c \
218         pgen.c pgen-stdev.c pgen-gcd.c pgen-simul.c \
219           prim.c strongprime.c limlee.c \
220         keycheck.c keycheck-mp.c keycheck-report.c \
221         bbs-rand.c bbs-gen.c bbs-jump.c bbs-fetch.c \
222         rsa-priv.c rsa-pub.c rsa-gen.c rsa-recover.c rsa-fetch.c \
223         oaep.c pkcs1.c pss.c \
224         dh-gen.c dh-limlee.c dh-kcdsa.c dh-check.c dh-fetch.c dh-param.c \
225         dsarand.c dsa-sign.c dsa-verify.c dsa-gen.c dsa-check.c \
226         gdsa.c gkcdsa.c \
227         key-data.c key-flags.c key-text.c key-binary.c key-pass.c \
228         key-pack.c key-misc.c key-file.c key-attr.c key-io.c key-moan.c \
229         key-error.c key-fetch.c \
230         primetab.c share.c')
231
232 libcatacomb_la_SOURCES = \
233         grand.c keysz.c \
234         lcrand.c fibrand.c rc4.c seal.c rand.c noise.c fipstest.c maurer.c \
235         arena.c \
236         passphrase.c pixie-common.c lmem.c \
237         tlsprf.c sslprf.c \
238         gfshare.c \
239         MP_BASE MP_SOURCES karatsuba.h \
240         gciphertab.c ghashtab.c gmactab.c \
241         des-base.c des-base.h \
242         desx-tab.h \
243         rc2-tab.h \
244         skipjack-tab.h \
245         cast-s.c cast-sk.c cast-base.h cast-tab.h \
246         rijndael-base.c rijndael-base.h \
247         md2-tab.h \
248         serpent-sbox.h skipjack-tab.h tiger-base.h \
249         daftstory.h \
250         addsuffix(join(`ciphers', `-', `cipher_modes'), `.c') \
251         addsuffix(join(`hashes', `-', `hash_modes'), `.c') \
252         addsuffix(`ciphers', `.c') addsuffix(`hashes', `.c') crc32.c
253
254 des-base.lo: des-tab.h
255 blowfish.lo: blowfish-tab.h
256 twofish.lo: twofish-tab.h
257 square.lo: square-tab.h
258 rijndael-base.lo: rijndael-tab.h
259 whirlpool.lo: whirlpool-tab.h
260 safer.lo: safer-tab.h
261 mars.lo: mars-tab.h
262 tiger.lo: tiger-tab.h
263 gfshare.lo: gfshare-tab.h
264 gfx-sqr.lo: gfx-sqr-tab.h
265
266 ## --- Utility programs ---
267
268 bin_PROGRAMS = \
269         dsig key pixie cookie rspit factorial hashsum mkphrase \
270         catcrypt catsign
271 noinst_LIBRARIES = libcatcrypt.a
272 bin_SCRIPTS = catacomb-config xpixie
273 noinst_PROGRAMS = \
274         genprimes mptypes genlimits serpent-check bittest mpdump \
275         perftest \
276         addsuffix(`gen_tables', `-mktab')
277 LDADD = libcatcrypt.a libcatacomb.la
278
279 define(`LIBCAT_SRC', `cc.h getdate.h dnl
280         cc-sig.c cc-subcmd.c cc-enc.c cc-kem.c cc-list.c')
281 libcatcrypt_a_SOURCES = LIBCAT_SRC getdate.y
282
283 patsubst(MP_BASE MP_SOURCES, `\.c\>', `.lo') dsig.o keyutil.o rspit.o \
284         patsubst(LIBCAT_SRC, `\.c\>', `.o'): \
285         mptypes.h primetab.h
286 patsubst(MP_SOURCES, `\.c\>', `.lo'): mplimits.h
287         
288 dsig_SOURCES = dsig.c
289 cookie_SOURCES = cookie.c
290 catcrypt_SOURCES = catcrypt.c
291 catsign_SOURCES = catsign.c
292 key_SOURCES = keyutil.c
293 hashsum_SOURCES = hashsum.c
294 rspit_SOURCES = rspit.c
295 factorial_SOURCES = factorial.c
296 perftest_SOURCES = perftest.c
297 pixie_SOURCES = pixie.c pixie-common.c lmem.c arena.c passphrase.c
298 pixie_LDADD =
299 pixie_CFLAGS = $(AM_CFLAGS)
300 mkphrase_SOURCES = mkphrase.c
301 bittest_SOURCES = bittest.c
302 bittest_LDADD = 
303
304 define(`emit', `
305 patsubst(_item, `[^a-zA-Z0-9]', `_')_mktab_SOURCES = _item`'-mktab.c
306 patsubst(_item, `[^a-zA-Z0-9]', `_')_mktab_LDADD =')dnl
307 gen_tables
308
309 serpent_check_SOURCES = serpent-check.c
310 serpent_check_LDADD =
311
312 genprimes_SOURCES = genprimes.c
313 genprimes_LDADD =
314
315 mptypes_SOURCES = mptypes.c
316 mptypes_LDADD =
317
318 genlimits_SOURCES = genlimits.c MP_BASE
319 genlimits_LDADD =
320 genlimits_CFLAGS = $(AM_CFLAGS)
321
322 mpdump_SOURCES = mpdump.c MP_BASE
323 mpdump_LDADD =
324 mpdump_CFLAGS = $(AM_CFLAGS)
325
326 ## --- Install the pixie setuid-root if we can ---
327 ##
328 ## Bodge around a bug in Automake: it doesn't call `install-exec-hook' from
329 ## `install' if there are subdirectories.
330
331 changequote(<, >)
332 # install: install-exec-hook
333 install-exec-hook:
334         @pixie="$(DESTDIR)$(bindir)/`echo pixie|sed $(transform)`"; \
335         if chown root $$pixie && chmod 4755 $$pixie; then \
336           echo "chown root $$pixie"; \
337           echo "chmod 4755 $$pixie"; \
338         else \
339           echo "***"; \
340           echo "*** You should probably install $$pixie setuid-root."; \
341           echo "***"; \
342         fi
343 changequote(`, ')
344
345 ## --- Documentation ---
346
347 man_MANS = \
348         key.1 dsig.1 cookie.1 catcrypt.1 catsign.1 hashsum.1 mkphrase.1 \
349         keyring.5 pixie.1
350
351 ## --- Prime group keyring ---
352
353 pkgdata_DATA = pgroups.kr
354
355 $(srcdir)/pgroups.kr: ptab.in mkpgroups
356         cd $(srcdir) && rm -f pgroups.kr && ./mkpgroups <ptab.in
357
358 ## --- Other handy definitions ---
359
360 EXTRA_DIST = \
361         Makefile.m4 genmodes gengctab $(man_MANS) xpixie \
362         group-test.c rsa-test.c \
363         ectab.in ec-gentab.awk \
364         ptab.in p-gentab.awk mkpgroups pgroups.kr \
365         bintab.in bin-gentab.awk \
366         README.cipher README.hash README.random README.mp \
367         debian/rules debian/copyright debian/control debian/changelog \
368         debian/catacomb-bin.postinst debian/catacomb-bin.config \
369         debian/catacomb-bin.prerm debian/catacomb-bin.templates
370
371 dist-hook:
372         @for i in getdate.c gciphertab.c ghashtab.c gmactab.c; do \
373           ln $$i $(distdir) || ln $(srcdir)/$$i $(distdir) || true; \
374         done
375         @echo datestamp >$(distdir)/modes-stamp || true
376         @for i in calc tests; do \
377           mkdir $(distdir)/$$i; \
378           ln $(srcdir)/$$i/*[!~] $(distdir)/$$i; \
379         done || true
380 #       kr=$$HOME/.catacomb/dsig-keyring; \
381 #       if [ -r $$kr ]; then \
382 #         cd $(distdir); \
383 #         ../key -k $$kr extract -f -secret KEYRING; \
384 #         find . -type f -print0 | ../dsig -k $$kr sign -0 -oMANIFEST; \
385 #       fi
386
387 ## --- Testing ---
388
389 define(`testprogs', `')
390
391 define(`CTESTRIG',
392 `define(`testprogs', testprogs \
393         $1.t$(EXEEXT))dnl
394 $1.to: $1.c
395         $(COMPILE) -c -DTEST_RIG -DSRCDIR=\"$(srcdir)\" $(srcdir)/$1.c -o $1.to
396 $1.t$(EXEEXT): $1.to libcatacomb.la
397         $(CC) $(CFLAGS) $(LDFLAGS) $1.to .libs/libcatacomb.a $(LIBS) -o $1.t$(EXEEXT)')
398
399 CTESTRIG(rc4)
400 CTESTRIG(seal)
401 adorn(`nl`'CTESTRIG(', `ciphers', `)')
402 adorn(`nl`'CTESTRIG(', `hashes', `)')
403 adorn(`nl`'CTESTRIG(', join(`ciphers', `-', `cipher_modes'), `)')
404 adorn(`nl`'CTESTRIG(', join(`hashes', `-', `hash_modes'), `)')
405 CTESTRIG(lcrand)
406 CTESTRIG(tlsprf)
407 CTESTRIG(sslprf)
408 CTESTRIG(mpx)
409 CTESTRIG(mpx-kmul)
410 CTESTRIG(mpx-ksqr)
411 CTESTRIG(mp-arith)
412 CTESTRIG(mp-modsqrt)
413 CTESTRIG(mp-gcd)
414 CTESTRIG(mp-jacobi)
415 CTESTRIG(mp-sqrt)
416 CTESTRIG(mp-modexp)
417 CTESTRIG(mptext)
418 CTESTRIG(mpint)
419 CTESTRIG(mpbarrett)
420 CTESTRIG(mpbarrett-exp)
421 CTESTRIG(mpbarrett-mexp)
422 CTESTRIG(mpmont)
423 CTESTRIG(mpmont-exp)
424 CTESTRIG(mpmont-mexp)
425 CTESTRIG(mpreduce)
426 CTESTRIG(mpcrt)
427 CTESTRIG(mpmul)
428 CTESTRIG(rsa-test)
429 CTESTRIG(gfx)
430 CTESTRIG(gfx-sqr)
431 CTESTRIG(gfx-kmul)
432 CTESTRIG(gf-arith)
433 CTESTRIG(gf-gcd)
434 CTESTRIG(gfreduce)
435 CTESTRIG(gfn)
436 CTESTRIG(ec-prime)
437 CTESTRIG(ec-bin)
438 CTESTRIG(ec-test)
439 CTESTRIG(ec-info)
440 CTESTRIG(dh-param)
441 CTESTRIG(group-test)
442 CTESTRIG(gdsa)
443 CTESTRIG(gkcdsa)
444 CTESTRIG(pgen)
445 CTESTRIG(dsa-gen)
446 CTESTRIG(dsa-sign)
447 CTESTRIG(dsa-verify)
448 CTESTRIG(bbs-rand)
449 CTESTRIG(bbs-jump)
450 CTESTRIG(gfshare)
451 CTESTRIG(share)
452 CTESTRIG(rho)
453
454 TESTS = serpent-check bittest testprogs
455
456 CLEANFILES = \
457         *.t$(EXEEXT) *.to *.kr.old \
458         mptypes.h primetab.c primetab.h ectab.c ptab.c bintab.c \
459         addsuffix(`gen_tables', `-tab.h')
460
461 ## --- Makefile building (haha!) ---
462
463 $(srcdir)/Makefile.am: $(srcdir)/Makefile.m4
464         m4 $(srcdir)/Makefile.m4 >$(srcdir)/Makefile.am.new
465         mv $(srcdir)/Makefile.am.new $(srcdir)/Makefile.am
466
467 DISTCLEANFILES = libtool
468
469 MAINTAINERCLEANFILES = \
470         $(srcdir)/Makefile.am \
471         $(srcdir)/getdate.c getdate.c \
472         $(srcdir)/pgroups.kr \
473         $(MODES) modes-stamp $(srcdir)/modes-stamp
474
475 ##----- That's all, folks ---------------------------------------------------