Documentation ¶
Overview ¶
Package jwa defines the various algorithm described in https://tools.ietf.org/html/rfc7518
Index ¶
- func ErrInvalidKeyAlgorithm() error
- func RegisterCompressionAlgorithm(algorithms ...CompressionAlgorithm)
- func RegisterContentEncryptionAlgorithm(algorithms ...ContentEncryptionAlgorithm)
- func RegisterEllipticCurveAlgorithm(algorithms ...EllipticCurveAlgorithm)
- func RegisterKeyEncryptionAlgorithm(algorithms ...KeyEncryptionAlgorithm)
- func RegisterKeyType(algorithms ...KeyType)
- func RegisterSignatureAlgorithm(algorithms ...SignatureAlgorithm)
- func UnregisterCompressionAlgorithm(algorithms ...CompressionAlgorithm)
- func UnregisterContentEncryptionAlgorithm(algorithms ...ContentEncryptionAlgorithm)
- func UnregisterEllipticCurveAlgorithm(algorithms ...EllipticCurveAlgorithm)
- func UnregisterKeyEncryptionAlgorithm(algorithms ...KeyEncryptionAlgorithm)
- func UnregisterKeyType(algorithms ...KeyType)
- func UnregisterSignatureAlgorithm(algorithms ...SignatureAlgorithm)
- type CompressionAlgorithm
- func CompressionAlgorithms() []CompressionAlgorithm
- func Deflate() CompressionAlgorithm
- func EmptyCompressionAlgorithm() CompressionAlgorithm
- func LookupCompressionAlgorithm(name string) (CompressionAlgorithm, bool)
- func NewCompressionAlgorithm(name string) CompressionAlgorithm
- func NoCompress() CompressionAlgorithm
- type ContentEncryptionAlgorithm
- func A128CBC_HS256() ContentEncryptionAlgorithm
- func A128GCM() ContentEncryptionAlgorithm
- func A192CBC_HS384() ContentEncryptionAlgorithm
- func A192GCM() ContentEncryptionAlgorithm
- func A256CBC_HS512() ContentEncryptionAlgorithm
- func A256GCM() ContentEncryptionAlgorithm
- func ContentEncryptionAlgorithms() []ContentEncryptionAlgorithm
- func EmptyContentEncryptionAlgorithm() ContentEncryptionAlgorithm
- func LookupContentEncryptionAlgorithm(name string) (ContentEncryptionAlgorithm, bool)
- func NewContentEncryptionAlgorithm(name string) ContentEncryptionAlgorithm
- type EllipticCurveAlgorithm
- func Ed25519() EllipticCurveAlgorithm
- func Ed448() EllipticCurveAlgorithm
- func EllipticCurveAlgorithms() []EllipticCurveAlgorithm
- func EmptyEllipticCurveAlgorithm() EllipticCurveAlgorithm
- func InvalidEllipticCurve() EllipticCurveAlgorithm
- func LookupEllipticCurveAlgorithm(name string) (EllipticCurveAlgorithm, bool)
- func NewEllipticCurveAlgorithm(name string) EllipticCurveAlgorithm
- func P256() EllipticCurveAlgorithm
- func P384() EllipticCurveAlgorithm
- func P521() EllipticCurveAlgorithm
- func X25519() EllipticCurveAlgorithm
- func X448() EllipticCurveAlgorithm
- type KeyAlgorithm
- type KeyEncryptionAlgorithm
- func A128GCMKW() KeyEncryptionAlgorithm
- func A128KW() KeyEncryptionAlgorithm
- func A192GCMKW() KeyEncryptionAlgorithm
- func A192KW() KeyEncryptionAlgorithm
- func A256GCMKW() KeyEncryptionAlgorithm
- func A256KW() KeyEncryptionAlgorithm
- func DIRECT() KeyEncryptionAlgorithm
- func ECDH_ES() KeyEncryptionAlgorithm
- func ECDH_ES_A128KW() KeyEncryptionAlgorithm
- func ECDH_ES_A192KW() KeyEncryptionAlgorithm
- func ECDH_ES_A256KW() KeyEncryptionAlgorithm
- func EmptyKeyEncryptionAlgorithm() KeyEncryptionAlgorithm
- func KeyEncryptionAlgorithms() []KeyEncryptionAlgorithm
- func LookupKeyEncryptionAlgorithm(name string) (KeyEncryptionAlgorithm, bool)
- func NewKeyEncryptionAlgorithm(name string, options ...NewKeyEncryptionAlgorithmOption) KeyEncryptionAlgorithm
- func PBES2_HS256_A128KW() KeyEncryptionAlgorithm
- func PBES2_HS384_A192KW() KeyEncryptionAlgorithm
- func PBES2_HS512_A256KW() KeyEncryptionAlgorithm
- func RSA1_5() KeyEncryptionAlgorithm
- func RSA_OAEP() KeyEncryptionAlgorithm
- func RSA_OAEP_256() KeyEncryptionAlgorithm
- func RSA_OAEP_384() KeyEncryptionAlgorithm
- func RSA_OAEP_512() KeyEncryptionAlgorithm
- type KeyType
- type NewKeyEncryptionAlgorithmOption
- type NewSignatureAlgorithmOption
- type NewSignatureKeyEncryptionAlgorithmOption
- type Option
- type SignatureAlgorithm
- func ES256() SignatureAlgorithm
- func ES256K() SignatureAlgorithm
- func ES384() SignatureAlgorithm
- func ES512() SignatureAlgorithm
- func EdDSA() SignatureAlgorithm
- func EmptySignatureAlgorithm() SignatureAlgorithm
- func HS256() SignatureAlgorithm
- func HS384() SignatureAlgorithm
- func HS512() SignatureAlgorithm
- func LookupSignatureAlgorithm(name string) (SignatureAlgorithm, bool)
- func NewSignatureAlgorithm(name string, options ...NewSignatureAlgorithmOption) SignatureAlgorithm
- func NoSignature() SignatureAlgorithm
- func PS256() SignatureAlgorithm
- func PS384() SignatureAlgorithm
- func PS512() SignatureAlgorithm
- func RS256() SignatureAlgorithm
- func RS384() SignatureAlgorithm
- func RS512() SignatureAlgorithm
- func SignatureAlgorithms() []SignatureAlgorithm
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 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 ¶
func A128GCM() ContentEncryptionAlgorithm
A128GCM returns the A128GCM algorithm object.
func A192CBC_HS384 ¶
func A192CBC_HS384() ContentEncryptionAlgorithm
A192CBC_HS384 returns the A192CBC_HS384 algorithm object.
func A192GCM ¶
func A192GCM() ContentEncryptionAlgorithm
A192GCM returns the A192GCM algorithm object.
func A256CBC_HS512 ¶
func A256CBC_HS512() ContentEncryptionAlgorithm
A256CBC_HS512 returns the A256CBC_HS512 algorithm object.
func A256GCM ¶
func A256GCM() ContentEncryptionAlgorithm
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 (s ContentEncryptionAlgorithm) String() 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 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 (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 A192GCMKW ¶
func A192GCMKW() KeyEncryptionAlgorithm
A192GCMKW returns the A192GCMKW algorithm object.
func A256GCMKW ¶
func A256GCMKW() KeyEncryptionAlgorithm
A256GCMKW returns the A256GCMKW 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 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 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 ¶
LookupKeyType returns the KeyType object for the given name
func (KeyType) MarshalJSON ¶
MarshalJSON serializes the KeyType object to a JSON string
func (*KeyType) UnmarshalJSON ¶
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 ¶
func WithIsSymmetric(v bool) NewSignatureKeyEncryptionAlgorithmOption
IsSymmetric specifies that the algorithm is symmetric
type SignatureAlgorithm ¶
type SignatureAlgorithm struct {
// contains filtered or unexported fields
}
func EmptySignatureAlgorithm ¶
func EmptySignatureAlgorithm() SignatureAlgorithm
EmptySignatureAlgorithm returns an empty SignatureAlgorithm object, used as a zero value
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 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