# Path: jose/jwe.py
# def encrypt(plaintext, key, encryption=ALGORITHMS.A256GCM, algorithm=ALGORITHMS.DIR, zip=None, cty=None, kid=None):
# def decrypt(jwe_str, key):
# def get_unverified_header(jwe_str):
# def _decrypt_and_auth(cek_bytes, enc, cipher_text, iv, aad, auth_tag):
# def _get_encryption_key_mac_key_and_key_length_from_cek(cek_bytes, enc):
# def _jwe_compact_deserialize(jwe_bytes):
# def _encoded_header(alg, enc, zip, cty, kid):
# def _big_endian(int_val):
# def _encrypt_and_auth(key, alg, enc, zip, plaintext, aad):
# def _get_hmac_key(enc, mac_key_bytes):
# def _compress(zip, plaintext):
# def _decompress(zip, compressed):
# def _get_cek(enc, alg, key):
# def _get_direct_key_wrap_cek(key):
# def _get_key_bytes_from_key(key):
# def _get_key_wrap_cek(enc, key):
# def _get_random_cek_bytes_for_enc(enc):
# def _auth_tag(ciphertext, iv, aad, mac_key, tag_length):
# def _jwe_compact_serialize(encoded_header, encrypted_cek, iv, cipher_text, auth_tag):
# 
# Path: jose/constants.py
# ALGORITHMS = Algorithms()
# 
# ZIPS = Zips()
# 
# Path: jose/exceptions.py
# class JWEParseError(JWEError):
#     """Could not parse the JWE string provided"""
# 
#     pass
# 
# Path: jose/jwk.py
# def get_key(algorithm):
# def register_key(algorithm, key_class):
# def construct(key_data, algorithm=None):
# 
# Path: jose/utils.py
# def base64url_decode(input):
#     """Helper method to base64url_decode a string.
# 
#     Args:
#         input (str): A base64url_encoded string to decode.
# 
#     """
#     rem = len(input) % 4
# 
#     if rem > 0:
#         input += b"=" * (4 - rem)
# 
#     return base64.urlsafe_b64decode(input)


import json
import pytest
import jose.backends
    import jose.backends.cryptography_backend  # noqa E402
import jose.backends.native  # noqa E402
from jose import jwe
from jose.constants import ALGORITHMS, ZIPS
from jose.exceptions import JWEParseError
from jose.jwk import AESKey, RSAKey
from jose.utils import base64url_decode
    from jose.backends.rsa_backend import RSAKey as RSABackendRSAKey
        pytest.param(
            b"eyJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiQTI1NktXIn0.i_-ehDezyG89YFcWqU-MxPB1HtVHauEAUGInnjlodx44IJBLS4ap4Q.nCEooStwaMWLfDxt.lqjEVnCRHCaufTIcxT2MzeBwUE2V-Q.sIr7c2QlWIYSVwnXUHgITA",
            id="alg: A256KW, enc: A256GCM",
        ),
    )

    @pytest.mark.parametrize("jwe_package", JWE_RSA_PACKAGES)
    def test_decrypt_rsa_key_wrap(self, jwe_package):
        headers = jwe.get_unverified_header(jwe_package)
        if headers["alg"] not in ALGORITHMS.SUPPORTED:
            pytest.skip("alg {} not supported".format(headers["alg"]))
        if headers["enc"] not in ALGORITHMS.SUPPORTED:
            pytest.skip("enc {} not supported".format(headers["enc"]))
        key = PRIVATE_KEY_PEM
        actual = jwe.decrypt(jwe_package, key)
        assert actual == b"Live long and prosper."

    @pytest.mark.parametrize("jwe_package", JWE_128_BIT_OCT_PACKAGES)
    def test_decrypt_oct_128_key_wrap(self, jwe_package):
        key = OCT_128_BIT_KEY
        headers = jwe.get_unverified_header(jwe_package)
        if headers["alg"] not in ALGORITHMS.SUPPORTED:
            pytest.skip("alg {} not supported".format(headers["alg"]))
        if headers["enc"] not in ALGORITHMS.SUPPORTED:
            pytest.skip("enc {} not supported".format(headers["enc"]))
        actual = jwe.decrypt(jwe_package, key)
        assert actual == b"Live long and prosper."

    @pytest.mark.parametrize("jwe_package", JWE_192_BIT_OCT_PACKAGES)
    def test_decrypt_oct_192_key_wrap(self, jwe_package):

