jwa

package
v3.0.0-alpha1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 6 Imported by: 3

README

JWA Go Reference

Package github.com/lestrrat-go/jwx/v3/jwa defines the various algorithm described in RFC7518

Documentation

Overview

Package jwa defines the various algorithm described in https://tools.ietf.org/html/rfc7518

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrInvalidKeyAlgorithm

func ErrInvalidKeyAlgorithm() error

func RegisterCompressionAlgorithm

func RegisterCompressionAlgorithm(algorithms ...CompressionAlgorithm)

RegisterCompressionAlgorithm registers a new CompressionAlgorithm. The signature value must be immutable and safe to be used by multiple goroutines, as it is going to be shared with all other users of this library

func RegisterContentEncryptionAlgorithm

func RegisterContentEncryptionAlgorithm(algorithms ...ContentEncryptionAlgorithm)

RegisterContentEncryptionAlgorithm registers a new ContentEncryptionAlgorithm. The signature value must be immutable and safe to be used by multiple goroutines, as it is going to be shared with all other users of this library

func RegisterEllipticCurveAlgorithm

func RegisterEllipticCurveAlgorithm(algorithms ...EllipticCurveAlgorithm)

RegisterEllipticCurveAlgorithm registers a new EllipticCurveAlgorithm. The signature value must be immutable and safe to be used by multiple goroutines, as it is going to be shared with all other users of this library

func RegisterKeyEncryptionAlgorithm

func RegisterKeyEncryptionAlgorithm(algorithms ...KeyEncryptionAlgorithm)

RegisterKeyEncryptionAlgorithm registers a new KeyEncryptionAlgorithm. The signature value must be immutable and safe to be used by multiple goroutines, as it is going to be shared with all other users of this library

func RegisterKeyType

func RegisterKeyType(algorithms ...KeyType)

RegisterKeyType registers a new KeyType. The signature value must be immutable and safe to be used by multiple goroutines, as it is going to be shared with all other users of this library

func RegisterSignatureAlgorithm

func RegisterSignatureAlgorithm(algorithms ...SignatureAlgorithm)

RegisterSignatureAlgorithm registers a new SignatureAlgorithm. The signature value must be immutable and safe to be used by multiple goroutines, as it is going to be shared with all other users of this library

func UnregisterCompressionAlgorithm

func UnregisterCompressionAlgorithm(algorithms ...CompressionAlgorithm)

UnregisterCompressionAlgorithm unregisters a CompressionAlgorithm from its known database. Non-existent entries, as well as built-in algorithms will silently be ignored

func UnregisterContentEncryptionAlgorithm

func UnregisterContentEncryptionAlgorithm(algorithms ...ContentEncryptionAlgorithm)

UnregisterContentEncryptionAlgorithm unregisters a ContentEncryptionAlgorithm from its known database. Non-existent entries, as well as built-in algorithms will silently be ignored

func UnregisterEllipticCurveAlgorithm

func UnregisterEllipticCurveAlgorithm(algorithms ...EllipticCurveAlgorithm)

UnregisterEllipticCurveAlgorithm unregisters a EllipticCurveAlgorithm from its known database. Non-existent entries, as well as built-in algorithms will silently be ignored

func UnregisterKeyEncryptionAlgorithm

func UnregisterKeyEncryptionAlgorithm(algorithms ...KeyEncryptionAlgorithm)

UnregisterKeyEncryptionAlgorithm unregisters a KeyEncryptionAlgorithm from its known database. Non-existent entries, as well as built-in algorithms will silently be ignored

func UnregisterKeyType

func UnregisterKeyType(algorithms ...KeyType)

UnregisterKeyType unregisters a KeyType from its known database. Non-existent entries, as well as built-in algorithms will silently be ignored

func UnregisterSignatureAlgorithm

func UnregisterSignatureAlgorithm(algorithms ...SignatureAlgorithm)

UnregisterSignatureAlgorithm unregisters a SignatureAlgorithm from its known database. Non-existent entries, as well as built-in algorithms will silently be ignored

Types

type CompressionAlgorithm

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

func CompressionAlgorithms

func CompressionAlgorithms() []CompressionAlgorithm

