ts.pod 21 KB

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