3 ### Build script for symmetric cryptography
5 ### (c) 2013 Straylight/Edgeware
8 ###----- Licensing notice ---------------------------------------------------
10 ### This file is part of Catacomb.
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.
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.
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.
27 include $(top_srcdir)/vars.am
29 noinst_LTLIBRARIES = libsymm.la
31 nodist_libsymm_la_SOURCES =
33 TEST_LIBS = libsymm.la
37 ###--------------------------------------------------------------------------
38 ### Autogenerated lists.
40 ## Fancy template substitutions.
41 multigen = $(PYTHON) $(srcdir)/multigen
42 EXTRA_DIST += multigen
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
51 EXTRA_DIST += modes.am.in modes.am
52 MAINTAINERCLEANFILES += $(srcdir)/modes.am
54 ## Generate the lists.
55 $(srcdir)/modes.am: modes.am.in
56 $(AM_V_GEN)$(multigen) -g $(srcdir)/modes.am.in $(srcdir)/modes.am \
58 blkcmode="$(BLKCMODES)" \
59 blkcciphermode="$(BLKCCIPHERMODES)" \
61 hashmode="$(HASHMODES)" \
62 hashciphermode="$(HASHCIPHERMODES)" \
63 hashmacmode="$(HASHMACMODES)"
65 ## Initialize lists of known classes.
66 ALL_CIPHERS = $(CIPHER_MODES)
67 ALL_HASHES = $(HASHES)
68 ALL_MACS = $(MAC_MODES)
70 ###--------------------------------------------------------------------------
77 BLKCMODES += $(BLKCCIPHERMODES)
79 ## A tool for translating the AES-contest test vectors into a form our test
81 EXTRA_DIST += aes-trans
83 ## Block cipher utility macros, mainly used in mode implementations.
84 pkginclude_HEADERS += blkc.h
86 ## Source code and headers for the block ciphers.
87 libsymm_la_SOURCES += $(BLKC_C)
88 pkginclude_HEADERS += $(BLKC_H)
90 ## Schneier's `Blowfish' block cipher.
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
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
112 ## IBM's `DES' block cipher, by Feistel, Coppersmith, and others.
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
122 ## Rivest's `DESX' variant, with pre- and post-whitening.
124 libsymm_la_SOURCES += desx-tab.h
126 ## Lai and Massey's IDEA.
129 ## IBM's `MARS' block cipher.
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
138 EXTRA_DIST += t/mars.aes
139 MAINTAINERCLEANFILES += $(srcdir)/t/mars
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
146 ## Daemen, Peeters, Van Assche and Rijmen's `Noekeon'.
149 ## Rivest's `RC2' block cipher.
151 libsymm_la_SOURCES += rc2-tab.h
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
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
183 ## Anderson, Biham and Knudsen's `Serpent' block cipher.
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
197 ## The National Security Agency's `Skipjack' block cipher. You don't want to
200 libsymm_la_SOURCES += skipjack-tab.h
202 ## Daemen and Rijmen's `Square' block cipher.
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
211 ## Wheeler and Needham's `TEA' and `XTEA' block ciphers.
214 ## Schneier, Kelsey, Whiting, Wagner, Hall and Ferguson's `Twofish' block
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
232 ## The old NIST modes for DES.
233 BLKCCIPHERMODES += cbc cfb ecb ofb
236 BLKCCIPHERMODES += counter
238 ###--------------------------------------------------------------------------
245 HASHMODES += $(HASHCIPHERMODES)
248 HASHMODES += $(HASHMACMODES)
250 ## Common definitions for hash functions.
251 pkginclude_HEADERS += hash.h
253 ## Source code and headers for the hash functions.
254 libsymm_la_SOURCES += $(HASH_C)
255 pkginclude_HEADERS += $(HASH_H)
257 ## Lim and KISA's `HAS-160', recommended for use with KCDSA.
260 ## Rivest's `MD' series of hash functions
261 HASHES += md2 md4 md5
262 libsymm_la_SOURCES += md2-tab.h
264 ## Dobbertin, Bosselaers and Preneel's `RIPEMD' suite.
265 HASHES += rmd128 rmd160 rmd256 rmd320
267 ## The National Security Agency's `SHA-1' hash function.
270 ## The National Security Agency's `SHA-2' suite.
271 HASHES += sha224 sha256
272 HASHES += sha384 sha512
274 ## Anderson and Biham's `Tiger' hash function.
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
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
293 ## Bellare, Canetti and Krawczyk's `HMAC' mode for message authentication.
296 ## MGF1, used in OAEP and PSS.
297 HASHCIPHERMODES += mgf
299 ###--------------------------------------------------------------------------
300 ### Other symmetric primitives.
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
307 ## Rivest's `RC4' stream cipher.
308 pkginclude_HEADERS += rc4.h
309 libsymm_la_SOURCES += rc4.c
314 ## Coppersmith and Rogaway's `SEAL' pseudorandom function.
315 pkginclude_HEADERS += seal.h
316 libsymm_la_SOURCES += seal.c
321 ###--------------------------------------------------------------------------
322 ### Autogenerated mode implementations.
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
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
343 ## The individual mode interfaces and implementations.
344 pkginclude_HEADERS += $(MODE_H)
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
352 ## Generated interfaces.
353 BUILT_SOURCES += $(GENMODES_H)
354 CLEANFILES += $(GENMODES_H)
355 nodist_pkginclude_HEADERS += $(GENMODES_H)
356 $(GENMODES_H): modes/gen-stamp
358 ###--------------------------------------------------------------------------
359 ### Tables of classes for encryption, hashing, and message authentication.
361 ## The skeleton for the class tables.
362 EXTRA_DIST += gthingtab.c.in
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)"
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)"
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)"
388 ###--------------------------------------------------------------------------
391 ## Run the test programs.
392 TESTS += $(SYMM_TESTS)
393 EXTRA_DIST += $(SYMM_TEST_FILES)
395 ## A piece of sample text for round-trip testing encryption modes.
396 EXTRA_DIST += daftstory.h
398 ## Clean the debris from the `modes' subdirectory.
399 CLEANFILES += modes/*.to modes/*.$t
401 ###----- That's all, folks --------------------------------------------------