Current File : //usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pyo
�
Bd\Rc@sVdZddlmZdZddlZddlZddlZddlZddlZddl	Z	e	j
ddkr�e	j
ddkr�ddlTnddlTyddl
Z
Wnek
r�dZ
nXddlZddlZd	ejfd
��YZd�Zdejfd
��YZid�ZedkrRd�Zejdd�ndS(s0Self-test suite for generic Crypto.Random stuff i����(t
nested_scopess$Id$Niii(t*tRNGForkTestcBseZd�Zd�ZRS(cCsBtjjj�}|jj�z|jjSWd|jj�XdS(s�
        Get `FortunaAccumulator.reseed_count`, the global count of the
        number of times that the PRNG has been reseeded.
        N(	tCryptotRandomt_UserFriendlyRNGt_get_singletont_locktacquiret_fatreseed_counttrelease(tselft
rng_singleton((sR/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pyt_get_reseed_count2s

cCs�tjjd�rdStjd�|j�}tjjj	�j
�tjjd�|j�}|j||�g}x�t
d�D]�}tj�\}}tj�dkrtj|�tj|d�}tjj�tjjd�}|j|�|j�tjd�ntj|�|jtj|d��q�Wg}	i}
xD|D]<}tj|j��}|	j|�d|
|<|j�qPWt|	�t|
j��kr�td	tj|	���ndS(
Ntwing333333�?ii
itwbitrbs'RNG output duplicated across fork():
%s(tsystplatformt
startswithttimetsleepRRRRRtreinittget_random_bytestassertNotEqualtrangetostpipetforktclosetfdopentatforktwritet_exittappendtbinasciithexlifytreadtlentkeystAssertionErrortpprinttpformat(Rtreseed_count_beforetreseed_count_aftertrfilestitrfdtwfdtftdatatresultstresults_dict((sR/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pytrunTest>s>








(t__name__t
__module__RR6(((sR/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pyR0s	cCsntjjd�}tjd�tjjd�}|jtj|��|jtj|��|jd�dS(Nig�������?(	RRRRRtputR$tb2a_hextNone(tqtatb((sR/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pyt
_task_mainss
tRNGMultiprocessingForkTestcBseZd�ZRS(c
Cs�d}tj�}gt|�D]}|jd�^q}tjd�tjjj	�j
�tjjd�tjd|dtjj
�}|jt|�}gt|�D]}||jd�^q�}gt|�D]}||jd�^q�}tt||��}	|jd�|j�|j�tt|��t|�ksgtt|	��t|	�kr�tdtj|	�f��ndS(Niig333333�?t	processestinitializeris'RNG output duplicated across fork():
%s(tmultiprocessingtManagerRtQueueRRRRRRRRtPoolR t	map_asyncR?tgettlisttzipRtjoinR'tsetR)R*R+(
Rtn_procstmanagerR/tqueuestpoolt
map_resulttaatbbtres((sR/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pyR6~s"(
,,


<(R7R8R6(((sR/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pyR@|scCs9g}|t�g7}tdk	r5|t�g7}n|S(N(RRCR;R@(tconfigttests((sR/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pyt	get_tests�s
t__main__cCstjt��S(N(tunittestt	TestSuiteRW(((sR/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pyt<lambda>�stdefaultTesttsuite(t__doc__t
__future__Rt__revision__R$R*RYRRRtversion_infotCrypto.Util.py21compattCrypto.Util.py3compatRCtImportErrorR;tCrypto.Random._UserFriendlyRNGRtCrypto.Random.randomtTestCaseRR?R@RWR7R]tmain(((sR/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pyt<module>s0&



C		$