2 $! A few very basic tests for the 'ts' time stamping authority command.
6 $ if f$getsyi("cpu") .ge. 128 then __arch := AXP
7 $ exe_dir := sys$disk:[-.'__arch'.exe.apps]
9 $ openssl := mcr 'f$parse(exe_dir+"openssl.exe")'
10 $ OPENSSL_CONF := [-]CAtsa.cnf
11 $ ! Because that's what ../apps/CA.sh really looks at
12 $ SSLEAY_CONFIG = "-config " + OPENSSL_CONF
16 $ write sys$error "TSA test failed!"
23 $ if f$search("tsa.dir") .nes ""
25 $ @[-.util]deltree [.tsa]*.*
26 $ set file/prot=(S:RWED,O:RWED,G:RWED,W:RWED) tsa.dir;*
38 $ @[-.util]deltree [.tsa]*.*
39 $ set file/prot=(S:RWED,O:RWED,G:RWED,W:RWED) tsa.dir;*
46 $ write sys$output "Creating a new CA for the TSA tests..."
47 $ @[--.util]deltree [.demoCA]*.*
49 $ open/write file VMStsa-response.create_ca
52 $ write file "Budapest"
53 $ write file "Budapest"
54 $ write file "Gov-CA Ltd."
57 $ open/read sys$ca_input VMStsa-response.create_ca
58 $ @[--.apps]CA.com -input sys$ca_input -newca
59 $ save_severity = $severity
61 $ if save_severity .ne. 1 then call error
69 $ open/write file VMStsa-response1.create_tsa_cert
71 $ write file "Budapest"
73 $ write file "Hun-TSA Ltd."
74 $ write file "tsa",INDEX
76 $ define/user sys$input VMStsa-response.create_tsa_cert
78 -out tsa_req'INDEX'.pem -keyout tsa_key'INDEX'.pem
79 $ if $severity .ne. 1 then call error
81 $ open/write file VMStsa-response2.create_tsa_cert
85 $ define/user sys$input VMStsa-response.create_tsa_cert
86 $ openssl ca -in tsa_req'INDEX'.pem -out tsa_cert'INDEX'.pem -
88 $ if $severity .ne. 1 then call error
94 $ openssl ts -query -in 'p1' -text
97 $ create_time_stamp_request1: subroutine
99 $ openssl ts -query -data [-]testtsa.com -policy tsa_policy1 -
101 $ if $severity .ne. 1 then call error
104 $ create_time_stamp_request2: subroutine
106 $ openssl ts -query -data [-]testtsa.com -policy tsa_policy2 -
107 -no_nonce -out req2.tsq
108 $ if $severity .ne. 1 then call error
111 $ create_time_stamp_request3: subroutine
113 $ openssl ts -query -data [-]CAtsa.cnf -no_nonce -out req3.tsq
114 $ if $severity .ne. 1 then call error
120 $ openssl ts -reply -in 'p1' -text
121 $ if $severity .ne. 1 then call error
124 $ create_time_stamp_response:
127 $ openssl ts -reply -section 'p3' -queryfile 'p1' -out 'p2'
128 $ if $severity .ne. 1 then call error
131 $ time_stamp_response_token_test:
134 $ RESPONSE2:='p2'.copy_tsr
135 $ TOKEN_DER:='p2'.token_der
136 $ openssl ts -reply -in 'p2' -out 'TOKEN_DER' -token_out
137 $ if $severity .ne. 1 then call error
138 $ openssl ts -reply -in 'TOKEN_DER' -token_in -out 'RESPONSE2'
139 $ if $severity .ne. 1 then call error
140 $ backup/compare 'RESPONSE2' 'p2'
141 $ if $severity .ne. 1 then call error
142 $ openssl ts -reply -in 'p2' -text -token_out
143 $ if $severity .ne. 1 then call error
144 $ openssl ts -reply -in 'TOKEN_DER' -token_in -text -token_out
145 $ if $severity .ne. 1 then call error
146 $ openssl ts -reply -queryfile 'p1' -text -token_out
147 $ if $severity .ne. 1 then call error
150 $ verify_time_stamp_response:
153 $ openssl ts -verify -queryfile 'p1' -in 'p2' -
154 -CAfile [.demoCA]cacert.pem -untrusted tsa_cert1.pem
155 $ if $severity .ne. 1 then call error
156 $ openssl ts -verify -data 'p3' -in 'p2' -
157 -CAfile [.demoCA]cacert.pem -untrusted tsa_cert1.pem
158 $ if $severity .ne. 1 then call error
161 $ verify_time_stamp_token:
164 $ # create the token from the response first
165 $ openssl ts -reply -in 'p2' -out 'p2'.token -token_out
166 $ if $severity .ne. 1 then call error
167 $ openssl ts -verify -queryfile 'p1' -in 'p2'.token -token_in \
168 -CAfile [.demoCA]cacert.pem -untrusted tsa_cert1.pem
169 $ if $severity .ne. 1 then call error
170 $ openssl ts -verify -data 'p3' -in 'p2'.token -token_in \
171 -CAfile [.demoCA]cacert.pem -untrusted tsa_cert1.pem
172 $ if $severity .ne. 1 then call error
175 $ verify_time_stamp_response_fail:
178 $ openssl ts -verify -queryfile 'p1' -in 'p2' -
179 -CAfile [.demoCA]cacert.pem -untrusted tsa_cert1.pem
180 $ # Checks if the verification failed, as it should have.
181 $ if $severity .ne. 1 then call error
182 $ write sys$output "Ok"
185 $ ! Main body ----------------------------------------------------------
187 $ write sys$output "Setting up TSA test directory..."
190 $ write sys$output "Creating CA for TSA tests..."
193 $ write sys$output "Creating tsa_cert1.pem TSA server cert..."
194 $ call create_tsa_cert 1 tsa_cert
196 $ write sys$output "Creating tsa_cert2.pem non-TSA server cert..."
197 $ call create_tsa_cert 2 non_tsa_cert
199 $ write sys$output "Creating req1.req time stamp request for file testtsa..."
200 $ call create_time_stamp_request1
202 $ write sys$output "Printing req1.req..."
203 $ call print_request req1.tsq
205 $ write sys$output "Generating valid response for req1.req..."
206 $ call create_time_stamp_response req1.tsq resp1.tsr tsa_config1
208 $ write sys$output "Printing response..."
209 $ call print_response resp1.tsr
211 $ write sys$output "Verifying valid response..."
212 $ call verify_time_stamp_response req1.tsq resp1.tsr ../testtsa
214 $ write sys$output "Verifying valid token..."
215 $ call verify_time_stamp_token req1.tsq resp1.tsr ../testtsa
217 $ ! The tests below are commented out, because invalid signer certificates
218 $ ! can no longer be specified in the config file.
220 $ ! write sys$output "Generating _invalid_ response for req1.req..."
221 $ ! call create_time_stamp_response req1.tsq resp1_bad.tsr tsa_config2
223 $ ! write sys$output "Printing response..."
224 $ ! call print_response resp1_bad.tsr
226 $ ! write sys$output "Verifying invalid response, it should fail..."
227 $ ! call verify_time_stamp_response_fail req1.tsq resp1_bad.tsr
229 $ write sys$output "Creating req2.req time stamp request for file testtsa..."
230 $ call create_time_stamp_request2
232 $ write sys$output "Printing req2.req..."
233 $ call print_request req2.tsq
235 $ write sys$output "Generating valid response for req2.req..."
236 $ call create_time_stamp_response req2.tsq resp2.tsr tsa_config1
238 $ write sys$output "Checking '-token_in' and '-token_out' options with '-reply'..."
239 $ call time_stamp_response_token_test req2.tsq resp2.tsr
241 $ write sys$output "Printing response..."
242 $ call print_response resp2.tsr
244 $ write sys$output "Verifying valid response..."
245 $ call verify_time_stamp_response req2.tsq resp2.tsr ../testtsa
247 $ write sys$output "Verifying response against wrong request, it should fail..."
248 $ call verify_time_stamp_response_fail req1.tsq resp2.tsr
250 $ write sys$output "Verifying response against wrong request, it should fail..."
251 $ call verify_time_stamp_response_fail req2.tsq resp1.tsr
253 $ write sys$output "Creating req3.req time stamp request for file CAtsa.cnf..."
254 $ call create_time_stamp_request3
256 $ write sys$output "Printing req3.req..."
257 $ call print_request req3.tsq
259 $ write sys$output "Verifying response against wrong request, it should fail..."
260 $ call verify_time_stamp_response_fail req3.tsq resp1.tsr
262 $ write sys$output "Cleaning up..."