jwa

package
v4.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 9 Imported by: 0

README

JWA Go Reference

Package github.com/lestrrat-go/jwx/v4/jwa defines the various algorithms described in RFC 7518.

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) error

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.

Registration is process-global. Built-in identifiers such as RS256 are reserved and cannot be replaced by callers after init has completed; use a distinct name for third-party algorithms.

func RegisterContentEncryptionAlgorithm

func RegisterContentEncryptionAlgorithm(algorithms ...ContentEncryptionAlgorithm) error

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.

Registration is process-global. Built-in identifiers such as RS256 are reserved and cannot be replaced by callers after init has completed; use a distinct name for third-party algorithms.

SignatureAlgorithm, KeyEncryptionAlgorithm, and ContentEncryptionAlgorithm share a single algorithm-name namespace so that KeyAlgorithmFrom can resolve unambiguously. Registering a name that is already registered as a different kind returns an error naming both the existing and the requested kind.

func RegisterEllipticCurveAlgorithm

func RegisterEllipticCurveAlgorithm(algorithms ...EllipticCurveAlgorithm) error

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.

Registration is process-global. Built-in identifiers such as RS256 are reserved and cannot be replaced by callers after init has completed; use a distinct name for third-party algorithms.

func RegisterKeyEncryptionAlgorithm

func RegisterKeyEncryptionAlgorithm(algorithms ...KeyEncryptionAlgorithm) error

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.

Registration is process-global. Built-in identifiers such as RS256 are reserved and cannot be replaced by callers after init has completed; use a distinct name for third-party algorithms.

SignatureAlgorithm, KeyEncryptionAlgorithm, and ContentEncryptionAlgorithm share a single algorithm-name namespace so that KeyAlgorithmFrom can resolve unambiguously. Registering a name that is already registered as a different kind returns an error naming both the existing and the requested kind.

func RegisterKeyType

func RegisterKeyType(algorithms ...KeyType) error

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.

Registration is process-global. Built-in identifiers such as RS256 are reserved and cannot be replaced by callers after init has completed; use a distinct name for third-party algorithms.

func RegisterSignatureAlgorithm

func RegisterSignatureAlgorithm(algorithms ...SignatureAlgorithm) error

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.

Registration is process-global. Built-in identifiers such as RS256 are reserved and cannot be replaced by callers after init has completed; use a distinct name for third-party algorithms.

SignatureAlgorithm, KeyEncryptionAlgorithm, and ContentEncryptionAlgorithm share a single algorithm-name namespace so that KeyAlgorithmFrom can resolve unambiguously. Registering a name that is already registered as a different kind returns an error naming both the existing and the requested kind.

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
}

CompressionAlgorithm represents the compression algorithms as described in https://tools.ietf.org/html/rfc7518#section-7.3

func CompressionAlgorithms

func CompressionAlgorithms() []CompressionAlgorithm

CompressionAlgorithms returns a list of all available values for CompressionAlgorithm.

func Deflate

func Deflate() CompressionAlgorithm

Deflate returns an object representing the "DEF" content compression algorithm value. Using this value specifies that the content should be compressed using DEFLATE (RFC 1951).

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, options ...NewAlgorithmOption) CompressionAlgorithm

NewCompressionAlgorithm creates a new CompressionAlgorithm object with the given name.

func NoCompress

func NoCompress() CompressionAlgorithm

NoCompress returns an object representing an empty compression algorithm value. Using this value specifies that the content should not be compressed.

func (CompressionAlgorithm) IsDeprecated

func (s CompressionAlgorithm) IsDeprecated() bool

IsDeprecated returns true if the CompressionAlgorithm object is deprecated.

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
}

ContentEncryptionAlgorithm represents the various encryption algorithms as described in https://tools.ietf.org/html/rfc7518#section-5

func A128CBC_HS256

func A128CBC_HS256() ContentEncryptionAlgorithm

