[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.142.198.70: ~ $
�

1�Dgz4���ddlmZmZmZddlZddlmZmZmZddl	m
Z
ddlmZGd�d��Zd�Z
d	�Zd
�Zd�ZdS)�)�bchr�bord�
iter_rangeN)�ceil_div�
long_to_bytes�
bytes_to_long)�strxor)�Randomc�*�eZdZdZd�Zd�Zd�Zd�ZdS)�
PSS_SigSchemezvA signature object for ``RSASSA-PSS``.
    Do not instantiate directly.
    Use :func:`Crypto.Signature.pss.new`.
    c�>�||_||_||_||_dS)atInitialize this PKCS#1 PSS signature scheme object.

        :Parameters:
          key : an RSA key object
            If a private half is given, both signature and
            verification are possible.
            If a public half is given, only verification is possible.
          mgfunc : callable
            A mask generation function that accepts two parameters:
            a string to use as seed, and the lenth of the mask to
            generate, in bytes.
          saltLen : integer
            Length of the salt, in bytes.
          randfunc : callable
            A function that returns random bytes.
        N)�_key�_saltLen�_mgfunc�	_randfunc)�self�key�mgfunc�saltLen�randfuncs     �v/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Signature/pss.py�__init__zPSS_SigScheme.__init__/s$��$��	���
����!�����c�4�|j���S)z<Return ``True`` if this object can be used to sign messages.)r�has_private)rs r�can_signzPSS_SigScheme.can_signFs���y�$�$�&�&�&rc���|j��j}n|j}|j��fd�}n|j}tjj�|jj��}t|d��}t�|dz
|j||��}t|��}|j�
|��}t||��}	|	S)a~Create the PKCS#1 PSS signature of a message.

        This function is also called ``RSASSA-PSS-SIGN`` and
        it is specified in
        `section 8.1.1 of RFC8017 <https://tools.ietf.org/html/rfc8017#section-8.1.1>`_.

        :parameter msg_hash:
            This is an object from the :mod:`Crypto.Hash` package.
            It has been used to digest the message to sign.
        :type msg_hash: hash object

        :return: the signature encoded as a *byte string*.
        :raise ValueError: if the RSA key is not long enough for the given hash algorithm.
        :raise TypeError: if the RSA key has no private half.
        Nc�&��t||���S�N��MGF1��x�y�msg_hashs  �r�<lambda>z$PSS_SigScheme.sign.<locals>.<lambda>b����t�A�q�(�3�3�r��)r�digest_sizer�Crypto�Util�number�sizer�nr�_EMSA_PSS_ENCODErr�_decryptr)
rr%�sLen�mgf�modBits�k�em�em_int�m_int�	signatures
 `        r�signzPSS_SigScheme.signJs����$�=� ��'�D�D��=�D��<��3�3�3�3�C�C��,�C��+�$�)�)�$�)�+�6�6��
�W�a� � ��
�h���	�4�>�3��
M�
M���r�"�"���	�"�"�6�*�*��!�%��+�+�	��rc����|j��j}n|j}|jr|j}n�fd�}tjj�|jj��}t|d��}t|��|krtd���t|��}|j�
|��}t|dz
d��}	t||	��}
t�|
|dz
||��dS)apCheck if the  PKCS#1 PSS signature over a message is valid.

        This function is also called ``RSASSA-PSS-VERIFY`` and
        it is specified in
        `section 8.1.2 of RFC8037 <https://tools.ietf.org/html/rfc8017#section-8.1.2>`_.

        :parameter msg_hash:
            The hash that was carried out over the message. This is an object
            belonging to the :mod:`Crypto.Hash` module.
        :type parameter: hash object

        :parameter signature:
            The signature that needs to be validated.
        :type signature: bytes

        :raise ValueError: if the signature is not valid.
        Nc�&��t||���Srr r"s  �rr&z&PSS_SigScheme.verify.<locals>.<lambda>�r'rr(�Incorrect signaturer))rr*rr+r,r-r.rr/r�len�
