Ñò
ðgcJc           @   sb   d  Z  d d k l Z d d k l Z d d k l Z d „  Z d „  Z d e	 f d „  ƒ  YZ
 d	 S(
   s,   
Utility functions for dealing with primes.
iÿÿÿÿ(   t   number(   t   util(   t   SSHExceptionc         C   sß   t  d |  d ƒ d } xÁ t o¹ | i |  d d ƒ } | d j o& t t | d ƒ | @ƒ | d } n t i | d ƒ } | d O} | d |  d >O} x t i | ƒ p | d 7} qœ Wt i	 | ƒ |  j o Pq q W| S(   s$   primtive attempt at prime generationi   i   i   i   i    (
   t   powt   Truet	   get_bytest   chrt   ordR   t   inflate_longR    t   isPrimet
   bit_length(   t   bitst   randpoolt
   hbyte_maskt   xt   n(    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\primes.pyt   _generate_prime   s     &
 
c         C   s±   t  i | d ƒ } | d d } t d | d ƒ d } xr t oj |  i | ƒ } | d j o& t t | d ƒ | @ƒ | d } n t  i | d ƒ } | | j  o Pq; q; W| S(   s    returns a random # from 0 to N-1i   i   i   i   i    (   R   R
   R   R   R   R   R   R   (   t   rpoolR   R   t   bytesR   R   t   num(    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\primes.pyt   _roll_random.   s     &
t   ModulusPackc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   sx   
    convenience object for holding the contents of the /etc/ssh/moduli file,
    on systems that have such a file.
    c         C   s   h  |  _  g  |  _ | |  _ d  S(   N(   t   packt	   discardedR   (   t   selfR   (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\primes.pyt   __init__J   s    		c   
      C   sh  | i  ƒ  \ } } } } } } } t | ƒ } t | ƒ } t | ƒ } t | ƒ } t | ƒ } t | d ƒ } | d j  p2 | d j  p% | d @o5 | d j  o( | d j  o |  i i | d f ƒ d  S| d j o
 d } n t i | ƒ }	 |	 | j o0 |	 | d j o |  i i | d	 | f ƒ d  S|	 |  i j o g  |  i |	 <n |  i |	 i | | f ƒ d  S(
   Ni   i   i   i   id   s    does not meet basic requirementsi    i   s"   incorrectly reported bit length %d(   t   splitt   intt   longR   t   appendR   R
   R   (
   R   t   linet	   timestampt   mod_typet   testst   triest   sizet	   generatort   modulust   bl(    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\primes.pyt   _parse_modulusP   s&    !?
c         C   sŒ   h  |  _  t | d ƒ } xc | D][ } | i ƒ  } t | ƒ d j p | d d j o q n y |  i | ƒ Wq q q Xq W| i ƒ  d S(   sL   
        @raise IOError: passed from any file operations that fail.
        t   ri    t   #N(   R   t   opent   stript   lenR'   t   close(   R   t   filenamet   fR   (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\primes.pyt	   read_filen   s    	 $c      	   C   sH  |  i  i ƒ  } | i ƒ  t | ƒ d j o t d ƒ ‚ n d } xL | D]D } | | j o1 | | j  o$ | | j  p | d j o
 | } qI qI W| d j oF xC | D]7 } | | j o$ | | j  o | | j o
 | } q¥ q¥ Wn | d j o) | d } | | j o | d } qn t |  i t |  i  | ƒ ƒ } |  i  | | S(   Ni    s   no moduli availableiÿÿÿÿ(   R   t   keyst   sortR,   R   R   R   (   R   t   mint   prefert   maxt   bitsizest   goodt   bR   (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\primes.pyt   get_modulus~   s(    
 4 '
(   t   __name__t
   __module__t   __doc__R   R'   R0   R9   (    (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\primes.pyR   D   s
   			N(   R<   t   Crypto.UtilR    t   paramikoR   t   paramiko.ssh_exceptionR   R   R   t   objectR   (    (    (    sN   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\paramiko\primes.pyt   <module>   s   		