TS(1) OpenSSL TS(1) NNAAMMEE openssl-ts, ts - Time Stamping Authority tool (client/server) SSYYNNOOPPSSIISS ooppeennssssll ttss --qquueerryy [--rraanndd file:file...] [--ccoonnffiigg configfile] [--ddaattaa file_to_hash] [--ddiiggeesstt digest_bytes] [--mmdd22|--mmdd44|--mmdd55|--sshhaa|--sshhaa11|--mmddcc22|--rriippeemmdd116600|......] [--ppoolliiccyy object_id] [--nnoo__nnoonnccee] [--cceerrtt] [--iinn request.tsq] [--oouutt request.tsq] [--tteexxtt] ooppeennssssll ttss --rreeppllyy [--ccoonnffiigg configfile] [--sseeccttiioonn tsa_section] [--qquueerryy-- ffiillee request.tsq] [--ppaassssiinn password_src] [--ssiiggnneerr tsa_cert.pem] [--iinnkkeeyy private.pem] [--cchhaaiinn certs_file.pem] [--ppoolliiccyy object_id] [--iinn response.tsr] [--ttookkeenn__iinn] [--oouutt response.tsr] [--ttookkeenn__oouutt] [--tteexxtt] [--eennggiinnee id] ooppeennssssll ttss --vveerriiffyy [--ddaattaa file_to_hash] [--ddiiggeesstt digest_bytes] [--qquueerryy-- ffiillee request.tsq] [--iinn response.tsr] [--ttookkeenn__iinn] [--CCAAppaatthh trusted_cert_path] [--CCAAffiillee trusted_certs.pem] [--uunnttrruusstteedd cert_file.pem] DDEESSCCRRIIPPTTIIOONN The ttss command is a basic Time Stamping Authority (TSA) client and server application as specified in RFC 3161 (Time-Stamp Protocol, TSP). A TSA can be part of a PKI deployment and its role is to provide long term proof of the existence of a certain datum before a particular time. Here is a brief description of the protocol: 1. The TSA client computes a one-way hash value for a data file and sends the hash to the TSA. 2. The TSA attaches the current date and time to the received hash value, signs them and sends the time stamp token back to the client. By creating this token the TSA certifies the existence of the original data file at the time of response generation. 3. The TSA client receives the time stamp token and verifies the sig- nature on it. It also checks if the token contains the same hash value that it had sent to the TSA. There is one DER encoded protocol data unit defined for transporting a time stamp request to the TSA and one for sending the time stamp response back to the client. The ttss command has three main functions: creating a time stamp request based on a data file, creating a time stamp response based on a request, verifying if a response corresponds to a particular request or a data file. There is no support for sending the requests/responses automatically over HTTP or TCP yet as suggested in RFC 3161. The users must send the requests either by ftp or e-mail. OOPPTTIIOONNSS TTiimmee SSttaammpp RReeqquueesstt ggeenneerraattiioonn The --qquueerryy switch can be used for creating and printing a time stamp request with the following options: --rraanndd file:file... The files containing random data for seeding the random number gen- erator. Multiple files can be specified, the separator is ;; for MS-Windows, ,, for VMS and :: for all other platforms. (Optional) --ccoonnffiigg configfile The configuration file to use, this option overrides the OOPPEENNSSSSLL__CCOONNFF environment variable. Only the OID section of the con- fig file is used with the --qquueerryy command. (Optional) --ddaattaa file_to_hash The data file for which the time stamp request needs to be created. stdin is the default if neither the --ddaattaa nor the --ddiiggeesstt parameter is specified. (Optional) --ddiiggeesstt digest_bytes It is possible to specify the message imprint explicitly without the data file. The imprint must be specified in a hexadecimal for- mat, two characters per byte, the bytes optionally separated by colons (e.g. 1A:F6:01:... or 1AF601...). The number of bytes must match the message digest algorithm in use. (Optional) --mmdd22|--mmdd44|--mmdd55|--sshhaa|--sshhaa11|--mmddcc22|--rriippeemmdd116600|...... The message digest to apply to the data file, it supports all the message digest algorithms that are supported by the openssl ddggsstt command. The default is SHA-1. (Optional) --ppoolliiccyy object_id The policy that the client expects the TSA to use for creating the time stamp token. Either the dotted OID notation or OID names defined in the config file can be used. If no policy is requested the TSA will use its own default policy. (Optional) --nnoo__nnoonnccee No nonce is specified in the request if this option is given. Oth- erwise a 64 bit long pseudo-random none is included in the request. It is recommended to use nonce to protect against replay-attacks. (Optional) --cceerrtt The TSA is expected to include its signing certificate in the response. (Optional) --iinn request.tsq This option specifies a previously created time stamp request in DER format that will be printed into the output file. Useful when you need to examine the content of a request in human-readable format. (Optional) --oouutt request.tsq Name of the output file to which the request will be written. Default is stdout. (Optional) --tteexxtt If this option is specified the output is human-readable text for- mat instead of DER. (Optional) TTiimmee SSttaammpp RReessppoonnssee ggeenneerraattiioonn A time stamp response (TimeStampResp) consists of a response status and the time stamp token itself (ContentInfo), if the token generation was successful. The --rreeppllyy command is for creating a time stamp response or time stamp token based on a request and printing the response/token in human-readable format. If --ttookkeenn__oouutt is not specified the output is always a time stamp response (TimeStampResp), otherwise it is a time stamp token (ContentInfo). --ccoonnffiigg configfile The configuration file to use, this option overrides the OOPPEENNSSSSLL__CCOONNFF environment variable. See CCOONNFFIIGGUURRAATTIIOONN FFIILLEE OOPPTTIIOONNSS for configurable variables. (Optional) --sseeccttiioonn tsa_section The name of the config file section conatining the settings for the response generation. If not specified the default TSA section is used, see CCOONNFFIIGGUURRAATTIIOONN FFIILLEE OOPPTTIIOONNSS for details. (Optional) --qquueerryyffiillee request.tsq The name of the file containing a DER encoded time stamp request. (Optional) --ppaassssiinn password_src Specifies the password source for the private key of the TSA. See PPAASSSS PPHHRRAASSEE AARRGGUUMMEENNTTSS in _o_p_e_n_s_s_l(1). (Optional) --ssiiggnneerr tsa_cert.pem The signer certificate of the TSA in PEM format. The TSA signing certificate must have exactly one extended key usage assigned to it: timeStamping. The extended key usage must also be critical, otherwise the certificate is going to be refused. Overrides the ssiiggnneerr__cceerrtt variable of the config file. (Optional) --iinnkkeeyy private.pem The signer private key of the TSA in PEM format. Overrides the ssiiggnneerr__kkeeyy config file option. (Optional) --cchhaaiinn certs_file.pem The collection of certificates in PEM format that will all be included in the response in addition to the signer certificate if the --cceerrtt option was used for the request. This file is supposed to contain the certificate chain for the signer certificate from its issuer upwards. The --rreeppllyy command does not build a certificate chain automatically. (Optional) --ppoolliiccyy object_id The default policy to use for the response unless the client explicitly requires a particular TSA policy. The OID can be speci- fied either in dotted notation or with its name. Overrides the ddeeffaauulltt__ppoolliiccyy config file option. (Optional) --iinn response.tsr Specifies a previously created time stamp response or time stamp token (if --ttookkeenn__iinn is also specified) in DER format that will be written to the output file. This option does not require a request, it is useful e.g. when you need to examine the content of a response or token or you want to extract the time stamp token from a response. If the input is a token and the output is a time stamp response a default 'granted' status info is added to the token. (Optional) --ttookkeenn__iinn This flag can be used together with the --iinn option and indicates that the input is a DER encoded time stamp token (ContentInfo) instead of a time stamp response (TimeStampResp). (Optional) --oouutt response.tsr The response is written to this file. The format and content of the file depends on other options (see --tteexxtt, --ttookkeenn__oouutt). The default is stdout. (Optional) --ttookkeenn__oouutt The output is a time stamp token (ContentInfo) instead of time stamp response (TimeStampResp). (Optional) --tteexxtt If this option is specified the output is human-readable text for- mat instead of DER. (Optional) --eennggiinnee id Specifying an engine (by its unique iidd string) will cause ttss to attempt to obtain a functional reference to the specified engine, thus initialising it if needed. The engine will then be set as the default for all available algorithms. Default is builtin. (Optional) TTiimmee SSttaammpp RReessppoonnssee vveerriiffiiccaattiioonn The --vveerriiffyy command is for verifying if a time stamp response or time stamp token is valid and matches a particular time stamp request or data file. The --vveerriiffyy command does not use the configuration file. --ddaattaa file_to_hash The response or token must be verified against file_to_hash. The file is hashed with the message digest algorithm specified in the token. The --ddiiggeesstt and --qquueerryyffiillee options must not be specified with this one. (Optional) --ddiiggeesstt digest_bytes The response or token must be verified against the message digest specified with this option. The number of bytes must match the mes- sage digest algorithm specified in the token. The --ddaattaa and --qquueerryy-- ffiillee options must not be specified with this one. (Optional) --qquueerryyffiillee request.tsq The original time stamp request in DER format. The --ddaattaa and --ddiiggeesstt options must not be specified with this one. (Optional) --iinn response.tsr The time stamp response that needs to be verified in DER format. (Mandatory) --ttookkeenn__iinn This flag can be used together with the --iinn option and indicates that the input is a DER encoded time stamp token (ContentInfo) instead of a time stamp response (TimeStampResp). (Optional) --CCAAppaatthh trusted_cert_path The name of the directory containing the trused CA certificates of the client. See the similar option of _v_e_r_i_f_y(1) for additional details. Either this option or --CCAAffiillee must be specified. (Optional) --CCAAffiillee trusted_certs.pem The name of the file containing a set of trusted self-signed CA certificates in PEM format. See the similar option of _v_e_r_i_f_y(1) for additional details. Either this option or --CCAAppaatthh must be speci- fied. (Optional) --uunnttrruusstteedd cert_file.pem Set of additional untrusted certificates in PEM format which may be needed when building the certificate chain for the TSA's signing certificate. This file must contain the TSA signing certificate and all intermediate CA certificates unless the response includes them. (Optional) CCOONNFFIIGGUURRAATTIIOONN FFIILLEE OOPPTTIIOONNSS The --qquueerryy and --rreeppllyy commands make use of a configuration file defined by the OOPPEENNSSSSLL__CCOONNFF environment variable. See _c_o_n_f_i_g(5) for a general description of the syntax of the config file. The --qquueerryy command uses only the symbolic OID names section and it can work without it. How- ever, the --rreeppllyy command needs the config file for its operation. When there is a command line switch equivalent of a variable the switch always overrides the settings in the config file. ttssaa section, ddeeffaauulltt__ttssaa This is the main section and it specifies the name of another sec- tion that contains all the options for the --rreeppllyy command. This default section can be overridden with the --sseeccttiioonn command line switch. (Optional) ooiidd__ffiillee See _c_a(1) for description. (Optional) ooiidd__sseeccttiioonn See _c_a(1) for description. (Optional) RRAANNDDFFIILLEE See _c_a(1) for description. (Optional) sseerriiaall The name of the file containing the hexadecimal serial number of the last time stamp response created. This number is incremented by 1 for each response. If the file does not exist at the time of response generation a new file is created with serial number 1. (Mandatory) ccrryyppttoo__ddeevviiccee Specifies the OpenSSL engine that will be set as the default for all available algorithms. The default value is builtin, you can specify any other engines supported by OpenSSL (e.g. use chil for the NCipher HSM). (Optional) ssiiggnneerr__cceerrtt TSA signing certificate in PEM format. The same as the --ssiiggnneerr com- mand line option. (Optional) cceerrttss A file containing a set of PEM encoded certificates that need to be included in the response. The same as the --cchhaaiinn command line option. (Optional) ssiiggnneerr__kkeeyy The private key of the TSA in PEM format. The same as the --iinnkkeeyy command line option. (Optional) ddeeffaauulltt__ppoolliiccyy The default policy to use when the request does not mandate any policy. The same as the --ppoolliiccyy command line option. (Optional) ootthheerr__ppoolliicciieess Comma separated list of policies that are also acceptable by the TSA and used only if the request explicitly specifies one of them. (Optional) ddiiggeessttss The list of message digest algorithms that the TSA accepts. At least one algorithm must be specified. (Mandatory) aaccccuurraaccyy The accuracy of the time source of the TSA in seconds, milliseconds and microseconds. E.g. secs:1, millisecs:500, microsecs:100. If any of the components is missing zero is assumed for that field. (Optional) cclloocckk__pprreecciissiioonn__ddiiggiittss Specifies the maximum number of digits, which represent the frac- tion of seconds, that need to be included in the time field. The trailing zeroes must be removed from the time, so there might actu- ally be fewer digits, or no fraction of seconds at all. Supported only on UNIX platforms. The maximum value is 6, default is 0. (Optional) oorrddeerriinngg If this option is yes the responses generated by this TSA can always be ordered, even if the time difference between two responses is less than the sum of their accuracies. Default is no. (Optional) ttssaa__nnaammee Set this option to yes if the subject name of the TSA must be included in the TSA name field of the response. Default is no. (Optional) eessss__cceerrtt__iidd__cchhaaiinn The SignedData objects created by the TSA always contain the cer- tificate identifier of the signing certificate in a signed attribute (see RFC 2634, Enhanced Security Services). If this option is set to yes and either the cceerrttss variable or the --cchhaaiinn option is specified then the certificate identifiers of the chain will also be included in the SigningCertificate signed attribute. If this variable is set to no, only the signing certificate identi- fier is included. Default is no. (Optional) EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS OOPPEENNSSSSLL__CCOONNFF contains the path of the configuration file and can be overridden by the --ccoonnffiigg command line option. EEXXAAMMPPLLEESS All the examples below presume that OOPPEENNSSSSLL__CCOONNFF is set to a proper configuration file, e.g. the example configuration file openssl/apps/openssl.cnf will do. TTiimmee SSttaammpp RReeqquueesstt To create a time stamp request for design1.txt with SHA-1 without nonce and policy and no certificate is required in the response: openssl ts -query -data design1.txt -no_nonce \ -out design1.tsq To create a similar time stamp request with specifying the message imprint explicitly: openssl ts -query -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \ -no_nonce -out design1.tsq To print the content of the previous request in human readable format: openssl ts -query -in design1.tsq -text To create a time stamp request which includes the MD-5 digest of design2.txt, requests the signer certificate and nonce, specifies a policy id (assuming the tsa_policy1 name is defined in the OID section of the config file): openssl ts -query -data design2.txt -md5 \ -policy tsa_policy1 -cert -out design2.tsq TTiimmee SSttaammpp RReessppoonnssee Before generating a response a signing certificate must be created for the TSA that contains the ttiimmeeSSttaammppiinngg critical extended key usage extension without any other key usage extensions. You can add the 'extendedKeyUsage = critical,timeStamping' line to the user certificate section of the config file to generate a proper certificate. See _r_e_q(1), _c_a(1), _x_5_0_9(1) for instructions. The examples below assume that cacert.pem contains the certificate of the CA, tsacert.pem is the sign- ing certificate issued by cacert.pem and tsakey.pem is the private key of the TSA. To create a time stamp response for a request: openssl ts -reply -queryfile design1.tsq -inkey tsakey.pem \ -signer tsacert.pem -out design1.tsr If you want to use the settings in the config file you could just write: openssl ts -reply -queryfile design1.tsq -out design1.tsr To print a time stamp reply to stdout in human readable format: openssl ts -reply -in design1.tsr -text To create a time stamp token instead of time stamp response: openssl ts -reply -queryfile design1.tsq -out design1_token.der -token_out To print a time stamp token to stdout in human readable format: openssl ts -reply -in design1_token.der -token_in -text -token_out To extract the time stamp token from a response: openssl ts -reply -in design1.tsr -out design1_token.der -token_out To add 'granted' status info to a time stamp token thereby creating a valid response: openssl ts -reply -in design1_token.der -token_in -out design1.tsr TTiimmee SSttaammpp VVeerriiffiiccaattiioonn To verify a time stamp reply against a request: openssl ts -verify -queryfile design1.tsq -in design1.tsr \ -CAfile cacert.pem -untrusted tsacert.pem To verify a time stamp reply that includes the certificate chain: openssl ts -verify -queryfile design2.tsq -in design2.tsr \ -CAfile cacert.pem To verify a time stamp token against the original data file: openssl ts -verify -data design2.txt -in design2.tsr \ -CAfile cacert.pem To verify a time stamp token against a message imprint: openssl ts -verify -digest b7e5d3f93198b38379852f2c04e78d73abdd0f4b \ -in design2.tsr -CAfile cacert.pem You could also look at the 'test' directory for more examples. BBUUGGSS If you find any bugs or you have suggestions please write to Zoltan Glozik . Known issues: * No support for time stamps over SMTP, though it is quite easy to implement an automatic e-mail based TSA with _p_r_o_c_m_a_i_l(1) and _p_e_r_l(1). HTTP server support is provided in the form of a separate apache mod- ule. HTTP client support is provided by _t_s_g_e_t(1). Pure TCP/IP protocol is not supported. * The file containing the last serial number of the TSA is not locked when being read or written. This is a problem if more than one instance of _o_p_e_n_s_s_l(1) is trying to create a time stamp response at the same time. This is not an issue when using the apache server module, it does proper locking. * Look for the FIXME word in the source files. * The source code should really be reviewed by somebody else, too. * More testing is needed, I have done only some basic tests (see test/testtsa). AAUUTTHHOORR Zoltan Glozik , OpenTSA project (http://www.opentsa.org) SSEEEE AALLSSOO _t_s_g_e_t(1), _o_p_e_n_s_s_l(1), _r_e_q(1), _x_5_0_9(1), _c_a(1), _g_e_n_r_s_a(1), _c_o_n_f_i_g(5) 1.0.2u 2019-12-20 TS(1)