jwe

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	A128CBCHS256 = AESCBCPreset{
		Enc:       jwa.A128CBC,
		Hash:      crypto.SHA256,
		KeyLen:    32,
		EncKeyLen: 16,
		MACKeyLen: 16,
		TagLength: 16,
	}
	A192CBCHS384 = AESCBCPreset{
		Enc:       jwa.A192CBC,
		Hash:      crypto.SHA384,
		KeyLen:    48,
		EncKeyLen: 24,
		MACKeyLen: 24,
		TagLength: 24,
	}
	A256CBCHS512 = AESCBCPreset{
		Enc:       jwa.A256CBC,
		Hash:      crypto.SHA512,
		KeyLen:    64,
		EncKeyLen: 32,
		MACKeyLen: 32,
		TagLength: 32,
	}
)
View Source
var (
	A128GCM = AESGCMPreset{
		Enc:    jwa.A128GCM,
		KeyLen: 16,
	}
	A192GCM = AESGCMPreset{
		Enc:    jwa.A192GCM,
		KeyLen: 24,
	}
	A256GCM = AESGCMPreset{
		Enc:    jwa.A256GCM,
		KeyLen: 32,
	}
)
View Source
var ErrInvalidSecret = errors.New("invalid secret")

Functions

This section is empty.

Types

type AESCBCDecryption

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

func NewAESCBCDecryption

func NewAESCBCDecryption(config *AESCBCDecryptionConfig, presets AESCBCPreset) *AESCBCDecryption

NewAESCBCDecryption creates a new jwt.RecipientPlugin for a decrypted token using AES_CBC_HMAC_SHA2.

Use any of the AESCBCPreset constants to set the algorithm and hash function.

  • A128CBCHS256: AES-128-CBC with HMAC-SHA-256
  • A192CBCHS384: AES-192-CBC with HMAC-SHA-384
  • A256CBCHS512: AES-256-CBC with HMAC-SHA-512

https://datatracker.ietf.org/doc/html/rfc7518#section-5.2

func (*AESCBCDecryption) Transform

func (dec *AESCBCDecryption) Transform(ctx context.Context, header *jwa.JWH, rawToken string) ([]byte, error)

type AESCBCDecryptionConfig

type AESCBCDecryptionConfig struct {
	CEKDecoder     CEKDecoder
	AdditionalData []byte
}

type AESCBCEncryption

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

func NewAESCBCEncryption

func NewAESCBCEncryption(config *AESCBCEncryptionConfig, presets AESCBCPreset) *AESCBCEncryption

NewAESCBCEncryption creates a new jwt.ProducerPlugin for an encrypted token using AES_CBC_HMAC_SHA2.

Use any of the AESCBCPreset constants to set the algorithm and hash function.

  • A128CBCHS256: AES-128-CBC with HMAC-SHA-256
  • A192CBCHS384: AES-192-CBC with HMAC-SHA-384
  • A256CBCHS512: AES-256-CBC with HMAC-SHA-512

https://datatracker.ietf.org/doc/html/rfc7518#section-5.2

func (*AESCBCEncryption) Header

func (enc *AESCBCEncryption) Header(ctx context.Context, header *jwa.JWH) (*jwa.JWH, error)

func (*AESCBCEncryption) Transform

func (enc *AESCBCEncryption) Transform(ctx context.Context, header *jwa.JWH, rawToken string) (string, error)

type AESCBCEncryptionConfig

type AESCBCEncryptionConfig struct {
	CEKManager     CEKManager
	AdditionalData []byte
}

type AESCBCPreset

type AESCBCPreset struct {
	Enc       jwa.Enc
	Hash      crypto.Hash
	KeyLen    int
	EncKeyLen int
	MACKeyLen int
	TagLength int
}

type AESGCMDecryption

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

func NewAESGCMDecryption

func NewAESGCMDecryption(config *AESGCMDecryptionConfig, presets AESGCMPreset) *AESGCMDecryption

NewAESGCMDecryption creates a new jwt.RecipientPlugin for an encrypted token using AES-GCM.

Use any of the AESGCMPreset constants to set the algorithm and hash function.

  • A128GCM: AES-128-GCM
  • A192GCM: AES-192-GCM
  • A256GCM: AES-256-GCM

func (*AESGCMDecryption) Transform

func (dec *AESGCMDecryption) Transform(ctx context.Context, header *jwa.JWH, rawToken string) ([]byte, error)

type AESGCMDecryptionConfig

type AESGCMDecryptionConfig struct {
	CEKDecoder     CEKDecoder
	AdditionalData []byte
}

type AESGCMEncryption

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

func NewAESGCMEncryption

func NewAESGCMEncryption(config *AESGCMEncryptionConfig, presets AESGCMPreset) *AESGCMEncryption

NewAESGCMEncryption creates a new jwt.ProducerPlugin for an encrypted token using AES-GCM.

Use any of the AESGCMPreset constants to set the algorithm and hash function.

  • A128GCM: AES-128-GCM
  • A192GCM: AES-192-GCM
  • A256GCM: AES-256-GCM

func (*AESGCMEncryption) Header

func (enc *AESGCMEncryption) Header(ctx context.Context, header *jwa.JWH) (*jwa.JWH, error)

func (*AESGCMEncryption) Transform

func (enc *AESGCMEncryption) Transform(ctx context.Context, header *jwa.JWH, rawToken string) (string, error)

type AESGCMEncryptionConfig

type AESGCMEncryptionConfig struct {
	CEKManager     CEKManager
	AdditionalData []byte
}

type AESGCMPreset

type AESGCMPreset struct {
	Enc    jwa.Enc
	KeyLen int
}

type CEKDecoder

type CEKDecoder interface {
	ComputeCEK(ctx context.Context, header *jwa.JWH, encKey []byte) (cek []byte, err error)
}

type CEKManager

type CEKManager interface {
	SetHeader(ctx context.Context, header *jwa.JWH) (modifiedHeader *jwa.JWH, err error)
	ComputeCEK(ctx context.Context, header *jwa.JWH) (cek []byte, err error)
	EncryptCEK(ctx context.Context, header *jwa.JWH, cek []byte) (encrypted []byte, err error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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