sign

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSignature              = errors.New("invalid signature")
	ErrorUnsupportedSignatureVersion = errors.New("unsupported signature version")
)

Functions

This section is empty.

Types

type Digest

type Digest struct {
	Ver Version
	// contains filtered or unexported fields
}

func NewDigest

func NewDigest(v Version, timeStamp time.Time) *Digest

func (*Digest) AddBytes

func (s *Digest) AddBytes(data []byte)

func (*Digest) AddRequest

func (s *Digest) AddRequest(r *http.Request) error

func (*Digest) AddString

func (s *Digest) AddString(str string)

func (*Digest) Sign

func (s *Digest) Sign(signer Signer) (Signature, error)

func (*Digest) Sum

func (s *Digest) Sum(b []byte) []byte

type RSASigner

type RSASigner rsa.PrivateKey

func (*RSASigner) Sign

func (key *RSASigner) Sign(digest []byte) (Signature, error)

type Signature

type Signature []byte

func ParseSignature

func ParseSignature(s string) (Signature, error)

func (Signature) Data

func (s Signature) Data() []byte

func (Signature) Equal

func (s Signature) Equal(other Signature, precision time.Duration) bool

Equal compares two signatures. Signatures are equal if they have the same version, body and timestamps differ by no more than precision.

func (Signature) HexString

func (s Signature) HexString() string

func (Signature) IssuedAt

func (s Signature) IssuedAt(t time.Time, leeway time.Duration) bool

IssuedAt checks if the signature was issued at the specified time. The signature is considered to be issued at the specified time if the difference between the signature time and the target time is less than the leeway. The signature with zero time is always considered to be issued at the specified time.

func (Signature) Time

func (s Signature) Time() time.Time

func (Signature) Ver

func (s Signature) Ver() Version

type Signer

type Signer interface {
	Sign(digest []byte) (Signature, error)
}

type Version

type Version int
const (
	VErr Version = iota

	V2
	V3
	V4
)

Jump to

Keyboard shortcuts

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