Current File : //usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pyc
�
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�r,ttd�s(t�dStjd�|j�}t	j
jj�j
�t	j
jd�|j�}|j||�g}x�td�D]�}tj�\}}tj�dkr)tj|�tj|d�}t	j
j�t	j
jd�}|j|�|j�tjd�ntj|�|jtj|d	��q�Wg}	i}
xD|D]<}tj|j��}|	j|�d|
|<|j�qfWt|	�t|
j��kr�td
tj|	���ndS(Ntwintforkg333333�?ii
itwbitrbs'RNG output duplicated across fork():
%s( tsystplatformt
startswiththasattrtostAssertionErrorttimetsleepRRRRRtreinittget_random_bytestassertNotEqualtrangetpipeRtclosetfdopentatforktwritet_exittappendtbinasciithexlifytreadtlentkeystpprinttpformat(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__RR7(((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@tgettlisttzipR tjoinR)tsetRR+R,(
Rtn_procstmanagerR0tqueuestpoolt
map_resulttaatbbtres((sR/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pyR7~s"(
,,


<(R8R9R7(((sR/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pyRA|scCs9g}|t�g7}tdk	r5|t�g7}n|S(N(RRDR<RA(tconfigttests((sR/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pyt	get_tests�s
t__main__cCstjt��S(N(tunittestt	TestSuiteRX(((sR/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pyt<lambda>�stdefaultTesttsuite(t__doc__t
__future__Rt__revision__R&R+RZRRRtversion_infotCrypto.Util.py21compattCrypto.Util.py3compatRDtImportErrorR<tCrypto.Random._UserFriendlyRNGRtCrypto.Random.randomtTestCaseRR@RARXR8R^tmain(((sR/usr/lib64/python2.7/site-packages/Crypto/SelfTest/Random/test__UserFriendlyRNG.pyt<module>s0&



C		$