Skip to content

Key Wrapping

Key Wrapping shares a symmetric key, kind of like Direct Key Encryption. However, instead of using the shared key as the CEK, it uses it to wrap the actual CEK, so that only a recipient with the correct KEK can unwrap the CEK and decrypt the token.

go
package main

import "github.com/a-novel-kit/jwt/jwe/jwek"

func main() {
	// The KEK is shared directly between the producer and the recipient.
	var kek []byte

	keyDecoder := jwek.NewAESKWDecoder(
		&jwek.AESKWDecoderConfig{WrapKey: kek},
		jwek.A128KW,
	)
}

Available presets:

PresetTarget "alg"
jwek.A128KWA128KW
jwek.A192KWA192KW
jwek.A256KWA256KW