A128CBC_HS256 returns an object representing A128CBC-HS256. Using this value specifies that the content should be encrypted using AES-CBC + HMAC-SHA256 (128).

func A128GCM

A128GCM returns an object representing A128GCM. Using this value specifies that the content should be encrypted using AES-GCM (128).

func A192CBC_HS384

func A192CBC_HS384() ContentEncryptionAlgorithm

A192CBC_HS384 returns an object representing A192CBC-HS384. Using this value specifies that the content should be encrypted using AES-CBC + HMAC-SHA384 (192).

func A192GCM

A192GCM returns an object representing A192GCM. Using this value specifies that the content should be encrypted using AES-GCM (192).

func A256CBC_HS512

func A256CBC_HS512() ContentEncryptionAlgorithm

A256CBC_HS512 returns an object representing A256CBC-HS512. Using this value specifies that the content should be encrypted using AES-CBC + HMAC-SHA512 (256).

func A256GCM

A256GCM returns an object representing A256GCM. Using this value specifies that the content should be encrypted using AES-GCM (256).

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, options ...NewAlgorithmOption) ContentEncryptionAlgorithm

NewContentEncryptionAlgorithm creates a new ContentEncryptionAlgorithm object with the given name.

func (ContentEncryptionAlgorithm) IsDeprecated

func (s ContentEncryptionAlgorithm) IsDeprecated() bool

IsDeprecated returns true if the ContentEncryptionAlgorithm object is deprecated.

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
}

EllipticCurveAlgorithm represents the algorithms used for EC keys

func Ed25519

func Ed25519() EllipticCurveAlgorithm

Ed25519 returns an object representing Ed25519 algorithm for EdDSA operations.

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 an object representing an invalid elliptic curve.

func LookupEllipticCurveAlgorithm

func LookupEllipticCurveAlgorithm(name string) (EllipticCurveAlgorithm, bool)

LookupEllipticCurveAlgorithm returns the EllipticCurveAlgorithm object for the given name.

func NewEllipticCurveAlgorithm

func NewEllipticCurveAlgorithm(name string, options ...NewAlgorithmOption) EllipticCurveAlgorithm

NewEllipticCurveAlgorithm creates a new EllipticCurveAlgorithm object with the given name.

func P256

P256 returns an object representing P-256 algorithm for ECDSA operations.

func P384

P384 returns an object representing P-384 algorithm for ECDSA operations.

func P521

P521 returns an object representing P-521 algorithm for ECDSA operations.

func X448

X448 returns an object representing X448 algorithm for ECDH operations.

func X25519

func X25519() EllipticCurveAlgorithm

X25519 returns an object representing X25519 algorithm for ECDH operations.

func (EllipticCurveAlgorithm) IsDeprecated

func (s EllipticCurveAlgorithm) IsDeprecated() bool

