trust

package
v0.0.0-...-f5d3e16 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrScope          sterror.Scope = "Signature verification"
	ErrOpDSSign       sterror.Op    = "DummySigner.Sign"
	ErrOpRSASSign     sterror.Op    = "RSAPSSSigner.Sign"
	ErrOpRSASVerify   sterror.Op    = "RSAPSSSigner.Verify"
	ErrOpEDSSign      sterror.Op    = "ED25519Signer.Sign"
	ErrOpEDSVerify    sterror.Op    = "ED25519Signer.Verify"
	ErrInfoInvalidKey               = "got key of type %T, expected %v"
)

Scope and operations used for raising Errors of this package.

Variables

View Source
var (
	ErrSigning      = errors.New("signature creation failed")
	ErrVerification = errors.New("signature verification failed")
	ErrInvalidKey   = errors.New("invalid key type")
)

Errors which may be raised and wrapped in this package.

Functions

This section is empty.

Types

type DummySigner

type DummySigner struct{}

DummySigner implements the Signer interface. It creates signatures that are always valid.

func (DummySigner) Sign

func (DummySigner) Sign(key crypto.PrivateKey, data []byte) ([]byte, error)

Sign returns a signature containing just 8 random bytes.

func (DummySigner) Verify

func (DummySigner) Verify(sig, hash []byte, key crypto.PublicKey) error

Verify will never return an error.

type ED25519Signer

type ED25519Signer struct{}

func (ED25519Signer) Sign

func (ED25519Signer) Sign(key crypto.PrivateKey, data []byte) ([]byte, error)

Sign signes the provided data with the key named by privKey. Problems are reported by an error wrapping SigningError.

func (ED25519Signer) Verify

func (ED25519Signer) Verify(sig, hash []byte, key crypto.PublicKey) error

Verify checks if sig contains a valid signature of hash.

type RSAPSSSigner

type RSAPSSSigner struct{}

RSAPSSSigner implements the Signer interface. It uses SHA256 hashes and PSS signatures along with x509 certificates.

func (RSAPSSSigner) Sign

func (RSAPSSSigner) Sign(key crypto.PrivateKey, data []byte) ([]byte, error)

Sign signes the provided data with the key named by privKey. The returned byte slice contains a PSS signature value. Problems are reported by an error wrapping SigningError.

func (RSAPSSSigner) Verify

func (RSAPSSSigner) Verify(sig, hash []byte, key crypto.PublicKey) error

Verify checks if sig contains a valid signature of hash.

type Signer

type Signer interface {
	Sign(key crypto.PrivateKey, data []byte) ([]byte, error)
	Verify(sig, hash []byte, key crypto.PublicKey) error
}

Signer is used by OSPackage to sign and varify the OSPackage.

Jump to

Keyboard shortcuts

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