package jwe

import "github.com/Azure/azure-sdk-for-go/sdk/azidentity/cache/internal/jwe"

Index

Types

type Header struct {
	Alg string `json:"alg"`
	Enc string `json:"enc"`
	KID string `json:"kid"`
}

type JWE

type JWE struct {
	Ciphertext, IV, Tag []byte
	Header              Header
}

JWE implements a subset of JSON Web Encryption (https://datatracker.ietf.org/doc/html/rfc7516). It supports only direct encryption (https://datatracker.ietf.org/doc/html/rfc7518#section-4.5) with A128CBC-HS256 and de/serializes only the compact format.

func Encrypt

func Encrypt(plaintext []byte, kid string, alg *aescbc.AESCBCHMACSHA2) (JWE, error)

func ParseCompactFormat

func ParseCompactFormat(b []byte) (JWE, error)

ParseCompactFormat deserializes the compact format as returned by JWE.Serialize

func (*JWE) Decrypt

func (j *JWE) Decrypt(key []byte) ([]byte, error)

func (*JWE) Serialize

func (j *JWE) Serialize() (string, error)

Serialize the JWE to compact format

Source Files

jwe.go

Version
v0.3.2 (latest)
Published
Jan 15, 2025
Platform
linux/amd64
Imports
7 packages
Last checked
2 months ago

Tools for package owners.