ValueErrorr�_encryptr�_EMSA_PSS_VERIFY)rr%r9r2r3r4r5�
signature_intr7�emLenr6s `         r�verifyzPSS_SigScheme.verifyts����(�=� ��'�D�D��=�D��<�	4��,�C�C�3�3�3�3�C��+�$�)�)�$�)�+�6�6��
�W�a� � ���y�>�>�Q����2�3�3�3�%�i�0�0�
���#�#�M�2�2����1��a�(�(��
�6�5�
)�
)����2�w�q�y�#�t�<�<�<�<�<rN)�__name__�
__module__�__qualname__�__doc__rrr:rD�rrrr)s[��������
"�"�"�.'�'�'�(�(�(�T,=�,=�,=�,=�,=rrc�4�d}tt||j����D]U}t|d��}|���}|�||z��||���z}�Vt|��|ksJ�|d|�S)a�Mask Generation Function, described in `B.2.1 of RFC8017
    <https://tools.ietf.org/html/rfc8017>`_.

    :param mfgSeed:
        seed from which the mask is generated
    :type mfgSeed: byte string

    :param maskLen:
        intended length in bytes of the mask
    :type maskLen: integer

    :param hash_gen:
        A module or a hash object from :mod:`Crypto.Hash`
    :type hash_object:

    :return: the mask, as a *byte string*
    r�N)rrr*r�new�update�digestr>)�mgfSeed�maskLen�hash_gen�T�counter�c�hobjs       rr!r!�s���&	�A��h�w��0D�E�E�F�F�����'�1�%�%���|�|�~�~�����G�a�K� � � �
����
�
�����q�6�6�W������X�g�X�;�rc���t|d��}d}td|z|z
��D]
}|dz	dz}�||j|zdzkrtd���||��}t	d��dz|���z|z}	|���}
|
�|	��t	d��||z
|jz
dz
z}|t	d��z|z}||
���||jz
dz
��}
t||
��}t	t|d��|z��|dd�z}||
���zt	d��z}|S)	a
    Implement the ``EMSA-PSS-ENCODE`` function, as defined
    in PKCS#1 v2.1 (RFC3447, 9.1.1).

    The original ``EMSA-PSS-ENCODE`` actually accepts the message ``M``
    as input, and hash it internally. Here, we expect that the message
    has already been hashed instead.

    :Parameters:
      mhash : hash object
        The hash object that holds the digest of the message being signed.
      emBits : int
        Maximum length of the final encoding, in bits.
      randFunc : callable
        An RNG function that accepts as only parameter an int, and returns
        a string of random bytes, to be used as salt.
      mgf : callable
        A mask generation function that accepts two parameters: a string to
        use as seed, and the lenth of the mask to generate, in bytes.
      sLen : int
        Length of the salt, in bytes.

    :Return: An ``emLen`` byte long string that encodes the hash
      (with ``emLen = \ceil(emBits/8)``).

    :Raise ValueError:
        When digest or salt length are too big.
    r(rr)��z6Digest or salt length are too long for given key size.N�)
rrr*r?rrNrLrMr	r)�mhash�emBits�randFuncr3r2rC�lmask�i�salt�m_prime�h�ps�db�dbMask�maskedDBr6s                rr0r0�s���<
�V�Q���E�
�E�
��%����
'�
'�"�"����
�T�!���
�u� ��%�a�'�'�'��0�1�1�	1��8�D�>�>�D��1�g�g�a�i�%�,�,�.�.�(�4�/�G�
�	�	���A��H�H�W����	
�a���%��*�U�.�.�q�0�	1�B�	�d�1�g�g���	�B�
�S������U�5�#4�4�Q�6�
7�
7�F��b�&�!�!�H��D��!��%�%���.�/�/�(�1�2�2�,�>�H�	�A�H�H�J�J�	��d���	+�B�
�Irc��t|d��}d}td|z|z
��D]
}|dz	dz}�||j|zdzkrtd���t	|dd���d	krtd���|d||jz
dz
�}|||jz
dz
d�}	|t|d��zrtd���||	||jz
dz
��}
t
||
��}tt|d��|z��|dd�z}|�td��||jz
|z
dz
ztd��z��std���|dkr||d�}nd
}td��dz|�	��z|z}
|�
��}|�|
��|�	��}|	|krtd���dS)a�
    Implement the ``EMSA-PSS-VERIFY`` function, as defined
    in PKCS#1 v2.1 (RFC3447, 9.1.2).

    ``EMSA-PSS-VERIFY`` actually accepts the message ``M`` as input,
    and hash it internally. Here, we expect that the message has already
    been hashed instead.

    :Parameters:
      mhash : hash object
        The hash object that holds the digest of the message to be verified.
      em : string
        The signature to verify, therefore proving that the sender really
        signed the message that was received.
      emBits : int
        Length of the final encoding (em), in bits.
      mgf : callable
        A mask generation function that accepts two parameters: a string to
        use as seed, and the lenth of the mask to generate, in bytes.
      sLen : int
        Length of the salt, in bytes.

    :Raise ValueError:
        When the encoding is inconsistent, or the digest or salt lengths
        are too big.
    r(rr)rWrXr=���NrYr)rrr*r?�ordrr	r�
startswithrNrLrM)rZr6r[r3r2rCr]r^rerardrcr_r`rU�hps                rrArAs'��8
�V�Q���E�
�E�
��%����
'�
'�"�"����
�T�!���
�u� ��%�a�'�'�'��.�/�/�/�
�2�b�c�c�7�|�|�t����.�/�/�/��,�5��*�*�1�,�,�-�H�
�5��"�"�1�$�R�'�(�A��t�B�q�E�{�{��0��.�/�/�/�
�S��E�%�+�+�A�-�
.�
.�F�	��&�	!�	!�B�	
�d�2�a�5�k�k�U�F�"�	#�	#�b����f�	,�B�
�=�=��a���%��(9�"9�$�">�q�"@�A�D��G�G�K�L�L�0��.�/�/�/��a�x�x��4�%�&�&�z������1�g�g�a�i�%�,�,�.�.�(�4�/�G��9�9�;�;�D��K�K�����	
�����B��B�w�w��.�/�/�/��wrc�,�|�dd��}|�dd��}|�dd��}|�tj}|r1tdt	|�����z���t
||||��S)aCreate an object for making or verifying PKCS#1 PSS signatures.

    :parameter rsa_key:
      The RSA key to use for signing or verifying the message.
      This is a :class:`Crypto.PublicKey.RSA` object.
      Signing is only possible when ``rsa_key`` is a **private** RSA key.
    :type rsa_key: RSA object

    :Keyword Arguments:

        *   *mask_func* (``callable``) --
            A function that returns the mask (as `bytes`).
            It must accept two parameters: a seed (as `bytes`)
            and the length of the data to return.

            If not specified, it will be the function :func:`MGF1` defined in
            `RFC8017 <https://tools.ietf.org/html/rfc8017#page-67>`_ and
            combined with the same hash algorithm applied to the
            message to sign or verify.

            If you want to use a different function, for instance still :func:`MGF1`
            but together with another hash, you can do::

                from Crypto.Hash import SHA256
                from Crypto.Signature.pss import MGF1
                mgf = lambda x, y: MGF1(x, y, SHA256)

        *   *salt_bytes* (``integer``) --
            Length of the salt, in bytes.
            It is a value between 0 and ``emLen - hLen - 2``, where ``emLen``
            is the size of the RSA modulus and ``hLen`` is the size of the digest
            applied to the message to sign or verify.

            The salt is generated internally, you don't need to provide it.

            If not specified, the salt length will be ``hLen``.
            If it is zero, the signature scheme becomes deterministic.

            Note that in some implementations such as OpenSSL the default
            salt length is ``emLen - hLen - 2`` (even though it is not more
            secure than ``hLen``).

        *   *rand_func* (``callable``) --
            A function that returns random ``bytes``, of the desired length.
            The default is :func:`Crypto.Random.get_random_bytes`.

    :return: a :class:`PSS_SigScheme` signature object
    �	mask_funcN�
salt_bytes�	rand_funczUnknown keywords: )�popr
�get_random_bytesr?�str�keysr)�rsa_key�kwargsrl�salt_lenrns     rrLrLIs���d�
�
�;��-�-�I��z�z�,��-�-�H��
�
�;��-�-�I����+�	�
�D��-��F�K�K�M�M�0B�0B�B�C�C�C���)�X�y�A�A�Ar)�Crypto.Util.py3compatrrr�Crypto.Util.numberr+rrr�Crypto.Util.strxorr	r
rr!r0rArLrIrr�<module>rys
��>9�8�8�8�8�8�8�8�8�8�����"�"�"�"�"�"�"�"�"�"�&�%�%�%�%�%�������w=�w=�w=�w=�w=�w=�w=�w=�t���:=�=�=�@F0�F0�F0�R9B�9B�9B�9B�9Br

Filemanager

Name Type Size Permission Actions
DSS.cpython-311.pyc File 17.82 KB 0644
PKCS1_PSS.cpython-311.pyc File 1.19 KB 0644
PKCS1_v1_5.cpython-311.pyc File 1.1 KB 0644
__init__.cpython-311.pyc File 432 B 0644
eddsa.cpython-311.pyc File 14.41 KB 0644
pkcs1_15.cpython-311.pyc File 7.55 KB 0644
pss.cpython-311.pyc File 14.61 KB 0644