util

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2021 License: Apache-2.0 Imports: 34 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckpointValidator added in v0.2.0

func CheckpointValidator(strToValidate string) bool

func CreateRfc3161Response added in v0.2.0

func CreateRfc3161Response(ctx context.Context, req pkcs9.TimeStampReq, certChain []*x509.Certificate, signer signature.Signer) (*pkcs9.TimeStampResp, error)

func FileOrURLReadCloser

func FileOrURLReadCloser(ctx context.Context, url string, content []byte) (io.ReadCloser, error)

FileOrURLReadCloser Note: caller is responsible for closing ReadCloser returned from method!

func ParseTimestampRequest added in v0.2.0

func ParseTimestampRequest(data []byte) (*pkcs9.TimeStampReq, error)

func PublicKey added in v0.2.0

func PublicKey(ctx context.Context, c *client.Rekor) (*ecdsa.PublicKey, error)

func RekorSTHValidator added in v0.2.0

func RekorSTHValidator(strToValidate string) bool

func SignedCheckpointValidator added in v0.2.0

func SignedCheckpointValidator(strToValidate string) bool

func TimestampRequestFromDigest added in v0.2.0

func TimestampRequestFromDigest(digest []byte, opts TimestampRequestOptions) (*pkcs9.TimeStampReq, error)

func YamlConsumer

func YamlConsumer() runtime.Consumer

func YamlProducer

func YamlProducer() runtime.Producer

Types

type Checkpoint added in v0.2.0

type Checkpoint struct {
	// Ecosystem is the ecosystem/version string
	Ecosystem string
	// Size is the number of entries in the log at this checkpoint.
	Size uint64
	// Hash is the hash which commits to the contents of the entire log.
	Hash []byte
	// OtherContent is any additional data to be included in the signed payload; each element is assumed to be one line
	OtherContent []string
}

func (Checkpoint) MarshalText added in v0.2.0

func (c Checkpoint) MarshalText() ([]byte, error)

MarshalText returns the common format representation of this Checkpoint.

func (Checkpoint) Sign added in v0.2.0

func (c Checkpoint) Sign(identity string, signer crypto.Signer, opts crypto.SignerOpts) (*note.Signature, error)

func (Checkpoint) String added in v0.2.0

func (c Checkpoint) String() string

String returns the String representation of the Checkpoint

func (*Checkpoint) UnmarshalText added in v0.2.0

func (c *Checkpoint) UnmarshalText(data []byte) error

UnmarshalText parses the common formatted checkpoint data and stores the result in the Checkpoint.

The supplied data is expected to begin with the following 3 lines of text, each followed by a newline: <ecosystem/version string> <decimal representation of log size> <base64 representation of root hash> <optional non-empty line of other content>... <optional non-empty line of other content>...

This will discard any content found after the checkpoint (including signatures)

type EssCertIDv2 added in v0.2.0

type EssCertIDv2 struct {
	HashAlgorithm       pkix.AlgorithmIdentifier `asn1:"optional"` // SHA256
	CertHash            []byte
	IssuerNameAndSerial IssuerNameAndSerial `asn1:"optional"`
}

type GeneralName added in v0.2.0

type GeneralName struct {
	Name asn1.RawValue `asn1:"optional,tag:4"`
}

type IssuerNameAndSerial added in v0.2.0

type IssuerNameAndSerial struct {
	IssuerName   GeneralName
	SerialNumber *big.Int
}

type RekorSTH added in v0.2.0

type RekorSTH struct {
	SignedCheckpoint
}

func (*RekorSTH) GetTimestamp added in v0.2.0

func (r *RekorSTH) GetTimestamp() uint64

func (*RekorSTH) SetTimestamp added in v0.2.0

func (r *RekorSTH) SetTimestamp(timestamp uint64)

type SignedCheckpoint added in v0.2.0

type SignedCheckpoint struct {
	Checkpoint
	// Signatures are one or more signature lines covering the payload
	Signatures []note.Signature
}

func (SignedCheckpoint) MarshalText added in v0.2.0

func (s SignedCheckpoint) MarshalText() ([]byte, error)

MarshalText returns the common format representation of this SignedCheckpoint.

func (*SignedCheckpoint) Sign added in v0.2.0

func (s *SignedCheckpoint) Sign(identity string, signer crypto.Signer, opts crypto.SignerOpts) (*note.Signature, error)

Sign adds an additional signature to a SignedCheckpoint object The signature is added to the signature array as well as being directly returned to the caller

func (SignedCheckpoint) String added in v0.2.0

func (s SignedCheckpoint) String() string

String returns the String representation of the SignedCheckpoint

func (*SignedCheckpoint) UnmarshalText added in v0.2.0

func (s *SignedCheckpoint) UnmarshalText(data []byte) error

UnmarshalText parses the common formatted checkpoint data and stores the result in the SignedCheckpoint. THIS DOES NOT VERIFY SIGNATURES INSIDE THE CONTENT!

The supplied data is expected to contain a single Checkpoint, followed by a single line with no comment, followed by one or more lines with the following format:

\u2014 name signature

  • name is the string associated with the signer
  • signature is a base64 encoded string; the first 4 bytes of the decoded value is a hint to the public key; it is a big-endian encoded uint32 representing the first 4 bytes of the SHA256 hash of the public key

func (SignedCheckpoint) Verify added in v0.2.0

func (s SignedCheckpoint) Verify(public crypto.PublicKey) bool

Verify checks that one of the signatures can be successfully verified using the supplied public key

type SigningCertificateV2 added in v0.2.0

type SigningCertificateV2 struct {
	Certs []EssCertIDv2
}

type TimestampRequestOptions added in v0.2.0

type TimestampRequestOptions struct {
	// The policy that the client expects the TSA to use for creating the timestamp token.
	// If no policy is specified the TSA uses its default policy.
	TSAPolicyOid asn1.ObjectIdentifier

	// The nonce to specify in the request.
	Nonce *big.Int

	// Hash function to use when constructing the timestamp request. Defaults to SHA-256.
	Hash crypto.Hash
}

Jump to

Keyboard shortcuts

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