§
    m:Rf�  ã                   óJ   — d Z dgZddlmZ ddlmZ  G d„ de¦  «        Zd„ ZdS )z
OpenPGP mode.
ÚOpenPgpModeé    )Ú_copy_bytes)Úget_random_bytesc                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )r   az  OpenPGP mode.

    This mode is a variant of CFB, and it is only used in PGP and
    OpenPGP_ applications. If in doubt, use another mode.

    An Initialization Vector (*IV*) is required.

    Unlike CFB, the *encrypted* IV (not the IV itself) is
    transmitted to the receiver.

    The IV is a random data block. For legacy reasons, two of its bytes are
    duplicated to act as a checksum for the correctness of the key, which is now
    known to be insecure and is ignored. The encrypted IV is therefore 2 bytes
    longer than the clean IV.

    .. _OpenPGP: http://tools.ietf.org/html/rfc4880

    :undocumented: __init__
    c                 ód  — |j         | _         d| _         |j        ||j        fd| j         z  | j         dz  dœ|¤Ž}t	          d d |¦  «        }t          |¦  «        | j         k    r&|                     ||dd …         z   ¦  «        | _        nat          |¦  «        | j         dz   k    r%|| _        |                     |¦  «        d d…         }n!t          d| j         | j         dz   fz  ¦  «        ‚|x| _
        | _         |j        ||j        f| j        | j          d …         | j         dz  dœ|¤Ž| _        d S )NFó    é   )ÚIVÚsegment_sizeéþÿÿÿé   z4Length of IV must be %d or %d bytes for MODE_OPENPGP)Ú
block_sizeÚ_done_first_blockÚnewÚMODE_CFBr   ÚlenÚencryptÚ_encrypted_IVÚdecryptÚ
ValueErrorÚivr
   Ú_cipher)ÚselfÚfactoryÚkeyr   Úcipher_paramsÚ	IV_ciphers         úN/var/www/bsim/venv/lib/python3.11/site-packages/Crypto/Cipher/_mode_openpgp.pyÚ__init__zOpenPgpMode.__init__=   s†  € ð "Ô,ˆŒà!&ˆÔð  �G”KØØÔ(ð)ð # T¤_Ñ4Ø%)¤_°qÑ%8ð	)ð )ð
 (ð)ð )ˆ	õ ˜˜t RÑ(Ô(ˆõ ˆr‰7Œ7�d”oÒ%Ð%à!*×!2Ò!2°2¸¸2¸3¸3¼±<Ñ!@Ô!@ˆDÔÐÝ�‰WŒW˜œ¨!Ñ+Ò+Ð+à!#ˆDÔð ×"Ò" 2Ñ&Ô& s¨ sÔ+ˆBˆBåð 1à $¤°´À1Ñ1DÐEñFñ Gô Gð Gð ÐˆŒ�$”'ð #�w”{ØØ#Ô,ð-ð  $Ô1°4´?Ð2BÐ2CÐ2CÔDØ)-¬¸1Ñ)<ð	-ð -ð
 ,ð-ð -ˆŒˆˆó    c                 ój   — | j                              |¦  «        }| j        s| j        |z   }d| _        |S )a›  Encrypt data with the key and the parameters set at initialization.

        A cipher object is stateful: once you have encrypted a message
        you cannot encrypt (or decrypt) another message using the same
        object.

        The data to encrypt can be broken up in two or
        more pieces and `encrypt` can be called multiple times.

        That is, the statement:

            >>> c.encrypt(a) + c.encrypt(b)

        is equivalent to:

             >>> c.encrypt(a+b)

        This function does not add any padding to the plaintext.

        :Parameters:
          plaintext : bytes/bytearray/memoryview
            The piece of data to encrypt.

        :Return:
            the encrypted data, as a byte string.
            It is as long as *plaintext* with one exception:
            when encrypting the first message chunk,
            the encypted IV is prepended to the returned ciphertext.
        T)r   r   r   r   )r   Ú	plaintextÚress      r   r   zOpenPgpMode.encryptg   s>   € ð> Œl×"Ò" 9Ñ-Ô-ˆØÔ%ð 	*ØÔ$ sÑ*ˆCØ%)ˆDÔ"Øˆ
r    c                 ó6   — | j                              |¦  «        S )aÙ  Decrypt data with the key and the parameters set at initialization.

        A cipher object is stateful: once you have decrypted a message
        you cannot decrypt (or encrypt) another message with the same
        object.

        The data to decrypt can be broken up in two or
        more pieces and `decrypt` can be called multiple times.

        That is, the statement:

            >>> c.decrypt(a) + c.decrypt(b)

        is equivalent to:

             >>> c.decrypt(a+b)

        This function does not remove any padding from the plaintext.

        :Parameters:
          ciphertext : bytes/bytearray/memoryview
            The piece of data to decrypt.

        :Return: the decrypted data (byte string).
        )r   r   )r   Ú
ciphertexts     r   r   zOpenPgpMode.decryptŒ   s   € ð6 Œ|×#Ò# JÑ/Ô/Ð/r    N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   © r    r   r   r   (   sM   € € € € € ðð ð((-ð (-ð (-ðT#ð #ð #ðJ0ð 0ð 0ð 0ð 0r    c                 ór  — |                      dd¦  «        }|                      dd¦  «        }d||fk    rt          | j        ¦  «        }|�|�t          d¦  «        ‚n|}	 |                      d¦  «        }n1# t          $ r$}t          dt          |¦  «        z   ¦  «        ‚d}~ww xY wt          | |||¦  «        S )a#  Create a new block cipher, configured in OpenPGP mode.

    :Parameters:
      factory : module
        The module.

    :Keywords:
      key : bytes/bytearray/memoryview
        The secret key to use in the symmetric cipher.

      IV : bytes/bytearray/memoryview
        The initialization vector to use for encryption or decryption.

        For encryption, the IV must be as long as the cipher block size.

        For decryption, it must be 2 bytes longer (it is actually the
        *encrypted* IV which was prefixed to the ciphertext).
    r
   Nr   )NNz*You must either use 'iv' or 'IV', not bothr   zMissing component: )Úpopr   r   Ú	TypeErrorÚKeyErrorÚstrr   )r   Úkwargsr   r
   r   Úes         r   Ú_create_openpgp_cipherr2   ª   sÕ   € ð( 
�Š�D˜$Ñ	Ô	€BØ	�Š�D˜$Ñ	Ô	€Bà˜˜B�xÒÐÝ˜gÔ0Ñ1Ô1ˆØ	€~Øˆ>ÝÐHÑIÔIÐIð ð ˆð8Ø�jŠj˜ÑÔˆˆøÝð 8ð 8ð 8ÝÐ-µ°A±´Ñ6Ñ7Ô7Ð7øøøøð8øøøõ �w  R¨Ñ0Ô0Ð0s   Á A6 Á6
B$Â BÂB$N)	r)   Ú__all__ÚCrypto.Util.py3compatr   ÚCrypto.Randomr   Úobjectr   r2   r*   r    r   ú<module>r7      sˆ   ðð>ð ð ˆ/€à -Ð -Ð -Ð -Ð -Ð -Ø *Ð *Ð *Ð *Ð *Ð *ð0ð 0ð 0ð 0ð 0�&ñ 0ô 0ð 0ðD$1ð $1ð $1ð $1ð $1r    