Your IP : 216.73.216.213


Current Path : /opt/alt/python35/lib64/python3.5/site-packages/Crypto/PublicKey/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib64/python3.5/site-packages/Crypto/PublicKey/__pycache__/pubkey.cpython-35.pyc



���^��@s?dZddlZddlZddlTGdd�d�ZdS)z$Id$�N)�*c@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zd d!�Zd"d#�Zd$d%�Zd&S)'�pubkeyzxAn abstract class for a public key object.

    :undocumented: __getstate__, __setstate__, __eq__, __ne__, validate
    cCsdS)N�)�selfrr�J/opt/alt/python35/lib64/python3.5/site-packages/Crypto/PublicKey/pubkey.py�__init__&szpubkey.__init__cCsA|j}x1|jD]&}||krt||�||<qW|S)z�To keep key objects platform-independent, the key data is
        converted to standard Python long integers before being
        written out.  It will then be reconverted as necessary on
        restoration.)�__dict__�keydata�int)r�d�keyrrr�__getstate__)s
	zpubkey.__getstate__cCs;x4|jD])}||kr
t||�|j|<q
WdS)z�On unpickling a key object, the key data is converted to the big
number representation being used, whether that is Python long
integers, MPZ objects, or whatever.N)r	Zbignumr)rrrrrr�__setstate__3szpubkey.__setstate__cCsud}t|t�r't|�}d}t|t�rBt|�}|j||�}|rmttt|��S|SdS)ajEncrypt a piece of data.

        :Parameter plaintext: The piece of data to encrypt.
        :Type plaintext: byte string or long

        :Parameter K: A random parameter required by some algorithms
        :Type K: byte string or long

        :Return: A tuple with two items. Each item is of the same type as the
         plaintext (string or long).
        r�N)�
isinstance�bytes�
bytes_to_longZ_encrypt�tuple�map�
long_to_bytes)r�	plaintext�K�	wasString�
ciphertextrrr�encrypt:szpubkey.encryptcCssd}t|t�s|f}t|dt�rLttt|��}d}|j|�}|rkt|�S|SdS)a.Decrypt a piece of data. 

        :Parameter ciphertext: The piece of data to decrypt.
        :Type ciphertext: byte string, long or a 2-item tuple as returned by `encrypt`

        :Return: A byte string if ciphertext was a byte string or a tuple
         of byte strings. A long otherwise.
        rrN)rrrrrZ_decryptr)rrrrrrr�decryptOs		
zpubkey.decryptcCs^|j�std��t|t�r3t|�}t|t�rNt|�}|j||�S)a
Sign a piece of data.

        :Parameter M: The piece of data to encrypt.
        :Type M: byte string or long

        :Parameter K: A random parameter required by some algorithms
        :Type K: byte string or long

        :Return: A tuple with two items.
        z(Private key not available in this object)�has_private�	TypeErrorrrrZ_sign)r�Mrrrr�signaszpubkey.signcCs+t|t�rt|�}|j||�S)a>Verify the validity of a signature.

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

        :Parameter signature: The signature to verify.
        :Type signature: tuple with two items, as return by `sign`

        :Return: True if the signature is correct, False otherwise.
        )rrrZ_verify)rr�	signaturerrr�verifyrsz
pubkey.verifycCstjdt�dS)Nz0validate() method name is obsolete; use verify())�warnings�warn�DeprecationWarning)rrr rrr�validate�s	zpubkey.validatecCsld}t|t�r't|�}d}t|t�rBt|�}|j||�}|rdt|�S|SdS)a&Blind a message to prevent certain side-channel attacks.
       
        :Parameter M: The message to blind.
        :Type M: byte string or long

        :Parameter B: Blinding factor.
        :Type B: byte string or long

        :Return: A byte string if M was so. A long otherwise.
        rrN)rrrZ_blindr)rr�BrZblindedmessagerrr�blind�s
zpubkey.blindcCsld}t|t�r't|�}d}t|t�rBt|�}|j||�}|rdt|�S|SdS)z�Unblind a message after cryptographic processing.
        
        :Parameter M: The encoded message to unblind.
        :Type M: byte string or long

        :Parameter B: Blinding factor.
        :Type B: byte string or long
        rrN)rrrZ_unblindr)rrr&rZunblindedmessagerrr�unblind�s	
zpubkey.unblindcCsdS)a(Tell if the algorithm can deal with cryptographic signatures.

        This property concerns the *algorithm*, not the key itself.
        It may happen that this particular key object hasn't got
        the private information required to generate a signature.

        :Return: boolean
        rr)rrrr�can_sign�s	zpubkey.can_signcCsdS)aTell if the algorithm can deal with data encryption.
       
        This property concerns the *algorithm*, not the key itself.
        It may happen that this particular key object hasn't got
        the private information required to decrypt data.

        :Return: boolean
        rr)rrrr�can_encrypt�s	zpubkey.can_encryptcCsdS)aTell if the algorithm can deal with data blinding.
       
        This property concerns the *algorithm*, not the key itself.
        It may happen that this particular key object hasn't got
        the private information required carry out blinding.

        :Return: boolean
        rr)rrrr�	can_blind�s	zpubkey.can_blindcCsdS)z_Tell the maximum number of bits that can be handled by this key.

        :Return: int
        rr)rrrr�size�szpubkey.sizecCsdS)zSTell if the key object contains private components.

        :Return: bool
        rr)rrrrr�szpubkey.has_privatecCs|S)zkConstruct a new key carrying only the public information.

        :Return: A new `pubkey` object.
        r)rrrr�	publickey�szpubkey.publickeycCs|j�|j�kS)zF__eq__(other): 0, 1
        Compare us to other for equality.
        )r
)r�otherrrr�__eq__�sz
pubkey.__eq__cCs|j|�S)zH__ne__(other): 0, 1
        Compare us to other for inequality.
        )r/)rr.rrr�__ne__�sz
pubkey.__ne__N)�__name__�
__module__�__qualname__�__doc__rr
rrrrr!r%r'r(r)r*r+r,rr-r/r0rrrrr!s&
r)�__revision__�typesr"ZCrypto.Util.numberrrrrr�<module>s