CompressionAlgorithms returns a list of all available values for CompressionAlgorithm

func Deflate

func Deflate() CompressionAlgorithm

Deflate returns the Deflate algorithm object.

func EmptyCompressionAlgorithm

func EmptyCompressionAlgorithm() CompressionAlgorithm

EmptyCompressionAlgorithm returns an empty CompressionAlgorithm object, used as a zero value

func LookupCompressionAlgorithm

func LookupCompressionAlgorithm(name string) (CompressionAlgorithm, bool)

LookupCompressionAlgorithm returns the CompressionAlgorithm object for the given name

func NewCompressionAlgorithm

func NewCompressionAlgorithm(name string) CompressionAlgorithm

NewCompressionAlgorithm creates a new CompressionAlgorithm object

func NoCompress

func NoCompress() CompressionAlgorithm

NoCompress returns the NoCompress algorithm object.

func (CompressionAlgorithm) MarshalJSON

func (s CompressionAlgorithm) MarshalJSON() ([]byte, error)

MarshalJSON serializes the CompressionAlgorithm object to a JSON string

func (CompressionAlgorithm) String

func (s CompressionAlgorithm) String() string

func (*CompressionAlgorithm) UnmarshalJSON

func (s *CompressionAlgorithm) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the JSON string to a CompressionAlgorithm object

type ContentEncryptionAlgorithm

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

func A128CBC_HS256

func A128CBC_HS256() ContentEncryptionAlgorithm

A128CBC_HS256 returns the A128CBC_HS256 algorithm object.

func A128GCM

A128GCM returns the A128GCM algorithm object.

func A192CBC_HS384

func A192CBC_HS384() ContentEncryptionAlgorithm

A192CBC_HS384 returns the A192CBC_HS384 algorithm object.

func A192GCM

A192GCM returns the A192GCM algorithm object.

func A256CBC_HS512

func A256CBC_HS512() ContentEncryptionAlgorithm

A256CBC_HS512 returns the A256CBC_HS512 algorithm object.

func A256GCM

A256GCM returns the A256GCM algorithm object.

func ContentEncryptionAlgorithms

func ContentEncryptionAlgorithms() []ContentEncryptionAlgorithm

ContentEncryptionAlgorithms returns a list of all available values for ContentEncryptionAlgorithm

func EmptyContentEncryptionAlgorithm

func EmptyContentEncryptionAlgorithm() ContentEncryptionAlgorithm

EmptyContentEncryptionAlgorithm returns an empty ContentEncryptionAlgorithm object, used as a zero value

func LookupContentEncryptionAlgorithm

func LookupContentEncryptionAlgorithm(name string) (ContentEncryptionAlgorithm, bool)

LookupContentEncryptionAlgorithm returns the ContentEncryptionAlgorithm object for the given name

func NewContentEncryptionAlgorithm

func NewContentEncryptionAlgorithm(name string) ContentEncryptionAlgorithm

NewContentEncryptionAlgorithm creates a new ContentEncryptionAlgorithm object

func (ContentEncryptionAlgorithm) MarshalJSON

func (s ContentEncryptionAlgorithm) MarshalJSON() ([]byte, error)

MarshalJSON serializes the ContentEncryptionAlgorithm object to a JSON string

func (ContentEncryptionAlgorithm) String

func (*ContentEncryptionAlgorithm) UnmarshalJSON

func (s *ContentEncryptionAlgorithm) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the JSON string to a ContentEncryptionAlgorithm object

type EllipticCurveAlgorithm

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

func Ed25519

func Ed25519() EllipticCurveAlgorithm

Ed25519 returns the Ed25519 algorithm object.

func Ed448

func Ed448() EllipticCurveAlgorithm

Ed448 returns the Ed448 algorithm object.

func EllipticCurveAlgorithms

func EllipticCurveAlgorithms() []EllipticCurveAlgorithm

EllipticCurveAlgorithms returns a list of all available values for EllipticCurveAlgorithm

func EmptyEllipticCurveAlgorithm

func EmptyEllipticCurveAlgorithm() EllipticCurveAlgorithm

EmptyEllipticCurveAlgorithm returns an empty EllipticCurveAlgorithm object, used as a zero value

