signature

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MaxJSONKeySize = 512 * 1024
)

Variables

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

Functions

func Decode

func Decode(input string) ([]byte, error)

func Encode

func Encode(input []byte) string

func NewEd25519PrivateKeyFromRaw

func NewEd25519PrivateKeyFromRaw(key []byte) (ed25519.PrivateKey, error)

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.PublicKey, error)

func NewJclabPrs2301ResignKey

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

func PgpPublicKeySerialize

func PgpPublicKeySerialize(key crypto.PublicKey) ([]byte, 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

	KeyTypeByPublicKey(key crypto.PublicKey) (string, error)
	KeyTypeByPrivateKey(key crypto.PrivateKey) (string, error)

	GeneratePublicKey(privateKey crypto.PrivateKey) (crypto.PublicKey, error)

	NewSigner(key crypto.PrivateKey, keyId string) (Signer, error)
	NewVerifier(key crypto.PublicKey, keyId string) (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
	SecretKey []byte
}

type JclabPrs2301PrivateKey

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

func (*JclabPrs2301PrivateKey) GetS

func (k *JclabPrs2301PrivateKey) GetS() []byte

type JclabPrs2301PublicKey

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

func (*JclabPrs2301PublicKey) GetW1

func (k *JclabPrs2301PublicKey) GetW1() []byte

type JclabPrs2301ResignKey

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

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 {
	Engine() Engine

	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 {
	Engine() Engine

	PublicKey() crypto.PublicKey
	KeyId() 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