Documentation ¶
Overview ¶
Package jws handles JSON Web Encryption defined in RFC 7516.
Index ¶
- type FindKeyWrapperFunc
- type Header
- func (h *Header) AgreementPartyUInfo() []byte
- func (h *Header) AgreementPartyVInfo() []byte
- func (h *Header) Algorithm() jwa.KeyManagementAlgorithm
- func (h *Header) AuthenticationTag() []byte
- func (h *Header) Clone() *Header
- func (h *Header) CompressionAlgorithm() jwa.CompressionAlgorithm
- func (h *Header) ContentType() string
- func (h *Header) Critical() []string
- func (h *Header) EncryptionAlgorithm() jwa.EncryptionAlgorithm
- func (h *Header) EphemeralPublicKey() *jwk.Key
- func (h *Header) InitializationVector() []byte
- func (h *Header) JWK() *jwk.Key
- func (h *Header) JWKSetURL() *url.URL
- func (h *Header) KeyID() string
- func (h *Header) MarshalJSON() ([]byte, error)
- func (h *Header) PBES2Count() int
- func (h *Header) PBES2SaltInput() []byte
- func (h *Header) SetAgreementPartyUInfo(apu []byte)
- func (h *Header) SetAgreementPartyVInfo(apv []byte)
- func (h *Header) SetAlgorithm(alg jwa.KeyManagementAlgorithm)
- func (h *Header) SetAuthenticationTag(tag []byte)
- func (h *Header) SetCompressionAlgorithm(zip jwa.CompressionAlgorithm)
- func (h *Header) SetContentType(cty string)
- func (h *Header) SetCritical(crit []string)
- func (h *Header) SetEncryptionAlgorithm(enc jwa.EncryptionAlgorithm)
- func (h *Header) SetEphemeralPublicKey(epk *jwk.Key)
- func (h *Header) SetInitializationVector(iv []byte)
- func (h *Header) SetJWK(jwk *jwk.Key)
- func (h *Header) SetJWKSetURL(jku *url.URL)
- func (h *Header) SetKeyID(kid string)
- func (h *Header) SetPBES2Count(p2c int)
- func (h *Header) SetPBES2SaltInput(p2s []byte)
- func (h *Header) SetType(typ string)
- func (h *Header) SetX509CertificateChain(x5c []*x509.Certificate)
- func (h *Header) SetX509CertificateSHA1(x5t []byte)
- func (h *Header) SetX509CertificateSHA256(x5tS256 []byte)
- func (h *Header) SetX509URL(x5u *url.URL)
- func (h *Header) Type() string
- func (h *Header) UnmarshalJSON(data []byte) error
- func (h *Header) X509CertificateChain() []*x509.Certificate
- func (h *Header) X509CertificateSHA1() []byte
- func (h *Header) X509CertificateSHA256() []byte
- func (h *Header) X509URL() *url.URL
- type KeyWrapperFinder
- type Message
- func NewMessage(enc jwa.EncryptionAlgorithm, protected *Header, plaintext []byte) (*Message, error)
- func NewMessageWithKW(enc jwa.EncryptionAlgorithm, kw keymanage.KeyWrapper, protected *Header, ...) (*Message, error)
- func Parse(data []byte) (*Message, error)
- func ParseJSON(data []byte) (*Message, error)
- func (msg *Message) Compact() ([]byte, error)
- func (msg *Message) Decrypt(finder KeyWrapperFinder) (plaintext []byte, err error)
- func (msg *Message) Encrypt(kw keymanage.KeyWrapper, header *Header) error
- func (msg *Message) MarshalJSON() ([]byte, error)
- func (msg *Message) UnmarshalJSON(data []byte) error
- type Recipient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FindKeyWrapperFunc ¶
type FindKeyWrapperFunc func(protected, unprotected, recipient *Header) (wrapper keymanage.KeyWrapper, err error)
func (FindKeyWrapperFunc) FindKeyWrapper ¶
func (f FindKeyWrapperFunc) FindKeyWrapper(protected, unprotected, recipient *Header) (wrapper keymanage.KeyWrapper, err error)
type Header ¶
type Header struct { // Raw is the raw data of JSON-decoded JOSE header. // JSON numbers are decoded as json.Number to avoid data loss. Raw map[string]any // contains filtered or unexported fields }
Header is a decoded JSON Object Signing and Encryption (JOSE) Header.
func (*Header) AgreementPartyUInfo ¶
AgreementPartyUInfo is RFC7518 Section 4.6.1.2. "apu" (Agreement PartyUInfo) Header Parameter
func (*Header) AgreementPartyVInfo ¶
AgreementPartyVInfo is RFC7518 Section 4.6.1.3. "apv" (Agreement PartyVInfo) Header Parameter
func (*Header) Algorithm ¶
func (h *Header) Algorithm() jwa.KeyManagementAlgorithm
Algorithm returns the key management algorithm defined in RFC7516 Section 4.1.1. "alg" (Algorithm) Header Parameter.
func (*Header) AuthenticationTag ¶
AuthenticationTag is RFC7518 Section 4.7.1.2. "tag" (Authentication Tag) Header Parameter.
func (*Header) CompressionAlgorithm ¶
func (h *Header) CompressionAlgorithm() jwa.CompressionAlgorithm
Compression is RFC7516 Section 4.1.3. "zip" (zip Algorithm) Header Parameter.
func (*Header) ContentType ¶
ContentType is RFC7516 Section 4.1.12. "cty" (Content Type) Header Parameter.
func (*Header) EncryptionAlgorithm ¶
func (h *Header) EncryptionAlgorithm() jwa.EncryptionAlgorithm
Encryption return the encryption algorithm defined in RFC7516 Section 4.1.2. "enc" (Encryption Algorithm) Header Parameter.
func (*Header) EphemeralPublicKey ¶
EphemeralPublicKey is RFC7518 Section 4.6.1.1. "epk" (Ephemeral Public Key) Header Parameter.
func (*Header) InitializationVector ¶
InitializationVector is RFC7518 Section 4.7.1.1. "iv" (Initialization Vector) Header Parameter. It is the 96-bit IV value used for the key encryption operation.
func (*Header) JWKSetURL ¶
JWKSetURL is RFC7516 Section 4.1.4. "jku" (JWK Set URL) Header Parameter.
func (*Header) MarshalJSON ¶
func (*Header) PBES2Count ¶
PBES2Count is the PBES2 Count defined in RFC7518 Section 4.8.1.2. "p2c" (PBES2 Count) Header Parameter.
func (*Header) PBES2SaltInput ¶
PBES2SaltInput is the PBES2 salt input defined in RFC7518 Section 4.8.1.1. "p2s" (PBES2 Salt Input) Header Parameter.
func (*Header) SetAgreementPartyUInfo ¶
func (*Header) SetAgreementPartyVInfo ¶
func (*Header) SetAlgorithm ¶
func (h *Header) SetAlgorithm(alg jwa.KeyManagementAlgorithm)
func (*Header) SetAuthenticationTag ¶
func (*Header) SetCompressionAlgorithm ¶
func (h *Header) SetCompressionAlgorithm(zip jwa.CompressionAlgorithm)
func (*Header) SetContentType ¶
func (*Header) SetCritical ¶
func (*Header) SetEncryptionAlgorithm ¶
func (h *Header) SetEncryptionAlgorithm(enc jwa.EncryptionAlgorithm)
func (*Header) SetEphemeralPublicKey ¶
func (*Header) SetInitializationVector ¶
func (*Header) SetJWKSetURL ¶
func (*Header) SetPBES2Count ¶
func (*Header) SetPBES2SaltInput ¶
func (*Header) SetX509CertificateChain ¶
func (h *Header) SetX509CertificateChain(x5c []*x509.Certificate)
func (*Header) SetX509CertificateSHA1 ¶
func (*Header) SetX509CertificateSHA256 ¶
func (*Header) SetX509URL ¶
func (*Header) UnmarshalJSON ¶
func (*Header) X509CertificateChain ¶
func (h *Header) X509CertificateChain() []*x509.Certificate
X509CertificateChain is RFC7516 Section 4.1.8. "x5c" (X.509 Certificate Chain) Header Parameter.
func (*Header) X509CertificateSHA1 ¶
X509CertificateSHA1 is RFC7516 Section 4.1.9. "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter.
func (*Header) X509CertificateSHA256 ¶
X509CertificateSHA256 is RFC7516 Section 4.1.10. "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Header Parameter.
type KeyWrapperFinder ¶
type KeyWrapperFinder interface {
FindKeyWrapper(protected, unprotected, recipient *Header) (wrapper keymanage.KeyWrapper, err error)
}
KeyWrapperFinder is a wrapper for the FindKeyWrapper method.
type Message ¶
type Message struct { UnprotectedHeader *Header Recipients []*Recipient // contains filtered or unexported fields }
Message is a decoded JWS.
func NewMessage ¶
func NewMessageWithKW ¶
func NewMessageWithKW(enc jwa.EncryptionAlgorithm, kw keymanage.KeyWrapper, protected *Header, plaintext []byte) (*Message, error)
func (*Message) Decrypt ¶
func (msg *Message) Decrypt(finder KeyWrapperFinder) (plaintext []byte, err error)
func (*Message) Encrypt ¶
func (msg *Message) Encrypt(kw keymanage.KeyWrapper, header *Header) error