func InvalidEllipticCurve

func InvalidEllipticCurve() EllipticCurveAlgorithm

InvalidEllipticCurve returns the InvalidEllipticCurve algorithm object.

func LookupEllipticCurveAlgorithm

func LookupEllipticCurveAlgorithm(name string) (EllipticCurveAlgorithm, bool)

LookupEllipticCurveAlgorithm returns the EllipticCurveAlgorithm object for the given name

func NewEllipticCurveAlgorithm

func NewEllipticCurveAlgorithm(name string) EllipticCurveAlgorithm

NewEllipticCurveAlgorithm creates a new EllipticCurveAlgorithm object

func P256

P256 returns the P256 algorithm object.

func P384

P384 returns the P384 algorithm object.

func P521

P521 returns the P521 algorithm object.

func X25519

func X25519() EllipticCurveAlgorithm

X25519 returns the X25519 algorithm object.

func X448

X448 returns the X448 algorithm object.

func (EllipticCurveAlgorithm) MarshalJSON

func (s EllipticCurveAlgorithm) MarshalJSON() ([]byte, error)

MarshalJSON serializes the EllipticCurveAlgorithm object to a JSON string

func (EllipticCurveAlgorithm) String

func (s EllipticCurveAlgorithm) String() string

func (*EllipticCurveAlgorithm) UnmarshalJSON

func (s *EllipticCurveAlgorithm) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the JSON string to a EllipticCurveAlgorithm object

type KeyAlgorithm

type KeyAlgorithm interface {
	String() string
}

KeyAlgorithm is a workaround for jwk.Key being able to contain different types of algorithms in its `alg` field.

Previously the storage for the `alg` field was represented as a string, but this caused some users to wonder why the field was not typed appropriately like other fields.

Ideally we would like to keep track of Signature Algorithms and Key Encryption Algorithms separately, and force the APIs to type-check at compile time, but this allows users to pass a value from a jwk.Key directly

func KeyAlgorithmFrom

func KeyAlgorithmFrom(v any) (KeyAlgorithm, error)

KeyAlgorithmFrom takes either a string, `jwa.SignatureAlgorithm`, `jwa.KeyEncryptionAlgorithm`, or `jwa.ContentEncryptionAlgorithm`. and returns a `jwa.KeyAlgorithm`.

If the value cannot be handled, it returns an `jwa.InvalidKeyAlgorithm` object instead of returning an error. This design choice was made to allow users to directly pass the return value to functions such as `jws.Sign()`

type KeyEncryptionAlgorithm

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

func A128GCMKW

func A128GCMKW() KeyEncryptionAlgorithm

A128GCMKW returns the A128GCMKW algorithm object.

func A128KW

func A128KW() KeyEncryptionAlgorithm

A128KW returns the A128KW algorithm object.

func A192GCMKW

func A192GCMKW() KeyEncryptionAlgorithm

A192GCMKW returns the A192GCMKW algorithm object.

func A192KW

func A192KW() KeyEncryptionAlgorithm

A192KW returns the A192KW algorithm object.

func A256GCMKW

func A256GCMKW() KeyEncryptionAlgorithm

A256GCMKW returns the A256GCMKW algorithm object.

func A256KW

func A256KW() KeyEncryptionAlgorithm

A256KW returns the A256KW algorithm object.

func DIRECT

func DIRECT() KeyEncryptionAlgorithm

DIRECT returns the DIRECT algorithm object.

func ECDH_ES

func ECDH_ES() KeyEncryptionAlgorithm

ECDH_ES returns the ECDH_ES algorithm object.

func ECDH_ES_A128KW

func ECDH_ES_A128KW() KeyEncryptionAlgorithm

ECDH_ES_A128KW returns the ECDH_ES_A128KW algorithm object.

func ECDH_ES_A192KW

func ECDH_ES_A192KW() KeyEncryptionAlgorithm

ECDH_ES_A192KW returns the ECDH_ES_A192KW algorithm object.

func ECDH_ES_A256KW

func ECDH_ES_A256KW() KeyEncryptionAlgorithm

ECDH_ES_A256KW returns the ECDH_ES_A256KW algorithm object.