# Path: jose/jwe.py
# def encrypt(plaintext, key, encryption=ALGORITHMS.A256GCM, algorithm=ALGORITHMS.DIR, zip=None, cty=None, kid=None):
# def decrypt(jwe_str, key):
# def get_unverified_header(jwe_str):
# def _decrypt_and_auth(cek_bytes, enc, cipher_text, iv, aad, auth_tag):
# def _get_encryption_key_mac_key_and_key_length_from_cek(cek_bytes, enc):
# def _jwe_compact_deserialize(jwe_bytes):
# def _encoded_header(alg, enc, zip, cty, kid):
# def _big_endian(int_val):
# def _encrypt_and_auth(key, alg, enc, zip, plaintext, aad):
# def _get_hmac_key(enc, mac_key_bytes):
# def _compress(zip, plaintext):
# def _decompress(zip, compressed):
# def _get_cek(enc, alg, key):
# def _get_direct_key_wrap_cek(key):
# def _get_key_bytes_from_key(key):
# def _get_key_wrap_cek(enc, key):
# def _get_random_cek_bytes_for_enc(enc):
# def _auth_tag(ciphertext, iv, aad, mac_key, tag_length):
# def _jwe_compact_serialize(encoded_header, encrypted_cek, iv, cipher_text, auth_tag):
# 
# Path: jose/constants.py
# ALGORITHMS = Algorithms()
# 
# ZIPS = Zips()
# 
# Path: jose/exceptions.py
# class JWEParseError(JWEError):
#     """Could not parse the JWE string provided"""
# 
#     pass
# 
# Path: jose/jwk.py
# def get_key(algorithm):
# def register_key(algorithm, key_class):
# def construct(key_data, algorithm=None):
# 
# Path: jose/utils.py
# def base64url_decode(input):
#     """Helper method to base64url_decode a string.
# 
#     Args:
#         input (str): A base64url_encoded string to decode.
# 
#     """
#     rem = len(input) % 4
# 
#     if rem > 0:
#         input += b"=" * (4 - rem)
# 
#     return base64.urlsafe_b64decode(input)


# Path: tests/test_jwe.py
import json
import pytest
import jose.backends
    import jose.backends.cryptography_backend  # noqa E402
import jose.backends.native  # noqa E402
from jose import jwe
from jose.constants import ALGORITHMS, ZIPS
from jose.exceptions import JWEParseError
from jose.jwk import AESKey, RSAKey
from jose.utils import base64url_decode
    from jose.backends.rsa_backend import RSAKey as RSABackendRSAKey

        pytest.param(
            b"eyJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiQTI1NktXIn0.i_-ehDezyG89YFcWqU-MxPB1HtVHauEAUGInnjlodx44IJBLS4ap4Q.nCEooStwaMWLfDxt.lqjEVnCRHCaufTIcxT2MzeBwUE2V-Q.sIr7c2QlWIYSVwnXUHgITA",
            id="alg: A256KW, enc: A256GCM",
        ),
    )

    @pytest.mark.parametrize("jwe_package", JWE_RSA_PACKAGES)
    def test_decrypt_rsa_key_wrap(self, jwe_package):
        headers = jwe.get_unverified_header(jwe_package)
        if headers["alg"] not in ALGORITHMS.SUPPORTED:
            pytest.skip("alg {} not supported".format(headers["alg"]))
        if headers["enc"] not in ALGORITHMS.SUPPORTED:
            pytest.skip("enc {} not supported".format(headers["enc"]))
        key = PRIVATE_KEY_PEM
        actual = jwe.decrypt(jwe_package, key)
        assert actual == b"Live long and prosper."

    @pytest.mark.parametrize("jwe_package", JWE_128_BIT_OCT_PACKAGES)
    def test_decrypt_oct_128_key_wrap(self, jwe_package):
        key = OCT_128_BIT_KEY
        headers = jwe.get_unverified_header(jwe_package)
        if headers["alg"] not in ALGORITHMS.SUPPORTED:
            pytest.skip("alg {} not supported".format(headers["alg"]))
        if headers["enc"] not in ALGORITHMS.SUPPORTED:
            pytest.skip("enc {} not supported".format(headers["enc"]))
        actual = jwe.decrypt(jwe_package, key)
        assert actual == b"Live long and prosper."

    @pytest.mark.parametrize("jwe_package", JWE_192_BIT_OCT_PACKAGES)
    def test_decrypt_oct_192_key_wrap(self, jwe_package):

        headers = jwe.get_unverified_header(jwe_package)