2 {- OpenSSL::safe::output_do_not_edit_headers(); -}
6 openssl-ts - Time Stamping Authority tool (client/server)
15 [B<-config> I<configfile>]
16 [B<-data> I<file_to_hash>]
17 [B<-digest> I<digest_bytes>]
19 [B<-tspolicy> I<object_id>]
22 [B<-in> I<request.tsq>]
23 [B<-out> I<request.tsq>]
25 {- $OpenSSL::safe::opt_r_synopsis -}
26 {- $OpenSSL::safe::opt_provider_synopsis -}
30 [B<-config> I<configfile>]
31 [B<-section> I<tsa_section>]
32 [B<-queryfile> I<request.tsq>]
33 [B<-passin> I<password_src>]
34 [B<-signer> I<tsa_cert.pem>]
35 [B<-inkey> I<file_or_id>]
37 [B<-chain> I<certs_file.pem>]
38 [B<-tspolicy> I<object_id>]
39 [B<-in> I<response.tsr>]
40 [B<-untrusted> I<file>]
42 [B<-out> I<response.tsr>]
45 {- $OpenSSL::safe::opt_engine_synopsis -}
46 {- $OpenSSL::safe::opt_provider_synopsis -}
50 [B<-data> I<file_to_hash>]
51 [B<-digest> I<digest_bytes>]
52 [B<-queryfile> I<request.tsq>]
53 [B<-in> I<response.tsr>]
58 {- $OpenSSL::safe::opt_v_synopsis -}
59 {- $OpenSSL::safe::opt_provider_synopsis -}
61 =for openssl ifdef engine
65 This command is a basic Time Stamping Authority (TSA) client and
66 server application as specified in RFC 3161 (Time-Stamp Protocol, TSP). A
67 TSA can be part of a PKI deployment and its role is to provide long
68 term proof of the existence of a certain datum before a particular
69 time. Here is a brief description of the protocol:
75 The TSA client computes a one-way hash value for a data file and sends
80 The TSA attaches the current date and time to the received hash value,
81 signs them and sends the timestamp token back to the client. By
82 creating this token the TSA certifies the existence of the original
83 data file at the time of response generation.
87 The TSA client receives the timestamp token and verifies the
88 signature on it. It also checks if the token contains the same hash
89 value that it had sent to the TSA.
93 There is one DER encoded protocol data unit defined for transporting a time
94 stamp request to the TSA and one for sending the timestamp response
95 back to the client. This command has three main functions:
96 creating a timestamp request based on a data file,
97 creating a timestamp response based on a request, verifying if a
98 response corresponds to a particular request or a data file.
100 There is no support for sending the requests/responses automatically
101 over HTTP or TCP yet as suggested in RFC 3161. The users must send the
102 requests either by ftp or e-mail.
110 Print out a usage message.
114 =head2 Timestamp Request generation
116 The B<-query> switch can be used for creating and printing a timestamp
117 request with the following options:
121 =item B<-config> I<configfile>
123 The configuration file to use.
124 Optional; for a description of the default value,
125 see L<openssl(1)/COMMAND SUMMARY>.
127 =item B<-data> I<file_to_hash>
129 The data file for which the timestamp request needs to be
130 created. stdin is the default if neither the B<-data> nor the B<-digest>
131 parameter is specified. (Optional)
133 =item B<-digest> I<digest_bytes>
135 It is possible to specify the message imprint explicitly without the data
136 file. The imprint must be specified in a hexadecimal format, two characters
137 per byte, the bytes optionally separated by colons (e.g. 1A:F6:01:... or
138 1AF601...). The number of bytes must match the message digest algorithm
143 The message digest to apply to the data file.
144 Any digest supported by the L<openssl-dgst(1)> command can be used.
145 The default is SHA-256. (Optional)
147 =item B<-tspolicy> I<object_id>
149 The policy that the client expects the TSA to use for creating the
150 timestamp token. Either the dotted OID notation or OID names defined
151 in the config file can be used. If no policy is requested the TSA will
152 use its own default policy. (Optional)
156 No nonce is specified in the request if this option is
157 given. Otherwise a 64 bit long pseudo-random none is
158 included in the request. It is recommended to use nonce to
159 protect against replay-attacks. (Optional)
163 The TSA is expected to include its signing certificate in the
166 =item B<-in> I<request.tsq>
168 This option specifies a previously created timestamp request in DER
169 format that will be printed into the output file. Useful when you need
170 to examine the content of a request in human-readable
173 =item B<-out> I<request.tsq>
175 Name of the output file to which the request will be written. Default
176 is stdout. (Optional)
180 If this option is specified the output is human-readable text format
181 instead of DER. (Optional)
183 {- $OpenSSL::safe::opt_r_item -}
187 =head2 Timestamp Response generation
189 A timestamp response (TimeStampResp) consists of a response status
190 and the timestamp token itself (ContentInfo), if the token generation was
191 successful. The B<-reply> command is for creating a timestamp
192 response or timestamp token based on a request and printing the
193 response/token in human-readable format. If B<-token_out> is not
194 specified the output is always a timestamp response (TimeStampResp),
195 otherwise it is a timestamp token (ContentInfo).
199 =item B<-config> I<configfile>
201 The configuration file to use.
202 Optional; for a description of the default value,
203 see L<openssl(1)/COMMAND SUMMARY>.
204 See L</CONFIGURATION FILE OPTIONS> for configurable variables.
206 =item B<-section> I<tsa_section>
208 The name of the config file section containing the settings for the
209 response generation. If not specified the default TSA section is
210 used, see L</CONFIGURATION FILE OPTIONS> for details. (Optional)
212 =item B<-queryfile> I<request.tsq>
214 The name of the file containing a DER encoded timestamp request. (Optional)
216 =item B<-passin> I<password_src>
218 Specifies the password source for the private key of the TSA. See
219 description in L<openssl(1)>. (Optional)
221 =item B<-signer> I<tsa_cert.pem>
223 The signer certificate of the TSA in PEM format. The TSA signing
224 certificate must have exactly one extended key usage assigned to it:
225 timeStamping. The extended key usage must also be critical, otherwise
226 the certificate is going to be refused. Overrides the B<signer_cert>
227 variable of the config file. (Optional)
229 =item B<-inkey> I<file_or_id>
231 The signer private key of the TSA in PEM format. Overrides the
232 B<signer_key> config file option. (Optional)
233 If no engine is used, the argument is taken as a file; if an engine is
234 specified, the argument is given to the engine as a key identifier.
238 Signing digest to use. Overrides the B<signer_digest> config file
239 option. (Mandatory unless specified in the config file)
241 =item B<-chain> I<certs_file.pem>
243 The collection of certificates in PEM format that will all
244 be included in the response in addition to the signer certificate if
245 the B<-cert> option was used for the request. This file is supposed to
246 contain the certificate chain for the signer certificate from its
247 issuer upwards. The B<-reply> command does not build a certificate
248 chain automatically. (Optional)
250 =item B<-tspolicy> I<object_id>
252 The default policy to use for the response unless the client
253 explicitly requires a particular TSA policy. The OID can be specified
254 either in dotted notation or with its name. Overrides the
255 B<default_policy> config file option. (Optional)
257 =item B<-in> I<response.tsr>
259 Specifies a previously created timestamp response or timestamp token
260 (if B<-token_in> is also specified) in DER format that will be written
261 to the output file. This option does not require a request, it is
262 useful e.g. when you need to examine the content of a response or
263 token or you want to extract the timestamp token from a response. If
264 the input is a token and the output is a timestamp response a default
265 'granted' status info is added to the token. (Optional)
269 This flag can be used together with the B<-in> option and indicates
270 that the input is a DER encoded timestamp token (ContentInfo) instead
271 of a timestamp response (TimeStampResp). (Optional)
273 =item B<-out> I<response.tsr>
275 The response is written to this file. The format and content of the
276 file depends on other options (see B<-text>, B<-token_out>). The default is
281 The output is a timestamp token (ContentInfo) instead of timestamp
282 response (TimeStampResp). (Optional)
286 If this option is specified the output is human-readable text format
287 instead of DER. (Optional)
289 {- $OpenSSL::safe::opt_engine_item -}
291 {- $OpenSSL::safe::opt_provider_item -}
295 =head2 Timestamp Response verification
297 The B<-verify> command is for verifying if a timestamp response or time
298 stamp token is valid and matches a particular timestamp request or
299 data file. The B<-verify> command does not use the configuration file.
303 =item B<-data> I<file_to_hash>
305 The response or token must be verified against file_to_hash. The file
306 is hashed with the message digest algorithm specified in the token.
307 The B<-digest> and B<-queryfile> options must not be specified with this one.
310 =item B<-digest> I<digest_bytes>
312 The response or token must be verified against the message digest specified
313 with this option. The number of bytes must match the message digest algorithm
314 specified in the token. The B<-data> and B<-queryfile> options must not be
315 specified with this one. (Optional)
317 =item B<-queryfile> I<request.tsq>
319 The original timestamp request in DER format. The B<-data> and B<-digest>
320 options must not be specified with this one. (Optional)
322 =item B<-in> I<response.tsr>
324 The timestamp response that needs to be verified in DER format. (Mandatory)
328 This flag can be used together with the B<-in> option and indicates
329 that the input is a DER encoded timestamp token (ContentInfo) instead
330 of a timestamp response (TimeStampResp). (Optional)
332 =item B<-untrusted> I<cert_file.pem>
334 Set of additional untrusted certificates in PEM format which may be
335 needed when building the certificate chain for the TSA's signing
336 certificate. This file must contain the TSA signing certificate and
337 all intermediate CA certificates unless the response includes them.
340 =item B<-CAfile> I<file>, B<-CApath> I<dir>, B<-CAstore> I<uri>
342 See L<openssl(1)/Trusted Certificate Options> for details.
343 At least one of B<-CApath>, B<-CAfile> or B<-CAstore> must be specified.
345 {- $OpenSSL::safe::opt_v_item -}
347 Any verification errors cause the command to exit.
351 =head1 CONFIGURATION FILE OPTIONS
353 The B<-query> and B<-reply> commands make use of a configuration file.
355 for a general description of the syntax of the config file. The
356 B<-query> command uses only the symbolic OID names section
357 and it can work without it. However, the B<-reply> command needs the
358 config file for its operation.
360 When there is a command line switch equivalent of a variable the
361 switch always overrides the settings in the config file.
365 =item B<tsa> section, B<default_tsa>
367 This is the main section and it specifies the name of another section
368 that contains all the options for the B<-reply> command. This default
369 section can be overridden with the B<-section> command line switch. (Optional)
373 This specifies a file containing additional B<OBJECT IDENTIFIERS>.
374 Each line of the file should consist of the numerical form of the
375 object identifier followed by white space then the short name followed
376 by white space and finally the long name. (Optional)
380 This specifies a section in the configuration file containing extra
381 object identifiers. Each line should consist of the short name of the
382 object identifier followed by B<=> and the numerical form. The short
383 and long names are the same when this option is used. (Optional)
387 At startup the specified file is loaded into the random number generator,
388 and at exit 256 bytes will be written to it. (Note: Using a RANDFILE is
389 not necessary anymore, see the L</HISTORY> section.
393 The name of the file containing the hexadecimal serial number of the
394 last timestamp response created. This number is incremented by 1 for
395 each response. If the file does not exist at the time of response
396 generation a new file is created with serial number 1. (Mandatory)
398 =item B<crypto_device>
400 Specifies the OpenSSL engine that will be set as the default for
401 all available algorithms. The default value is built-in, you can specify
402 any other engines supported by OpenSSL (e.g. use chil for the NCipher HSM).
407 TSA signing certificate in PEM format. The same as the B<-signer>
408 command line option. (Optional)
412 A file containing a set of PEM encoded certificates that need to be
413 included in the response. The same as the B<-chain> command line
418 The private key of the TSA in PEM format. The same as the B<-inkey>
419 command line option. (Optional)
421 =item B<signer_digest>
423 Signing digest to use. The same as the
424 B<-I<digest>> command line option. (Mandatory unless specified on the command
427 =item B<default_policy>
429 The default policy to use when the request does not mandate any
430 policy. The same as the B<-tspolicy> command line option. (Optional)
432 =item B<other_policies>
434 Comma separated list of policies that are also acceptable by the TSA
435 and used only if the request explicitly specifies one of them. (Optional)
439 The list of message digest algorithms that the TSA accepts. At least
440 one algorithm must be specified. (Mandatory)
444 The accuracy of the time source of the TSA in seconds, milliseconds
445 and microseconds. E.g. secs:1, millisecs:500, microsecs:100. If any of
446 the components is missing zero is assumed for that field. (Optional)
448 =item B<clock_precision_digits>
450 Specifies the maximum number of digits, which represent the fraction of
451 seconds, that need to be included in the time field. The trailing zeros
452 must be removed from the time, so there might actually be fewer digits,
453 or no fraction of seconds at all. Supported only on UNIX platforms.
454 The maximum value is 6, default is 0.
459 If this option is yes the responses generated by this TSA can always
460 be ordered, even if the time difference between two responses is less
461 than the sum of their accuracies. Default is no. (Optional)
465 Set this option to yes if the subject name of the TSA must be included in
466 the TSA name field of the response. Default is no. (Optional)
468 =item B<ess_cert_id_chain>
470 The SignedData objects created by the TSA always contain the
471 certificate identifier of the signing certificate in a signed
472 attribute (see RFC 2634, Enhanced Security Services). If this option
473 is set to yes and either the B<certs> variable or the B<-chain> option
474 is specified then the certificate identifiers of the chain will also
475 be included in the SigningCertificate signed attribute. If this
476 variable is set to no, only the signing certificate identifier is
477 included. Default is no. (Optional)
479 =item B<ess_cert_id_alg>
481 This option specifies the hash function to be used to calculate the TSA's
482 public key certificate identifier. Default is sha256. (Optional)
488 All the examples below presume that B<OPENSSL_CONF> is set to a proper
489 configuration file, e.g. the example configuration file
490 F<openssl/apps/openssl.cnf> will do.
492 =head2 Timestamp Request
494 To create a timestamp request for F<design1.txt> with SHA-256 digest,
495 without nonce and policy, and without requirement for a certificate
498 openssl ts -query -data design1.txt -no_nonce \
501 To create a similar timestamp request with specifying the message imprint
504 openssl ts -query -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
505 -no_nonce -out design1.tsq
507 To print the content of the previous request in human readable format:
509 openssl ts -query -in design1.tsq -text
511 To create a timestamp request which includes the SHA-512 digest
512 of F<design2.txt>, requests the signer certificate and nonce, and
513 specifies a policy id (assuming the tsa_policy1 name is defined in the
514 OID section of the config file):
516 openssl ts -query -data design2.txt -sha512 \
517 -tspolicy tsa_policy1 -cert -out design2.tsq
519 =head2 Timestamp Response
521 Before generating a response a signing certificate must be created for
522 the TSA that contains the B<timeStamping> critical extended key usage extension
523 without any other key usage extensions. You can add this line to the
524 user certificate section of the config file to generate a proper certificate;
526 extendedKeyUsage = critical,timeStamping
528 See L<openssl-req(1)>, L<openssl-ca(1)>, and L<openssl-x509(1)> for
529 instructions. The examples below assume that F<cacert.pem> contains the
530 certificate of the CA, F<tsacert.pem> is the signing certificate issued
531 by F<cacert.pem> and F<tsakey.pem> is the private key of the TSA.
533 To create a timestamp response for a request:
535 openssl ts -reply -queryfile design1.tsq -inkey tsakey.pem \
536 -signer tsacert.pem -out design1.tsr
538 If you want to use the settings in the config file you could just write:
540 openssl ts -reply -queryfile design1.tsq -out design1.tsr
542 To print a timestamp reply to stdout in human readable format:
544 openssl ts -reply -in design1.tsr -text
546 To create a timestamp token instead of timestamp response:
548 openssl ts -reply -queryfile design1.tsq -out design1_token.der -token_out
550 To print a timestamp token to stdout in human readable format:
552 openssl ts -reply -in design1_token.der -token_in -text -token_out
554 To extract the timestamp token from a response:
556 openssl ts -reply -in design1.tsr -out design1_token.der -token_out
558 To add 'granted' status info to a timestamp token thereby creating a
561 openssl ts -reply -in design1_token.der -token_in -out design1.tsr
563 =head2 Timestamp Verification
565 To verify a timestamp reply against a request:
567 openssl ts -verify -queryfile design1.tsq -in design1.tsr \
568 -CAfile cacert.pem -untrusted tsacert.pem
570 To verify a timestamp reply that includes the certificate chain:
572 openssl ts -verify -queryfile design2.tsq -in design2.tsr \
575 To verify a timestamp token against the original data file:
576 openssl ts -verify -data design2.txt -in design2.tsr \
579 To verify a timestamp token against a message imprint:
580 openssl ts -verify -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \
581 -in design2.tsr -CAfile cacert.pem
583 You could also look at the 'test' directory for more examples.
587 =for openssl foreign manual procmail(1) perl(1)
593 No support for timestamps over SMTP, though it is quite easy
594 to implement an automatic e-mail based TSA with L<procmail(1)>
595 and L<perl(1)>. HTTP server support is provided in the form of
596 a separate apache module. HTTP client support is provided by
597 L<tsget(1)>. Pure TCP/IP protocol is not supported.
601 The file containing the last serial number of the TSA is not
602 locked when being read or written. This is a problem if more than one
603 instance of L<openssl(1)> is trying to create a timestamp
604 response at the same time. This is not an issue when using the apache
605 server module, it does proper locking.
609 Look for the FIXME word in the source files.
613 The source code should really be reviewed by somebody else, too.
617 More testing is needed, I have done only some basic tests (see
624 OpenSSL 1.1.1 introduced a new random generator (CSPRNG) with an improved
625 seeding mechanism. The new seeding mechanism makes it unnecessary to
626 define a RANDFILE for saving and restoring randomness. This option is
627 retained mainly for compatibility reasons.
636 L<openssl-genrsa(1)>,
638 L<ossl_store-file(7)>
642 Copyright 2006-2019 The OpenSSL Project Authors. All Rights Reserved.
644 Licensed under the Apache License 2.0 (the "License"). You may not use
645 this file except in compliance with the License. You can obtain a copy
646 in the file LICENSE in the source distribution or at
647 L<https://www.openssl.org/source/license.html>.