timestamp package - github.com/digitorus/timestamp - Go Packages
Package timestamp implements the Time-Stamp Protocol (TSP) as specified in RFC3161 (Internet X.509 Public Key Infrastructure Time-Stamp Protocol (TSP)).
This section is empty.
This section is empty.
func CreateErrorResponse(pkiStatus Status, pkiFailureInfo FailureInfo) ([]byte, error)
CreateErrorResponse is used to create response other than granted and granted with mod status
CreateRequest returns a DER-encoded, timestamp request for the status of cert. If opts is nil then sensible defaults are used.
ExampleCreateRequest demonstrates how to create a new time-stamping request for an io.Reader.
_, err := CreateRequest(strings.NewReader("Content to be time-stamped"), nil)
if err != nil {
panic(err)
}
ExampleCreateRequest_customHashingAlgorithm demonstrates how to create a new time-stamping request with options
_, err := CreateRequest(
strings.NewReader("Content to be time-stamped"),
&RequestOptions{
Hash: crypto.SHA512,
})
if err != nil {
panic(err)
}
FailureInfo contains the failure details of an Time-Stamp request. See https://tools.ietf.org/html/rfc3161#section-2.4.2
const ( UnknownFailureInfo FailureInfo = -1 BadAlgorithm FailureInfo = 0 BadRequest FailureInfo = 2 BadDataFormat FailureInfo = 5 TimeNotAvailable FailureInfo = 14 UnacceptedPolicy FailureInfo = 15 UnacceptedExtension FailureInfo = 16 AddInfoNotAvailable FailureInfo = 17 SystemFailure FailureInfo = 25 )
ParseError results from an invalid Time-Stamp request or response.
Request represents an Time-Stamp request. See https://tools.ietf.org/html/rfc3161#section-2.4.1
ParseRequest parses an timestamp request in DER form.
ExampleParseRequest demonstrates how to parse a raw der time-stamping request
// CreateRequest returns the request in der bytes
createdRequest, err := CreateRequest(strings.NewReader("Content to be time-stamped"), nil)
if err != nil {
panic(err)
}
// ParseRequest parses a request in der bytes
parsedRequest, err := ParseRequest(createdRequest)
if err != nil {
panic(err)
}
fmt.Printf("%x\n", parsedRequest.HashedMessage)
Output: 51a3620a3b62ffaff41a434e932223b31bc69e86490c365fa1186033904f1132
Marshal marshals the Time-Stamp request to ASN.1 DER encoded form.
RequestOptions contains options for constructing timestamp requests.
Timestamp represents an Time-Stamp. See: https://tools.ietf.org/html/rfc3161#section-2.4.1
Parse parses an Time-Stamp in DER form. If the time-stamp contains a certificate then the signature over the response is checked.
Invalid signatures or parse failures will result in a ParseError. Error responses will result in a ResponseError.
ParseResponse parses an Time-Stamp response in DER form containing a TimeStampToken.
Invalid signatures or parse failures will result in a ParseError. Error responses will result in a ResponseError.
CreateResponse returns a DER-encoded timestamp response with the specified contents. The fields in the response are populated as follows:
The responder cert is used to populate the responder's name field, and the certificate itself is provided alongside the timestamp response signature.
This function is equivalent to CreateResponseWithOpts, using a SHA256 hash.
Deprecated: Use CreateResponseWithOpts instead.
CreateResponseWithOpts returns a DER-encoded timestamp response with the specified contents. The fields in the response are populated as follows:
The responder cert is used to populate the responder's name field, and the certificate itself is provided alongside the timestamp response signature.