func EmptyKeyEncryptionAlgorithm

func EmptyKeyEncryptionAlgorithm() KeyEncryptionAlgorithm

EmptyKeyEncryptionAlgorithm returns an empty KeyEncryptionAlgorithm object, used as a zero value

func KeyEncryptionAlgorithms

func KeyEncryptionAlgorithms() []KeyEncryptionAlgorithm

KeyEncryptionAlgorithms returns a list of all available values for KeyEncryptionAlgorithm

func LookupKeyEncryptionAlgorithm

func LookupKeyEncryptionAlgorithm(name string) (KeyEncryptionAlgorithm, bool)

LookupKeyEncryptionAlgorithm returns the KeyEncryptionAlgorithm object for the given name

func NewKeyEncryptionAlgorithm

func NewKeyEncryptionAlgorithm(name string, options ...NewKeyEncryptionAlgorithmOption) KeyEncryptionAlgorithm

NewKeyEncryptionAlgorithm creates a new KeyEncryptionAlgorithm object

func PBES2_HS256_A128KW

func PBES2_HS256_A128KW() KeyEncryptionAlgorithm

PBES2_HS256_A128KW returns the PBES2_HS256_A128KW algorithm object.

func PBES2_HS384_A192KW

func PBES2_HS384_A192KW() KeyEncryptionAlgorithm

PBES2_HS384_A192KW returns the PBES2_HS384_A192KW algorithm object.

func PBES2_HS512_A256KW

func PBES2_HS512_A256KW() KeyEncryptionAlgorithm

PBES2_HS512_A256KW returns the PBES2_HS512_A256KW algorithm object.

func RSA1_5

func RSA1_5() KeyEncryptionAlgorithm

RSA1_5 returns the RSA1_5 algorithm object.

func RSA_OAEP

func RSA_OAEP() KeyEncryptionAlgorithm

RSA_OAEP returns the RSA_OAEP algorithm object.

func RSA_OAEP_256

func RSA_OAEP_256() KeyEncryptionAlgorithm

RSA_OAEP_256 returns the RSA_OAEP_256 algorithm object.

func RSA_OAEP_384

func RSA_OAEP_384() KeyEncryptionAlgorithm

RSA_OAEP_384 returns the RSA_OAEP_384 algorithm object.

func RSA_OAEP_512

func RSA_OAEP_512() KeyEncryptionAlgorithm

RSA_OAEP_512 returns the RSA_OAEP_512 algorithm object.

func (KeyEncryptionAlgorithm) IsSymmetric

func (s KeyEncryptionAlgorithm) IsSymmetric() bool

func (KeyEncryptionAlgorithm) MarshalJSON

func (s KeyEncryptionAlgorithm) MarshalJSON() ([]byte, error)

MarshalJSON serializes the KeyEncryptionAlgorithm object to a JSON string

func (KeyEncryptionAlgorithm) String

func (s KeyEncryptionAlgorithm) String() string

func (*KeyEncryptionAlgorithm) UnmarshalJSON

func (s *KeyEncryptionAlgorithm) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the JSON string to a KeyEncryptionAlgorithm object

type KeyType

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

func EC

func EC() KeyType

EC returns the EC algorithm object.

func EmptyKeyType

func EmptyKeyType() KeyType

EmptyKeyType returns an empty KeyType object, used as a zero value

func InvalidKeyType

func InvalidKeyType() KeyType

InvalidKeyType returns the InvalidKeyType algorithm object.

func KeyTypes

func KeyTypes() []KeyType

KeyTypes returns a list of all available values for KeyType

func LookupKeyType

func LookupKeyType(name string) (KeyType, bool)

LookupKeyType returns the KeyType object for the given name

func NewKeyType

func NewKeyType(name string) KeyType

NewKeyType creates a new KeyType object

func OKP

func OKP() KeyType

OKP returns the OKP algorithm object.

func OctetSeq

func OctetSeq() KeyType

OctetSeq returns the OctetSeq algorithm object.

func RSA

func RSA() KeyType

RSA returns the RSA algorithm object.

func (KeyType) MarshalJSON

func (s KeyType) MarshalJSON() ([]byte, error)

