RFC7516: JSON Web Encryption

This section contains the generic implementation of RFC7516. Find how to use it in JWE Guide.

API Reference

authlib.jose.rfc7516.JWE

alias of authlib.jose.rfc7516.jwe.JsonWebEncryption

class authlib.jose.rfc7516.JWEAlgorithm(name)

Interface for JWE algorithm. JWA specification (RFC7518) SHOULD implement the algorithms for JWE with this base implementation.

class authlib.jose.rfc7516.JWEEncAlgorithm
encrypt(msg, aad, iv, key)

Encrypt the given “msg” text.

Parameters:
  • msg – text to be encrypt in bytes
  • aad – additional authenticated data in bytes
  • iv – initialization vector in bytes
  • key – encrypted key in bytes
Returns:

(ciphertext, iv, tag)

decrypt(ciphertext, aad, iv, tag, key)

Decrypt the given cipher text.

Parameters:
  • ciphertext – ciphertext in bytes
  • aad – additional authenticated data in bytes
  • iv – initialization vector in bytes
  • tag – authentication tag in bytes
  • key – encrypted key in bytes
Returns:

message

class authlib.jose.rfc7516.JWEZipAlgorithm