§
    iÝ[fD  ã                   ó>   — d Z ddlmZ ddlmZ  G d„ de¦  «        ZdS )z¿
    authlib.jose.draft
    ~~~~~~~~~~~~~~~~~~~~

    Content Encryption per `Section 4`_.

    .. _`Section 4`: https://datatracker.ietf.org/doc/html/draft-amringer-jose-chacha-02#section-4
é    )ÚJWEEncAlgorithm)ÚChaCha20_Poly1305c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚXC20PEncAlgorithméÀ   c                 ó>   — d| _         d| _        || _        || _        d S )NÚXC20PzXChaCha20-Poly1305)ÚnameÚdescriptionÚkey_sizeÚCEK_SIZE)Úselfr   s     ú[/var/www/piapp/venv/lib/python3.11/site-packages/authlib/jose/drafts/_jwe_enc_cryptodome.pyÚ__init__zXC20PEncAlgorithm.__init__   s#   € ØˆŒ	Ø/ˆÔØ ˆŒØ ˆŒˆˆó    c                 óº   — |                       |¦  «         t          j        ||¬¦  «        }|                     |¦  «         |                     |¦  «        \  }}||fS )a$  Content Encryption with AEAD_XCHACHA20_POLY1305

        :param msg: text to be encrypt in bytes
        :param aad: additional authenticated data in bytes
        :param iv: initialization vector in bytes
        :param key: encrypted key in bytes
        :return: (ciphertext, tag)
        ©ÚkeyÚnonce)Úcheck_ivÚCryptodome_ChaCha20_Poly1305ÚnewÚupdateÚencrypt_and_digest)r   ÚmsgÚaadÚivr   ÚchachaÚ
ciphertextÚtags           r   ÚencryptzXC20PEncAlgorithm.encrypt   s^   € ð 	�Š�bÑÔÐÝ-Ô1°cÀÐDÑDÔDˆØ�Š�cÑÔÐØ ×3Ò3°CÑ8Ô8‰ˆ
�CØ˜3ˆÐr   c                 ó®   — |                       |¦  «         t          j        ||¬¦  «        }|                     |¦  «         |                     ||¦  «        S )aI  Content Decryption with AEAD_XCHACHA20_POLY1305

        :param ciphertext: ciphertext in bytes
        :param aad: additional authenticated data in bytes
        :param iv: initialization vector in bytes
        :param tag: authentication tag in bytes
        :param key: encrypted key in bytes
        :return: message
        r   )r   r   r   r   Údecrypt_and_verify)r   r   r   r   r    r   r   s          r   ÚdecryptzXC20PEncAlgorithm.decrypt'   sS   € ð 	�Š�bÑÔÐÝ-Ô1°cÀÐDÑDÔDˆØ�Š�cÑÔÐØ×(Ò(¨°SÑ9Ô9Ð9r   N)Ú__name__Ú
__module__Ú__qualname__ÚIV_SIZEr   r!   r$   © r   r   r   r      sH   € € € € € ð €Gð!ð !ð !ðð ð ð:ð :ð :ð :ð :r   r   N)Ú__doc__Úauthlib.jose.rfc7516r   ÚCryptodome.Cipherr   r   r   r)   r   r   ú<module>r-      si   ððð ð 1Ð 0Ð 0Ð 0Ð 0Ð 0Ø OÐ OÐ OÐ OÐ OÐ Oð':ð ':ð ':ð ':ð ':˜ñ ':ô ':ð ':ð ':ð ':r   