[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@18.221.123.33: ~ $
�

1�Dg�;����ddlmZddlmZddlmZddlmZddlm	Z	ddl
mZddgZGd	�de
��ZGd
�de��ZGd�d
e��ZGd�de��Zdd�ZdS)�)�DerSequence)�
long_to_bytes)�Integer)�HMAC)�EccKey)�DsaKey�DssSigScheme�newc�6�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	dS)	r	zkA (EC)DSA signature object.
    Do not instantiate directly.
    Use :func:`Crypto.Signature.DSS.new`.
    c��||_||_||_|j���|_|jdz
dzdz|_dS)z�Create a new Digital Signature Standard (DSS) object.

        Do not instantiate this object directly,
        use `Crypto.Signature.DSS.new` instead.
        ��N)�_key�	_encoding�_order�size_in_bits�_order_bits�_order_bytes)�self�key�encoding�orders    �v/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Signature/DSS.py�__init__zDssSigScheme.__init__3sO����	�!�������;�3�3�5�5���!�-��1�a�7�!�;�����c�4�|j���S)zRReturn ``True`` if this signature object can be used
        for signing messages.)r�has_private)rs r�can_signzDssSigScheme.can_signAs���y�$�$�&�&�&rc� �td����NzTo be provided by subclasses��NotImplementedError�r�msg_hashs  r�_compute_noncezDssSigScheme._compute_nonceG���!�"@�A�A�Arc� �td���r r!r#s  r�_valid_hashzDssSigScheme._valid_hashJr&rc����j���std�����|��st	d�����|��}t
j|���d�j	���}�j�
||��}�jdkr"d��fd�|D����}n!t|�����}|S)aCompute the DSA/ECDSA signature of a message.

        Args:
          msg_hash (hash object):
            The hash that was carried out over the message.
            The object belongs to the :mod:`Crypto.Hash` package.
            Under mode ``'fips-186-3'``, the hash must be a FIPS
            approved secure hash (SHA-2 or SHA-3).

        :return: The signature as ``bytes``
        :raise ValueError: if the hash algorithm is incompatible to the (EC)DSA key
        :raise TypeError: if the (EC)DSA key has no private half
        zPrivate key is needed to sign�Hash is not sufficiently strongN�binaryrc�:��g|]}t|�j����S�)rr)�.0�xrs  �r�
<listcomp>z%DssSigScheme.sign.<locals>.<listcomp>ks6���2�2�2�#$� -�Q��0A�B�B�2�2�2r)rr�	TypeErrorr(�
ValueErrorr%r�
from_bytes�digestr�_signr�joinr�encode)rr$�nonce�z�sig_pair�outputs`     r�signzDssSigScheme.signMs����y�$�$�&�&�	=��;�<�<�<�����)�)�	@��>�?�?�?��#�#�H�-�-��
��x���0�0�1C�$�2C�1C�D�E�E���9�?�?�1�e�,�,���>�X�%�%��X�X�2�2�2�2�(0�2�2�2�3�3�F�F�!��*�*�1�1�3�3�F��
rc��|�|��std���|jdkrVt|��d|jzkrtd���d�|d|j�||jd�fD��\}}n�	t���|d���}n$#ttf$rtd	���wxYwt|��dks|���std
���t|d��t|d��}}d|cxkr|j
krnnd|cxkr|j
ksntd
���tj|���d|j���}|j
�|||f��}|std���dS)a�Check if a certain (EC)DSA signature is authentic.

        Args:
          msg_hash (hash object):
            The hash that was carried out over the message.
            This is an object belonging to the :mod:`Crypto.Hash` module.
            Under mode ``'fips-186-3'``, the hash must be a FIPS
            approved secure hash (SHA-2 or SHA-3).

          signature (``bytes``):
            The signature that needs to be validated.

        :raise ValueError: if the signature is not authentic
        r*r+�z'The signature is not authentic (length)c�6�g|]}tj|����Sr-)rr3)r.r/s  rr0z'DssSigScheme.verify.<locals>.<listcomp>�s9�� J� J� J�$%�!(� 2�1� 5� 5� J� J� JrNT)�strictz$The signature is not authentic (DER)z,The signature is not authentic (DER content)rr
z"The signature is not authentic (d)zThe signature is not authenticF)r(r2r�lenrr�decode�
IndexError�hasOnlyIntsrrr3r4r�_verify)rr$�	signature�r_prime�s_prime�der_seqr9�results        r�verifyzDssSigScheme.verifyzs
�� ����)�)�	@��>�?�?�?��>�X�%�%��9�~�~�!�d�&7�"7�8�8� �!J�K�K�K� J� J�*3�4F�T�5F�4F�*G�*3�D�4E�4F�4F�*G�*I� J� J� J��G�W�W�
I�%�-�-�.�.�y��.�F�F�����
�+�
I�
I�
I� �!G�H�H�H�
I�����7�|�|�q� � ��(;�(;�(=�(=� � �!O�P�P�P�&�w�q�z�2�2�G�G�A�J�4G�4G�W�G��G�)�)�)�)�d�k�)�)�)�)�)�1�w�3L�3L�3L�3L���3L�3L�3L�3L��A�B�B�B���x���0�0�1C�$�2C�1C�D�E�E����"�"�1�w��&8�9�9���	?��=�>�>�>��us�#B+�+!CN)
�__name__�
__module__�__qualname__�__doc__rrr%r(r<rKr-rrr	r	-s��������
<�<�<�'�'�'�B�B�B�B�B�B�+�+�+�Z*�*�*�*�*rc�<��eZdZ�fd�Zd�Zd�Zd�Zd�Zd�Z�xZ	S)�DeterministicDsaSigSchemec�j��tt|���|||��||_dS�N)�superrQr�_private_key)rrrr�private_key�	__class__s     �rrz"DeterministicDsaSigScheme.__init__�s4���
�'��.�.�7�7��X�u�M�M�M�'����rc��tj|��}|j���}t	|��dz}||kr|||z
z}|S)zSee 2.3.2 in RFC6979r)rr3rrrA)r�bstrrJ�q_len�b_lens     r�	_bits2intz#DeterministicDsaSigScheme._bits2int�sR���#�D�)�)����(�(�*�*���D�	�	�A�
���5�=�=����
�&�F��
rc�X�d|cxkr|jksnJ�t||j��S)zSee 2.3.3 in RFC6979r)rrr)r�	int_mod_qs  r�_int2octetsz%DeterministicDsaSigScheme._int2octets�s>���9�*�*�*�*�t�{�*�*�*�*�*�*��Y��(9�:�:�:rc��|�|��}||jkr|}n
||jz
}|�|��S)zSee 2.3.4 in RFC6979)r\rr_)rrY�z1�z2s    r�_bits2octetsz&DeterministicDsaSigScheme._bits2octets�sI���^�^�D�
!�
!��
������B�B��d�k�!�B�����#�#�#rc�X�|���}d|jz}d|jz}dD]�}tj|||z|�|j��z|�|��z|�����}tj|||�����}��d}d|cxkr|jks�n|dkrStj||dz|�����}tj|||�����}d}t|��|j	krEtj|||�����}||z
}t|��|j	k�E|�
|��}d|cxkr|jk��n��|S)z!Generate k in a deterministic way��)rfre���rr)r4�digest_sizerr
r_rUrcrrArr\)r�mhash�h1�mask_v�nonce_k�int_octr8�mask_ts        rr%z(DeterministicDsaSigScheme._compute_nonce�s���
�\�\�^�^���5�,�,���E�-�-��)�	?�	?�G��h�w�%��/�#�/�/��0A�B�B� C�#�0�0��4�4� 5�6;�=�=�>D�V�X�X�
�
�X�g�v�u�5�5�<�<�>�>�F�F����u�*�*�*�*�t�{�*�*�*�*���{�{��(�7�F�W�,<�#(�*�*�*0�&�(�(����'�6�5�9�9�@�@�B�B���F��f�+�+�� 1�1�1���'�6�5�9�9�@�@�B�B���&� ���f�+�+�� 1�1�1�
�N�N�6�*�*�E�!�u�*�*�*�*�t�{�*�*�*�*�*�"�rc��dS)NTr-r#s  rr(z%DeterministicDsaSigScheme._valid_hash�s���tr)
rLrMrNrr\r_rcr%r(�
__classcell__�rWs@rrQrQ�s��������(�(�(�(�(�	�	�	�;�;�;�$�$�$�&�&�&�P������rrQc�.��eZdZdZ�fd�Zd�Zd�Z�xZS)�FipsDsaSigScheme))i�)���)ru�)irwc���tt|���|||��||_t	|j�����}||jf|jvrd||jfz}t|���dS)Nz+L/N (%d, %d) is not compliant to FIPS 186-3)
rTrsr�	_randfuncr�prr�_fips_186_3_L_Nr2)rrrr�randfunc�L�errorrWs       �rrzFipsDsaSigScheme.__init__s����
���%�%�.�.�s�H�e�D�D�D�!����C�E�N�N�'�'�)�)��
�t�� ��(<�<�<�B��4�+�,�-�E��U�#�#�#�=�<rc�D�tjd|j|j���S�Nr
)�
min_inclusive�
max_exclusiver|)r�random_rangerryr#s  rr%zFipsDsaSigScheme._compute_nonces(���#�!�26�+�-1�^�=�=�=�	=rc�L�|jdkp|j�d��S)z*Verify that SHA-1, SHA-2 or SHA-3 are usedz
1.3.14.3.2.26z2.16.840.1.101.3.4.2.)�oid�
startswithr#s  rr(zFipsDsaSigScheme._valid_hashs,�����/�A���'�'�(?�@�@�	Br)rLrMrNr{rr%r(rprqs@rrsrs�sd�������
�O�$�$�$�$�$�=�=�=�B�B�B�B�B�B�Brrsc�*��eZdZ�fd�Zd�Zd�Z�xZS)�FipsEcDsaSigSchemec�j��tt|���|||��||_dSrS)rTr�rry)rrrrr|rWs     �rrzFipsEcDsaSigScheme.__init__s1���
� �$�'�'�0�0��h��F�F�F�!����rc�X�tjd|jjj|j���Sr�)rr�r�_curverryr#s  rr%z!FipsEcDsaSigScheme._compute_nonces.���#�!�26�)�2B�2H�-1�^�=�=�=�	=rc��|jj���}d}d}d}d}||z|z|z}	|j|v}n#t$rd}YnwxYw|S)zxVerify that the strength of the hash matches or exceeds
        the strength of the EC. We fail if the hash is too weak.)z2.16.840.1.101.3.4.2.4z2.16.840.1.101.3.4.2.7z2.16.840.1.101.3.4.2.5)z2.16.840.1.101.3.4.2.1z2.16.840.1.101.3.4.2.8z2.16.840.1.101.3.4.2.6)z2.16.840.1.101.3.4.2.2z2.16.840.1.101.3.4.2.9)z2.16.840.1.101.3.4.2.3z2.16.840.1.101.3.4.2.10F)r�pointQrr��AttributeError)	rr$�modulus_bits�sha224�sha256�sha384�sha512�shsrJs	         rr(zFipsEcDsaSigScheme._valid_hash"s����y�'�4�4�6�6��`��_��E��F���v�o��&��/��	��\�S�(�F�F���	�	�	��F�F�F�	�����
s�	=�A�A)rLrMrNrr%r(rprqs@rr�r�sV�������"�"�"�"�"�=�=�=�
������rr�r+Nc��|dvrtd|z���t|t��r.|jj}d}|jjdkrtd���nXt|t��rt|j��}d}n,tdtt|����z���|���rt||��}nd}|d	krt||||��S|d
kr9t|t��rt||||��St||||��Std|z���)a�
Create a signature object :class:`DssSigScheme` that
    can perform (EC)DSA signature or verification.

    .. note::
        Refer to `NIST SP 800 Part 1 Rev 4`_ (or newer release) for an
        overview of the recommended key lengths.

    Args:
        key (:class:`Crypto.PublicKey.DSA` or :class:`Crypto.PublicKey.ECC`):
            The key to use for computing the signature (*private* keys only)
            or for verifying one.
            For DSA keys, let ``L`` and ``N`` be the bit lengths of the modulus ``p``
            and of ``q``: the pair ``(L,N)`` must appear in the following list,
            in compliance to section 4.2 of `FIPS 186-4`_:

            - (1024, 160) *legacy only; do not create new signatures with this*
            - (2048, 224) *deprecated; do not create new signatures with this*
            - (2048, 256)
            - (3072, 256)

            For ECC, only keys over P-224, P-256, P-384, and P-521 are accepted.

        mode (string):
            The parameter can take these values:

            - ``'fips-186-3'``. The signature generation is randomized and carried out
              according to `FIPS 186-3`_: the nonce ``k`` is taken from the RNG.
            - ``'deterministic-rfc6979'``. The signature generation is not
              randomized. See RFC6979_.

        encoding (string):
            How the signature is encoded. This value determines the output of
            :meth:`sign` and the input to :meth:`verify`.

            The following values are accepted:

            - ``'binary'`` (default), the signature is the raw concatenation
              of ``r`` and ``s``. It is defined in the IEEE P.1363 standard.
              For DSA, the size in bytes of the signature is ``N/4`` bytes
              (e.g. 64 for ``N=256``).
              For ECDSA, the signature is always twice the length of a point
              coordinate (e.g. 64 bytes for P-256).

            - ``'der'``, the signature is a ASN.1 DER SEQUENCE
              with two INTEGERs (``r`` and ``s``). It is defined in RFC3279_.
              The size of the signature is variable.

        randfunc (callable):
            A function that returns random ``bytes``, of a given length.
            If omitted, the internal RNG is used.
            Only applicable for the *'fips-186-3'* mode.

    .. _FIPS 186-3: http://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf
    .. _FIPS 186-4: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
    .. _NIST SP 800 Part 1 Rev 4: http://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-57pt1r4.pdf
    .. _RFC6979: http://tools.ietf.org/html/rfc6979
    .. _RFC3279: https://tools.ietf.org/html/rfc3279#section-2.2.2
    )r+�derzUnknown encoding '%s'�d�ed25519z ECC key is not on a NIST P curver/zUnsupported key type Nzdeterministic-rfc6979z
