openssl-ts.pod.in 20 KB

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