Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/Crypto/Random/Fortuna/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/Crypto/Random/Fortuna/FortunaAccumulator.pyc

ó
T:´Nc@sØdZddlZejddkrEejddkrEddlTnddlTddlmZddlZddlZddl	m
Z
ddlZddlZd	e
fd
„ƒYZd„Zde
fd
„ƒYZdS(s$Id$iÿÿÿÿNiii(t*(tb2a_hex(tClockRewindWarningtFortunaPoolcBsDeZdZejZd„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((sL/usr/lib/python2.7/dist-packages/Crypto/Random/Fortuna/FortunaAccumulator.pyt__init__6scCs)|jj|ƒ|jt|ƒ7_dS(N(t_htupdatetlengthtlen(Rtdata((sL/usr/lib/python2.7/dist-packages/Crypto/Random/Fortuna/FortunaAccumulator.pytappend9scCs
|jjƒS(N(Rtdigest(R((sL/usr/lib/python2.7/dist-packages/Crypto/Random/Fortuna/FortunaAccumulator.pyR
=scCs=tjddkr#t|jƒƒSt|jƒƒjƒSdS(Nii(tsystversion_infoRR
tdecode(R((sL/usr/lib/python2.7/dist-packages/Crypto/Random/Fortuna/FortunaAccumulator.pyt	hexdigest@scCstjƒ|_d|_dS(Ni(tSHAd256tnewRR	(R((sL/usr/lib/python2.7/dist-packages/Crypto/Random/Fortuna/FortunaAccumulator.pyRFs(
t__name__t
__module__t__doc__Rtdigest_sizeRRR
RR(((sL/usr/lib/python2.7/dist-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((sL/usr/lib/python2.7/dist-packages/Crypto/Random/Fortuna/FortunaAccumulator.pytwhich_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	generatortNonetlast_reseedRRtpoolsR(RR((sL/usr/lib/python2.7/dist-packages/Crypto/Random/Fortuna/FortunaAccumulator.pyRds
		%cCs¤tjƒ}|jdk	rF|j|krFtjdtƒd|_n|jdj|jkr”|jdks„||j|j	kr”|j
|ƒn|jj|ƒ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((sL/usr/lib/python2.7/dist-packages/Crypto/Random/Fortuna/FortunaAccumulator.pytrandom_datapscCs§|dkrtjƒ}ng}|jd7_||_xBt|jƒD]1}|j|j|jƒƒ|j|jƒqIWt	dƒj
|ƒ}|jj|ƒdS(Nit(
R$R'R R%RRR&R
RtbtjoinR#treseed(RR/tseedR((sL/usr/lib/python2.7/dist-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_numbertpool_numberR((sL/usr/lib/python2.7/dist-packages/Crypto/Random/Fortuna/FortunaAccumulator.pytadd_random_event‰s("" N(	RRR*R+RR0R$R,R9(((sL/usr/lib/python2.7/dist-packages/Crypto/Random/Fortuna/FortunaAccumulator.pyR_s		
(t__revision__RRtCrypto.Util.py21compattCrypto.Util.py3compattbinasciiRR'R(tCrypto.pct_warningsRRR!tobjectRRR(((sL/usr/lib/python2.7/dist-packages/Crypto/Random/Fortuna/FortunaAccumulator.pyt<module>s&

!