Documentation ¶
Overview ¶
Package timestamp implements the timestamp protocol rfc 3161
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( //Opts are options for timestamp certificate verficiation. Opts = x509.VerifyOptions{ Intermediates: x509.NewCertPool(), CurrentTime: time.Now(), KeyUsages: []x509.ExtKeyUsage{x509.ExtKeyUsageTimeStamping}, } )
Functions ¶
func FetchTSToken ¶
FetchTSToken tries to fetch a TSTokem of the given msg with hash using the given URL.
func GenerateNonce ¶
GenerateNonce generates a new nonce for this TSR.
Types ¶
type Accuracy ¶
type Accuracy struct { Seconds int `asn1:"optional"` Millis int `asn1:"tag:0,optional"` Micros int `asn1:"tag:1,optional"` }
Accuracy of the timestamp
type MessageImprint ¶
type MessageImprint struct { HashAlgorithm pkix.AlgorithmIdentifier HashedMessage []byte }
MessageImprint ::= SEQUENCE { hashAlgorithm AlgorithmIdentifier, hashedMessage OCTET STRING }
func NewMessageImprint ¶
func NewMessageImprint(hash crypto.Hash, msg []byte) (MessageImprint, error)
NewMessageImprint creates a new MessageImprint, digesting msg using the specified hash.
type PKIFreeText ¶
PKIFreeText ::= SEQUENCE SIZE (1..MAX) OF UTF8String
func (PKIFreeText) Append ¶
func (ft PKIFreeText) Append(t string) PKIFreeText
Append returns a new copy of the PKIFreeText with the provided string appended.
func (PKIFreeText) Strings ¶
func (ft PKIFreeText) Strings() ([]string, error)
Strings decodes the PKIFreeText into a []string.
type PKIStatusInfo ¶
type PKIStatusInfo struct { Status int StatusString PKIFreeText `asn1:"optional"` FailInfo asn1.BitString `asn1:"optional"` }
PKIStatusInfo ::= SEQUENCE { status PKIStatus, statusString PKIFreeText OPTIONAL, failInfo PKIFailureInfo OPTIONAL }
func (PKIStatusInfo) Error ¶
func (si PKIStatusInfo) Error() string
Error implements the error interface.
func (PKIStatusInfo) GetError ¶
func (si PKIStatusInfo) GetError() error
GetError represents an unsuccessful PKIStatusInfo as an error.
type TSTInfo ¶
type TSTInfo struct { Version int Policy asn1.ObjectIdentifier MessageImprint MessageImprint SerialNumber *big.Int GenTime time.Time `asn1:"generalized"` Accuracy Accuracy `asn1:"optional"` Ordering bool `asn1:"optional,default:false"` Nonce *big.Int `asn1:"optional"` TSA asn1.RawValue `asn1:"tag:0,optional"` Extensions []pkix.Extension `asn1:"tag:1,optional"` }
TSTInfo ::= SEQUENCE { version INTEGER { v1(1) }, policy TSAPolicyId, messageImprint MessageImprint, -- MUST have the same value as the similar field in -- TimeStampReq serialNumber INTEGER, -- Time-Stamping users MUST be ready to accommodate integers -- up to 160 bits. genTime GeneralizedTime, accuracy Accuracy OPTIONAL, ordering BOOLEAN DEFAULT FALSE, nonce INTEGER OPTIONAL, -- MUST be present if the similar field was present -- in TimeStampReq. In that case it MUST have the same value. tsa [0] GeneralName OPTIONAL, extensions [1] IMPLICIT Extensions OPTIONAL }
func ParseInfo ¶
func ParseInfo(enci cms.EncapsulatedContentInfo) (TSTInfo, error)
ParseInfo parses an Info out of a CMS EncapsulatedContentInfo.
func VerfiyTS ¶
func VerfiyTS(ci cms.ContentInfo) (info TSTInfo, err error)
VerfiyTS verfies the given TSToken and returns the TSTInfo.
type TimeStampReq ¶
type TimeStampReq struct { Version int MessageImprint MessageImprint ReqPolicy asn1.ObjectIdentifier `asn1:"optional"` Nonce *big.Int `asn1:"optional"` CertReq bool `asn1:"optional,default:false"` Extensions []pkix.Extension `asn1:"tag:1,optional"` }
TimeStampReq ::= SEQUENCE { version INTEGER { v1(1) }, messageImprint MessageImprint, --a hash algorithm OID and the hash value of the data to be --time-stamped reqPolicy TSAPolicyId OPTIONAL, nonce INTEGER OPTIONAL, certReq BOOLEAN DEFAULT FALSE, extensions [0] IMPLICIT Extensions OPTIONAL }
func (TimeStampReq) Do ¶
func (req TimeStampReq) Do(url string) (TimeStampResp, error)
Do sends this timestamp request to the specified timestamp service, returning the parsed response.
type TimeStampResp ¶
type TimeStampResp struct { Status PKIStatusInfo TimeStampToken cms.ContentInfo `asn1:"optional"` }
TimeStampResp ::= SEQUENCE { status PKIStatusInfo, timeStampToken TimeStampToken OPTIONAL }
func ParseResponse ¶
func ParseResponse(der []byte) (TimeStampResp, error)
ParseResponse parses a ASN.1 encoded TimeStampResp.
func (TimeStampResp) Info ¶
func (r TimeStampResp) Info() (TSTInfo, error)
Info returns the timestampinfo from a response.