ó
BwLc           @   s?   d  Z  d d l Z d d l Z d d l Td d d „  ƒ  YZ d S(   s   $Id$iÿÿÿÿN(   t   *t   pubkeyc           B   sª   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s   d  S(   N(    (   t   self(    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   __init__"   s    c         C   sG   |  j  } x7 |  j D], } | j | ƒ r t | | ƒ | | <q q W| S(   sÐ   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.(   t   __dict__t   keydatat   has_keyt   long(   R   t   dt   key(    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   __getstate__%   s
    	 c         C   sA   x: |  j  D]/ } | j | ƒ r
 t | | ƒ |  j | <q
 q
 Wd S(   s¢   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   R   t   bignumR   (   R   R   R	   (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   __setstate__/   s     c         C   s   d } t  | t j ƒ r- t | ƒ } d } n  t  | t j ƒ rN t | ƒ } n  |  j | | ƒ } | ry t t t | ƒ ƒ S| Sd S(   s­   encrypt(plaintext:string|long, K:string|long) : tuple
        Encrypt the string or integer plaintext.  K is a random
        parameter required by some algorithms.
        i    i   N(   t
   isinstancet   typest
   StringTypet   bytes_to_longt   _encryptt   tuplet   mapt   long_to_bytes(   R   t	   plaintextt   Kt	   wasStringt
   ciphertext(    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   encrypt6   s     	 c         C   s   d } t  | t j ƒ s$ | f } n  t  | d t j ƒ rX t t t | ƒ ƒ } d } n  |  j | ƒ } | rw t | ƒ S| Sd S(   sc   decrypt(ciphertext:tuple|string|long): string
        Decrypt 'ciphertext' using this key.
        i    i   N(	   R   R   t	   TupleTypeR   R   R   R   t   _decryptR   (   R   R   R   R   (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   decryptD   s     	 
c         C   sm   |  j  ƒ  s t d ƒ ‚ n  t | t j ƒ r< t | ƒ } n  t | t j ƒ r] t | ƒ } n  |  j | | ƒ S(   sµ   sign(M : string|long, K:string|long) : tuple
        Return a tuple containing the signature for the message M.
        K is a random parameter required by some algorithms.
        s(   Private key not available in this object(   t   has_privatet	   TypeErrorR   R   R   R   t   _sign(   R   t   MR   (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   signQ   s      c         C   s1   t  | t j ƒ r! t | ƒ } n  |  j | | ƒ S(   s¦   verify(M:string|long, signature:tuple) : bool
        Verify that the signature is valid for the message M;
        returns true if the signature checks out.
        (   R   R   R   R   t   _verify(   R   R    t	   signature(    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   verify\   s     c         C   s   t  j d t ƒ d  S(   Ns0   validate() method name is obsolete; use verify()(   t   warningst   warnt   DeprecationWarning(   R   R    R#   (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   validatee   s    	c         C   sx   d } t  | t j ƒ r- t | ƒ } d } n  t  | t j ƒ rN t | ƒ } n  |  j | | ƒ } | rp t | ƒ S| Sd S(   so   blind(M : string|long, B : string|long) : string|long
        Blind message M using blinding factor B.
        i    i   N(   R   R   R   R   t   _blindR   (   R   R    t   BR   t   blindedmessage(    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   blindi   s     	  
c         C   sx   d } t  | t j ƒ r- t | ƒ } d } n  t  | t j ƒ rN t | ƒ } n  |  j | | ƒ } | rp t | ƒ S| Sd S(   ss   unblind(M : string|long, B : string|long) : string|long
        Unblind message M using blinding factor B.
        i    i   N(   R   R   R   R   t   _unblindR   (   R   R    R*   R   t   unblindedmessage(    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   unblindu   s     	  
c         C   s   d S(   s  can_sign() : bool
        Return a Boolean value recording whether this algorithm can
        generate signatures.  (This does not imply that this
        particular key object has the private information required to
        to generate a signature.)
        i   (    (   R   (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   can_sign…   s    c         C   s   d S(   sü   can_encrypt() : bool
        Return a Boolean value recording whether this algorithm can
        encrypt data.  (This does not imply that this
        particular key object has the private information required to
        to decrypt a message.)
        i   (    (   R   (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   can_encryptŽ   s    c         C   s   d S(   sö   can_blind() : bool
        Return a Boolean value recording whether this algorithm can
        blind data.  (This does not imply that this
        particular key object has the private information required to
        to blind a message.)
        i    (    (   R   (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt	   can_blind—   s    c         C   s   d S(   s`   size() : int
        Return the maximum number of bits that can be handled by this key.
        i    (    (   R   (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   size£   s    c         C   s   d S(   sw   has_private() : bool
        Return a Boolean denoting whether the object contains
        private components.
        i    (    (   R   (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyR   ©   s    c         C   s   |  S(   sd   publickey(): object
        Return a new key object containing only the public information.
        (    (   R   (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt	   publickey°   s    c         C   s   |  j  ƒ  | j  ƒ  k S(   sF   __eq__(other): 0, 1
        Compare us to other for equality.
        (   R
   (   R   t   other(    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   __eq__¶   s    c         C   s   |  j  | ƒ S(   sH   __ne__(other): 0, 1
        Compare us to other for inequality.
        (   R6   (   R   R5   (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   __ne__¼   s    (   t   __name__t
   __module__R   R
   R   R   R   R!   R$   R(   R,   R/   R0   R1   R2   R3   R   R4   R6   R7   (    (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyR   !   s$   		
																		(    (   t   __revision__R   R%   t   Crypto.Util.numberR   (    (    (    s;   /usr/lib/python2.7/dist-packages/Crypto/PublicKey/pubkey.pyt   <module>   s   
