signature

package
v16.11.1 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractSignature

func ExtractSignature(tb testing.TB, ctx context.Context, objectData []byte) (string, string)

ExtractSignature extracts the signature from a commit object for testing purposes

Types

type GpgSigningKey

type GpgSigningKey struct {
	Entity *openpgp.Entity
}

GpgSigningKey is a struct that implements SigningKey interface for GPG keys

func (*GpgSigningKey) CreateSignature

func (sk *GpgSigningKey) CreateSignature(contentToSign []byte, date time.Time) ([]byte, error)

CreateSignature creates a gpg signature

func (*GpgSigningKey) Verify

func (sk *GpgSigningKey) Verify(signature, signedText []byte) error

Verify method verifies whether a signature has been created by this signing key

type SSHSigningKey

type SSHSigningKey struct {
	PrivateKey ssh.Signer
}

SSHSigningKey is a struct that implements SigningKey interface for SSH keys

func (*SSHSigningKey) CreateSignature

func (sk *SSHSigningKey) CreateSignature(contentToSign []byte, _ time.Time) ([]byte, error)

CreateSignature creates an SSH signature

func (*SSHSigningKey) Verify

func (sk *SSHSigningKey) Verify(signatureText, signedText []byte) error

Verify method verifies whether a signature has been created by this signing key

type SigningKey

type SigningKey interface {
	CreateSignature([]byte, time.Time) ([]byte, error)
	Verify([]byte, []byte) error
}

SigningKey is the common interface of SSH and GPG signing keys

type SigningKeys added in v16.4.0

type SigningKeys struct {
	// contains filtered or unexported fields
}

SigningKeys represents all signing keys configured in the system. The primary key is used for creating signatures, the secondary keys are used for verification if the primary key failed to verify a signature

func ParseSigningKeys added in v16.4.0

func ParseSigningKeys(primaryPath string, secondaryPaths ...string) (*SigningKeys, error)

ParseSigningKeys parses a list of signing keys separated by a comma and returns a list of GPG or SSH keys. Multiple signing keys are necessary to provide proper key rotation. The latest signing key is specified first and used for creating a signature. The previous signing keys go after and are used to verify a signature.

func (*SigningKeys) CreateSignature added in v16.4.0

func (s *SigningKeys) CreateSignature(contentToSign []byte, date time.Time) ([]byte, error)

CreateSignature uses the primary key to create a signature

func (*SigningKeys) Verify added in v16.4.0

func (s *SigningKeys) Verify(signature, signedText []byte) error

Verify iterates over all signing keys and returns nil if any verification was successful. Otherwise, the last error is returned. Note: when Golang 1.19 is no longer supported, can be refactored using errors.Join

Jump to

Keyboard shortcuts

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