signature

package
v2.0.0-...-d1367cc Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2021 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidToken         = errors.New("invalid token")
	ErrInvalidSignatureType = errors.New("invalid signature type")
	ErrUnknownSignatureType = errors.New("unknown signature type")
	ErrUnknownSigner        = errors.New("unknown signer")
	ErrDigestMismatch       = errors.New("digest mismatch")
	ErrSizeMismatch         = errors.New("size mismatch")
	ErrMediaTypeMismatch    = errors.New("media type mismatch")
)

common errors

Functions

func DecodeSegment

func DecodeSegment(seg string) ([]byte, error)

DecodeSegment JWT specific base64url encoding with padding stripped

func EncodeSegment

func EncodeSegment(seg []byte) string

EncodeSegment JWT specific base64url encoding with padding stripped

Types

type Claims

type Claims struct {
	Manifest
	Expiration int64 `json:"exp,omitempty"`
	IssuedAt   int64 `json:"iat,omitempty"`
	NotBefore  int64 `json:"nbf,omitempty"`
}

Claims contains the claims to be signed

func DecodeClaims

func DecodeClaims(seg string) (Claims, error)

DecodeClaims JWT specific base64url encoding with padding stripped as Claims

type Descriptor

type Descriptor struct {
	MediaType string `json:"mediaType,omitempty"`
	Digest    string `json:"digest"`
	Size      int64  `json:"size"`
}

Descriptor describes the basic information of the target content

type Header struct {
	Raw  []byte `json:"-"`
	Type string `json:"typ"`
}

Header defines the signature header

type Manifest

type Manifest struct {
	Descriptor
	References []string `json:"references,omitempty"`
}

Manifest to be signed

type Scheme

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

Scheme is a signature scheme

func NewScheme

func NewScheme() *Scheme

NewScheme creates a new scheme

func (*Scheme) RegisterSigner

func (s *Scheme) RegisterSigner(signerID string, signer Signer)

RegisterSigner registers signer with a name

func (*Scheme) RegisterVerifier

func (s *Scheme) RegisterVerifier(verifier Verifier)

RegisterVerifier registers verifier

func (*Scheme) Sign

func (s *Scheme) Sign(signerID string, claims Claims) (string, error)

Sign signs claims by a signer

func (*Scheme) SignRaw

func (s *Scheme) SignRaw(signerID string, content []byte) (string, error)

SignRaw signs raw content by a signer

func (*Scheme) Verify

func (s *Scheme) Verify(token string) (Claims, error)

Verify verifies the JWT-like token

type Signer

type Signer interface {
	Sign(claims string) (string, []byte, error)
}

Signer signs content

type Verifier

type Verifier interface {
	Type() string
	Verify(header Header, signed string, sig []byte) error
}

Verifier verifies content

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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