U mf@sUddlZddlZddlZddlZddlZddlmZmZGdddZeZ eee d<z e Z Wne k r~dZ YnXedddZeeed d d ZdS) N)AnyOptionalc@seZdZdeedddZeddddZedddd Zdd d d Ze d d dZ e d ddZ e d ddZ e e e dddZ dS) EntropyPoolN)seedcCspd|_d|_d|_t|_t|_d|_ t d|j |_ |dk r`| |d|_ t|_n d|_ d|_dS)NrTF) pool_indexdigest next_byte threadingLocklockhashlibsha1hashhash_len bytearraypool_stirseededosgetpidseed_pid)selfrr9/opt/hc_python/lib/python3.8/site-packages/dns/entropy.py__init__ s    zEntropyPool.__init__)entropyreturncCsJ|D]@}|j|jkrd|_|d@}|j|j|N<|jd7_qdS)Nr)rrr)rrcbrrrr0s  zEntropyPool._stirc Cs |j||W5QRXdS)N)r r)rrrrrstir8szEntropyPool.stirrc Cs|jr|jtkrztd}Wn`tk rz&tddd}|d}W5QRXWn$tk r|tt  }YnXYnXd|_t|_d|_ t |}| |dS)Nz /dev/urandomrbrT)rrrrurandom Exceptionopenreadstrtimeencoder rr)rrrrrr _maybe_seed<s zEntropyPool._maybe_seedc Cs|jr||jdks&|j|jkrZ|jt|jt |j|_| |jd|_|j|j}|jd7_W5QRX|S)Nrr ) r r/r r rrupdatebytesrrr)rvaluerrrrandom_8Ls  zEntropyPool.random_8cCs|d|S)N)r3rrrr random_16XszEntropyPool.random_16cCs|d|S)N)r6r5rrr random_32[szEntropyPool.random_32firstlastrcCsd||d}|dkrtd|dkr0|j}d}n|dkrD|j}d}n |j}d}||||dS) Nr lztoo bigr7lr4ir) ValueErrorr8r6r3)rr:r;sizeZrandmaxrrrrandom_between^s zEntropyPool.random_between)N)__name__ __module__ __qualname__rr1rrr#r/intr3r6r8r?rrrrrs r system_randomr$cCs tdk rtddStSdS)Nrr7)rD randrangerr6rrrrr6ws r6r9cCs(tdk rt||dSt||SdS)Nr )rDrErr?)r:r;rrrbetween~srF)rrrandomr r,typingrrrr__annotations__ SystemRandomrDr(rCr6rFrrrrsT