signing

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSigning                   = algorithm.ErrSigning
	ErrBadSignature              = algorithm.ErrBadSignature
	ErrSignatureMismatch         = algorithm.ErrSignatureMismatch
	ErrSignatureExpired          = algorithm.ErrSignatureExpired
	ErrUnknownSignatureAlgorithm = algorithm.ErrUnknownSignatureAlgorithm
)
View Source
var (
	DefaultEncoder = JSONEncoder
	DefaultDecoder = JSONDecoder
)

Functions

func SignObject

func SignObject(ctx context.Context, signer Signer, obj interface{}) (string, error)

func SignObjectEncoder

func SignObjectEncoder(ctx context.Context, signer Signer, obj interface{}, encoder func(w io.Writer) Encoder) (string, error)

func UnsignObject

func UnsignObject(ctx context.Context, signer Signer, signed string, obj interface{}) error

func UnsignObjectDecoder

func UnsignObjectDecoder(ctx context.Context, signer Signer, signed string, obj interface{}, decoder func(r io.Reader) Decoder) error

Types

type BaseSigner

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

func NewBaseSigner

func NewBaseSigner(key []byte, sep string, salt []byte, algo string, fallbackKeys [][]byte) *BaseSigner

func (*BaseSigner) Algorithm

func (s *BaseSigner) Algorithm() algorithm.Algorithm

func (*BaseSigner) FallbackKeys

func (s *BaseSigner) FallbackKeys() [][]byte

func (*BaseSigner) Key

func (s *BaseSigner) Key() []byte

func (*BaseSigner) Salt

func (s *BaseSigner) Salt() []byte

func (*BaseSigner) Separator

func (s *BaseSigner) Separator() string

func (*BaseSigner) Sign

func (s *BaseSigner) Sign(ctx context.Context, data []byte) (string, error)

func (*BaseSigner) Signature

func (s *BaseSigner) Signature(ctx context.Context, data []byte) ([]byte, error)

func (*BaseSigner) Unsign

func (s *BaseSigner) Unsign(ctx context.Context, signedData string) ([]byte, error)

type Decoder

type Decoder interface {
	Decode(v any) error
}

func JSONDecoder

func JSONDecoder(r io.Reader) Decoder

type Encoder

type Encoder interface {
	Encode(v any) error
}

func JSONEncoder

func JSONEncoder(w io.Writer) Encoder

type Signer

type Signer interface {
	Separator() string
	Salt() []byte
	Key() []byte
	FallbackKeys() [][]byte
	Sign(ctx context.Context, data []byte) (string, error)
	Unsign(ctx context.Context, signature string) ([]byte, error)
	Algorithm() algorithm.Algorithm
}

type TimestampSigner

type TimestampSigner struct {
	Signer
	MaxAge time.Duration
}

func NewTimestampSigner

func NewTimestampSigner(key []byte, sep string, salt []byte, algo string, fallbackKeys [][]byte, maxAge time.Duration) *TimestampSigner

func (*TimestampSigner) Sign

func (s *TimestampSigner) Sign(ctx context.Context, data []byte) (string, error)

func (*TimestampSigner) Unsign

func (s *TimestampSigner) Unsign(ctx context.Context, signedData string, maxAge time.Duration) ([]byte, error)

Jump to

Keyboard shortcuts

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