keys

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2022 License: BSD-3-Clause Imports: 16 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalid    = errors.New("tuf: signature verification failed")
	ErrInvalidKey = errors.New("invalid key")
)
View Source
var SignerMap sync.Map

SignerMap stores mapping between key type strings and signer constructors.

View Source
var VerifierMap sync.Map

Verifier stores mapping between key type strings and verifier constructors.

Functions

func GenerateEd25519Key

func GenerateEd25519Key() (*ed25519Signer, error)

func GenerateRsaKey

func GenerateRsaKey() (*rsaSigner, error)

func NewEd25519Signer

func NewEd25519Signer(keyValue Ed25519PrivateKeyValue) *ed25519Signer

Types

type Ed25519PrivateKeyValue

type Ed25519PrivateKeyValue struct {
	Public  data.HexBytes `json:"public"`
	Private data.HexBytes `json:"private"`
}

type Signer

type Signer interface {
	// MarshalPrivateKey returns the private key data.
	MarshalPrivateKey() (*data.PrivateKey, error)

	// UnmarshalPrivateKey takes private key data to a working Signer implementation for the key type.
	UnmarshalPrivateKey(key *data.PrivateKey) error

	// Returns the public data.PublicKey from the private key
	PublicData() *data.PublicKey

	// Sign returns the signature of the message.
	// The signer is expected to do its own hashing, so the full message will be
	// provided as the message to Sign with a zero opts.HashFunc().
	SignMessage(message []byte) ([]byte, error)
}

func GetSigner

func GetSigner(key *data.PrivateKey) (Signer, error)

func NewP256Signer

func NewP256Signer() Signer

func NewRsaSigner

func NewRsaSigner() Signer

type Verifier

type Verifier interface {
	// UnmarshalPublicKey takes key data to a working verifier implementation for the key type.
	// This performs any validation over the data.PublicKey to ensure that the verifier is usable
	// to verify signatures.
	UnmarshalPublicKey(key *data.PublicKey) error

	// MarshalPublicKey returns the data.PublicKey object associated with the verifier.
	MarshalPublicKey() *data.PublicKey

	// This is the public string used as a unique identifier for the verifier instance.
	Public() string

	// Verify takes a message and signature, all as byte slices,
	// and determines whether the signature is valid for the given
	// key and message.
	Verify(msg, sig []byte) error
}

A Verifier verifies public key signatures.

func GetVerifier

func GetVerifier(key *data.PublicKey) (Verifier, error)

func NewEcdsaVerifier

func NewEcdsaVerifier() Verifier

func NewP256Verifier

func NewP256Verifier() Verifier

func NewRsaVerifier

func NewRsaVerifier() Verifier

Jump to

Keyboard shortcuts

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