1TS(1) OpenSSL TS(1)
2
3
4
6 ts - Time Stamping Authority tool (client/server)
7
9 openssl ts -query [-rand file:file...] [-config configfile] [-data
10 file_to_hash] [-digest digest_bytes]
11 [-md2|-md4|-md5|-sha|-sha1|-mdc2|-ripemd160|...] [-policy object_id]
12 [-no_nonce] [-cert] [-in request.tsq] [-out request.tsq] [-text]
13
14 openssl ts -reply [-config configfile] [-section tsa_section]
15 [-queryfile request.tsq] [-passin password_src] [-signer tsa_cert.pem]
16 [-inkey private.pem] [-chain certs_file.pem] [-policy object_id] [-in
17 response.tsr] [-token_in] [-out response.tsr] [-token_out] [-text]
18 [-engine id]
19
20 openssl ts -verify [-data file_to_hash] [-digest digest_bytes]
21 [-queryfile request.tsq] [-in response.tsr] [-token_in] [-CApath
22 trusted_cert_path] [-CAfile trusted_certs.pem] [-trusted_first]
23 [-untrusted cert_file.pem]
24
26 The ts command is a basic Time Stamping Authority (TSA) client and
27 server application as specified in RFC 3161 (Time-Stamp Protocol, TSP).
28 A TSA can be part of a PKI deployment and its role is to provide long
29 term proof of the existence of a certain datum before a particular
30 time. Here is a brief description of the protocol:
31
32 1. The TSA client computes a one-way hash value for a data file and
33 sends the hash to the TSA.
34
35 2. The TSA attaches the current date and time to the received hash
36 value, signs them and sends the time stamp token back to the
37 client. By creating this token the TSA certifies the existence of
38 the original data file at the time of response generation.
39
40 3. The TSA client receives the time stamp token and verifies the
41 signature on it. It also checks if the token contains the same hash
42 value that it had sent to the TSA.
43
44 There is one DER encoded protocol data unit defined for transporting a
45 time stamp request to the TSA and one for sending the time stamp
46 response back to the client. The ts command has three main functions:
47 creating a time stamp request based on a data file, creating a time
48 stamp response based on a request, verifying if a response corresponds
49 to a particular request or a data file.
50
51 There is no support for sending the requests/responses automatically
52 over HTTP or TCP yet as suggested in RFC 3161. The users must send the
53 requests either by ftp or e-mail.
54
56 Time Stamp Request generation
57 The -query switch can be used for creating and printing a time stamp
58 request with the following options:
59
60 -rand file:file...
61 The files containing random data for seeding the random number
62 generator. Multiple files can be specified, the separator is ; for
63 MS-Windows, , for VMS and : for all other platforms. (Optional)
64
65 -config configfile
66 The configuration file to use, this option overrides the
67 OPENSSL_CONF environment variable. Only the OID section of the
68 config file is used with the -query command. (Optional)
69
70 -data file_to_hash
71 The data file for which the time stamp request needs to be created.
72 stdin is the default if neither the -data nor the -digest parameter
73 is specified. (Optional)
74
75 -digest digest_bytes
76 It is possible to specify the message imprint explicitly without
77 the data file. The imprint must be specified in a hexadecimal
78 format, two characters per byte, the bytes optionally separated by
79 colons (e.g. 1A:F6:01:... or 1AF601...). The number of bytes must
80 match the message digest algorithm in use. (Optional)
81
82 -md2|-md4|-md5|-sha|-sha1|-mdc2|-ripemd160|...
83 The message digest to apply to the data file, it supports all the
84 message digest algorithms that are supported by the openssl dgst
85 command. The default is SHA-1. (Optional)
86
87 -policy object_id
88 The policy that the client expects the TSA to use for creating the
89 time stamp token. Either the dotted OID notation or OID names
90 defined in the config file can be used. If no policy is requested
91 the TSA will use its own default policy. (Optional)
92
93 -no_nonce
94 No nonce is specified in the request if this option is given.
95 Otherwise a 64 bit long pseudo-random none is included in the
96 request. It is recommended to use nonce to protect against replay-
97 attacks. (Optional)
98
99 -cert
100 The TSA is expected to include its signing certificate in the
101 response. (Optional)
102
103 -in request.tsq
104 This option specifies a previously created time stamp request in
105 DER format that will be printed into the output file. Useful when
106 you need to examine the content of a request in human-readable
107
108 format. (Optional)
109
110 -out request.tsq
111 Name of the output file to which the request will be written.
112 Default is stdout. (Optional)
113
114 -text
115 If this option is specified the output is human-readable text
116 format instead of DER. (Optional)
117
118 Time Stamp Response generation
119 A time stamp response (TimeStampResp) consists of a response status and
120 the time stamp token itself (ContentInfo), if the token generation was
121 successful. The -reply command is for creating a time stamp response or
122 time stamp token based on a request and printing the response/token in
123 human-readable format. If -token_out is not specified the output is
124 always a time stamp response (TimeStampResp), otherwise it is a time
125 stamp token (ContentInfo).
126
127 -config configfile
128 The configuration file to use, this option overrides the
129 OPENSSL_CONF environment variable. See CONFIGURATION FILE OPTIONS
130 for configurable variables. (Optional)
131
132 -section tsa_section
133 The name of the config file section conatining the settings for the
134 response generation. If not specified the default TSA section is
135 used, see CONFIGURATION FILE OPTIONS for details. (Optional)
136
137 -queryfile request.tsq
138 The name of the file containing a DER encoded time stamp request.
139 (Optional)
140
141 -passin password_src
142 Specifies the password source for the private key of the TSA. See
143 PASS PHRASE ARGUMENTS in openssl(1). (Optional)
144
145 -signer tsa_cert.pem
146 The signer certificate of the TSA in PEM format. The TSA signing
147 certificate must have exactly one extended key usage assigned to
148 it: timeStamping. The extended key usage must also be critical,
149 otherwise the certificate is going to be refused. Overrides the
150 signer_cert variable of the config file. (Optional)
151
152 -inkey private.pem
153 The signer private key of the TSA in PEM format. Overrides the
154 signer_key config file option. (Optional)
155
156 -chain certs_file.pem
157 The collection of certificates in PEM format that will all be
158 included in the response in addition to the signer certificate if
159 the -cert option was used for the request. This file is supposed to
160 contain the certificate chain for the signer certificate from its
161 issuer upwards. The -reply command does not build a certificate
162 chain automatically. (Optional)
163
164 -policy object_id
165 The default policy to use for the response unless the client
166 explicitly requires a particular TSA policy. The OID can be
167 specified either in dotted notation or with its name. Overrides the
168 default_policy config file option. (Optional)
169
170 -in response.tsr
171 Specifies a previously created time stamp response or time stamp
172 token (if -token_in is also specified) in DER format that will be
173 written to the output file. This option does not require a request,
174 it is useful e.g. when you need to examine the content of a
175 response or token or you want to extract the time stamp token from
176 a response. If the input is a token and the output is a time stamp
177 response a default 'granted' status info is added to the token.
178 (Optional)
179
180 -token_in
181 This flag can be used together with the -in option and indicates
182 that the input is a DER encoded time stamp token (ContentInfo)
183 instead of a time stamp response (TimeStampResp). (Optional)
184
185 -out response.tsr
186 The response is written to this file. The format and content of the
187 file depends on other options (see -text, -token_out). The default
188 is stdout. (Optional)
189
190 -token_out
191 The output is a time stamp token (ContentInfo) instead of time
192 stamp response (TimeStampResp). (Optional)
193
194 -text
195 If this option is specified the output is human-readable text
196 format instead of DER. (Optional)
197
198 -engine id
199 Specifying an engine (by its unique id string) will cause ts to
200 attempt to obtain a functional reference to the specified engine,
201 thus initialising it if needed. The engine will then be set as the
202 default for all available algorithms. Default is builtin.
203 (Optional)
204
205 Time Stamp Response verification
206 The -verify command is for verifying if a time stamp response or time
207 stamp token is valid and matches a particular time stamp request or
208 data file. The -verify command does not use the configuration file.
209
210 -data file_to_hash
211 The response or token must be verified against file_to_hash. The
212 file is hashed with the message digest algorithm specified in the
213 token. The -digest and -queryfile options must not be specified
214 with this one. (Optional)
215
216 -digest digest_bytes
217 The response or token must be verified against the message digest
218 specified with this option. The number of bytes must match the
219 message digest algorithm specified in the token. The -data and
220 -queryfile options must not be specified with this one. (Optional)
221
222 -queryfile request.tsq
223 The original time stamp request in DER format. The -data and
224 -digest options must not be specified with this one. (Optional)
225
226 -in response.tsr
227 The time stamp response that needs to be verified in DER format.
228 (Mandatory)
229
230 -token_in
231 This flag can be used together with the -in option and indicates
232 that the input is a DER encoded time stamp token (ContentInfo)
233 instead of a time stamp response (TimeStampResp). (Optional)
234
235 -CApath trusted_cert_path
236 The name of the directory containing the trused CA certificates of
237 the client. See the similar option of verify(1) for additional
238 details. Either this option or -CAfile must be specified.
239 (Optional)
240
241 -CAfile trusted_certs.pem
242 The name of the file containing a set of trusted self-signed CA
243 certificates in PEM format. See the similar option of verify(1) for
244 additional details. Either this option or -CApath must be
245 specified. (Optional)
246
247 -trusted_first
248 Use certificates in CA file or CA directory before other
249 certificates when building the trust chain to verify certificates.
250 This is mainly useful in environments with Bridge CA or Cross-
251 Certified CAs.
252
253 -untrusted cert_file.pem
254 Set of additional untrusted certificates in PEM format which may be
255 needed when building the certificate chain for the TSA's signing
256 certificate. This file must contain the TSA signing certificate and
257 all intermediate CA certificates unless the response includes them.
258 (Optional)
259
261 The -query and -reply commands make use of a configuration file defined
262 by the OPENSSL_CONF environment variable. See config(5) for a general
263 description of the syntax of the config file. The -query command uses
264 only the symbolic OID names section and it can work without it.
265 However, the -reply command needs the config file for its operation.
266
267 When there is a command line switch equivalent of a variable the switch
268 always overrides the settings in the config file.
269
270 tsa section, default_tsa
271 This is the main section and it specifies the name of another
272 section that contains all the options for the -reply command. This
273 default section can be overridden with the -section command line
274 switch. (Optional)
275
276 oid_file
277 See ca(1) for description. (Optional)
278
279 oid_section
280 See ca(1) for description. (Optional)
281
282 RANDFILE
283 See ca(1) for description. (Optional)
284
285 serial
286 The name of the file containing the hexadecimal serial number of
287 the last time stamp response created. This number is incremented by
288 1 for each response. If the file does not exist at the time of
289 response generation a new file is created with serial number 1.
290 (Mandatory)
291
292 crypto_device
293 Specifies the OpenSSL engine that will be set as the default for
294 all available algorithms. The default value is builtin, you can
295 specify any other engines supported by OpenSSL (e.g. use chil for
296 the NCipher HSM). (Optional)
297
298 signer_cert
299 TSA signing certificate in PEM format. The same as the -signer
300 command line option. (Optional)
301
302 certs
303 A file containing a set of PEM encoded certificates that need to be
304 included in the response. The same as the -chain command line
305 option. (Optional)
306
307 signer_key
308 The private key of the TSA in PEM format. The same as the -inkey
309 command line option. (Optional)
310
311 default_policy
312 The default policy to use when the request does not mandate any
313 policy. The same as the -policy command line option. (Optional)
314
315 other_policies
316 Comma separated list of policies that are also acceptable by the
317 TSA and used only if the request explicitly specifies one of them.
318 (Optional)
319
320 digests
321 The list of message digest algorithms that the TSA accepts. At
322 least one algorithm must be specified. (Mandatory)
323
324 accuracy
325 The accuracy of the time source of the TSA in seconds, milliseconds
326 and microseconds. E.g. secs:1, millisecs:500, microsecs:100. If any
327 of the components is missing zero is assumed for that field.
328 (Optional)
329
330 clock_precision_digits
331 Specifies the maximum number of digits, which represent the
332 fraction of seconds, that need to be included in the time field.
333 The trailing zeroes must be removed from the time, so there might
334 actually be fewer digits, or no fraction of seconds at all.
335 Supported only on UNIX platforms. The maximum value is 6, default
336 is 0. (Optional)
337
338 ordering
339 If this option is yes the responses generated by this TSA can
340 always be ordered, even if the time difference between two
341 responses is less than the sum of their accuracies. Default is no.
342 (Optional)
343
344 tsa_name
345 Set this option to yes if the subject name of the TSA must be
346 included in the TSA name field of the response. Default is no.
347 (Optional)
348
349 ess_cert_id_chain
350 The SignedData objects created by the TSA always contain the
351 certificate identifier of the signing certificate in a signed
352 attribute (see RFC 2634, Enhanced Security Services). If this
353 option is set to yes and either the certs variable or the -chain
354 option is specified then the certificate identifiers of the chain
355 will also be included in the SigningCertificate signed attribute.
356 If this variable is set to no, only the signing certificate
357 identifier is included. Default is no. (Optional)
358
360 OPENSSL_CONF contains the path of the configuration file and can be
361 overridden by the -config command line option.
362
364 All the examples below presume that OPENSSL_CONF is set to a proper
365 configuration file, e.g. the example configuration file
366 openssl/apps/openssl.cnf will do.
367
368 Time Stamp Request
369 To create a time stamp request for design1.txt with SHA-1 without nonce
370 and policy and no certificate is required in the response:
371
372 openssl ts -query -data design1.txt -no_nonce \
373 -out design1.tsq
374
375 To create a similar time stamp request with specifying the message
376 imprint explicitly:
377
378 openssl ts -query -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
379 -no_nonce -out design1.tsq
380
381 To print the content of the previous request in human readable format:
382
383 openssl ts -query -in design1.tsq -text
384
385 To create a time stamp request which includes the MD-5 digest of
386 design2.txt, requests the signer certificate and nonce, specifies a
387 policy id (assuming the tsa_policy1 name is defined in the OID section
388 of the config file):
389
390 openssl ts -query -data design2.txt -md5 \
391 -policy tsa_policy1 -cert -out design2.tsq
392
393 Time Stamp Response
394 Before generating a response a signing certificate must be created for
395 the TSA that contains the timeStamping critical extended key usage
396 extension without any other key usage extensions. You can add the
397 'extendedKeyUsage = critical,timeStamping' line to the user certificate
398 section of the config file to generate a proper certificate. See
399 req(1), ca(1), x509(1) for instructions. The examples below assume that
400 cacert.pem contains the certificate of the CA, tsacert.pem is the
401 signing certificate issued by cacert.pem and tsakey.pem is the private
402 key of the TSA.
403
404 To create a time stamp response for a request:
405
406 openssl ts -reply -queryfile design1.tsq -inkey tsakey.pem \
407 -signer tsacert.pem -out design1.tsr
408
409 If you want to use the settings in the config file you could just
410 write:
411
412 openssl ts -reply -queryfile design1.tsq -out design1.tsr
413
414 To print a time stamp reply to stdout in human readable format:
415
416 openssl ts -reply -in design1.tsr -text
417
418 To create a time stamp token instead of time stamp response:
419
420 openssl ts -reply -queryfile design1.tsq -out design1_token.der -token_out
421
422 To print a time stamp token to stdout in human readable format:
423
424 openssl ts -reply -in design1_token.der -token_in -text -token_out
425
426 To extract the time stamp token from a response:
427
428 openssl ts -reply -in design1.tsr -out design1_token.der -token_out
429
430 To add 'granted' status info to a time stamp token thereby creating a
431 valid response:
432
433 openssl ts -reply -in design1_token.der -token_in -out design1.tsr
434
435 Time Stamp Verification
436 To verify a time stamp reply against a request:
437
438 openssl ts -verify -queryfile design1.tsq -in design1.tsr \
439 -CAfile cacert.pem -untrusted tsacert.pem
440
441 To verify a time stamp reply that includes the certificate chain:
442
443 openssl ts -verify -queryfile design2.tsq -in design2.tsr \
444 -CAfile cacert.pem
445
446 To verify a time stamp token against the original data file:
447 openssl ts -verify -data design2.txt -in design2.tsr \ -CAfile
448 cacert.pem
449
450 To verify a time stamp token against a message imprint:
451 openssl ts -verify -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
452 -in design2.tsr -CAfile cacert.pem
453
454 You could also look at the 'test' directory for more examples.
455
457 If you find any bugs or you have suggestions please write to Zoltan
458 Glozik <zglozik@opentsa.org>. Known issues:
459
460 · No support for time stamps over SMTP, though it is quite easy to
461 implement an automatic e-mail based TSA with procmail(1) and
462 perl(1). HTTP server support is provided in the form of a separate
463 apache module. HTTP client support is provided by tsget(1). Pure
464 TCP/IP protocol is not supported.
465
466 · The file containing the last serial number of the TSA is not locked
467 when being read or written. This is a problem if more than one
468 instance of openssl(1) is trying to create a time stamp response at
469 the same time. This is not an issue when using the apache server
470 module, it does proper locking.
471
472 · Look for the FIXME word in the source files.
473
474 · The source code should really be reviewed by somebody else, too.
475
476 · More testing is needed, I have done only some basic tests (see
477 test/testtsa).
478
480 Zoltan Glozik <zglozik@opentsa.org>, OpenTSA project
481 (http://www.opentsa.org)
482
484 tsget(1), openssl(1), req(1), x509(1), ca(1), genrsa(1), config(5)
485
486
487
4881.0.2k 2019-03-12 TS(1)