MarshalJSON serializes the KeyType object to a JSON string

func (KeyType) String

func (s KeyType) String() string

func (*KeyType) UnmarshalJSON

func (s *KeyType) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the JSON string to a KeyType object

type NewKeyEncryptionAlgorithmOption

type NewKeyEncryptionAlgorithmOption interface {
	Option
	// contains filtered or unexported methods
}

NewKeyEncryptionAlgorithmOption represents an option that can be passed to the NewKeyEncryptionAlgorithm

type NewSignatureAlgorithmOption

type NewSignatureAlgorithmOption interface {
	Option
	// contains filtered or unexported methods
}

NewSignatureAlgorithmOption represents an option that can be passed to the NewSignatureAlgorithm

type NewSignatureKeyEncryptionAlgorithmOption

type NewSignatureKeyEncryptionAlgorithmOption interface {
	Option
	// contains filtered or unexported methods
}

NewSignatureKeyEncryptionAlgorithmOption represents an option that can be passed to both NewSignatureAlgorithm and NewKeyEncryptionAlgorithm

func WithIsSymmetric

IsSymmetric specifies that the algorithm is symmetric

type Option

type Option = option.Interface

type SignatureAlgorithm

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

func ES256

func ES256() SignatureAlgorithm

ES256 returns the ES256 algorithm object.

func ES256K

func ES256K() SignatureAlgorithm

ES256K returns the ES256K algorithm object.

func ES384

func ES384() SignatureAlgorithm

ES384 returns the ES384 algorithm object.

func ES512

func ES512() SignatureAlgorithm

ES512 returns the ES512 algorithm object.

func EdDSA

func EdDSA() SignatureAlgorithm

EdDSA returns the EdDSA algorithm object.

func EmptySignatureAlgorithm

func EmptySignatureAlgorithm() SignatureAlgorithm

EmptySignatureAlgorithm returns an empty SignatureAlgorithm object, used as a zero value

func HS256

func HS256() SignatureAlgorithm

HS256 returns the HS256 algorithm object.

func HS384

func HS384() SignatureAlgorithm

HS384 returns the HS384 algorithm object.

func HS512

func HS512() SignatureAlgorithm

HS512 returns the HS512 algorithm object.

func LookupSignatureAlgorithm

func LookupSignatureAlgorithm(name string) (SignatureAlgorithm, bool)

LookupSignatureAlgorithm returns the SignatureAlgorithm object for the given name

func NewSignatureAlgorithm

func NewSignatureAlgorithm(name string, options ...NewSignatureAlgorithmOption) SignatureAlgorithm

NewSignatureAlgorithm creates a new SignatureAlgorithm object

func NoSignature

func NoSignature() SignatureAlgorithm

NoSignature returns the NoSignature algorithm object.

func PS256

func PS256() SignatureAlgorithm

PS256 returns the PS256 algorithm object.

func PS384

func PS384() SignatureAlgorithm

PS384 returns the PS384 algorithm object.

func PS512

func PS512() SignatureAlgorithm

PS512 returns the PS512 algorithm object.

func RS256

func RS256() SignatureAlgorithm

RS256 returns the RS256 algorithm object.

func RS384

func RS384() SignatureAlgorithm

RS384 returns the RS384 algorithm object.

func RS512

func RS512() SignatureAlgorithm

RS512 returns the RS512 algorithm object.

func SignatureAlgorithms

func SignatureAlgorithms() []SignatureAlgorithm

SignatureAlgorithms returns a list of all available values for SignatureAlgorithm

func (SignatureAlgorithm) IsSymmetric

func (s SignatureAlgorithm) IsSymmetric() bool

func (SignatureAlgorithm) MarshalJSON

func (s SignatureAlgorithm) MarshalJSON() ([]byte, error)

MarshalJSON serializes the SignatureAlgorithm object to a JSON string

func (SignatureAlgorithm) String

func (s SignatureAlgorithm) String() string

func (*SignatureAlgorithm) UnmarshalJSON

func (s *SignatureAlgorithm) UnmarshalJSON(data []byte) error

UnmarshalJSON deserializes the JSON string to a SignatureAlgorithm object

Jump to

Keyboard shortcuts

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