jwe

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package jws handles JSON Web Encryption defined in RFC 7516.

Index

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

func (h *Header) AgreementPartyUInfo() []byte

AgreementPartyUInfo is RFC 7518 Section 4.6.1.2. "apu" (Agreement PartyUInfo) Header Parameter

func (*Header) AgreementPartyVInfo

func (h *Header) AgreementPartyVInfo() []byte

AgreementPartyVInfo is RFC 7518 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 RFC 7516 Section 4.1.1. "alg" (Algorithm) Header Parameter.

func (*Header) AuthenticationTag

func (h *Header) AuthenticationTag() []byte

AuthenticationTag is RFC 7518 Section 4.7.1.2. "tag" (Authentication Tag) Header Parameter.

func (*Header) Clone

func (h *Header) Clone() *Header

Clone returns a shallow copy of h.

func (*Header) CompressionAlgorithm

func (h *Header) CompressionAlgorithm() jwa.CompressionAlgorithm

Compression is RFC 7516 Section 4.1.3. "zip" (zip Algorithm) Header Parameter.

func (*Header) ContentType

func (h *Header) ContentType() string

ContentType is RFC 7516 Section 4.1.12. "cty" (Content Type) Header Parameter.

func (*Header) Critical

func (h *Header) Critical() []string

Critical is RFC 7516 Section 4.1.13. "crit" (Critical) Header Parameter.

func (*Header) EncryptionAlgorithm

func (h *Header) EncryptionAlgorithm() jwa.EncryptionAlgorithm

Encryption return the encryption algorithm defined in RFC 7516 Section 4.1.2. "enc" (Encryption Algorithm) Header Parameter.

func (*Header) EphemeralPublicKey

func (h *Header) EphemeralPublicKey() *jwk.Key

EphemeralPublicKey is RFC 7518 Section 4.6.1.1. "epk" (Ephemeral Public Key) Header Parameter.

func (*Header) InitializationVector

func (h *Header) InitializationVector() []byte

InitializationVector is RFC 7518 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) JWK

func (h *Header) JWK() *jwk.Key

JWK is RFC 7516 Section 4.1.5. "jwk" (JSON Web Key) Header Parameter.

func (*Header) JWKSetURL

func (h *Header) JWKSetURL() *url.URL

JWKSetURL is RFC 7516 Section 4.1.4. "jku" (JWK Set URL) Header Parameter.

func (*Header) KeyID

func (h *Header) KeyID() string

KeyID is RFC 7516 Section 4.1.6. "kid" (Key ID) Header Parameter.

func (*Header) MarshalJSON

func (h *Header) MarshalJSON() ([]byte, error)

func (*Header) PBES2Count

func (h *Header) PBES2Count() int

PBES2Count is the PBES2 Count defined in RFC 7518 Section 4.8.1.2. "p2c" (PBES2 Count) Header Parameter.

func (*Header) PBES2SaltInput

func (h *Header) PBES2SaltInput() []byte

PBES2SaltInput is the PBES2 salt input defined in RFC 7518 Section 4.8.1.1. "p2s" (PBES2 Salt Input) Header Parameter.

func (*Header) SetAgreementPartyUInfo

func (h *Header) SetAgreementPartyUInfo(apu []byte)

func (*Header) SetAgreementPartyVInfo

func (h *Header) SetAgreementPartyVInfo(apv []byte)

func (*Header) SetAlgorithm

func (h *Header) SetAlgorithm(alg jwa.KeyManagementAlgorithm)

func (*Header) SetAuthenticationTag

func (h *Header) SetAuthenticationTag(tag []byte)

func (*Header) SetCompressionAlgorithm

func (h *Header) SetCompressionAlgorithm(zip jwa.CompressionAlgorithm)

func (*Header) SetContentType

func (h *Header) SetContentType(cty string)

func (*Header) SetCritical

func (h *Header) SetCritical(crit []string)

func (*Header) SetEncryptionAlgorithm

func (h *Header) SetEncryptionAlgorithm(enc jwa.EncryptionAlgorithm)

func (*Header) SetEphemeralPublicKey

func (h *Header) SetEphemeralPublicKey(epk *jwk.Key)

func (*Header) SetInitializationVector

func (h *Header) SetInitializationVector(iv []byte)

func (*Header) SetJWK

func (h *Header) SetJWK(jwk *jwk.Key)

func (*Header) SetJWKSetURL

func (h *Header) SetJWKSetURL(jku *url.URL)

func (*Header) SetKeyID

func (h *Header) SetKeyID(kid string)

func (*Header) SetPBES2Count

func (h *Header) SetPBES2Count(p2c int)

func (*Header) SetPBES2SaltInput

func (h *Header) SetPBES2SaltInput(p2s []byte)

func (*Header) SetType

func (h *Header) SetType(typ string)

func (*Header) SetX509CertificateChain

func (h *Header) SetX509CertificateChain(x5c []*x509.Certificate)

func (*Header) SetX509CertificateSHA1

func (h *Header) SetX509CertificateSHA1(x5t []byte)

func (*Header) SetX509CertificateSHA256

func (h *Header) SetX509CertificateSHA256(x5tS256 []byte)

func (*Header) SetX509URL

func (h *Header) SetX509URL(x5u *url.URL)

func (*Header) Type

func (h *Header) Type() string

Type is RFC 7516 Section 4.1.11. "typ" (Type) Header Parameter.

func (*Header) UnmarshalJSON

func (h *Header) UnmarshalJSON(data []byte) error

func (*Header) X509CertificateChain

func (h *Header) X509CertificateChain() []*x509.Certificate

X509CertificateChain is RFC 7516 Section 4.1.8. "x5c" (X.509 Certificate Chain) Header Parameter.

func (*Header) X509CertificateSHA1

func (h *Header) X509CertificateSHA1() []byte

X509CertificateSHA1 is RFC 7516 Section 4.1.9. "x5t" (X.509 Certificate SHA-1 Thumbprint) Header Parameter.

func (*Header) X509CertificateSHA256

func (h *Header) X509CertificateSHA256() []byte

X509CertificateSHA256 is RFC 7516 Section 4.1.10. "x5t#S256" (X.509 Certificate SHA-256 Thumbprint) Header Parameter.

func (*Header) X509URL

func (h *Header) X509URL() *url.URL

X509URL is RFC 7516 Section 4.1.7. "x5u" (X.509 URL) 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 NewMessage(enc jwa.EncryptionAlgorithm, protected *Header, plaintext []byte) (*Message, error)

func NewMessageWithKW

func NewMessageWithKW(enc jwa.EncryptionAlgorithm, kw keymanage.KeyWrapper, protected *Header, plaintext []byte) (*Message, error)

func Parse

func Parse(data []byte) (*Message, error)

Parse parses a Compact Serialized JWE.

func ParseJSON

func ParseJSON(data []byte) (*Message, error)

func (*Message) Compact

func (msg *Message) Compact() ([]byte, 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

func (*Message) MarshalJSON

func (msg *Message) MarshalJSON() ([]byte, error)

func (*Message) UnmarshalJSON

func (msg *Message) UnmarshalJSON(data []byte) error

type Recipient

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

Jump to

Keyboard shortcuts

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