IsDeprecated returns true if the EllipticCurveAlgorithm object is deprecated.

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
	IsDeprecated() bool
}

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`.

String inputs resolve through the shared algorithm registry: the returned KeyAlgorithm holds the concrete typed value (Signature, KeyEncryption, or ContentEncryption) for whichever kind owns the name. Cross-kind name reuse is structurally impossible — the registry refuses it at registration time — so KeyAlgorithmFrom no longer needs precedence rules.

Typed inputs whose String() is empty (for example a zero-value `var sa jwa.SignatureAlgorithm`) are rejected with ErrInvalidKeyAlgorithm. Without this check the typed arms accepted names that would never resolve through any registry, surfacing as confusing failures far from the call site.

type KeyEncryptionAlgorithm

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

KeyEncryptionAlgorithm represents the various encryption algorithms as described in https://tools.ietf.org/html/rfc7518#section-4.1

func A128GCMKW

func A128GCMKW() KeyEncryptionAlgorithm

A128GCMKW returns an object representing AES-GCM key wrap (128) key encryption algorithm.

func A128KW

func A128KW() KeyEncryptionAlgorithm

A128KW returns an object representing AES key wrap (128) key encryption algorithm.

func A192GCMKW

func A192GCMKW() KeyEncryptionAlgorithm

A192GCMKW returns an object representing AES-GCM key wrap (192) key encryption algorithm.

func A192KW

func A192KW() KeyEncryptionAlgorithm

A192KW returns an object representing AES key wrap (192) key encryption algorithm.

func A256GCMKW

func A256GCMKW() KeyEncryptionAlgorithm

A256GCMKW returns an object representing AES-GCM key wrap (256) key encryption algorithm.

func A256KW

func A256KW() KeyEncryptionAlgorithm

A256KW returns an object representing AES key wrap (256) key encryption algorithm.

func DIRECT

func DIRECT() KeyEncryptionAlgorithm

DIRECT returns an object representing Direct key encryption algorithm.

func ECDH_ES

func ECDH_ES() KeyEncryptionAlgorithm

ECDH_ES returns an object representing ECDH-ES key encryption algorithm.

func ECDH_ES_A128KW

func ECDH_ES_A128KW() KeyEncryptionAlgorithm

ECDH_ES_A128KW returns an object representing ECDH-ES + AES key wrap (128) key encryption algorithm.

func ECDH_ES_A192KW

func ECDH_ES_A192KW() KeyEncryptionAlgorithm

ECDH_ES_A192KW returns an object representing ECDH-ES + AES key wrap (192) key encryption algorithm.

func ECDH_ES_A256KW

func ECDH_ES_A256KW() KeyEncryptionAlgorithm

ECDH_ES_A256KW returns an object representing ECDH-ES + AES key wrap (256) key encryption algorithm.

func EmptyKeyEncryptionAlgorithm

func EmptyKeyEncryptionAlgorithm() KeyEncryptionAlgorithm

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

func HPKE_0_KE

func HPKE_0_KE() KeyEncryptionAlgorithm

HPKE_0_KE returns an object representing HPKE-0-KE key encryption (DHKEM(P-256) + HKDF-SHA256 + AES-128-GCM). Based on draft-ietf-jose-hpke-encrypt-16: API is not yet stable.

func HPKE_1_KE

func HPKE_1_KE() KeyEncryptionAlgorithm

HPKE_1_KE returns an object representing HPKE-1-KE key encryption (DHKEM(P-384) + HKDF-SHA384 + AES-256-GCM). Based on draft-ietf-jose-hpke-encrypt-16: API is not yet stable.

func HPKE_2_KE

func HPKE_2_KE() KeyEncryptionAlgorithm

HPKE_2_KE returns an object representing HPKE-2-KE key encryption (DHKEM(P-521) + HKDF-SHA512 + AES-256-GCM). Based on draft-ietf-jose-hpke-encrypt-16: API is not yet stable.

func HPKE_3_KE

func HPKE_3_KE() KeyEncryptionAlgorithm

HPKE_3_KE returns an object representing HPKE-3-KE key encryption (DHKEM(X25519) + HKDF-SHA256 + AES-128-GCM). Based on draft-ietf-jose-hpke-encrypt-16: API is not yet stable.

func HPKE_4_KE

func HPKE_4_KE() KeyEncryptionAlgorithm

HPKE_4_KE returns an object representing HPKE-4-KE key encryption (DHKEM(X25519) + HKDF-SHA256 + ChaCha20Poly1305). Based on draft-ietf-jose-hpke-encrypt-16: API is not yet stable.

func HPKE_7_KE

func HPKE_7_KE() KeyEncryptionAlgorithm

HPKE_7_KE returns an object representing HPKE-7-KE key encryption (DHKEM(P-256) + HKDF-SHA256 + AES-256-GCM). Based on draft-ietf-jose-hpke-encrypt-16: API is not yet stable.

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 with the given name.

func PBES2_HS256_A128KW

func PBES2_HS256_A128KW() KeyEncryptionAlgorithm

PBES2_HS256_A128KW returns an object representing PBES2 + HMAC-SHA256 + AES key wrap (128) key encryption algorithm.

func PBES2_HS384_A192KW

func PBES2_HS384_A192KW() KeyEncryptionAlgorithm

PBES2_HS384_A192KW returns an object representing PBES2 + HMAC-SHA384 + AES key wrap (192) key encryption algorithm.

func PBES2_HS512_A256KW

func PBES2_HS512_A256KW() KeyEncryptionAlgorithm

PBES2_HS512_A256KW returns an object representing PBES2 + HMAC-SHA512 + AES key wrap (256) key encryption algorithm.

func RSA1_5

func RSA1_5() KeyEncryptionAlgorithm

RSA1_5 returns an object representing RSA-PKCS1v1.5 key encryption algorithm.

func RSA_OAEP

func RSA_OAEP() KeyEncryptionAlgorithm

RSA_OAEP returns an object representing RSA-OAEP-SHA1 key encryption algorithm.

func RSA_OAEP_256

func RSA_OAEP_256() KeyEncryptionAlgorithm

RSA_OAEP_256 returns an object representing RSA-OAEP-SHA256 key encryption algorithm.

func RSA_OAEP_384

func RSA_OAEP_384() KeyEncryptionAlgorithm

RSA_OAEP_384 returns an object representing RSA-OAEP-SHA384 key encryption algorithm.

func RSA_OAEP_512

func RSA_OAEP_512() KeyEncryptionAlgorithm

RSA_OAEP_512 returns an object representing RSA-OAEP-SHA512 key encryption algorithm.

func (KeyEncryptionAlgorithm) IsDeprecated

func (s KeyEncryptionAlgorithm) IsDeprecated() bool

IsDeprecated returns true if the KeyEncryptionAlgorithm object is deprecated.

func (KeyEncryptionAlgorithm) IsSymmetric

func (s KeyEncryptionAlgorithm) IsSymmetric() bool

IsSymmetric returns true if the KeyEncryptionAlgorithm object is symmetric. Symmetric algorithms use the same key for both encryption and decryption.

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
}

KeyType represents the key type ("kty") that are supported

func AKP

func AKP() KeyType

AKP returns an object representing AKP. Algorithm Key Pair (post-quantum KEM/signature keys)

func EC

func EC() KeyType

EC returns an object representing EC. Elliptic Curve

func EmptyKeyType

func EmptyKeyType() KeyType

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

func InvalidKeyType

func InvalidKeyType() KeyType

InvalidKeyType returns an object representing invalid key type. Invalid KeyType

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, options ...NewAlgorithmOption) KeyType

NewKeyType creates a new KeyType object with the given name.

func OKP

func OKP() KeyType

OKP returns an object representing OKP. Octet string key pairs

func OctetSeq

func OctetSeq() KeyType

OctetSeq returns an object representing oct. Octet sequence (used to represent symmetric keys)

func RSA

func RSA() KeyType

RSA returns an object representing RSA. RSA

func (KeyType) IsDeprecated

func (s KeyType) IsDeprecated() bool

IsDeprecated returns true if the KeyType object is deprecated.

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 NewAlgorithmOption

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

NewAlgorithmOption represents an option that can be passed to any of the constructor functions

func WithDeprecated

func WithDeprecated(v bool) NewAlgorithmOption

WithDeprecated specifies that the algorithm is deprecated. In order to un-deprecate an algorithm, you will have to create a new algorithm with the same values but with the Deprecated option set to false, and then call RegisterXXXXAlgorithm with the new algorithm.

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
}

SignatureAlgorithm represents the various signature algorithms as described in https://tools.ietf.org/html/rfc7518#section-3.1

func ES256

func ES256() SignatureAlgorithm

ES256 returns an object representing ECDSA signature algorithm using P-256 curve and SHA-256.

func ES384

func ES384() SignatureAlgorithm

ES384 returns an object representing ECDSA signature algorithm using P-384 curve and SHA-384.

func ES512

func ES512() SignatureAlgorithm

ES512 returns an object representing ECDSA signature algorithm using P-521 curve and SHA-512.

func EdDSA

func EdDSA() SignatureAlgorithm

EdDSA returns an object representing EdDSA signature algorithms (deprecated by RFC 9864, use EdDSAEd25519 or EdDSAEd448).

func EdDSAEd25519

func EdDSAEd25519() SignatureAlgorithm

EdDSAEd25519 returns an object representing EdDSA signature algorithm using Ed25519 (RFC 9864). The function name is tentative and may change in future releases.

func EmptySignatureAlgorithm

func EmptySignatureAlgorithm() SignatureAlgorithm

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

func HS256

func HS256() SignatureAlgorithm

HS256 returns an object representing HMAC signature algorithm using SHA-256.

func HS384

func HS384() SignatureAlgorithm

HS384 returns an object representing HMAC signature algorithm using SHA-384.

func HS512

func HS512() SignatureAlgorithm

HS512 returns an object representing HMAC signature algorithm using SHA-512.

func LookupSignatureAlgorithm

func LookupSignatureAlgorithm(name string) (SignatureAlgorithm, bool)

LookupSignatureAlgorithm returns the SignatureAlgorithm object for the given name.

func MLDSA44 added in v4.4.0

func MLDSA44() SignatureAlgorithm

MLDSA44 returns an object representing the ML-DSA-44 signature algorithm (FIPS 204, NIST security level 2). Available only when jwx is built with Go 1.27 or later.

func MLDSA65 added in v4.4.0

func MLDSA65() SignatureAlgorithm

MLDSA65 returns an object representing the ML-DSA-65 signature algorithm (FIPS 204, NIST security level 3). Available only when jwx is built with Go 1.27 or later.

func MLDSA87 added in v4.4.0

func MLDSA87() SignatureAlgorithm

MLDSA87 returns an object representing the ML-DSA-87 signature algorithm (FIPS 204, NIST security level 5). Available only when jwx is built with Go 1.27 or later.

func NewSignatureAlgorithm

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

NewSignatureAlgorithm creates a new SignatureAlgorithm object with the given name.

func NoSignature

func NoSignature() SignatureAlgorithm

NoSignature returns an object representing the lack of a signature algorithm. Using this value specifies that the content should not be signed, which you should avoid doing.

func PS256

func PS256() SignatureAlgorithm

PS256 returns an object representing RSASSA-PSS signature algorithm using SHA-256 and MGF1-SHA256.

func PS384

func PS384() SignatureAlgorithm

PS384 returns an object representing RSASSA-PSS signature algorithm using SHA-384 and MGF1-SHA384.

func PS512

func PS512() SignatureAlgorithm

PS512 returns an object representing RSASSA-PSS signature algorithm using SHA-512 and MGF1-SHA512.

func RS256

func RS256() SignatureAlgorithm

RS256 returns an object representing RSASSA-PKCS-v1.5 signature algorithm using SHA-256.

func RS384

func RS384() SignatureAlgorithm

RS384 returns an object representing RSASSA-PKCS-v1.5 signature algorithm using SHA-384.

func RS512

func RS512() SignatureAlgorithm

RS512 returns an object representing RSASSA-PKCS-v1.5 signature algorithm using SHA-512.

func SignatureAlgorithms

func SignatureAlgorithms() []SignatureAlgorithm

SignatureAlgorithms returns a list of all available values for SignatureAlgorithm.

func (SignatureAlgorithm) IsDeprecated

func (s SignatureAlgorithm) IsDeprecated() bool

IsDeprecated returns true if the SignatureAlgorithm object is deprecated.

func (SignatureAlgorithm) IsSymmetric

func (s SignatureAlgorithm) IsSymmetric() bool

IsSymmetric returns true if the SignatureAlgorithm object is symmetric. Symmetric algorithms use the same key for both encryption and decryption.

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