ó õùPc@sØdZddlZejddkrEejddkrEddlTnddlTddlmZddlZddlZddl m Z ddl Z ddl Z d e fd „ƒYZd „Zd e fd „ƒYZdS(s$Id$iÿÿÿÿNiii(t*(tb2a_hex(tClockRewindWarningt FortunaPoolcBsDeZdZejZd„Zd„Zd„Zd„Zd„Z RS(sgFortuna pool type This object acts like a hash object, with the following differences: - It keeps a count (the .length attribute) of the number of bytes that have been added to the pool - It supports a .reset() method for in-place reinitialization - The method to add bytes to the pool is .append(), not .update(). cCs|jƒdS(N(treset(tself((sC..\python\site-packages\Crypto\Random\Fortuna\FortunaAccumulator.pyt__init__6scCs)|jj|ƒ|jt|ƒ7_dS(N(t_htupdatetlengthtlen(Rtdata((sC..\python\site-packages\Crypto\Random\Fortuna\FortunaAccumulator.pytappend9scCs |jjƒS(N(Rtdigest(R((sC..\python\site-packages\Crypto\Random\Fortuna\FortunaAccumulator.pyR =scCs=tjddkr#t|jƒƒSt|jƒƒjƒSdS(Nii(tsyst version_infoRR tdecode(R((sC..\python\site-packages\Crypto\Random\Fortuna\FortunaAccumulator.pyt hexdigest@scCstjƒ|_d|_dS(Ni(tSHAd256tnewRR (R((sC..\python\site-packages\Crypto\Random\Fortuna\FortunaAccumulator.pyRFs( t__name__t __module__t__doc__Rt digest_sizeRR R RR(((sC..\python\site-packages\Crypto\Random\Fortuna\FortunaAccumulator.pyR)s      cCsh|dkst‚g}d}xCtdƒD]5}||@dkrQ|j|ƒnP|d>dB}q+W|S(s?Return a list of pools indexes (in range(32)) that are to be included during reseed number r. According to _Practical Cryptography_, chapter 10.5.2 "Pools": "Pool P_i is included if 2**i is a divisor of r. Thus P_0 is used every reseed, P_1 every other reseed, P_2 every fourth reseed, etc." iii l(tAssertionErrortrangeR (trtretvaltmaskti((sC..\python\site-packages\Crypto\Random\Fortuna\FortunaAccumulator.pyt which_poolsJs tFortunaAccumulatorcBs;eZdZdZd„Zd„Zdd„Zd„ZRS(i@gš™™™™™¹?cCsjd|_tjƒ|_d|_gtdƒD]}tƒ^q.|_|jd|jdk sft ‚dS(Nii i( t reseed_counttFortunaGeneratort AESGeneratort generatortNonet last_reseedRRtpoolsR(RR((sC..\python\site-packages\Crypto\Random\Fortuna\FortunaAccumulator.pyRds   %cCs¤tjƒ}|jdk rF|j|krFtjdtƒd|_n|jdj|jkr”|jdks„||j|j kr”|j |ƒn|j j |ƒS(Ns-Clock rewind detected. Resetting last_reseed.i( ttimeR%R$twarningstwarnRR&R t min_pool_sizetreseed_intervalt_reseedR#tpseudo_random_data(Rtbytest current_time((sC..\python\site-packages\Crypto\Random\Fortuna\FortunaAccumulator.pyt random_dataps  cCs§|dkrtjƒ}ng}|jd7_||_xBt|jƒD]1}|j|j|jƒƒ|j|jƒqIWt dƒj |ƒ}|j j |ƒdS(Nit( R$R'R R%RR R&R RtbtjoinR#treseed(RR/tseedR((sC..\python\site-packages\Crypto\Random\Fortuna\FortunaAccumulator.pyR,|s  cCs¾dt|ƒkodkns(t‚d|ko?dknsJt‚d|koadknslt‚|j|jt|ƒƒ|j|jtt|ƒƒƒ|j|j|ƒdS(Nii iiÿi(R RR&R tbchr(Rt source_numbert pool_numberR ((sC..\python\site-packages\Crypto\Random\Fortuna\FortunaAccumulator.pytadd_random_event‰s ("" N( RRR*R+RR0R$R,R9(((sC..\python\site-packages\Crypto\Random\Fortuna\FortunaAccumulator.pyR_s  (t __revision__RRtCrypto.Util.py21compattCrypto.Util.py3compattbinasciiRR'R(tCrypto.pct_warningsRRR!tobjectRRR(((sC..\python\site-packages\Crypto\Random\Fortuna\FortunaAccumulator.pyts &      !