Ñò
BwLc           @   sœ   d  Z  d Z d g Z d d k Td d k l Z l Z d e f d „  ƒ  YZ d e	 f d	 „  ƒ  YZ
 d d d d d
 „ Z d e	 f d „  ƒ  YZ d d „ Z d S(   sU   Pure Python implementation of the RSA-related portions of Crypto.PublicKey._fastmath.s   $Id$t   rsa_constructiÿÿÿÿ(   t   *(   t   sizet   inverset   errorc           B   s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyR   #   s   t   _RSAKeyc           B   sP   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   c         C   s   | t  | |  i |  i ƒ S(   N(   t   powt   et   n(   t   selft   mt   r(    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyt   _blind'   s    c         C   s   t  | |  i ƒ | |  i S(   N(   R   R
   (   R   R   R   (    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyt   _unblind+   s    c         C   s3   |  i  ƒ  p t d ƒ ‚ n t | |  i |  i ƒ S(   Ns   No private key(   t   has_privatet	   TypeErrorR   t   dR
   (   R   t   c(    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyt   _decrypt/   s    c         C   s   t  | |  i |  i ƒ S(   N(   R   R	   R
   (   R   R   (    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyt   _encrypt5   s    c         C   s*   |  i  ƒ  p t d ƒ ‚ n |  i | ƒ S(   Ns   No private key(   R   R   R   (   R   R   (    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyt   _sign9   s    c         C   s   |  i  | ƒ | j S(   N(   R   (   R   R   t   sig(    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyt   _verify>   s    c         C   s   t  |  d ƒ S(   NR   (   t   hasattr(   R   (    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyR   A   s    c         C   s   t  |  i ƒ d S(   s7   Return the maximum number of bits that can be encryptedi   (   R   R
   (   R   (    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyR   D   s    (
   R   R   R   R   R   R   R   R   R   R   (    (    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyR   &   s   							c         C   sq  t  |  t ƒ p t ‚ t  | t ƒ p t ‚ t  | t t d ƒ f ƒ p t ‚ t  | t t d ƒ f ƒ p t ‚ t  | t t d ƒ f ƒ p t ‚ t  | t t d ƒ f ƒ p t ‚ t ƒ  } |  | _ | | _ | d j	 o | | _ n | d j	 o | | _	 n | d j	 o | | _
 n | d j	 o | | _ n1 | d j	 o# | d j	 o t | | ƒ | _ n | S(   s   Construct an RSAKey objectN(   t
   isinstancet   longt   AssertionErrort   typet   NoneR   R
   R	   R   t   pt   qt   uR   (   R
   R	   R   R   R    R!   t   obj(    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyR    H   s(    ####			   t   _DSAKeyc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   s   t  |  i ƒ d S(   s7   Return the maximum number of bits that can be encryptedi   (   R   R   (   R   (    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyR   ]   s    c         C   s   t  |  d ƒ S(   Nt   x(   R   (   R   (    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyR   a   s    c         C   s¥   |  i  ƒ  p t d ƒ ‚ n d | j  o |  i j  n p t d ƒ ‚ n t | |  i ƒ } t |  i | |  i ƒ |  i } | | |  i | |  i } | | f S(   Ns   No private keyl    s   k is not between 2 and q-1(	   R   R   R    t
   ValueErrorR   R   t   gR   R$   (   R   R   t   kt   inv_kR   t   s(    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyR   d   s    !c         C   sÃ   d | j  o |  i  j  n p" d | j  o |  i  j  n o t St | |  i  ƒ } | | |  i  } | | |  i  } t |  i | |  i ƒ t |  i | |  i ƒ |  i |  i  } | | j S(   Ni    (   R    t   FalseR   R   R&   R   t   y(   R   R   R   R)   t   wt   u1t   u2t   v(    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyR   o   s    D<(   R   R   R   R   R   R   (    (    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyR#   \   s   			c         C   sÊ   t  |  t ƒ p t ‚ t  | t ƒ p t ‚ t  | t ƒ p t ‚ t  | t ƒ p t ‚ t  | t t d  ƒ f ƒ p t ‚ t ƒ  } |  | _ | | _ | | _ | | _	 | d  j	 o | | _
 n | S(   N(   R   R   R   R   R   R#   R+   R&   R   R    R$   (   R+   R&   R   R    R$   R"   (    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyt   dsa_constructy   s    #					 N(   t   __doc__t   __revision__t   __all__t   Crypto.Util.python_compatt   Crypto.Util.numberR   R   t	   ExceptionR   t   objectR   R   R    R#   R0   (    (    (    sY   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\PublicKey\_slowmath.pyt   <module>   s   	
"