v0.0.0-...-a93f71f Latest Latest

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

Go to latest
Published: Oct 2, 2017 License: Apache-2.0 Imports: 12 Imported by: 0



Package jose is DEPRECATED. Use instead.



View Source
const (
	HeaderMediaType    = "typ"
	HeaderKeyAlgorithm = "alg"
	HeaderKeyID        = "kid"
View Source
const (
	// Encryption Algorithm Header Parameter Values for JWS
	// See:
	AlgHS256 = "HS256"
	AlgHS384 = "HS384"
	AlgHS512 = "HS512"
	AlgRS256 = "RS256"
	AlgRS384 = "RS384"
	AlgRS512 = "RS512"
	AlgES256 = "ES256"
	AlgES384 = "ES384"
	AlgES512 = "ES512"
	AlgPS256 = "PS256"
	AlgPS384 = "PS384"
	AlgPS512 = "PS512"
	AlgNone  = "none"
View Source
const (
	// Algorithm Header Parameter Values for JWE
	// See:
	AlgRSA15            = "RSA1_5"
	AlgRSAOAEP          = "RSA-OAEP"
	AlgRSAOAEP256       = "RSA-OAEP-256"
	AlgA128KW           = "A128KW"
	AlgA192KW           = "A192KW"
	AlgA256KW           = "A256KW"
	AlgDir              = "dir"
	AlgECDHES           = "ECDH-ES"
	AlgECDHESA128KW     = "ECDH-ES+A128KW"
	AlgECDHESA192KW     = "ECDH-ES+A192KW"
	AlgECDHESA256KW     = "ECDH-ES+A256KW"
	AlgA128GCMKW        = "A128GCMKW"
	AlgA192GCMKW        = "A192GCMKW"
	AlgA256GCMKW        = "A256GCMKW"
	AlgPBES2HS256A128KW = "PBES2-HS256+A128KW"
	AlgPBES2HS384A192KW = "PBES2-HS384+A192KW"
	AlgPBES2HS512A256KW = "PBES2-HS512+A256KW"
View Source
const (
	// Encryption Algorithm Header Parameter Values for JWE
	// See:
	EncA128CBCHS256 = "A128CBC-HS256"
	EncA128CBCHS384 = "A128CBC-HS384"
	EncA256CBCHS512 = "A256CBC-HS512"
	EncA128GCM      = "A128GCM"
	EncA192GCM      = "A192GCM"
	EncA256GCM      = "A256GCM"


This section is empty.


This section is empty.


type Claims

type Claims map[string]interface{}

func (Claims) Add

func (c Claims) Add(name string, value interface{})

func (Claims) Float64Claim

func (c Claims) Float64Claim(name string) (float64, bool, error)

func (Claims) Int64Claim

func (c Claims) Int64Claim(name string) (int64, bool, error)

func (Claims) StringClaim

func (c Claims) StringClaim(name string) (string, bool, error)

func (Claims) StringsClaim

func (c Claims) StringsClaim(name string) ([]string, bool, error)

func (Claims) TimeClaim

func (c Claims) TimeClaim(name string) (time.Time, bool, error)

type JOSEHeader

type JOSEHeader map[string]string

func (JOSEHeader) Validate

func (j JOSEHeader) Validate() error

type JWK

type JWK struct {
	ID       string
	Type     string
	Alg      string
	Use      string
	Exponent int
	Modulus  *big.Int
	Secret   []byte

JSON Web Key

func (*JWK) MarshalJSON

func (j *JWK) MarshalJSON() ([]byte, error)

func (*JWK) UnmarshalJSON

func (j *JWK) UnmarshalJSON(data []byte) error

type JWKSet

type JWKSet struct {
	Keys []JWK `json:"keys"`

type JWS

type JWS struct {
	RawHeader  string
	Header     JOSEHeader
	RawPayload string
	Payload    []byte
	Signature  []byte

func ParseJWS

func ParseJWS(raw string) (JWS, error)

Given a raw encoded JWS token parses it and verifies the structure.

type JWT

type JWT JWS

func NewJWT

func NewJWT(header JOSEHeader, claims Claims) (jwt JWT, err error)

func NewSignedJWT

func NewSignedJWT(claims Claims, s Signer) (*JWT, error)

func ParseJWT

func ParseJWT(token string) (jwt JWT, err error)

func (*JWT) Claims

func (j *JWT) Claims() (Claims, error)

func (*JWT) Data

func (j *JWT) Data() string

Encoded data part of the token which may be signed.

func (*JWT) Encode

func (j *JWT) Encode() string

Full encoded JWT token string in format:

func (*JWT) KeyID

func (j *JWT) KeyID() (string, bool)

type Signer

type Signer interface {
	Sign(data []byte) (sig []byte, err error)

type SignerRSA

type SignerRSA struct {
	PrivateKey rsa.PrivateKey

func NewSignerRSA

func NewSignerRSA(kid string, key rsa.PrivateKey) *SignerRSA

func (*SignerRSA) Sign

func (s *SignerRSA) Sign(data []byte) ([]byte, error)

type Verifier

type Verifier interface {
	ID() string
	Alg() string
	Verify(sig []byte, data []byte) error

func NewVerifier

func NewVerifier(jwk JWK) (Verifier, error)

type VerifierRSA

type VerifierRSA struct {
	KeyID     string
	Hash      crypto.Hash
	PublicKey rsa.PublicKey

func NewVerifierRSA

func NewVerifierRSA(jwk JWK) (*VerifierRSA, error)

func (*VerifierRSA) Alg

func (v *VerifierRSA) Alg() string

func (*VerifierRSA) ID

func (v *VerifierRSA) ID() string

func (*VerifierRSA) Verify

func (v *VerifierRSA) Verify(sig []byte, data []byte) error

Jump to

Keyboard shortcuts

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