blob: 8c18378a9fa6e2a4721fa18d953578fc5fb1a416 [file] [log] [blame]
Paul Bakker0049c2f2009-07-11 19:15:43 +00001
2# To compile on SunOS: add "-lsocket -lnsl" to LDFLAGS
Paul Bakker62f88dc2012-05-10 21:26:28 +00003# To compile on MinGW: add "-lws2_32" to LDFLAGS or define WINDOWS in your env
Paul Bakker43b7e352011-01-18 15:27:19 +00004# To compile with PKCS11: add "-lpkcs11-helper" to LDFLAGS
Paul Bakker0049c2f2009-07-11 19:15:43 +00005
Paul Bakker46eb1382011-01-30 17:10:13 +00006CFLAGS += -I../include -D_FILE_OFFSET_BITS=64 -Wall -W -Wdeclaration-after-statement \
Paul Bakker0049c2f2009-07-11 19:15:43 +00007 -Wno-unused-function -Wno-unused-value
8
Paul Bakkerf1ab0ec2012-10-23 12:12:53 +00009OFLAGS = -O2
Paul Bakkera585beb2011-06-21 08:59:44 +000010LDFLAGS += -L../library -lpolarssl $(SYS_LDFLAGS)
Paul Bakker0049c2f2009-07-11 19:15:43 +000011
Paul Bakkerbc898492014-03-26 13:26:52 +010012ifndef SHARED
13DEP=../library/libpolarssl.a
14CHECK_PRELOAD=
15else
16DEP=../library/libpolarssl.so
17CHECK_PRELOAD= LD_PRELOAD=../library/libpolarssl.so
18endif
19
Paul Bakkerc7ffd362012-04-05 12:08:29 +000020ifdef DEBUG
21CFLAGS += -g3
22endif
23
Paul Bakkercd5b5292012-05-10 20:49:10 +000024ifdef WINDOWS
25LDFLAGS += -lws2_32
26endif
27
Paul Bakker2770fbd2012-07-03 13:30:23 +000028# Zlib shared library extensions:
29ifdef ZLIB
30LDFLAGS += -lz
31endif
32
Paul Bakkerd68703b2013-04-12 13:20:30 +020033APPS = test_suite_aes.ecb test_suite_aes.cbc \
34 test_suite_aes.cfb test_suite_aes.rest \
35 test_suite_arc4 \
Paul Bakkera9379c02012-07-04 11:02:11 +000036 test_suite_base64 test_suite_blowfish \
Paul Bakker6132d0a2012-07-04 17:10:40 +000037 test_suite_camellia test_suite_cipher.aes \
38 test_suite_cipher.blowfish \
39 test_suite_cipher.camellia \
Paul Bakkerfab5c822012-02-06 16:45:10 +000040 test_suite_cipher.des test_suite_cipher.null \
41 test_suite_ctr_drbg test_suite_debug \
Paul Bakker9d781402011-05-09 16:17:09 +000042 test_suite_des test_suite_dhm \
Paul Bakkerd68703b2013-04-12 13:20:30 +020043 test_suite_error \
44 test_suite_gcm.decrypt_128 \
45 test_suite_gcm.decrypt_192 \
46 test_suite_gcm.decrypt_256 \
47 test_suite_gcm.encrypt_128 \
48 test_suite_gcm.encrypt_192 \
49 test_suite_gcm.encrypt_256 \
50 test_suite_hmac_shax \
Paul Bakker9d781402011-05-09 16:17:09 +000051 test_suite_md test_suite_mdx \
Paul Bakkerf518b162012-08-23 13:03:18 +000052 test_suite_mpi test_suite_pbkdf2 \
Paul Bakker19bd2972013-06-14 12:06:45 +020053 test_suite_pkcs1_v21 test_suite_pkcs5 \
Paul Bakker9d781402011-05-09 16:17:09 +000054 test_suite_rsa test_suite_shax \
Paul Bakker6d620502012-02-16 14:09:13 +000055 test_suite_x509parse test_suite_x509write \
56 test_suite_xtea test_suite_version
Paul Bakker0049c2f2009-07-11 19:15:43 +000057
58.SILENT:
59
60all: $(APPS)
61
Paul Bakkerd68703b2013-04-12 13:20:30 +020062test_suite_aes.ecb.c : suites/test_suite_aes.function suites/test_suite_aes.ecb.data scripts/generate_code.pl suites/helpers.function
63 echo " Generate $@"
64 scripts/generate_code.pl suites test_suite_aes test_suite_aes.ecb
65
66test_suite_aes.cbc.c : suites/test_suite_aes.function suites/test_suite_aes.cbc.data scripts/generate_code.pl suites/helpers.function
67 echo " Generate $@"
68 scripts/generate_code.pl suites test_suite_aes test_suite_aes.cbc
69
70test_suite_aes.cfb.c : suites/test_suite_aes.function suites/test_suite_aes.cfb.data scripts/generate_code.pl suites/helpers.function
71 echo " Generate $@"
72 scripts/generate_code.pl suites test_suite_aes test_suite_aes.cfb
73
74test_suite_aes.rest.c : suites/test_suite_aes.function suites/test_suite_aes.rest.data scripts/generate_code.pl suites/helpers.function
75 echo " Generate $@"
76 scripts/generate_code.pl suites test_suite_aes test_suite_aes.rest
77
Paul Bakker46c17942011-07-13 14:54:54 +000078test_suite_cipher.aes.c : suites/test_suite_cipher.function suites/test_suite_cipher.aes.data scripts/generate_code.pl suites/helpers.function
79 echo " Generate $@"
80 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.aes
81
Paul Bakker6132d0a2012-07-04 17:10:40 +000082test_suite_cipher.blowfish.c : suites/test_suite_cipher.function suites/test_suite_cipher.blowfish.data scripts/generate_code.pl suites/helpers.function
83 echo " Generate $@"
84 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.blowfish
85
Paul Bakker46c17942011-07-13 14:54:54 +000086test_suite_cipher.camellia.c : suites/test_suite_cipher.function suites/test_suite_cipher.camellia.data scripts/generate_code.pl suites/helpers.function
87 echo " Generate $@"
88 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.camellia
89
90test_suite_cipher.des.c : suites/test_suite_cipher.function suites/test_suite_cipher.des.data scripts/generate_code.pl suites/helpers.function
91 echo " Generate $@"
92 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.des
93
Paul Bakkerfab5c822012-02-06 16:45:10 +000094test_suite_cipher.null.c : suites/test_suite_cipher.function suites/test_suite_cipher.null.data scripts/generate_code.pl suites/helpers.function
95 echo " Generate $@"
96 scripts/generate_code.pl suites test_suite_cipher test_suite_cipher.null
97
Paul Bakkerd68703b2013-04-12 13:20:30 +020098test_suite_gcm.decrypt_128.c : suites/test_suite_gcm.function suites/test_suite_gcm.decrypt_128.data scripts/generate_code.pl suites/helpers.function
Paul Bakker89e80c92012-03-20 13:50:09 +000099 echo " Generate $@"
Paul Bakkerd68703b2013-04-12 13:20:30 +0200100 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.decrypt_128
Paul Bakker89e80c92012-03-20 13:50:09 +0000101
Paul Bakkerd68703b2013-04-12 13:20:30 +0200102test_suite_gcm.decrypt_192.c : suites/test_suite_gcm.function suites/test_suite_gcm.decrypt_192.data scripts/generate_code.pl suites/helpers.function
Paul Bakker89e80c92012-03-20 13:50:09 +0000103 echo " Generate $@"
Paul Bakkerd68703b2013-04-12 13:20:30 +0200104 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.decrypt_192
105
106test_suite_gcm.decrypt_256.c : suites/test_suite_gcm.function suites/test_suite_gcm.decrypt_256.data scripts/generate_code.pl suites/helpers.function
107 echo " Generate $@"
108 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.decrypt_256
109
110test_suite_gcm.encrypt_128.c : suites/test_suite_gcm.function suites/test_suite_gcm.encrypt_128.data scripts/generate_code.pl suites/helpers.function
111 echo " Generate $@"
112 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.encrypt_128
113
114test_suite_gcm.encrypt_192.c : suites/test_suite_gcm.function suites/test_suite_gcm.encrypt_192.data scripts/generate_code.pl suites/helpers.function
115 echo " Generate $@"
116 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.encrypt_192
117
118test_suite_gcm.encrypt_256.c : suites/test_suite_gcm.function suites/test_suite_gcm.encrypt_256.data scripts/generate_code.pl suites/helpers.function
119 echo " Generate $@"
120 scripts/generate_code.pl suites test_suite_gcm test_suite_gcm.encrypt_256
Paul Bakker89e80c92012-03-20 13:50:09 +0000121
Paul Bakker4fa1a762011-03-13 16:56:11 +0000122%.c : suites/%.function suites/%.data scripts/generate_code.pl suites/helpers.function
Paul Bakker0049c2f2009-07-11 19:15:43 +0000123 echo " Generate $@"
Paul Bakker46c17942011-07-13 14:54:54 +0000124 scripts/generate_code.pl suites $* $*
Paul Bakker0049c2f2009-07-11 19:15:43 +0000125
Paul Bakkerbc898492014-03-26 13:26:52 +0100126test_suite_aes.ecb: test_suite_aes.ecb.c $(DEP)
Paul Bakkerd68703b2013-04-12 13:20:30 +0200127 echo " CC $@.c"
128 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
129
Paul Bakkerbc898492014-03-26 13:26:52 +0100130test_suite_aes.cbc: test_suite_aes.cbc.c $(DEP)
Paul Bakkerd68703b2013-04-12 13:20:30 +0200131 echo " CC $@.c"
132 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
133
Paul Bakkerbc898492014-03-26 13:26:52 +0100134test_suite_aes.cfb: test_suite_aes.cfb.c $(DEP)
Paul Bakkerd68703b2013-04-12 13:20:30 +0200135 echo " CC $@.c"
136 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
137
Paul Bakkerbc898492014-03-26 13:26:52 +0100138test_suite_aes.rest: test_suite_aes.rest.c $(DEP)
Paul Bakker0049c2f2009-07-11 19:15:43 +0000139 echo " CC $@.c"
140 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
141
Paul Bakkerbc898492014-03-26 13:26:52 +0100142test_suite_arc4: test_suite_arc4.c $(DEP)
Paul Bakker0049c2f2009-07-11 19:15:43 +0000143 echo " CC $@.c"
144 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
145
Paul Bakkerbc898492014-03-26 13:26:52 +0100146test_suite_base64: test_suite_base64.c $(DEP)
Paul Bakker0049c2f2009-07-11 19:15:43 +0000147 echo " CC $@.c"
148 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
149
Paul Bakkerbc898492014-03-26 13:26:52 +0100150test_suite_blowfish: test_suite_blowfish.c $(DEP)
Paul Bakkera9379c02012-07-04 11:02:11 +0000151 echo " CC $@.c"
152 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
153
Paul Bakkerbc898492014-03-26 13:26:52 +0100154test_suite_camellia: test_suite_camellia.c $(DEP)
Paul Bakker0049c2f2009-07-11 19:15:43 +0000155 echo " CC $@.c"
156 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
157
Paul Bakkerbc898492014-03-26 13:26:52 +0100158test_suite_cipher.aes: test_suite_cipher.aes.c $(DEP)
Paul Bakker46c17942011-07-13 14:54:54 +0000159 echo " CC $@.c"
160 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
161
Paul Bakkerbc898492014-03-26 13:26:52 +0100162test_suite_cipher.blowfish: test_suite_cipher.blowfish.c $(DEP)
Paul Bakker6132d0a2012-07-04 17:10:40 +0000163 echo " CC $@.c"
164 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
165
Paul Bakkerbc898492014-03-26 13:26:52 +0100166test_suite_cipher.camellia: test_suite_cipher.camellia.c $(DEP)
Paul Bakker46c17942011-07-13 14:54:54 +0000167 echo " CC $@.c"
168 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
169
Paul Bakkerbc898492014-03-26 13:26:52 +0100170test_suite_cipher.des: test_suite_cipher.des.c $(DEP)
Paul Bakker0e04d0e2011-11-27 14:46:59 +0000171 echo " CC $@.c"
172 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
173
Paul Bakkerbc898492014-03-26 13:26:52 +0100174test_suite_cipher.null: test_suite_cipher.null.c $(DEP)
Paul Bakkerfab5c822012-02-06 16:45:10 +0000175 echo " CC $@.c"
176 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
177
Paul Bakkerbc898492014-03-26 13:26:52 +0100178test_suite_ctr_drbg: test_suite_ctr_drbg.c $(DEP)
Paul Bakker8123e9d2011-01-06 15:37:30 +0000179 echo " CC $@.c"
180 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
181
Paul Bakkerbc898492014-03-26 13:26:52 +0100182test_suite_des: test_suite_des.c $(DEP)
Paul Bakker0049c2f2009-07-11 19:15:43 +0000183 echo " CC $@.c"
184 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
185
Paul Bakkerbc898492014-03-26 13:26:52 +0100186test_suite_dhm: test_suite_dhm.c $(DEP)
Paul Bakker0049c2f2009-07-11 19:15:43 +0000187 echo " CC $@.c"
188 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
189
Paul Bakkerbc898492014-03-26 13:26:52 +0100190test_suite_error: test_suite_error.c $(DEP)
Paul Bakker9d781402011-05-09 16:17:09 +0000191 echo " CC $@.c"
192 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
193
Paul Bakkerbc898492014-03-26 13:26:52 +0100194test_suite_gcm.decrypt_128: test_suite_gcm.decrypt_128.c $(DEP)
Paul Bakker89e80c92012-03-20 13:50:09 +0000195 echo " CC $@.c"
196 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
197
Paul Bakkerbc898492014-03-26 13:26:52 +0100198test_suite_gcm.decrypt_192: test_suite_gcm.decrypt_192.c $(DEP)
Paul Bakkerd68703b2013-04-12 13:20:30 +0200199 echo " CC $@.c"
200 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
201
Paul Bakkerbc898492014-03-26 13:26:52 +0100202test_suite_gcm.decrypt_256: test_suite_gcm.decrypt_256.c $(DEP)
Paul Bakkerd68703b2013-04-12 13:20:30 +0200203 echo " CC $@.c"
204 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
205
Paul Bakkerbc898492014-03-26 13:26:52 +0100206test_suite_gcm.encrypt_128: test_suite_gcm.encrypt_128.c $(DEP)
Paul Bakkerd68703b2013-04-12 13:20:30 +0200207 echo " CC $@.c"
208 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
209
Paul Bakkerbc898492014-03-26 13:26:52 +0100210test_suite_gcm.encrypt_192: test_suite_gcm.encrypt_192.c $(DEP)
Paul Bakkerd68703b2013-04-12 13:20:30 +0200211 echo " CC $@.c"
212 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
213
Paul Bakkerbc898492014-03-26 13:26:52 +0100214test_suite_gcm.encrypt_256: test_suite_gcm.encrypt_256.c $(DEP)
Paul Bakker89e80c92012-03-20 13:50:09 +0000215 echo " CC $@.c"
216 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
217
Paul Bakkerbc898492014-03-26 13:26:52 +0100218test_suite_hmac_shax: test_suite_hmac_shax.c $(DEP)
Paul Bakker0049c2f2009-07-11 19:15:43 +0000219 echo " CC $@.c"
220 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
221
Paul Bakkerbc898492014-03-26 13:26:52 +0100222test_suite_md: test_suite_md.c $(DEP)
Paul Bakker17373852011-01-06 14:20:01 +0000223 echo " CC $@.c"
224 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
225
Paul Bakkerbc898492014-03-26 13:26:52 +0100226test_suite_mdx: test_suite_mdx.c $(DEP)
Paul Bakker0049c2f2009-07-11 19:15:43 +0000227 echo " CC $@.c"
228 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
229
Paul Bakkerbc898492014-03-26 13:26:52 +0100230test_suite_mpi: test_suite_mpi.c $(DEP)
Paul Bakker0049c2f2009-07-11 19:15:43 +0000231 echo " CC $@.c"
232 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
233
Paul Bakkerbc898492014-03-26 13:26:52 +0100234test_suite_pbkdf2: test_suite_pbkdf2.c $(DEP)
Paul Bakkerf518b162012-08-23 13:03:18 +0000235 echo " CC $@.c"
236 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
237
Paul Bakkerbc898492014-03-26 13:26:52 +0100238test_suite_pkcs1_v21: test_suite_pkcs1_v21.c $(DEP)
Paul Bakker9dcc3222011-03-08 14:16:06 +0000239 echo " CC $@.c"
240 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
241
Paul Bakkerbc898492014-03-26 13:26:52 +0100242test_suite_pkcs5: test_suite_pkcs5.c $(DEP)
Paul Bakker19bd2972013-06-14 12:06:45 +0200243 echo " CC $@.c"
244 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
245
Paul Bakkerbc898492014-03-26 13:26:52 +0100246test_suite_rsa: test_suite_rsa.c $(DEP)
Paul Bakker0049c2f2009-07-11 19:15:43 +0000247 echo " CC $@.c"
248 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
249
Paul Bakkerbc898492014-03-26 13:26:52 +0100250test_suite_shax: test_suite_shax.c $(DEP)
Paul Bakker0049c2f2009-07-11 19:15:43 +0000251 echo " CC $@.c"
252 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
253
Paul Bakkerbc898492014-03-26 13:26:52 +0100254test_suite_x509parse: test_suite_x509parse.c $(DEP)
Paul Bakker0049c2f2009-07-11 19:15:43 +0000255 echo " CC $@.c"
256 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
257
Paul Bakkerbc898492014-03-26 13:26:52 +0100258test_suite_x509write: test_suite_x509write.c $(DEP)
Paul Bakker6d620502012-02-16 14:09:13 +0000259 echo " CC $@.c"
260 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
261
Paul Bakkerbc898492014-03-26 13:26:52 +0100262test_suite_xtea: test_suite_xtea.c $(DEP)
Paul Bakker0049c2f2009-07-11 19:15:43 +0000263 echo " CC $@.c"
264 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
265
Paul Bakkerbc898492014-03-26 13:26:52 +0100266test_suite_debug: test_suite_debug.c $(DEP)
Paul Bakker7d7f4f42010-02-18 18:26:04 +0000267 echo " CC $@.c"
268 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
269
Paul Bakkerbc898492014-03-26 13:26:52 +0100270test_suite_version: test_suite_version.c $(DEP)
Paul Bakker3ac1b2d2010-06-18 22:47:29 +0000271 echo " CC $@.c"
272 $(CC) $(CFLAGS) $(OFLAGS) $@.c $(LDFLAGS) -o $@
273
Paul Bakker0049c2f2009-07-11 19:15:43 +0000274clean:
Paul Bakker62f88dc2012-05-10 21:26:28 +0000275ifndef WINDOWS
Paul Bakker0049c2f2009-07-11 19:15:43 +0000276 rm -f $(APPS) *.c
Paul Bakker62f88dc2012-05-10 21:26:28 +0000277endif
278ifdef WINDOWS
279 del /Q /F *.c *.exe
280endif
Paul Bakker0049c2f2009-07-11 19:15:43 +0000281
Paul Bakker9794cb42009-07-28 18:55:00 +0000282check: $(APPS)
Paul Bakker62f88dc2012-05-10 21:26:28 +0000283ifndef WINDOWS
Paul Bakkerbc898492014-03-26 13:26:52 +0100284 echo "Running checks (Success if all tests PASSED)"
Paul Bakkerd14cd352012-05-08 15:39:50 +0000285 RETURN=0; \
Paul Bakkerd947d762009-07-28 20:16:47 +0000286 for i in $(APPS); \
287 do \
288 echo " - $${i}"; \
Paul Bakkerbc898492014-03-26 13:26:52 +0100289 RESULT=`$(CHECK_PRELOAD) ./$${i} | grep -v 'PASS$$' | grep -v -- '----' | grep -v '^$$'`; \
Paul Bakkerd14cd352012-05-08 15:39:50 +0000290 FAILED=`echo $$RESULT |grep FAILED`; \
291 echo " $$RESULT"; \
292 if [ "$$FAILED" != "" ]; \
293 then \
294 echo "**** Failed ***************"; \
295 RETURN=1; \
296 fi; \
Paul Bakkerd947d762009-07-28 20:16:47 +0000297 echo ""; \
Paul Bakkerd14cd352012-05-08 15:39:50 +0000298 done; \
299 if [ "$$RETURN" -eq 1 ]; then exit 1; fi
Paul Bakker62f88dc2012-05-10 21:26:28 +0000300endif