fips-186-3zUnknown DSS mode '%s')r2�
isinstancerr�r�namerr�q�str�typer�getattrrQr�rs)r�moderr|r�private_key_attrrVs       rr
r
6sW��D�(�(�(��0�8�;�<�<�<��#�v���	C��
� �����:�?�i�'�'��?�@�@�@�(�	�C��	 �	 �C�����������0�3�t�C�y�y�>�>�A�B�B�B�
�������c�#3�4�4������&�&�&�(��h��{�K�K�K�	
��	�	��c�6�"�"�	D�%�c�8�U�H�E�E�E�#�C��5�(�C�C�C��0�4�7�8�8�8r)r+N)�Crypto.Util.asn1r�Crypto.Util.numberr�Crypto.Math.Numbersr�Crypto.Hashr�Crypto.PublicKey.ECCr�Crypto.PublicKey.DSAr�__all__�objectr	rQrsr�r
r-rr�<module>r�se��D)�(�(�(�(�(�,�,�,�,�,�,�'�'�'�'�'�'�������'�'�'�'�'�'�'�'�'�'�'�'��5�
!��w�w�w�w�w�6�w�w�w�tK�K�K�K�K��K�K�K�\B�B�B�B�B�|�B�B�B�D���������>]9�]9�]9�]9�]9�]9r

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