5 ts - Time Stamping Authority tool (client/server)
11 [B<-rand> file:file...]
12 [B<-config> configfile]
13 [B<-data> file_to_hash]
14 [B<-digest> digest_bytes]
16 [B<-policy> object_id]
25 [B<-config> configfile]
26 [B<-section> tsa_section]
27 [B<-queryfile> request.tsq]
28 [B<-passin> password_src]
29 [B<-signer> tsa_cert.pem]
30 [B<-inkey> private.pem]
31 [B<-sha1|-sha224|-sha256|-sha384|-sha512>]
32 [B<-chain> certs_file.pem]
33 [B<-policy> object_id]
36 [B<-out> response.tsr]
43 [B<-data> file_to_hash]
44 [B<-digest> digest_bytes]
45 [B<-queryfile> request.tsq]
48 [B<-CApath> trusted_cert_path]
49 [B<-CAfile> trusted_certs.pem]
50 [B<-untrusted> cert_file.pem]
54 The B<ts> command is a basic Time Stamping Authority (TSA) client and server
55 application as specified in RFC 3161 (Time-Stamp Protocol, TSP). A
56 TSA can be part of a PKI deployment and its role is to provide long
57 term proof of the existence of a certain datum before a particular
58 time. Here is a brief description of the protocol:
64 The TSA client computes a one-way hash value for a data file and sends
69 The TSA attaches the current date and time to the received hash value,
70 signs them and sends the time stamp token back to the client. By
71 creating this token the TSA certifies the existence of the original
72 data file at the time of response generation.
76 The TSA client receives the time stamp token and verifies the
77 signature on it. It also checks if the token contains the same hash
78 value that it had sent to the TSA.
82 There is one DER encoded protocol data unit defined for transporting a time
83 stamp request to the TSA and one for sending the time stamp response
84 back to the client. The B<ts> command has three main functions:
85 creating a time stamp request based on a data file,
86 creating a time stamp response based on a request, verifying if a
87 response corresponds to a particular request or a data file.
89 There is no support for sending the requests/responses automatically
90 over HTTP or TCP yet as suggested in RFC 3161. The users must send the
91 requests either by ftp or e-mail.
95 =head2 Time Stamp Request generation
97 The B<-query> switch can be used for creating and printing a time stamp
98 request with the following options:
102 =item B<-rand> file:file...
104 The files containing random data for seeding the random number
105 generator. Multiple files can be specified, the separator is B<;> for
106 MS-Windows, B<,> for VMS and B<:> for all other platforms. (Optional)
108 =item B<-config> configfile
110 The configuration file to use, this option overrides the
111 B<OPENSSL_CONF> environment variable. Only the OID section
112 of the config file is used with the B<-query> command. (Optional)
114 =item B<-data> file_to_hash
116 The data file for which the time stamp request needs to be
117 created. stdin is the default if neither the B<-data> nor the B<-digest>
118 parameter is specified. (Optional)
120 =item B<-digest> digest_bytes
122 It is possible to specify the message imprint explicitly without the data
123 file. The imprint must be specified in a hexadecimal format, two characters
124 per byte, the bytes optionally separated by colons (e.g. 1A:F6:01:... or
125 1AF601...). The number of bytes must match the message digest algorithm
130 The message digest to apply to the data file.
131 Any digest supported by the OpenSSL B<dgst> command can be used.
132 The default is SHA-1. (Optional)
134 =item B<-policy> object_id
136 The policy that the client expects the TSA to use for creating the
137 time stamp token. Either the dotted OID notation or OID names defined
138 in the config file can be used. If no policy is requested the TSA will
139 use its own default policy. (Optional)
143 No nonce is specified in the request if this option is
144 given. Otherwise a 64 bit long pseudo-random none is
145 included in the request. It is recommended to use nonce to
146 protect against replay-attacks. (Optional)
150 The TSA is expected to include its signing certificate in the
153 =item B<-in> request.tsq
155 This option specifies a previously created time stamp request in DER
156 format that will be printed into the output file. Useful when you need
157 to examine the content of a request in human-readable
161 =item B<-out> request.tsq
163 Name of the output file to which the request will be written. Default
164 is stdout. (Optional)
168 If this option is specified the output is human-readable text format
169 instead of DER. (Optional)
173 =head2 Time Stamp Response generation
175 A time stamp response (TimeStampResp) consists of a response status
176 and the time stamp token itself (ContentInfo), if the token generation was
177 successful. The B<-reply> command is for creating a time stamp
178 response or time stamp token based on a request and printing the
179 response/token in human-readable format. If B<-token_out> is not
180 specified the output is always a time stamp response (TimeStampResp),
181 otherwise it is a time stamp token (ContentInfo).
185 =item B<-config> configfile
187 The configuration file to use, this option overrides the
188 B<OPENSSL_CONF> environment variable. See B<CONFIGURATION FILE
189 OPTIONS> for configurable variables. (Optional)
191 =item B<-section> tsa_section
193 The name of the config file section containing the settings for the
194 response generation. If not specified the default TSA section is
195 used, see B<CONFIGURATION FILE OPTIONS> for details. (Optional)
197 =item B<-queryfile> request.tsq
199 The name of the file containing a DER encoded time stamp request. (Optional)
201 =item B<-passin> password_src
203 Specifies the password source for the private key of the TSA. See
204 B<PASS PHRASE ARGUMENTS> in L<openssl(1)>. (Optional)
206 =item B<-signer> tsa_cert.pem
208 The signer certificate of the TSA in PEM format. The TSA signing
209 certificate must have exactly one extended key usage assigned to it:
210 timeStamping. The extended key usage must also be critical, otherwise
211 the certificate is going to be refused. Overrides the B<signer_cert>
212 variable of the config file. (Optional)
214 =item B<-inkey> private.pem
216 The signer private key of the TSA in PEM format. Overrides the
217 B<signer_key> config file option. (Optional)
219 =item B<-sha1|-sha224|-sha256|-sha384|-sha512>
221 Signing digest to use. Overrides the B<signer_digest> config file
224 =item B<-chain> certs_file.pem
226 The collection of certificates in PEM format that will all
227 be included in the response in addition to the signer certificate if
228 the B<-cert> option was used for the request. This file is supposed to
229 contain the certificate chain for the signer certificate from its
230 issuer upwards. The B<-reply> command does not build a certificate
231 chain automatically. (Optional)
233 =item B<-policy> object_id
235 The default policy to use for the response unless the client
236 explicitly requires a particular TSA policy. The OID can be specified
237 either in dotted notation or with its name. Overrides the
238 B<default_policy> config file option. (Optional)
240 =item B<-in> response.tsr
242 Specifies a previously created time stamp response or time stamp token
243 (if B<-token_in> is also specified) in DER format that will be written
244 to the output file. This option does not require a request, it is
245 useful e.g. when you need to examine the content of a response or
246 token or you want to extract the time stamp token from a response. If
247 the input is a token and the output is a time stamp response a default
248 'granted' status info is added to the token. (Optional)
252 This flag can be used together with the B<-in> option and indicates
253 that the input is a DER encoded time stamp token (ContentInfo) instead
254 of a time stamp response (TimeStampResp). (Optional)
256 =item B<-out> response.tsr
258 The response is written to this file. The format and content of the
259 file depends on other options (see B<-text>, B<-token_out>). The default is
264 The output is a time stamp token (ContentInfo) instead of time stamp
265 response (TimeStampResp). (Optional)
269 If this option is specified the output is human-readable text format
270 instead of DER. (Optional)
274 Specifying an engine (by its unique B<id> string) will cause B<ts>
275 to attempt to obtain a functional reference to the specified engine,
276 thus initialising it if needed. The engine will then be set as the default
277 for all available algorithms. Default is builtin. (Optional)
281 =head2 Time Stamp Response verification
283 The B<-verify> command is for verifying if a time stamp response or time
284 stamp token is valid and matches a particular time stamp request or
285 data file. The B<-verify> command does not use the configuration file.
289 =item B<-data> file_to_hash
291 The response or token must be verified against file_to_hash. The file
292 is hashed with the message digest algorithm specified in the token.
293 The B<-digest> and B<-queryfile> options must not be specified with this one.
296 =item B<-digest> digest_bytes
298 The response or token must be verified against the message digest specified
299 with this option. The number of bytes must match the message digest algorithm
300 specified in the token. The B<-data> and B<-queryfile> options must not be
301 specified with this one. (Optional)
303 =item B<-queryfile> request.tsq
305 The original time stamp request in DER format. The B<-data> and B<-digest>
306 options must not be specified with this one. (Optional)
308 =item B<-in> response.tsr
310 The time stamp response that needs to be verified in DER format. (Mandatory)
314 This flag can be used together with the B<-in> option and indicates
315 that the input is a DER encoded time stamp token (ContentInfo) instead
316 of a time stamp response (TimeStampResp). (Optional)
318 =item B<-CApath> trusted_cert_path
320 The name of the directory containing the trusted CA certificates of the
321 client. See the similar option of L<verify(1)> for additional
322 details. Either this option or B<-CAfile> must be specified. (Optional)
325 =item B<-CAfile> trusted_certs.pem
327 The name of the file containing a set of trusted self-signed CA
328 certificates in PEM format. See the similar option of
329 L<verify(1)> for additional details. Either this option
330 or B<-CApath> must be specified.
333 =item B<-untrusted> cert_file.pem
335 Set of additional untrusted certificates in PEM format which may be
336 needed when building the certificate chain for the TSA's signing
337 certificate. This file must contain the TSA signing certificate and
338 all intermediate CA certificates unless the response includes them.
343 =head1 CONFIGURATION FILE OPTIONS
345 The B<-query> and B<-reply> commands make use of a configuration file
346 defined by the B<OPENSSL_CONF> environment variable. See L<config(5)>
347 for a general description of the syntax of the config file. The
348 B<-query> command uses only the symbolic OID names section
349 and it can work without it. However, the B<-reply> command needs the
350 config file for its operation.
352 When there is a command line switch equivalent of a variable the
353 switch always overrides the settings in the config file.
357 =item B<tsa> section, B<default_tsa>
359 This is the main section and it specifies the name of another section
360 that contains all the options for the B<-reply> command. This default
361 section can be overridden with the B<-section> command line switch. (Optional)
365 See L<ca(1)> for description. (Optional)
369 See L<ca(1)> for description. (Optional)
373 See L<ca(1)> for description. (Optional)
377 The name of the file containing the hexadecimal serial number of the
378 last time stamp response created. This number is incremented by 1 for
379 each response. If the file does not exist at the time of response
380 generation a new file is created with serial number 1. (Mandatory)
382 =item B<crypto_device>
384 Specifies the OpenSSL engine that will be set as the default for
385 all available algorithms. The default value is builtin, you can specify
386 any other engines supported by OpenSSL (e.g. use chil for the NCipher HSM).
391 TSA signing certificate in PEM format. The same as the B<-signer>
392 command line option. (Optional)
396 A file containing a set of PEM encoded certificates that need to be
397 included in the response. The same as the B<-chain> command line
402 The private key of the TSA in PEM format. The same as the B<-inkey>
403 command line option. (Optional)
405 =item B<signer_digest>
407 Signing digest to use. The same as the
408 B<-sha1|-sha224|-sha256|-sha384|-sha512> command line option. (Optional)
410 =item B<default_policy>
412 The default policy to use when the request does not mandate any
413 policy. The same as the B<-policy> command line option. (Optional)
415 =item B<other_policies>
417 Comma separated list of policies that are also acceptable by the TSA
418 and used only if the request explicitly specifies one of them. (Optional)
422 The list of message digest algorithms that the TSA accepts. At least
423 one algorithm must be specified. (Mandatory)
427 The accuracy of the time source of the TSA in seconds, milliseconds
428 and microseconds. E.g. secs:1, millisecs:500, microsecs:100. If any of
429 the components is missing zero is assumed for that field. (Optional)
431 =item B<clock_precision_digits>
433 Specifies the maximum number of digits, which represent the fraction of
434 seconds, that need to be included in the time field. The trailing zeroes
435 must be removed from the time, so there might actually be fewer digits,
436 or no fraction of seconds at all. Supported only on UNIX platforms.
437 The maximum value is 6, default is 0.
442 If this option is yes the responses generated by this TSA can always
443 be ordered, even if the time difference between two responses is less
444 than the sum of their accuracies. Default is no. (Optional)
448 Set this option to yes if the subject name of the TSA must be included in
449 the TSA name field of the response. Default is no. (Optional)
451 =item B<ess_cert_id_chain>
453 The SignedData objects created by the TSA always contain the
454 certificate identifier of the signing certificate in a signed
455 attribute (see RFC 2634, Enhanced Security Services). If this option
456 is set to yes and either the B<certs> variable or the B<-chain> option
457 is specified then the certificate identifiers of the chain will also
458 be included in the SigningCertificate signed attribute. If this
459 variable is set to no, only the signing certificate identifier is
460 included. Default is no. (Optional)
464 =head1 ENVIRONMENT VARIABLES
466 B<OPENSSL_CONF> contains the path of the configuration file and can be
467 overridden by the B<-config> command line option.
471 All the examples below presume that B<OPENSSL_CONF> is set to a proper
472 configuration file, e.g. the example configuration file
473 openssl/apps/openssl.cnf will do.
475 =head2 Time Stamp Request
477 To create a time stamp request for design1.txt with SHA-1
478 without nonce and policy and no certificate is required in the response:
480 openssl ts -query -data design1.txt -no_nonce \
483 To create a similar time stamp request with specifying the message imprint
486 openssl ts -query -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
487 -no_nonce -out design1.tsq
489 To print the content of the previous request in human readable format:
491 openssl ts -query -in design1.tsq -text
493 To create a time stamp request which includes the MD-5 digest
494 of design2.txt, requests the signer certificate and nonce,
495 specifies a policy id (assuming the tsa_policy1 name is defined in the
496 OID section of the config file):
498 openssl ts -query -data design2.txt -md5 \
499 -policy tsa_policy1 -cert -out design2.tsq
501 =head2 Time Stamp Response
503 Before generating a response a signing certificate must be created for
504 the TSA that contains the B<timeStamping> critical extended key usage extension
505 without any other key usage extensions. You can add the
506 'extendedKeyUsage = critical,timeStamping' line to the user certificate section
507 of the config file to generate a proper certificate. See L<req(1)>,
508 L<ca(1)>, L<x509(1)> for instructions. The examples
509 below assume that cacert.pem contains the certificate of the CA,
510 tsacert.pem is the signing certificate issued by cacert.pem and
511 tsakey.pem is the private key of the TSA.
513 To create a time stamp response for a request:
515 openssl ts -reply -queryfile design1.tsq -inkey tsakey.pem \
516 -signer tsacert.pem -out design1.tsr
518 If you want to use the settings in the config file you could just write:
520 openssl ts -reply -queryfile design1.tsq -out design1.tsr
522 To print a time stamp reply to stdout in human readable format:
524 openssl ts -reply -in design1.tsr -text
526 To create a time stamp token instead of time stamp response:
528 openssl ts -reply -queryfile design1.tsq -out design1_token.der -token_out
530 To print a time stamp token to stdout in human readable format:
532 openssl ts -reply -in design1_token.der -token_in -text -token_out
534 To extract the time stamp token from a response:
536 openssl ts -reply -in design1.tsr -out design1_token.der -token_out
538 To add 'granted' status info to a time stamp token thereby creating a
541 openssl ts -reply -in design1_token.der -token_in -out design1.tsr
543 =head2 Time Stamp Verification
545 To verify a time stamp reply against a request:
547 openssl ts -verify -queryfile design1.tsq -in design1.tsr \
548 -CAfile cacert.pem -untrusted tsacert.pem
550 To verify a time stamp reply that includes the certificate chain:
552 openssl ts -verify -queryfile design2.tsq -in design2.tsr \
555 To verify a time stamp token against the original data file:
556 openssl ts -verify -data design2.txt -in design2.tsr \
559 To verify a time stamp token against a message imprint:
560 openssl ts -verify -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
561 -in design2.tsr -CAfile cacert.pem
563 You could also look at the 'test' directory for more examples.
567 If you find any bugs or you have suggestions please write to
568 Zoltan Glozik <zglozik@opentsa.org>. Known issues:
572 =item * No support for time stamps over SMTP, though it is quite easy
573 to implement an automatic e-mail based TSA with L<procmail(1)>
574 and L<perl(1)>. HTTP server support is provided in the form of
575 a separate apache module. HTTP client support is provided by
576 L<tsget(1)>. Pure TCP/IP protocol is not supported.
578 =item * The file containing the last serial number of the TSA is not
579 locked when being read or written. This is a problem if more than one
580 instance of L<openssl(1)> is trying to create a time stamp
581 response at the same time. This is not an issue when using the apache
582 server module, it does proper locking.
584 =item * Look for the FIXME word in the source files.
586 =item * The source code should really be reviewed by somebody else, too.
588 =item * More testing is needed, I have done only some basic tests (see
597 L<tsget(1)>, L<openssl(1)>, L<req(1)>,
598 L<x509(1)>, L<ca(1)>, L<genrsa(1)>,