blob: fa7e0b4e848d2625bd4d81e42b7bd3d57022c520 [file] [log] [blame]
Gilles Peskinefd14bca2017-05-11 17:57:22 +02001## This file contains a record of how some of the test data was
2## generated. The final build products are committed to the repository
3## as well to make sure that the test data is identical. You do not
4## need to use this makefile unless you're extending mbed TLS's tests.
Gilles Peskinef040a172017-05-05 18:56:12 +02005
Gilles Peskinefd14bca2017-05-11 17:57:22 +02006## Many data files were generated prior to the existence of this
7## makefile, so the method of their generation was not recorded.
Gilles Peskinef040a172017-05-05 18:56:12 +02008
Gilles Peskinefd14bca2017-05-11 17:57:22 +02009## Note that in addition to depending on the version of the data
10## generation tool, many of the build outputs are randomized, so
11## running this makefile twice would not produce the same results.
12
13## Tools
14OPENSSL ?= openssl
15
16## Build the generated test data. Note that since the final outputs
17## are committed to the repository, this target should do nothing on a
18## fresh checkout. Furthermore, since the generation is randomized,
19## re-running the same targets may result in differing files. The goal
20## of this makefile is primarily to serve as a record of how the
21## targets were generated in the first place.
Gilles Peskinef040a172017-05-05 18:56:12 +020022default: all_final
23
24all_intermediate := # temporary files
25all_final := # files used by tests
26
Gilles Peskinefd14bca2017-05-11 17:57:22 +020027
28
29################################################################
30#### Generate certificates from existing keys
31################################################################
32
33test_ca_key_file_rsa = test-ca.key
34test_ca_pwd_rsa = PolarSSLTest
35test_ca_config_file = test-ca.opensslconf
36
Gilles Peskinef040a172017-05-05 18:56:12 +020037test-ca.csr: $(test_ca_key_file_rsa) $(test_ca_config_file)
38 $(OPENSSL) req -new -config $(test_ca_config_file) -key $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -subj "/C=NL/O=PolarSSL/CN=PolarSSL Test CA" -out $@
39all_intermediate += test-ca.csr
40test-ca-sha1.crt: $(test_ca_key_file_rsa) $(test_ca_config_file) test-ca.csr
41 $(OPENSSL) req -x509 -config $(test_ca_config_file) -key $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 0 -days 3653 -sha1 -in test-ca.csr -out $@
42all_final += test-ca-sha1.crt
43test-ca-sha256.crt: $(test_ca_key_file_rsa) $(test_ca_config_file) test-ca.csr
44 $(OPENSSL) req -x509 -config $(test_ca_config_file) -key $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 0 -days 3653 -sha256 -in test-ca.csr -out $@
45all_final += test-ca-sha256.crt
46
Gilles Peskinefd14bca2017-05-11 17:57:22 +020047cli_crt_key_file_rsa = cli-rsa.key
48cli_crt_extensions_file = cli.opensslconf
49
Gilles Peskinef040a172017-05-05 18:56:12 +020050cli-rsa.csr: $(cli_crt_key_file_rsa)
51 $(OPENSSL) req -new -key $(cli_crt_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -subj "/C=NL/O=PolarSSL/CN=PolarSSL Client 2" -out $@
52all_intermediate += cli-rsa.csr
53cli-rsa-sha1.crt: $(cli_crt_key_file_rsa) test-ca-sha1.crt cli-rsa.csr
54 $(OPENSSL) x509 -req -extfile $(cli_crt_extensions_file) -extensions cli-rsa -CA test-ca-sha1.crt -CAkey $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 4 -days 3653 -sha1 -in cli-rsa.csr -out $@
55all_final += cli-rsa-sha1.crt
56cli-rsa-sha256.crt: $(cli_crt_key_file_rsa) test-ca-sha256.crt cli-rsa.csr
57 $(OPENSSL) x509 -req -extfile $(cli_crt_extensions_file) -extensions cli-rsa -CA test-ca-sha256.crt -CAkey $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 4 -days 3653 -sha256 -in cli-rsa.csr -out $@
58all_final += cli-rsa-sha256.crt
59
Gilles Peskinebc70a182017-05-09 15:59:24 +020060server2-rsa.csr: server2.key
61 $(OPENSSL) req -new -key server2.key -passin "pass:$(test_ca_pwd_rsa)" -subj "/C=NL/O=PolarSSL/CN=localhost" -out $@
62all_intermediate += server2-rsa.csr
63server2-sha256.crt: server2-rsa.csr
64 $(OPENSSL) x509 -req -extfile $(cli_crt_extensions_file) -extensions cli-rsa -CA test-ca-sha256.crt -CAkey $(test_ca_key_file_rsa) -passin "pass:$(test_ca_pwd_rsa)" -set_serial 4 -days 3653 -sha256 -in server2-rsa.csr -out $@
65all_final += server2-sha256.crt
66
Hanno Beckerd16f6122017-09-05 09:23:50 +010067################################################################
68#### Generate various RSA keys
69################################################################
Gilles Peskinebc70a182017-05-09 15:59:24 +020070
Hanno Beckerd16f6122017-09-05 09:23:50 +010071### Password used for PKCS1-encoded encrypted RSA keys
72keys_rsa_basic_pwd = testkey
73
74### Password used for PKCS8-encoded encrypted RSA keys
75keys_rsa_pkcs8_pwd = PolarSSLTest
76
77### Basic 1024-, 2048- and 4096-bit unencrypted RSA keys from which
78### all other encrypted RSA keys are derived.
79keyfile:
80 $(OPENSSL) genrsa -out $@ 1024
81keyfile_2048:
82 $(OPENSSL) genrsa -out $@ 2048
83keyfile_4096:
84 $(OPENSSL) genrsa -out $@ 4096
85
86###
87### PKCS1-encoded, encrypted RSA keys
88###
89
90### 1024-bit
91keyfile.des: keyfile
92 $(OPENSSL) rsa -des -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
93keyfile.3des: keyfile
94 $(OPENSSL) rsa -des3 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
95keyfile.aes128: keyfile
96 $(OPENSSL) rsa -aes128 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
97keyfile.aes192: keyfile
98 $(OPENSSL) rsa -aes192 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
99keyfile.aes256: keyfile
100 $(OPENSSL) rsa -aes256 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
101keys_rsa_enc_basic_1024: keyfile.des keyfile.3des keyfile.aes128 keyfile.aes192 keyfile.aes256
102
103# 2048-bit
104keyfile_2048.des: keyfile_2048
105 $(OPENSSL) rsa -des -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
106keyfile_2048.3des: keyfile_2048
107 $(OPENSSL) rsa -des3 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
108keyfile_2048.aes128: keyfile_2048
109 $(OPENSSL) rsa -aes128 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
110keyfile_2048.aes192: keyfile_2048
111 $(OPENSSL) rsa -aes192 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
112keyfile_2048.aes256: keyfile_2048
113 $(OPENSSL) rsa -aes256 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
114keys_rsa_enc_basic_2048: keyfile_2048.des keyfile_2048.3des keyfile_2048.aes128 keyfile_2048.aes192 keyfile_2048.aes256
115
116# 4096-bit
117keyfile_4096.des: keyfile_4096
118 $(OPENSSL) rsa -des -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
119keyfile_4096.3des: keyfile_4096
120 $(OPENSSL) rsa -des3 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
121keyfile_4096.aes128: keyfile_4096
122 $(OPENSSL) rsa -aes128 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
123keyfile_4096.aes192: keyfile_4096
124 $(OPENSSL) rsa -aes192 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
125keyfile_4096.aes256: keyfile_4096
126 $(OPENSSL) rsa -aes256 -in $< -out $@ -passout "pass:$(keys_rsa_basic_pwd)"
127keys_rsa_enc_basic_4096: keyfile_4096.des keyfile_4096.3des keyfile_4096.aes128 keyfile_4096.aes192 keyfile_4096.aes256
128
129###
130### PKCS8-v1 encoded, encrypted RSA keys
131###
132
133### 1024-bit
134pkcs8_pbe_sha1_3des.der: keyfile
135 $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-3DES
136pkcs8_pbe_sha1_3des.key: keyfile
137 $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-3DES
138keys_rsa_enc_pkcs8_v1_1024_3des: pkcs8_pbe_sha1_3des.key pkcs8_pbe_sha1_3des.der
139
140pkcs8_pbe_sha1_2des.der: keyfile
141 $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-2DES
142pkcs8_pbe_sha1_2des.key: keyfile
143 $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-2DES
144keys_rsa_enc_pkcs8_v1_1024_2des: pkcs8_pbe_sha1_2des.key pkcs8_pbe_sha1_2des.der
145
146pkcs8_pbe_sha1_rc4_128.der: keyfile
147 $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-RC4-128
148pkcs8_pbe_sha1_rc4_128.key: keyfile
149 $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-RC4-128
150keys_rsa_enc_pkcs8_v1_1024_rc4_128: pkcs8_pbe_sha1_rc4_128.key pkcs8_pbe_sha1_rc4_128.der
151
152keys_rsa_enc_pkcs8_v1_1024: keys_rsa_enc_pkcs8_v1_1024_3des keys_rsa_enc_pkcs8_v1_1024_2des keys_rsa_enc_pkcs8_v1_1024_rc4_128
153
154### 2048-bit
155pkcs8_pbe_sha1_3des_2048.der: keyfile_2048
156 $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-3DES
157pkcs8_pbe_sha1_3des_2048.key: keyfile_2048
158 $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-3DES
159keys_rsa_enc_pkcs8_v1_2048_3des: pkcs8_pbe_sha1_3des_2048.key pkcs8_pbe_sha1_3des_2048.der
160
161pkcs8_pbe_sha1_2des_2048.der: keyfile_2048
162 $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-2DES
163pkcs8_pbe_sha1_2des_2048.key: keyfile_2048
164 $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-2DES
165keys_rsa_enc_pkcs8_v1_2048_2des: pkcs8_pbe_sha1_2des_2048.key pkcs8_pbe_sha1_2des_2048.der
166
167pkcs8_pbe_sha1_rc4_128_2048.der: keyfile_2048
168 $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-RC4-128
169pkcs8_pbe_sha1_rc4_128_2048.key: keyfile_2048
170 $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-RC4-128
171keys_rsa_enc_pkcs8_v1_2048_rc4_128: pkcs8_pbe_sha1_rc4_128_2048.key pkcs8_pbe_sha1_rc4_128_2048.der
172
173keys_rsa_enc_pkcs8_v1_2048: keys_rsa_enc_pkcs8_v1_2048_3des keys_rsa_enc_pkcs8_v1_2048_2des keys_rsa_enc_pkcs8_v1_2048_rc4_128
174
175### 4096-bit
176pkcs8_pbe_sha1_3des_4096.der: keyfile_4096
177 $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-3DES
178pkcs8_pbe_sha1_3des_4096.key: keyfile_4096
179 $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-3DES
180keys_rsa_enc_pkcs8_v1_4096_3des: pkcs8_pbe_sha1_3des_4096.key pkcs8_pbe_sha1_3des_4096.der
181
182pkcs8_pbe_sha1_2des_4096.der: keyfile_4096
183 $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-2DES
184pkcs8_pbe_sha1_2des_4096.key: keyfile_4096
185 $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-2DES
186keys_rsa_enc_pkcs8_v1_4096_2des: pkcs8_pbe_sha1_2des_4096.key pkcs8_pbe_sha1_2des_4096.der
187
188pkcs8_pbe_sha1_rc4_128_4096.der: keyfile_4096
189 $(OPENSSL) pkcs8 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-RC4-128
190pkcs8_pbe_sha1_rc4_128_4096.key: keyfile_4096
191 $(OPENSSL) pkcs8 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)" -topk8 -v1 PBE-SHA1-RC4-128
192keys_rsa_enc_pkcs8_v1_4096_rc4_128: pkcs8_pbe_sha1_rc4_128_4096.key pkcs8_pbe_sha1_rc4_128_4096.der
193
194keys_rsa_enc_pkcs8_v1_4096: keys_rsa_enc_pkcs8_v1_4096_3des keys_rsa_enc_pkcs8_v1_4096_2des keys_rsa_enc_pkcs8_v1_4096_rc4_128
195
196###
197### PKCS8-v2 encoded, encrypted RSA keys
198###
199
200### 1024-bit
201pkcs8_pbes2_pbkdf2_3des.der: keyfile
202 $(OPENSSL) pkcs8 -topk8 -v2 des3 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
203pkcs8_pbes2_pbkdf2_3des.key: keyfile
204 $(OPENSSL) pkcs8 -topk8 -v2 des3 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
205keys_rsa_enc_pkcs8_v2_1024_3des: pkcs8_pbes2_pbkdf2_3des.der pkcs8_pbes2_pbkdf2_3des.key
206
207pkcs8_pbes2_pbkdf2_des.der: keyfile
208 $(OPENSSL) pkcs8 -topk8 -v2 des -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
209pkcs8_pbes2_pbkdf2_des.key: keyfile
210 $(OPENSSL) pkcs8 -topk8 -v2 des -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
211keys_rsa_enc_pkcs8_v2_1024_des: pkcs8_pbes2_pbkdf2_des.der pkcs8_pbes2_pbkdf2_des.key
212
213keys_rsa_enc_pkcs8_v2_1024: keys_rsa_enc_pkcs8_v2_1024_3des keys_rsa_enc_pkcs8_v2_1024_des
214
215### 2048-bit
216pkcs8_pbes2_pbkdf2_3des_2048.der: keyfile_2048
217 $(OPENSSL) pkcs8 -topk8 -v2 des3 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
218pkcs8_pbes2_pbkdf2_3des_2048.key: keyfile_2048
219 $(OPENSSL) pkcs8 -topk8 -v2 des3 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
220keys_rsa_enc_pkcs8_v2_2048_3des: pkcs8_pbes2_pbkdf2_3des_2048.der pkcs8_pbes2_pbkdf2_3des_2048.key
221
222pkcs8_pbes2_pbkdf2_des_2048.der: keyfile_2048
223 $(OPENSSL) pkcs8 -topk8 -v2 des -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
224pkcs8_pbes2_pbkdf2_des_2048.key: keyfile_2048
225 $(OPENSSL) pkcs8 -topk8 -v2 des -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
226keys_rsa_enc_pkcs8_v2_2048_des: pkcs8_pbes2_pbkdf2_des_2048.der pkcs8_pbes2_pbkdf2_des_2048.key
227
228keys_rsa_enc_pkcs8_v2_2048: keys_rsa_enc_pkcs8_v2_2048_3des keys_rsa_enc_pkcs8_v2_2048_des
229
230### 4096-bit
231pkcs8_pbes2_pbkdf2_3des_4096.der: keyfile_4096
232 $(OPENSSL) pkcs8 -topk8 -v2 des3 -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
233pkcs8_pbes2_pbkdf2_3des_4096.key: keyfile_4096
234 $(OPENSSL) pkcs8 -topk8 -v2 des3 -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
235keys_rsa_enc_pkcs8_v2_4096_3des: pkcs8_pbes2_pbkdf2_3des_4096.der pkcs8_pbes2_pbkdf2_3des_4096.key
236
237pkcs8_pbes2_pbkdf2_des_4096.der: keyfile_4096
238 $(OPENSSL) pkcs8 -topk8 -v2 des -inform PEM -in $< -outform DER -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
239pkcs8_pbes2_pbkdf2_des_4096.key: keyfile_4096
240 $(OPENSSL) pkcs8 -topk8 -v2 des -inform PEM -in $< -outform PEM -out $@ -passout "pass:$(keys_rsa_pkcs8_pwd)"
241keys_rsa_enc_pkcs8_v2_4096_des: pkcs8_pbes2_pbkdf2_des_4096.der pkcs8_pbes2_pbkdf2_des_4096.key
242
243keys_rsa_enc_pkcs8_v2_4096: keys_rsa_enc_pkcs8_v2_4096_3des keys_rsa_enc_pkcs8_v2_4096_des
244
245###
246### Rules to generate all RSA keys from a particular class
247###
248
249### Generate basic unencrypted RSA keys
250keys_rsa_unenc: keyfile keyfile_2048 keyfile_4096
251
252### Generate PKCS1-encoded encrypted RSA keys
253keys_rsa_enc_basic: keys_rsa_enc_basic_1024 keys_rsa_enc_basic_2048 keys_rsa_enc_basic_4096
254
255### Generate PKCS8-v1 encrypted RSA keys
256keys_rsa_enc_pkcs8_v1: keys_rsa_enc_pkcs8_v1_1024 keys_rsa_enc_pkcs8_v1_2048 keys_rsa_enc_pkcs8_v1_4096
257
258### Generate PKCS8-v2 encrypted RSA keys
259keys_rsa_enc_pkcs8_v2: keys_rsa_enc_pkcs8_v2_1024 keys_rsa_enc_pkcs8_v2_2048 keys_rsa_enc_pkcs8_v2_4096
260
261### Generate all RSA keys
262keys_rsa_all: keys_rsa_unenc keys_rsa_enc_basic keys_rsa_enc_pkcs8_v1 keys_rsa_enc_pkcs8_v2
263
264all_final += keys_rsa_all
Gilles Peskinefd14bca2017-05-11 17:57:22 +0200265
266################################################################
267#### Meta targets
268################################################################
269
Gilles Peskinef040a172017-05-05 18:56:12 +0200270all_final: $(all_final)
271all: $(all_intermediate) $(all_final)
272
Gilles Peskinefd14bca2017-05-11 17:57:22 +0200273.PHONY: default all_final all
274
Gilles Peskinef040a172017-05-05 18:56:12 +0200275# These files should not be committed to the repository.
276list_intermediate:
277 @printf '%s\n' $(all_intermediate) | sort
278# These files should be committed to the repository so that the test data is
279# available upon checkout without running a randomized process depending on
280# third-party tools.
281list_final:
282 @printf '%s\n' $(all_final) | sort
Gilles Peskinefd14bca2017-05-11 17:57:22 +0200283.PHONY: list_intermediate list_final
Gilles Peskinef040a172017-05-05 18:56:12 +0200284
Gilles Peskinefd14bca2017-05-11 17:57:22 +0200285## Remove intermediate files
Gilles Peskinef040a172017-05-05 18:56:12 +0200286clean:
287 rm -f $(all_intermediate)
Gilles Peskinefd14bca2017-05-11 17:57:22 +0200288## Remove all build products, even the ones that are committed
Gilles Peskinef040a172017-05-05 18:56:12 +0200289neat: clean
290 rm -f $(all_final)
Gilles Peskinefd14bca2017-05-11 17:57:22 +0200291.PHONY: clean neat