keys

package
v0.0.6-rc1 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxJSONKeySize = 512 * 1024
)

Variables

View Source
var (
	ErrGpgNotSupported = errors.New("GPG Not Supported")
	ErrGpgCancelled    = errors.New("cancelled")
)
View Source
var (
	ErrInvalid    = errors.New("tuf: signature verification failed")
	ErrInvalidKey = errors.New("invalid key")
)

Functions

func NewJclabPrs2301Bls12381PrivateKey

func NewJclabPrs2301Bls12381PrivateKey(S []byte) (crypto.PrivateKey, error)

func NewJclabPrs2301Bls12381PublicKey

func NewJclabPrs2301Bls12381PublicKey(W1 []byte) (crypto.PrivateKey, error)

func NewJclabPrs2301Bls12381ResignKey

func NewJclabPrs2301Bls12381ResignKey(RK []byte, W1 []byte) (crypto.PrivateKey, error)

func NewJclabPrs2301PrivateKey

func NewJclabPrs2301PrivateKey(curveEngine engine.CurveEngine, keyType string, S []byte) (crypto.PrivateKey, error)

func NewJclabPrs2301PublicKey

func NewJclabPrs2301PublicKey(curveEngine engine.CurveEngine, keyType string, W1 []byte) (crypto.PrivateKey, error)

func NewJclabPrs2301ResignKey

func NewJclabPrs2301ResignKey(curveEngine engine.CurveEngine, keyType string, RK []byte, W1 []byte) (crypto.PrivateKey, error)

func ReadPgpArmorPrivateKey

func ReadPgpArmorPrivateKey(input string) (crypto.PrivateKey, error)

func ReadPgpArmorPublicKey

func ReadPgpArmorPublicKey(input string) (crypto.PublicKey, error)

Types

type Engine

type Engine interface {
	Schema() string
	GenerateKeyPair() (crypto.PrivateKey, crypto.PublicKey, error)
	GeneratePublicKey(privateKey crypto.PrivateKey) (crypto.PublicKey, error)
	MarshalPublicKey(key crypto.PublicKey) (string, error)
	UnmarshalPublicKey(key string) (crypto.PublicKey, error)
	MarshalPrivateKey(key crypto.PrivateKey) (string, error)
	UnmarshalPrivateKey(key string) (crypto.PrivateKey, error)
	MarshalPublicKeyRaw(key crypto.PublicKey) ([]byte, error)
	UnmarshalPublicKeyRaw(key []byte) (crypto.PublicKey, error)
	MarshalPrivateKeyRaw(key crypto.PrivateKey) ([]byte, error)
	UnmarshalPrivateKeyRaw(key []byte) (crypto.PrivateKey, error)
	KeyId(key crypto.PublicKey) (string, error)
	KeyTypeByPublicKey(key crypto.PublicKey) (string, error)
	KeyTypeByPrivateKey(key crypto.PrivateKey) (string, error)
	NewSigner(key crypto.PrivateKey) (Signer, error)
	NewVerifier(key crypto.PublicKey) (Verifier, error)
}

func GetEngine

func GetEngine(schema string) (Engine, error)

func NewEd25519Engine

func NewEd25519Engine() Engine

func NewHmacEngine

func NewHmacEngine() Engine

func NewJclabPrs2301FinalEngine

func NewJclabPrs2301FinalEngine() Engine

func NewJclabPrs2301FirstEngine

func NewJclabPrs2301FirstEngine() Engine

func NewPgpEngine

func NewPgpEngine() Engine

type GpgConfig

type GpgConfig struct {
	Command    string // default: gpg(.exe)
	UseAgent   bool
	Passphrase string
	KeyName    string
}

type HmacKey

type HmacKey struct {
	Algorithm string
	KeyId     string
	SecretKey []byte
}

type PKIXPublicKey

type PKIXPublicKey struct {
	crypto.PublicKey
}

func (*PKIXPublicKey) MarshalJSON

func (p *PKIXPublicKey) MarshalJSON() ([]byte, error)

func (*PKIXPublicKey) UnmarshalJSON

func (p *PKIXPublicKey) UnmarshalJSON(b []byte) error

type SignedJson

type SignedJson[T interface{}] struct {
	Signed     T                      `json:"signed"`
	Signatures []*SignedJsonSignature `json:"signatures"`
}

type SignedJsonSignature

type SignedJsonSignature struct {
	Keyid string `json:"keyid"`
	Sig   string `json:"sig"`
}

type Signer

type Signer interface {
	PrivateKey() crypto.PrivateKey
	PublicKey() crypto.PublicKey
	KeyId() string

	SignMessage(msg []byte) ([]byte, error)
	SignJson(msg *SignedJson[any]) error
}

func NewGpgSigner

func NewGpgSigner(config *GpgConfig) (Signer, error)

type Verifier

type Verifier interface {
	PublicKey() crypto.PublicKey
	KeyId() string
	MarshalPublicKey() string
	VerifyMessage(msg []byte, sig []byte) (bool, error)
	VerifyJson(msg *SignedJson[any]) (bool, error)
}

Jump to

Keyboard shortcuts

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