5 openssl-ts - Time Stamping Authority tool (client/server)
12 [B<-writerand> I<file>]
13 [B<-config> I<configfile>]
14 [B<-data> I<file_to_hash>]
15 [B<-digest> I<digest_bytes>]
17 [B<-tspolicy> I<object_id>]
20 [B<-in> I<request.tsq>]
21 [B<-out> I<request.tsq>]
26 [B<-config> I<configfile>]
27 [B<-section> I<tsa_section>]
28 [B<-queryfile> I<request.tsq>]
29 [B<-passin> I<password_src>]
30 [B<-signer> I<tsa_cert.pem>]
31 [B<-inkey> I<file_or_id>]
33 [B<-chain> I<certs_file.pem>]
34 [B<-tspolicy> I<object_id>]
35 [B<-in> I<response.tsr>]
37 [B<-out> I<response.tsr>]
44 [B<-data> I<file_to_hash>]
45 [B<-digest> I<digest_bytes>]
46 [B<-queryfile> I<request.tsq>]
47 [B<-in> I<response.tsr>]
49 [B<-CApath> I<trusted_cert_path>]
50 [B<-CAfile> I<trusted_certs.pem>]
51 [B<-untrusted> I<cert_file.pem>]
55 [B<-attime> I<timestamp>]
71 [B<-purpose> I<purpose>]
77 [B<-auth_level> I<num>]
78 [B<-verify_depth> I<num>]
79 [B<-verify_email> I<email>]
80 [B<-verify_hostname> I<hostname>]
82 [B<-verify_name> I<name>]
85 =for comment ifdef engine
89 The B<ts> command is a basic Time Stamping Authority (TSA) client and server
90 application as specified in RFC 3161 (Time-Stamp Protocol, TSP). A
91 TSA can be part of a PKI deployment and its role is to provide long
92 term proof of the existence of a certain datum before a particular
93 time. Here is a brief description of the protocol:
99 The TSA client computes a one-way hash value for a data file and sends
104 The TSA attaches the current date and time to the received hash value,
105 signs them and sends the time stamp token back to the client. By
106 creating this token the TSA certifies the existence of the original
107 data file at the time of response generation.
111 The TSA client receives the time stamp token and verifies the
112 signature on it. It also checks if the token contains the same hash
113 value that it had sent to the TSA.
117 There is one DER encoded protocol data unit defined for transporting a time
118 stamp request to the TSA and one for sending the time stamp response
119 back to the client. The B<ts> command has three main functions:
120 creating a time stamp request based on a data file,
121 creating a time stamp response based on a request, verifying if a
122 response corresponds to a particular request or a data file.
124 There is no support for sending the requests/responses automatically
125 over HTTP or TCP yet as suggested in RFC 3161. The users must send the
126 requests either by ftp or e-mail.
130 =head2 Time Stamp Request generation
132 The B<-query> switch can be used for creating and printing a time stamp
133 request with the following options:
137 =item B<-rand> I<file...>
139 A file or files containing random data used to seed the random number
141 Multiple files can be specified separated by an OS-dependent character.
142 The separator is B<;> for MS-Windows, B<,> for OpenVMS, and B<:> for
145 =item B<-writerand> I<file>
147 Writes random data to the specified I<file> upon exit.
148 This can be used with a subsequent B<-rand> flag.
150 =item B<-config> I<configfile>
152 The configuration file to use.
153 Optional; for a description of the default value,
154 see L<openssl(1)/COMMAND SUMMARY>.
156 =item B<-data> I<file_to_hash>
158 The data file for which the time stamp request needs to be
159 created. stdin is the default if neither the B<-data> nor the B<-digest>
160 parameter is specified. (Optional)
162 =item B<-digest> I<digest_bytes>
164 It is possible to specify the message imprint explicitly without the data
165 file. The imprint must be specified in a hexadecimal format, two characters
166 per byte, the bytes optionally separated by colons (e.g. 1A:F6:01:... or
167 1AF601...). The number of bytes must match the message digest algorithm
172 The message digest to apply to the data file.
173 Any digest supported by the OpenSSL B<dgst> command can be used.
174 The default is SHA-256. (Optional)
176 =item B<-tspolicy> I<object_id>
178 The policy that the client expects the TSA to use for creating the
179 time stamp token. Either the dotted OID notation or OID names defined
180 in the config file can be used. If no policy is requested the TSA will
181 use its own default policy. (Optional)
185 No nonce is specified in the request if this option is
186 given. Otherwise a 64 bit long pseudo-random none is
187 included in the request. It is recommended to use nonce to
188 protect against replay-attacks. (Optional)
192 The TSA is expected to include its signing certificate in the
195 =item B<-in> I<request.tsq>
197 This option specifies a previously created time stamp request in DER
198 format that will be printed into the output file. Useful when you need
199 to examine the content of a request in human-readable
202 =item B<-out> I<request.tsq>
204 Name of the output file to which the request will be written. Default
205 is stdout. (Optional)
209 If this option is specified the output is human-readable text format
210 instead of DER. (Optional)
214 =head2 Time Stamp Response generation
216 A time stamp response (TimeStampResp) consists of a response status
217 and the time stamp token itself (ContentInfo), if the token generation was
218 successful. The B<-reply> command is for creating a time stamp
219 response or time stamp token based on a request and printing the
220 response/token in human-readable format. If B<-token_out> is not
221 specified the output is always a time stamp response (TimeStampResp),
222 otherwise it is a time stamp token (ContentInfo).
226 =item B<-config> I<configfile>
228 The configuration file to use.
229 Optional; for a description of the default value,
230 see L<openssl(1)/COMMAND SUMMARY>.
231 See L</CONFIGURATION FILE OPTIONS> for configurable variables.
233 =item B<-section> I<tsa_section>
235 The name of the config file section containing the settings for the
236 response generation. If not specified the default TSA section is
237 used, see L</CONFIGURATION FILE OPTIONS> for details. (Optional)
239 =item B<-queryfile> I<request.tsq>
241 The name of the file containing a DER encoded time stamp request. (Optional)
243 =item B<-passin> I<password_src>
245 Specifies the password source for the private key of the TSA. See
246 description in L<openssl(1)>. (Optional)
248 =item B<-signer> I<tsa_cert.pem>
250 The signer certificate of the TSA in PEM format. The TSA signing
251 certificate must have exactly one extended key usage assigned to it:
252 timeStamping. The extended key usage must also be critical, otherwise
253 the certificate is going to be refused. Overrides the B<signer_cert>
254 variable of the config file. (Optional)
256 =item B<-inkey> I<file_or_id>
258 The signer private key of the TSA in PEM format. Overrides the
259 B<signer_key> config file option. (Optional)
260 If no engine is used, the argument is taken as a file; if an engine is
261 specified, the argument is given to the engine as a key identifier.
265 Signing digest to use. Overrides the B<signer_digest> config file
266 option. (Mandatory unless specified in the config file)
268 =item B<-chain> I<certs_file.pem>
270 The collection of certificates in PEM format that will all
271 be included in the response in addition to the signer certificate if
272 the B<-cert> option was used for the request. This file is supposed to
273 contain the certificate chain for the signer certificate from its
274 issuer upwards. The B<-reply> command does not build a certificate
275 chain automatically. (Optional)
277 =item B<-tspolicy> I<object_id>
279 The default policy to use for the response unless the client
280 explicitly requires a particular TSA policy. The OID can be specified
281 either in dotted notation or with its name. Overrides the
282 B<default_policy> config file option. (Optional)
284 =item B<-in> I<response.tsr>
286 Specifies a previously created time stamp response or time stamp token
287 (if B<-token_in> is also specified) in DER format that will be written
288 to the output file. This option does not require a request, it is
289 useful e.g. when you need to examine the content of a response or
290 token or you want to extract the time stamp token from a response. If
291 the input is a token and the output is a time stamp response a default
292 'granted' status info is added to the token. (Optional)
296 This flag can be used together with the B<-in> option and indicates
297 that the input is a DER encoded time stamp token (ContentInfo) instead
298 of a time stamp response (TimeStampResp). (Optional)
300 =item B<-out> I<response.tsr>
302 The response is written to this file. The format and content of the
303 file depends on other options (see B<-text>, B<-token_out>). The default is
308 The output is a time stamp token (ContentInfo) instead of time stamp
309 response (TimeStampResp). (Optional)
313 If this option is specified the output is human-readable text format
314 instead of DER. (Optional)
316 =item B<-engine> I<id>
318 Specifying an engine (by its unique B<id> string) will cause B<ts>
319 to attempt to obtain a functional reference to the specified engine,
320 thus initialising it if needed. The engine will then be set as the default
321 for all available algorithms. Default is builtin. (Optional)
325 =head2 Time Stamp Response verification
327 The B<-verify> command is for verifying if a time stamp response or time
328 stamp token is valid and matches a particular time stamp request or
329 data file. The B<-verify> command does not use the configuration file.
333 =item B<-data> I<file_to_hash>
335 The response or token must be verified against file_to_hash. The file
336 is hashed with the message digest algorithm specified in the token.
337 The B<-digest> and B<-queryfile> options must not be specified with this one.
340 =item B<-digest> I<digest_bytes>
342 The response or token must be verified against the message digest specified
343 with this option. The number of bytes must match the message digest algorithm
344 specified in the token. The B<-data> and B<-queryfile> options must not be
345 specified with this one. (Optional)
347 =item B<-queryfile> I<request.tsq>
349 The original time stamp request in DER format. The B<-data> and B<-digest>
350 options must not be specified with this one. (Optional)
352 =item B<-in> I<response.tsr>
354 The time stamp response that needs to be verified in DER format. (Mandatory)
358 This flag can be used together with the B<-in> option and indicates
359 that the input is a DER encoded time stamp token (ContentInfo) instead
360 of a time stamp response (TimeStampResp). (Optional)
362 =item B<-CApath> I<trusted_cert_path>
364 The name of the directory containing the trusted CA certificates of the
365 client. See the similar option of L<verify(1)> for additional
366 details. Either this option or B<-CAfile> must be specified. (Optional)
369 =item B<-CAfile> I<trusted_certs.pem>
371 The name of the file containing a set of trusted self-signed CA
372 certificates in PEM format. See the similar option of
373 L<verify(1)> for additional details. Either this option
374 or B<-CApath> must be specified.
377 =item B<-untrusted> I<cert_file.pem>
379 Set of additional untrusted certificates in PEM format which may be
380 needed when building the certificate chain for the TSA's signing
381 certificate. This file must contain the TSA signing certificate and
382 all intermediate CA certificates unless the response includes them.
385 =item I<verify options>
387 The options B<-attime>, B<-check_ss_sig>, B<-crl_check>,
388 B<-crl_check_all>, B<-explicit_policy>, B<-extended_crl>, B<-ignore_critical>,
389 B<-inhibit_any>, B<-inhibit_map>, B<-issuer_checks>, B<-no_alt_chains>,
390 B<-no_check_time>, B<-partial_chain>, B<-policy>, B<-policy_check>,
391 B<-policy_print>, B<-purpose>, B<-suiteB_128>, B<-suiteB_128_only>,
392 B<-suiteB_192>, B<-trusted_first>, B<-use_deltas>, B<-auth_level>,
393 B<-verify_depth>, B<-verify_email>, B<-verify_hostname>, B<-verify_ip>,
394 B<-verify_name>, and B<-x509_strict> can be used to control timestamp
395 verification. See L<verify(1)>.
399 =head1 CONFIGURATION FILE OPTIONS
401 The B<-query> and B<-reply> commands make use of a configuration file.
403 for a general description of the syntax of the config file. The
404 B<-query> command uses only the symbolic OID names section
405 and it can work without it. However, the B<-reply> command needs the
406 config file for its operation.
408 When there is a command line switch equivalent of a variable the
409 switch always overrides the settings in the config file.
413 =item B<tsa> section, B<default_tsa>
415 This is the main section and it specifies the name of another section
416 that contains all the options for the B<-reply> command. This default
417 section can be overridden with the B<-section> command line switch. (Optional)
421 See L<ca(1)> for description. (Optional)
425 See L<ca(1)> for description. (Optional)
429 See L<ca(1)> for description. (Optional)
433 The name of the file containing the hexadecimal serial number of the
434 last time stamp response created. This number is incremented by 1 for
435 each response. If the file does not exist at the time of response
436 generation a new file is created with serial number 1. (Mandatory)
438 =item B<crypto_device>
440 Specifies the OpenSSL engine that will be set as the default for
441 all available algorithms. The default value is builtin, you can specify
442 any other engines supported by OpenSSL (e.g. use chil for the NCipher HSM).
447 TSA signing certificate in PEM format. The same as the B<-signer>
448 command line option. (Optional)
452 A file containing a set of PEM encoded certificates that need to be
453 included in the response. The same as the B<-chain> command line
458 The private key of the TSA in PEM format. The same as the B<-inkey>
459 command line option. (Optional)
461 =item B<signer_digest>
463 Signing digest to use. The same as the
464 B<->I<digest> command line option. (Mandatory unless specified on the command
467 =item B<default_policy>
469 The default policy to use when the request does not mandate any
470 policy. The same as the B<-tspolicy> command line option. (Optional)
472 =item B<other_policies>
474 Comma separated list of policies that are also acceptable by the TSA
475 and used only if the request explicitly specifies one of them. (Optional)
479 The list of message digest algorithms that the TSA accepts. At least
480 one algorithm must be specified. (Mandatory)
484 The accuracy of the time source of the TSA in seconds, milliseconds
485 and microseconds. E.g. secs:1, millisecs:500, microsecs:100. If any of
486 the components is missing zero is assumed for that field. (Optional)
488 =item B<clock_precision_digits>
490 Specifies the maximum number of digits, which represent the fraction of
491 seconds, that need to be included in the time field. The trailing zeroes
492 must be removed from the time, so there might actually be fewer digits,
493 or no fraction of seconds at all. Supported only on UNIX platforms.
494 The maximum value is 6, default is 0.
499 If this option is yes the responses generated by this TSA can always
500 be ordered, even if the time difference between two responses is less
501 than the sum of their accuracies. Default is no. (Optional)
505 Set this option to yes if the subject name of the TSA must be included in
506 the TSA name field of the response. Default is no. (Optional)
508 =item B<ess_cert_id_chain>
510 The SignedData objects created by the TSA always contain the
511 certificate identifier of the signing certificate in a signed
512 attribute (see RFC 2634, Enhanced Security Services). If this option
513 is set to yes and either the B<certs> variable or the B<-chain> option
514 is specified then the certificate identifiers of the chain will also
515 be included in the SigningCertificate signed attribute. If this
516 variable is set to no, only the signing certificate identifier is
517 included. Default is no. (Optional)
519 =item B<ess_cert_id_alg>
521 This option specifies the hash function to be used to calculate the TSA's
522 public key certificate identifier. Default is sha256. (Optional)
528 All the examples below presume that B<OPENSSL_CONF> is set to a proper
529 configuration file, e.g. the example configuration file
530 openssl/apps/openssl.cnf will do.
532 =head2 Time Stamp Request
534 To create a time stamp request for design1.txt with SHA-256 digest,
535 without nonce and policy, and without requirement for a certificate
538 openssl ts -query -data design1.txt -no_nonce \
541 To create a similar time stamp request with specifying the message imprint
544 openssl ts -query -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
545 -no_nonce -out design1.tsq
547 To print the content of the previous request in human readable format:
549 openssl ts -query -in design1.tsq -text
551 To create a time stamp request which includes the SHA-512 digest
552 of design2.txt, requests the signer certificate and nonce, and
553 specifies a policy id (assuming the tsa_policy1 name is defined in the
554 OID section of the config file):
556 openssl ts -query -data design2.txt -sha512 \
557 -tspolicy tsa_policy1 -cert -out design2.tsq
559 =head2 Time Stamp Response
561 Before generating a response a signing certificate must be created for
562 the TSA that contains the B<timeStamping> critical extended key usage extension
563 without any other key usage extensions. You can add this line to the
564 user certificate section of the config file to generate a proper certificate;
566 extendedKeyUsage = critical,timeStamping
568 See L<req(1)>, L<ca(1)>, and L<x509(1)> for instructions. The examples
569 below assume that cacert.pem contains the certificate of the CA,
570 tsacert.pem is the signing certificate issued by cacert.pem and
571 tsakey.pem is the private key of the TSA.
573 To create a time stamp response for a request:
575 openssl ts -reply -queryfile design1.tsq -inkey tsakey.pem \
576 -signer tsacert.pem -out design1.tsr
578 If you want to use the settings in the config file you could just write:
580 openssl ts -reply -queryfile design1.tsq -out design1.tsr
582 To print a time stamp reply to stdout in human readable format:
584 openssl ts -reply -in design1.tsr -text
586 To create a time stamp token instead of time stamp response:
588 openssl ts -reply -queryfile design1.tsq -out design1_token.der -token_out
590 To print a time stamp token to stdout in human readable format:
592 openssl ts -reply -in design1_token.der -token_in -text -token_out
594 To extract the time stamp token from a response:
596 openssl ts -reply -in design1.tsr -out design1_token.der -token_out
598 To add 'granted' status info to a time stamp token thereby creating a
601 openssl ts -reply -in design1_token.der -token_in -out design1.tsr
603 =head2 Time Stamp Verification
605 To verify a time stamp reply against a request:
607 openssl ts -verify -queryfile design1.tsq -in design1.tsr \
608 -CAfile cacert.pem -untrusted tsacert.pem
610 To verify a time stamp reply that includes the certificate chain:
612 openssl ts -verify -queryfile design2.tsq -in design2.tsr \
615 To verify a time stamp token against the original data file:
616 openssl ts -verify -data design2.txt -in design2.tsr \
619 To verify a time stamp token against a message imprint:
620 openssl ts -verify -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
621 -in design2.tsr -CAfile cacert.pem
623 You could also look at the 'test' directory for more examples.
627 =for comment foreign manuals: procmail(1), perl(1)
633 No support for time stamps over SMTP, though it is quite easy
634 to implement an automatic e-mail based TSA with L<procmail(1)>
635 and L<perl(1)>. HTTP server support is provided in the form of
636 a separate apache module. HTTP client support is provided by
637 L<tsget(1)>. Pure TCP/IP protocol is not supported.
641 The file containing the last serial number of the TSA is not
642 locked when being read or written. This is a problem if more than one
643 instance of L<openssl(1)> is trying to create a time stamp
644 response at the same time. This is not an issue when using the apache
645 server module, it does proper locking.
649 Look for the FIXME word in the source files.
653 The source code should really be reviewed by somebody else, too.
657 More testing is needed, I have done only some basic tests (see
669 L<openssl-genrsa(1)>,
674 Copyright 2006-2019 The OpenSSL Project Authors. All Rights Reserved.
676 Licensed under the Apache License 2.0 (the "License"). You may not use
677 this file except in compliance with the License. You can obtain a copy
678 in the file LICENSE in the source distribution or at
679 L<https://www.openssl.org/source/license.html>.