Trusted time

TL;DR: This is an implementation of a Time Stamp Authority (RFC 3161) using JWS. Source is available at Github.

Time stamping is an increasingly valuable complement to digital signing practices, enabling organizations to record when a digital item—such as a message, document, transaction or piece of software—was signed. For some applications, the timing of a digital signature is critical, as in the case of stock trades, lottery ticket issuance and some legal proceedings. Even when time is not intrinsic to the application, time stamping is helpful for record keeping and audit processes, because it provides a mechanism to prove whether the digital certificate was valid at the time it was used.


Time Stamp Authorities are not a new concept.

For example, when Robert Hooke discovered Hooke's law in 1660, he did not want to publish it yet, but wanted to be able to claim priority. So he published the anagram ceiiinosssttuv and later published the translation ut tensio sic vis (Latin for "as is the extension, so is the force").
– Wikipedia

Similarly, we may want to be able to publish a hash of some data to claim ownership of the data at a specific time.

This has been possible in trusted digital time stamping for quite some time too. So really there is little news here. RFC 3161 services have been around for quite some time, there are even a handful free servers available.

Current state of affairs

OpenSSL has some command line tools for requesting and verifying time stamps. The steps are (courtesy of DigiStamp):

Create a time stamp query

openssl ts -query -data "YOUR FILE" -cert -sha256 -no_nonce -out request.tsq

Send it to a time stamp authority

cat request.tsq | curl -s -S -H 'Content-Type: application/timestamp-query' --data-binary @- -o response.tsr

Before being able to verify the response you will need a root certificate from the Time Stamp Authority

curl -L -O

Finally, verify the response

openssl ts -verify -in response.tsr -data "your original timestamped file" -CAfile com.digistamp.bundle.pem

To see the trusted time stamp

openssl ts -reply -in response.tsr -text

The contents of the time stamp will look something like this:

Status info:
Status: Granted.
Status description: unspecified
Failure info: unspecified

TST info:
Version: 1
Policy OID: 2.16.840.1.113733.
Hash Algorithm: sha256
Message data:
    0000 - 06 07 9c 9d 85 79 48 da-50 15 aa 83 51 5e d9 00   .....yH.P...Q^..
    0010 - bb 2d 0c d0 bb 26 cd b0-fe c5 0a 2d 94 47 b3 84   .-...&.....-.G..
Serial number: 0x9C90E88CA3EE000856460DA154626879700E534B
Time stamp: Dec 14 09:53:46 2019 GMT
Accuracy: 0x1E seconds, unspecified millis, unspecified micros
Ordering: no
TSA: DirName:/C=US/O=DigiStamp/OU=DigiStamp/CN=DigiStamp SHA256 TimeStamping Signer

A better way

This is all nice and well, but it would be even better if there was a way to integrate it in modern tool chains.

The RFC 3161 specifies a binary protocol for requesting and providing secure time stamps. The protocol specifies a request which includes a hash of the data to be timestamped and a policy under which to time stamp it.

This project provides the same data points while utilising modern technologies to achieve the same goals. Using the proposed standard RFC 7515 to encode a signed time stamp from the Time-Stamp Authority.

The new request format

A time stamp request is now made in the form of a HTTP POST request with a JSON body:

  "version": 1,
  "messageImprint": {
    "hashAlgorithm": "sha1",
    "hashedMessage": "40f1f310cbae011642d33edbad742ea3c581864d"
  "context": "some context",
  "nonce": "3455345232345454"

The new response format

The response is encoded as a JWS (one existing use is JWT, which is in use in many places). It is composed of three base 64 encoded parts, separated by a dot.

For example, a response could look like this:


The components can be found by splitting on "." and base 64 decoding them into:


  "alg": "RS256",
  "x5u": "",
  "typ": "application/timestamp-reply+jws",
  "jku": ""


  "status": {
    "status": 0
  "timeStampToken": {
    "contentType": "id-signedData",
    "content": {
      "version": 1,
      "context": "some context",
      "messageImprint": "40f1f310cbae011642d33edbad742ea3c581864d",
      "serialNumber": 1,
      "genTime": "2019-12-17T13:52:22+0000",
      "accuracy": {
        "seconds": 0,
        "millis": 0,
        "micros": 0
      "ordering": false,
      "nonce": 3455345232345454

The signature is binary data which can be used to verify the payload using the certificate which can be obtained from the endpoint found in the header.

∙   ∙   ∙

It's available today

You can use the free service available by making a POST request as described above to or self-host. The service source code is available at tsa-json.

Libraries are available today which can read and verify JWS data:

C/C++: cjose
C#: JWT for .NET 3.5+ (and many others)
Haskell: jose-jwt
Java: jose4j (and many others)
Javascript: jsrsasign (and many others)
Ruby: json-jwt
Python: pyjwkest


The following is an example of time stamping some data in javascript. It is assumed that the data exists elsewhere and has been hashed using a sha1 hashing algorithm.

const request = require('request-promise');
const jose = require('jose');

(async () => {
  const response = await request({
    method: 'POST',
    uri: '',
    body: JSON.stringify({
      version: 1,
      messageImprint: {
        hashAlgorithm: 'sha1',
        hashedMessage: '40f1f310cbae011642d33edbad742ea3c581864d'
      context: 'some context',
      nonce: '234534534534'
  const token = jose.JWT.decode(response, { complete: true });
  const keyset = await request(token.header.jku, { json: true });
  // Get the first key from the set of public keys,
  // for the purposes of this example
  const key = jose.JWK.asKey(keyset.keys[0]);
  const valid = jose.JWS.verify(response, key);
  if (!valid) return;
  const success = token.payload.status.status == 0;
  if (!success) return;
  const timestamp = Date.parse(token
  console.log('signed time stamp: ' + timestamp);

Final thoughts

Given this, we can now create trusted time stamps for data that we have available to us and publicly make claims of ownership of said data at the present time, and we can do this using current tools in modern tool chains.