9c2895b99a8c2a1e24b953471c19589d567d5137
[u/mdw/catacomb] / symm / Makefile.am
1 ### -*-makefile-*-
2 ###
3 ### Build script for symmetric cryptography
4 ###
5 ### (c) 2013 Straylight/Edgeware
6 ###
7
8 ###----- Licensing notice ---------------------------------------------------
9 ###
10 ### This file is part of Catacomb.
11 ###
12 ### Catacomb is free software; you can redistribute it and/or modify
13 ### it under the terms of the GNU Library General Public License as
14 ### published by the Free Software Foundation; either version 2 of the
15 ### License, or (at your option) any later version.
16 ###
17 ### Catacomb is distributed in the hope that it will be useful,
18 ### but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ### GNU Library General Public License for more details.
21 ###
22 ### You should have received a copy of the GNU Library General Public
23 ### License along with Catacomb; if not, write to the Free
24 ### Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 ### MA 02111-1307, USA.
26
27 include $(top_srcdir)/vars.am
28
29 noinst_LTLIBRARIES = libsymm.la
30 libsymm_la_SOURCES =
31 nodist_libsymm_la_SOURCES =
32
33 TEST_LIBS = libsymm.la
34
35 VPATH += modes
36
37 ###--------------------------------------------------------------------------
38 ### Autogenerated lists.
39
40 ## Fancy template substitutions.
41 multigen = $(PYTHON) $(srcdir)/multigen
42 EXTRA_DIST += multigen
43
44 ## The heart of this is an enormous cross-product of crypto primitives and
45 ## the corresponding modes of operation. Rather than write it out longhand,
46 ## we generate it using `multigen'. Unfortunately, this needs to be done
47 ## at the Automake level, which causes some interesting bootstrapping
48 ## problems.
49 include modes.am
50
51 EXTRA_DIST += modes.am.in modes.am
52 MAINTAINERCLEANFILES += $(srcdir)/modes.am
53
54 ## Generate the lists.
55 $(srcdir)/modes.am: modes.am.in
56 $(AM_V_GEN)$(multigen) -g $(srcdir)/modes.am.in $(srcdir)/modes.am \
57 blkc="$(BLKCS)" \
58 blkcmode="$(BLKCMODES)" \
59 blkcciphermode="$(BLKCCIPHERMODES)" \
60 hash="$(HASHES)" \
61 hashmode="$(HASHMODES)" \
62 hashciphermode="$(HASHCIPHERMODES)" \
63 hashmacmode="$(HASHMACMODES)"
64
65 ## Initialize lists of known classes.
66 ALL_CIPHERS = $(CIPHER_MODES)
67 ALL_HASHES = $(HASHES)
68 ALL_MACS = $(MAC_MODES)
69
70 ###--------------------------------------------------------------------------
71 ### Block ciphers.
72
73 BLKCS =
74 BLKCMODES =
75
76 BLKCCIPHERMODES =
77 BLKCMODES += $(BLKCCIPHERMODES)
78
79 ## A tool for translating the AES-contest test vectors into a form our test
80 ## rigs understand.
81 EXTRA_DIST += aes-trans
82
83 ## Block cipher utility macros, mainly used in mode implementations.
84 pkginclude_HEADERS += blkc.h
85
86 ## Source code and headers for the block ciphers.
87 libsymm_la_SOURCES += $(BLKC_C)
88 pkginclude_HEADERS += $(BLKC_H)
89
90 ## Schneier's `Blowfish' block cipher.
91 BLKCS += blowfish
92 blowfish.lo: blowfish-tab.h
93 CLEANFILES += blowfish-tab.h
94 noinst_PROGRAMS += blowfish-mktab
95 blowfish_mktab_CPPFLAGS = $(AM_CPPFLAGS) -DQUIET
96 blowfish-tab.h: blowfish-mktab$e
97 $(AM_V_GEN)./blowfish-mktab >blowfish-tab.h.new && \
98 mv blowfish-tab.h.new blowfish-tab.h
99
100 ## Adams and Tavares' `CAST' block ciphers.
101 BLKCS += cast128 cast256
102 libsymm_la_SOURCES += cast-s.c cast-sk.c cast-base.h cast-tab.h
103 cast256.$t: t/cast256
104 EXTRA_DIST += t/cast256.aes
105 MAINTAINERCLEANFILES += $(srcdir)/t/cast256
106 t/cast256: t/cast256.aes
107 $(AM_V_GEN)$(srcdir)/aes-trans CAST256 \
108 <$(srcdir)/t/cast256.aes \
109 >$(srcdir)/t/cast256.new && \
110 mv $(srcdir)/t/cast256.new $(srcdir)/t/cast256
111
112 ## IBM's `DES' block cipher, by Feistel, Coppersmith, and others.
113 BLKCS += des des3
114 libsymm_la_SOURCES += des-base.h des-base.c desx-tab.h
115 des-base.lo: des-tab.h
116 CLEANFILES += des-tab.h
117 noinst_PROGRAMS += des-mktab
118 des-tab.h: des-mktab$e
119 $(AM_V_GEN)./des-mktab >des-tab.h.new && \
120 mv des-tab.h.new des-tab.h
121
122 ## Rivest's `DESX' variant, with pre- and post-whitening.
123 BLKCS += desx
124 libsymm_la_SOURCES += desx-tab.h
125
126 ## Lai and Massey's IDEA.
127 BLKCS += idea
128
129 ## IBM's `MARS' block cipher.
130 BLKCS += mars
131 mars.lo: mars-tab.h
132 CLEANFILES += mars-tab.h
133 noinst_PROGRAMS += mars-mktab
134 mars-tab.h: mars-mktab$e
135 $(AM_V_GEN)./mars-mktab >mars-tab.h.new && \
136 mv mars-tab.h.new mars-tab.h
137 mars.$t: t/mars
138 EXTRA_DIST += t/mars.aes
139 MAINTAINERCLEANFILES += $(srcdir)/t/mars
140 t/mars: t/mars.aes
141 $(AM_V_GEN)$(srcdir)/aes-trans Mars \
142 <$(srcdir)/t/mars.aes \
143 >$(srcdir)/t/mars.new && \
144 mv $(srcdir)/t/mars.new $(srcdir)/t/mars
145
146 ## Daemen, Peeters, Van Assche and Rijmen's `Noekeon'.
147 BLKCS += noekeon
148
149 ## Rivest's `RC2' block cipher.
150 BLKCS += rc2
151 libsymm_la_SOURCES += rc2-tab.h
152
153 ## Rivest's `RC5'.
154 BLKCS += rc5
155
156 ## Daemen and Rijmen's `Rijndael' block cipher, selected as AES.
157 BLKCS += rijndael rijndael192 rijndael256
158 libsymm_la_SOURCES += rijndael-base.h rijndael-base.c
159 rijndael-base.lo: rijndael-tab.h
160 CLEANFILES += rijndael-tab.h
161 noinst_PROGRAMS += rijndael-mktab
162 rijndael-tab.h: rijndael-mktab$e
163 $(AM_V_GEN)./rijndael-mktab >rijndael-tab.h.new && \
164 mv rijndael-tab.h.new rijndael-tab.h
165 rijndael.$t: t/rijndael
166 EXTRA_DIST += t/rijndael.aes
167 MAINTAINERCLEANFILES += $(srcdir)/t/rijndael
168 t/rijndael: t/rijndael.aes
169 $(AM_V_GEN)$(srcdir)/aes-trans Rijndael \
170 <$(srcdir)/t/rijndael.aes \
171 >$(srcdir)/t/rijndael.new && \
172 mv $(srcdir)/t/rijndael.new $(srcdir)/t/rijndael
173
174 ## Massey's `SAFER' block ciphers.
175 BLKCS += safer safersk
176 safer.lo: safer-tab.h
177 CLEANFILES += safer-tab.h
178 noinst_PROGRAMS += safer-mktab
179 safer-tab.h: safer-mktab$e
180 $(AM_V_GEN)./safer-mktab >safer-tab.h.new && \
181 mv safer-tab.h.new safer-tab.h
182
183 ## Anderson, Biham and Knudsen's `Serpent' block cipher.
184 BLKCS += serpent
185 libsymm_la_SOURCES += serpent-sbox.h
186 noinst_PROGRAMS += serpent-check
187 TESTS += serpent-check
188 serpent.$t: t/serpent
189 EXTRA_DIST += t/serpent.aes
190 MAINTAINERCLEANFILES += $(srcdir)/t/serpent
191 t/serpent: t/serpent.aes
192 $(AM_V_GEN)$(srcdir)/aes-trans Serpent -v rev=1 \
193 <$(srcdir)/t/serpent.aes \
194 >$(srcdir)/t/serpent.new && \
195 mv $(srcdir)/t/serpent.new $(srcdir)/t/serpent
196
197 ## The National Security Agency's `Skipjack' block cipher. You don't want to
198 ## use this.
199 BLKCS += skipjack
200 libsymm_la_SOURCES += skipjack-tab.h
201
202 ## Daemen and Rijmen's `Square' block cipher.
203 BLKCS += square
204 square.lo: square-tab.h
205 CLEANFILES += square-tab.h
206 noinst_PROGRAMS += square-mktab
207 square-tab.h: square-mktab$e
208 $(AM_V_GEN)./square-mktab >square-tab.h.new && \
209 mv square-tab.h.new square-tab.h
210
211 ## Wheeler and Needham's `TEA' and `XTEA' block ciphers.
212 BLKCS += tea xtea
213
214 ## Schneier, Kelsey, Whiting, Wagner, Hall and Ferguson's `Twofish' block
215 ## cipher.
216 BLKCS += twofish
217 twofish.lo: twofish-tab.h
218 CLEANFILES += twofish-tab.h
219 noinst_PROGRAMS += twofish-mktab
220 twofish-tab.h: twofish-mktab$e
221 $(AM_V_GEN)./twofish-mktab >twofish-tab.h.new && \
222 mv twofish-tab.h.new twofish-tab.h
223 twofish.$t: t/twofish
224 EXTRA_DIST += t/twofish.aes
225 MAINTAINERCLEANFILES += $(srcdir)/t/twofish
226 t/twofish: t/twofish.aes
227 $(AM_V_GEN)$(srcdir)/aes-trans Twofish \
228 <$(srcdir)/t/twofish.aes \
229 >$(srcdir)/t/twofish.new && \
230 mv $(srcdir)/t/twofish.new $(srcdir)/t/twofish
231
232 ## The old NIST modes for DES.
233 BLKCCIPHERMODES += cbc cfb ecb ofb
234
235 ## Counter mode.
236 BLKCCIPHERMODES += counter
237
238 ###--------------------------------------------------------------------------
239 ### Hash functions.
240
241 HASHES =
242 HASHMODES =
243
244 HASHCIPHERMODES =
245 HASHMODES += $(HASHCIPHERMODES)
246
247 HASHMACMODES =
248 HASHMODES += $(HASHMACMODES)
249
250 ## Common definitions for hash functions.
251 pkginclude_HEADERS += hash.h
252
253 ## Source code and headers for the hash functions.
254 libsymm_la_SOURCES += $(HASH_C)
255 pkginclude_HEADERS += $(HASH_H)
256
257 ## Lim and KISA's `HAS-160', recommended for use with KCDSA.
258 HASHES += has160
259
260 ## Rivest's `MD' series of hash functions
261 HASHES += md2 md4 md5
262 libsymm_la_SOURCES += md2-tab.h
263
264 ## Dobbertin, Bosselaers and Preneel's `RIPEMD' suite.
265 HASHES += rmd128 rmd160 rmd256 rmd320
266
267 ## The National Security Agency's `SHA-1' hash function.
268 HASHES += sha
269
270 ## The National Security Agency's `SHA-2' suite.
271 HASHES += sha224 sha256
272 HASHES += sha384 sha512
273
274 ## Anderson and Biham's `Tiger' hash function.
275 HASHES += tiger
276 libsymm_la_SOURCES += tiger-base.h
277 tiger.lo: tiger-tab.h
278 CLEANFILES += tiger-tab.h
279 noinst_PROGRAMS += tiger-mktab
280 tiger-tab.h: tiger-mktab$e
281 $(AM_V_GEN)./tiger-mktab >tiger-tab.h.new && \
282 mv tiger-tab.h.new tiger-tab.h
283
284 ## Barreto and Rijmen's `Whirlpool' hash function.
285 HASHES += whirlpool whirlpool256
286 whirlpool.lo: whirlpool-tab.h
287 CLEANFILES += whirlpool-tab.h
288 noinst_PROGRAMS += whirlpool-mktab
289 whirlpool-tab.h: whirlpool-mktab$e
290 $(AM_V_GEN)./whirlpool-mktab >whirlpool-tab.h.new && \
291 mv whirlpool-tab.h.new whirlpool-tab.h
292
293 ## Bellare, Canetti and Krawczyk's `HMAC' mode for message authentication.
294 HASHMACMODES += hmac
295
296 ## MGF1, used in OAEP and PSS.
297 HASHCIPHERMODES += mgf
298
299 ###--------------------------------------------------------------------------
300 ### Other symmetric primitives.
301
302 ## The CRC32 algorithm, which is useful, but has no worthwhile security.
303 pkginclude_HEADERS += crc32.h
304 libsymm_la_SOURCES += crc32.c
305 ALL_HASHES += crc32=gcrc32
306
307 ## Rivest's `RC4' stream cipher.
308 pkginclude_HEADERS += rc4.h
309 libsymm_la_SOURCES += rc4.c
310 TESTS += rc4.$t
311 EXTRA_DIST += t/rc4
312 ALL_CIPHERS += rc4
313
314 ## Coppersmith and Rogaway's `SEAL' pseudorandom function.
315 pkginclude_HEADERS += seal.h
316 libsymm_la_SOURCES += seal.c
317 TESTS += seal.$t
318 EXTRA_DIST += t/seal
319 ALL_CIPHERS += seal
320
321 ###--------------------------------------------------------------------------
322 ### Autogenerated mode implementations.
323
324 ## The master stamp file, indicating that we generated all of the sources.
325 CLEANFILES += modes/gen-stamp
326 EXTRA_DIST += mode.h.in mode.c.in
327 modes/gen-stamp:
328 $(AM_V_at)$(MKDIR_P) modes
329 $(AM_V_GEN)$(multigen) -g $(srcdir)/mode.c.in \
330 modes/@base-@mode.c \
331 base="$(BLKCS)" mode="$(BLKCMODES)"
332 $(AM_V_at)$(multigen) -g $(srcdir)/mode.h.in \
333 modes/@base-@mode.h \
334 base="$(BLKCS)" mode="$(BLKCMODES)"
335 $(AM_V_at)$(multigen) -g $(srcdir)/mode.c.in \
336 modes/@base-@mode.c \
337 base="$(HASHES)" mode="$(HASHMODES)"
338 $(AM_V_at)$(multigen) -g $(srcdir)/mode.h.in \
339 modes/@base-@mode.h \
340 base="$(HASHES)" mode="$(HASHMODES)"
341 $(AM_V_at)touch modes/gen-stamp
342
343 ## The individual mode interfaces and implementations.
344 pkginclude_HEADERS += $(MODE_H)
345
346 ## Generated implementations.
347 BUILT_SOURCES += $(GENMODES_C)
348 CLEANFILES += $(GENMODES_C)
349 nodist_libsymm_la_SOURCES += $(GENMODES_C)
350 $(GENMODES_C): modes/gen-stamp
351
352 ## Generated interfaces.
353 BUILT_SOURCES += $(GENMODES_H)
354 CLEANFILES += $(GENMODES_H)
355 nodist_pkginclude_HEADERS += $(GENMODES_H)
356 $(GENMODES_H): modes/gen-stamp
357
358 ###--------------------------------------------------------------------------
359 ### Tables of classes for encryption, hashing, and message authentication.
360
361 ## The skeleton for the class tables.
362 EXTRA_DIST += gthingtab.c.in
363
364 ## Table of cipher classes.
365 pkginclude_HEADERS += gcipher.h
366 CLEANFILES += gciphertab.c
367 nodist_libsymm_la_SOURCES += gciphertab.c
368 gciphertab.c: gthingtab.c.in
369 $(AM_V_GEN)$(multigen) -g $(srcdir)/gthingtab.c.in gciphertab.c \
370 what=gcipher cls=gccipher thing="$(ALL_CIPHERS)"
371
372 ## Table of hash classes.
373 pkginclude_HEADERS += ghash.h ghash-def.h
374 CLEANFILES += ghashtab.c
375 nodist_libsymm_la_SOURCES += ghashtab.c
376 ghashtab.c: gthingtab.c.in
377 $(AM_V_GEN)$(multigen) -g $(srcdir)/gthingtab.c.in ghashtab.c \
378 what=ghash cls=gchash thing="$(ALL_HASHES)"
379
380 ## Table of MAC classes.
381 pkginclude_HEADERS += gmac.h
382 CLEANFILES += gmactab.c
383 nodist_libsymm_la_SOURCES += gmactab.c
384 gmactab.c: gthingtab.c.in
385 $(AM_V_GEN)$(multigen) -g $(srcdir)/gthingtab.c.in gmactab.c \
386 what=gmac cls=gcmac thing="$(ALL_MACS)"
387
388 ###--------------------------------------------------------------------------
389 ### Testing.
390
391 ## Run the test programs.
392 TESTS += $(SYMM_TESTS)
393 EXTRA_DIST += $(SYMM_TEST_FILES)
394
395 ## A piece of sample text for round-trip testing encryption modes.
396 EXTRA_DIST += daftstory.h
397
398 ## Clean the debris from the `modes' subdirectory.
399 CLEANFILES += modes/*.to modes/*.$t
400
401 ###----- That's all, folks --------------------------------------------------