ó õùPc@sMdZddlZejddkrEejddkrEddlTnddlZddlZddlZddlZddlm Z ddl m Z dd l m Z d efd „ƒYZd efd „ƒYZdefd„ƒYZdefd„ƒYZdefd„ƒYZejƒZdad„Zd„Zd„Zd„ZdS(s$Id$iÿÿÿÿNiii(t*(tfloor(tOSRNG(tFortunaAccumulatort_EntropySourcecBseZd„Zd„ZRS(cCs||_||_d|_dS(Ni(t_fortunat_src_numt _pool_num(tselft accumulatortsrc_num((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyt__init__)s  cCs4|jj|j|j|ƒ|jdd@|_dS(Nii(Rtadd_random_eventRR(Rtdata((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pytfeed.s(t__name__t __module__R R(((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR(s t_EntropyCollectorcBs#eZd„Zd„Zd„ZRS(cCsItjƒ|_t|dƒ|_t|dƒ|_t|dƒ|_dS(Niÿiþiý(Rtnewt_osrngRt _osrng_est_time_est _clock_es(RR ((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR 4scCszxftdƒD]X}|jjdƒ}x7tdƒD])}|jj||d|dd!ƒq2Wd}q W|jjƒdS(Nii ii(trangeRtreadRRtNonetflush(Rtitblocktp((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pytreinit:s ' cCs˜|jj|jjdƒƒtjƒ}|jjtjdtd|t |ƒƒƒƒtj ƒ}|j jtjdtd|t |ƒƒƒƒdS(Nis@Iiii@i@( RRRRttimeRtstructtpacktintRtclockR(Rtt((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pytcollectDs  0 (RRR RR%(((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR2s  t_UserFriendlyRNGcBs>eZd„Zd„Zd„Zd„Zd„Zd„ZRS(cCs8t|_tjƒ|_t|jƒ|_|jƒdS(N(tFalsetclosedRt_faRt_ecR(R((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR Ss cCs tjƒ|_|jjƒdS(skInitialize the random number generator and seed it with entropy from the operating system. N(tostgetpidt_pidR*R(R((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyRYscCst|_d|_d|_dS(N(tTrueR(RRR)(R((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pytclose`s  cCsdS(N((R((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyRescCs„|jrtdƒ‚nt|ttfƒs<tdƒ‚n|dkrWtdƒ‚n|jjƒ|jj |ƒ}|j ƒ|S(sReturn N bytes from the RNG.sI/O operation on closed filesan integer is requiredis%cannot read to end of infinite stream( R(t ValueErrort isinstancetlongR"t TypeErrorR*R%R)t random_datat _check_pid(RtNtretval((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyRhs    cCs(tjƒ|jkr$tdƒ‚ndS(NsTPID check failed. RNG must be re-initialized after fork(). Hint: Try Random.atfork()(R+R,R-tAssertionError(R((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR5s (RRR RR/RRR5(((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR&Qs      t_LockingUserFriendlyRNGcBs,eZd„Zd„Zd„Zd„ZRS(cCs tjƒ|_tj|ƒdS(N(t threadingtLockt_lockR&R (R((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR ŽscCs3|jjƒztj|ƒSWd|jjƒXdS(N(R<tacquireR&R/trelease(R((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR/’s cCs3|jjƒztj|ƒSWd|jjƒXdS(N(R<R=R&RR>(R((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR™s cCs6|jjƒztj||ƒSWd|jjƒXdS(N(R<R=R&RR>(Rtbytes((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR s (RRR R/RR(((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR9s   tRNGFilecBs>eZd„Zd„Zd„Zd„Zd„Zd„ZRS(cCst|_||_dS(N(R'R(t _singleton(Rt singleton((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR ¨s cCsdS(sPEP 343 supportN((R((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyt __enter__­scCs|jƒdS(sPEP 343 supportN(R/(R((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyt__exit__¯scCst|_d|_dS(N(R.R(RRA(R((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR/³s cCs(|jrtdƒ‚n|jj|ƒS(NsI/O operation on closed file(R(R0RAR(RR?((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR¸s cCs|jrtdƒ‚ndS(NsI/O operation on closed file(R(R0(R((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR½s (RRR RCRDR/RR(((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyR@§s      cCs<tjƒz tdkr%tƒantSWdtjƒXdS(N(t_singleton_lockR=RARR9R>(((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyt_get_singletonÃs    cCs ttƒƒS(N(R@RF(((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyRÍscCstƒjƒdS(N(RFR(((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyRÐscCstƒj|ƒS(sEReturn the specified number of cryptographically-strong random bytes.(RFR(tn((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pytget_random_bytesÓs(t __revision__tsyst version_infotCrypto.Util.py21compatR+R:R RtmathRt Crypto.RandomRtCrypto.Random.FortunaRtobjectRRR&R9R@R;RERRARFRRRH(((s9..\python\site-packages\Crypto\Random\_UserFriendlyRNG.pyts* &      <