Tspex.TSTInfo (tspex v0.1.0)

Copy Markdown View Source

The TSTInfo of a time-stamp token (RFC 3161, 2.4.2): what the TSA signed.

Tspex.decode_token/2 reads one without verifying anything: the signature, the certificate and the match with a request are checked only by Tspex.verify/3, which returns the same struct as info of Tspex.Verified. Do not trust the time of a TSTInfo that was not verified.

Fields:

  • :version - always 1.
  • :policy - the policy of the TSA, as an OID tuple.
  • :hash and :digest - the messageImprint: the hash as a name such as :sha256 (:md5, or the OID tuple, for an algorithm this library does not implement) and the digest.
  • :serial - the serial number.
  • :gen_time - the time, a UTC DateTime with up to microseconds.
  • :accuracy - %{seconds: n, millis: n, micros: n} (what is absent is zero) or nil; see bounds/1.
  • :ordering - whether the tokens of this TSA are ordered by genTime within the accuracy.
  • :nonce - the nonce, or nil.
  • :tsa - the name of the TSA, or nil: {:directory_name, der} (the Name, in DER), {:dns_name, text}, {:uri, text}, {:rfc822_name, text}, {:ip_address, octets} or {:other, der}.
  • :extensions - [%{oid: tuple, critical: boolean, value: binary}], with the value as the DER bytes of the extension.
  • :deviations - what was tolerated against the RFC; :gen_time_encoding when genTime has a fraction that is not in DER.

Summary

Types

The accuracy of the genTime; a part that the token leaves out is 0.

The name of the TSA, as a GeneralName.

t()

A TSTInfo, the content of a token.

Functions

The interval the time is known to be in: {earliest, latest}, genTime minus and plus the accuracy. Both are genTime when there is no accuracy. The ends are kept inside the years 1 to 9999.

Types

accuracy()

@type accuracy() :: %{seconds: non_neg_integer(), millis: 0..999, micros: 0..999}

The accuracy of the genTime; a part that the token leaves out is 0.

name()

@type name() :: Tspex.general_name()

The name of the TSA, as a GeneralName.

t()

@type t() :: %Tspex.TSTInfo{
  accuracy: accuracy() | nil,
  deviations: [atom()],
  digest: binary(),
  extensions: [Tspex.extension()],
  gen_time: DateTime.t(),
  hash: Tspex.hash() | :md5 | tuple(),
  nonce: integer() | nil,
  ordering: boolean(),
  policy: tuple(),
  serial: integer(),
  tsa: name() | nil,
  version: 1
}

A TSTInfo, the content of a token.

Functions

bounds(tst_info)

@spec bounds(t()) :: {DateTime.t(), DateTime.t()}

The interval the time is known to be in: {earliest, latest}, genTime minus and plus the accuracy. Both are genTime when there is no accuracy. The ends are kept inside the years 1 to 9999.

iex> info = %Tspex.TSTInfo{
...>   policy: {1, 2, 3},
...>   hash: :sha256,
...>   digest: <<0::256>>,
...>   serial: 1,
...>   gen_time: ~U[2026-11-09 12:00:00Z],
...>   accuracy: %{seconds: 1, millis: 500, micros: 0}
...> }
iex> Tspex.TSTInfo.bounds(info)
{~U[2026-11-09 11:59:58.500000Z], ~U[2026-11-09 12:00:01.500000Z]}