Ñò
BwLc           @   s  d  Z  d d k Td d k Z d d k Z d d k Z d d k Z d d k l Z d d k l	 Z	 d d k
 l Z d e f d „  ƒ  YZ d	 e f d
 „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ e i ƒ  Z d a d „  Z d „  Z d „  Z d „  Z d S(   s   $Id$iÿÿÿÿ(   t   *N(   t   floor(   t   OSRNG(   t   FortunaAccumulatort   _EntropySourcec           B   s   e  Z d  „  Z d „  Z RS(   c         C   s   | |  _  | |  _ d |  _ d  S(   Ni    (   t   _fortunat   _src_numt	   _pool_num(   t   selft   accumulatort   src_num(    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyt   __init__'   s    		c         C   s4   |  i  i |  i |  i | ƒ |  i d d @|  _ d  S(   Ni   i   (   R   t   add_random_eventR   R   (   R   t   data(    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyt   feed,   s    (   t   __name__t
   __module__R   R   (    (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR   &   s   	t   _EntropyCollectorc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   sI   t  i ƒ  |  _ t | d ƒ |  _ t | d ƒ |  _ t | d ƒ |  _ d  S(   Niÿ   iþ   iý   (   R   t   newt   _osrngR   t	   _osrng_est   _time_est	   _clock_es(   R   R	   (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR   2   s    c         C   sz   xf t  d ƒ D]X } |  i i d ƒ } x7 t  d ƒ D]) } |  i i | | d | d d !ƒ q2 Wd  } q W|  i i ƒ  d  S(   Ni   i    i   i   (   t   rangeR   t   readR   R   t   Nonet   flush(   R   t   it   blockt   p(    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyt   reinit8   s      '
c         C   s˜   |  i  i |  i i d ƒ ƒ t i ƒ  } |  i i t i d t d | t	 | ƒ ƒ ƒ ƒ t i
 ƒ  } |  i i t i d t d | t	 | ƒ ƒ ƒ ƒ d  S(   Ni   s   @Ii   i   i   @i   @(   R   R   R   R   t   timeR   t   structt   packt   intR   t   clockR   (   R   t   t(    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyt   collectB   s
    0(   R   R   R   R   R%   (    (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR   0   s   		
t   _UserFriendlyRNGc           B   s>   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s8   t  |  _ t i ƒ  |  _ t |  i ƒ |  _ |  i ƒ  d  S(   N(   t   Falset   closedR   t   _faR   t   _ecR   (   R   (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR   Q   s    	c         C   s    t  i ƒ  |  _ |  i i ƒ  d S(   sk   Initialize the random number generator and seed it with entropy from
        the operating system.
        N(   t   ost   getpidt   _pidR*   R   (   R   (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR   W   s    c         C   s   t  |  _ d  |  _ d  |  _ d  S(   N(   t   TrueR(   R   R   R)   (   R   (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyt   close^   s    		c         C   s   d  S(   N(    (   R   (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR   c   s    c         C   sŠ   |  i  o t d ƒ ‚ n t | t t f ƒ p t d ƒ ‚ n | d j  o t d ƒ ‚ n |  i i ƒ  |  i i	 | ƒ } |  i
 ƒ  | S(   s   Return N bytes from the RNG.s   I/O operation on closed files   an integer is requiredi    s%   cannot read to end of infinite stream(   R(   t
   ValueErrort
   isinstancet   longR"   t	   TypeErrorR*   R%   R)   t   random_datat
   _check_pid(   R   t   Nt   retval(    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR   f   s    

c         C   s*   t  i ƒ  |  i j o t d ƒ ‚ n d  S(   NsT   PID check failed. RNG must be re-initialized after fork(). Hint: Try Random.atfork()(   R+   R,   R-   t   AssertionError(   R   (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR5   }   s    
(   R   R   R   R   R/   R   R   R5   (    (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR&   O   s   					t   _LockingUserFriendlyRNGc           B   s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C   s    t  i ƒ  |  _ t i |  ƒ d  S(   N(   t	   threadingt   Lockt   _lockR&   R   (   R   (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR   Œ   s    c         C   s3   |  i  i ƒ  z t i |  ƒ SWd  |  i  i ƒ  Xd  S(   N(   R<   t   acquireR&   R/   t   release(   R   (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR/      s    c         C   s3   |  i  i ƒ  z t i |  ƒ SWd  |  i  i ƒ  Xd  S(   N(   R<   R=   R&   R   R>   (   R   (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR   —   s    c         C   s6   |  i  i ƒ  z t i |  | ƒ SWd  |  i  i ƒ  Xd  S(   N(   R<   R=   R&   R   R>   (   R   t   bytes(    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR   ž   s    (   R   R   R   R/   R   R   (    (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR9   ‹   s   			t   RNGFilec           B   s>   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         C   s   t  |  _ | |  _ d  S(   N(   R'   R(   t
   _singleton(   R   t	   singleton(    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR   ¦   s    	c         C   s   d S(   s   PEP 343 supportN(    (   R   (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyt	   __enter__«   s    c         C   s   |  i  ƒ  d S(   s   PEP 343 supportN(   R/   (   R   (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyt   __exit__­   s    c         C   s   t  |  _ d  |  _ d  S(   N(   R.   R(   R   RA   (   R   (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR/   ±   s    	c         C   s*   |  i  o t d ƒ ‚ n |  i i | ƒ S(   Ns   I/O operation on closed file(   R(   R0   RA   R   (   R   R?   (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR   ¶   s    
c         C   s   |  i  o t d ƒ ‚ n d  S(   Ns   I/O operation on closed file(   R(   R0   (   R   (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR   »   s    
(   R   R   R   RC   RD   R/   R   R   (    (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR@   ¥   s   					c           C   s>   t  i ƒ  z" t d  j o t ƒ  a n t SWd  t  i ƒ  Xd  S(   N(   t   _singleton_lockR=   RA   R   R9   R>   (    (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyt   _get_singletonÁ   s    
c           C   s   t  t ƒ  ƒ S(   N(   R@   RF   (    (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR   Ë   s    c           C   s   t  ƒ  i ƒ  d  S(   N(   RF   R   (    (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyR   Î   s    c         C   s   t  ƒ  i |  ƒ S(   sE   Return the specified number of cryptographically-strong random bytes.(   RF   R   (   t   n(    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyt   get_random_bytesÑ   s    (   t   __revision__t   Crypto.Util.python_compatR+   R:   R    R   t   mathR   t   Crypto.RandomR   t   Crypto.Random.FortunaR   t   objectR   R   R&   R9   R@   R;   RE   R   RA   RF   R   R   RH   (    (    (    s]   C:\Documents and Settings\red08xgu\Desktop\python_webupdate\Crypto\Random\_UserFriendlyRNG.pyt   <module>   s&   

<	
		