tsa

package
v1.115.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 16, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Overview

Package tsa requests RFC 3161 timestamp tokens and reads the TSTInfo inside them.

Index

Constants

This section is empty.

Variables

View Source
var ErrBadResponse = errors.New("bad timestamping service response")

ErrBadResponse is a timestamping service that refused, answered something unreadable, or answered with a token that is not for this request or not from a trusted authority; it is the service's failure, not the caller's input.

Functions

This section is empty.

Types

type Client

type Client struct {
	Url string
	// Roots are the trust anchors the authority's certificate has to chain to; a client without them refuses to timestamp.
	Roots *x509.CertPool
	// Intermediates complete that chain where the token does not carry the whole of it.
	Intermediates []*x509.Certificate
	FetchOptions  []fetch_config.Option
	// Nonce makes the request nonce; nil means a random one.
	Nonce func() (*big.Int, error)
}

Client is a Timestamper speaking RFC 3161 over HTTP.

func (*Client) Timestamp

func (c *Client) Timestamp(ctx context.Context, digest []byte) ([]byte, error)

Timestamp requests a token over a SHA-256 digest and checks that it answers this request.

type Timestamper

type Timestamper interface {
	Timestamp(ctx context.Context, digest []byte) ([]byte, error)
}

Timestamper returns a timestamp token, a CMS ContentInfo, over the SHA-256 digest given.

type Token

type Token struct {
	Der         []byte
	Info        *TstInfo
	Certificate *x509.Certificate
	SignedData  *cms.ParsedSignedData
}

Token is a verified timestamp token.

func ParseToken

func ParseToken(der []byte) (*Token, error)

ParseToken reads a timestamp token and checks the TSA's signature over it; it does not check the TSA's certificate chain.

type TstInfo

type TstInfo struct {
	Policy        asn1.ObjectIdentifier
	HashAlgorithm asn1.ObjectIdentifier
	HashedMessage []byte
	SerialNumber  *big.Int
	GenTime       time.Time
	Nonce         *big.Int
}

TstInfo is what a timestamp authority asserts: that the imprint existed at GenTime.

func ParseTstInfo

func ParseTstInfo(der []byte) (*TstInfo, error)

ParseTstInfo reads a TSTInfo; its optional fields are told apart by tag, which encoding/asn1 cannot do for untagged ones.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL