ffF!dZddlZddlZddlTddlmZddlmZddlm Z Gdde Z Gd d ej Z Gd d ej Zifd ZedkrdZejddSdS)z+Self-tests for (some of) Crypto.Util.numberN)*)list_test_cases)number) long_to_bytesceZdZdZdS)MyErrorzDummy exception used for testsN)__name__ __module__ __qualname____doc__/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/SelfTest/Util/test_number.pyrr%s((((rrc,eZdZdZdZdZdZdZdS) MiscTestsc |ttjdd|ttjdd|ttjdd|dtjdd|dtjdd|dtjdd|dtjdd|dtjdd|dtjdd|dtjdd|dtjdd|dtjdd|dtjdd|dtjdd|dtjdd|dtjdd|dtjdd|dtjdd|dtjdd|dtjd d|dtjd d|dtjdd|dtjdd|dtjdd|dtjdd|dtjdd|dtjdd|dtjd d|dtjd d|dtjd d|dtjd dd S)zUtil.number.ceil_div1r N) assertRaises TypeErrorrceil_divZeroDivisionError assertEqualselfs r test_ceil_divzMiscTests.test_ceil_div-s )V_c1=== +V_aCCC +V_b!DDD FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq11222 FOAq1122222rc|ttjd|ttjd|ttjdd}t dD]S}tj|}||d|dz zkd||d|zkdTd}tj|}||dzd||d|dz zkd||d|zkddS) zUtil.number.getPrimeirrrdrN)r ValueErrorrgetPrimeranger"assertNotEqual)r$bitsixs r test_getPrimezMiscTests.test_getPrimeWs2 *fot<<< *foq999 *foq999s 1 1A%%A   Q1q=11 5 5 5   Q!t)_a 0 0 0 0 OD ! ! AE1%%% qD1H}-q111 a4i!,,,,,rc|ttjd|ttjdd}tj|}||dzd||d|dz zdz kd||d|zkdd}tj||}|tj|dz |d||dzd||d|dz zdz kd||d|zkdd}tj||}|tj|dz dz |d||dzd||d|dz zdz kd||d|zkdd S) zUtil.number.getStrongPrimeir(rrriiN)rr)rgetStrongPrimer,r"GCD)r$r-r/es rtest_getStrongPrimezMiscTests.test_getStrongPrimeis *f&;SAAA *f&;SAAA  !$ ' ' AE1%%% a46k1_,a000 a4i!,,,   !$ * * AaC++Q/// AE1%%% a46k1_,a000 a4i!,,,   !$ * * QqS1Ha00!444 AE1%%% a46k1_,a000 a4i!,,,,,rc|tjdd|tjdd|tjdd|tjdd|tjdd|tjdd|tjdd zdz d|tjdd zdz dd D]7}|tjt|d8d S) zUtil.number.isPrimeFrrTrri) iiidlu^l+%!alMnz]lg4+lI>6lS{AKW lb\\QNlzIlv3l_VB;.(N)r"risPrimeint)r$ composites r test_isPrimezMiscTests.test_isPrimes_ ++U333 ++U333 **E222 **D111 **D111 **E222 4 22D999 !T'!) 55u===L D DI   V^C NN;;U C C C C  D Drc|tjdd|tjdd|tjdd|tjdd|tjdd|ttjd dS) Nrrri@lE)8^n, n:zb|DELU"N79Y Sh "*f8<>ktk26"zBT6 VRNcc\]]rX" Sw~o 8I(jO32 ir)r"rsizerr)r#s r test_sizezMiscTests.test_sizes Q*** Q*** T**1--- X..s333 &hiiko p p p *fk266666rN)r r r r%r0r6r=rBr rrrr+sc(3(3(3T---$---,DDD&77777rrc eZdZdZdZdZdS) LongTestsc|tdd|tdd|tdd|tdd|tdd|td d |td d dS) Nrrr2lslw*M s"3DUfwlLUs "3DUfwr"rr#s rtest1zLongTests.test1s q))7333 q))7333 u--{;;; |446MNNN |446MNNN '9::<_``` ';<<>efffffrc|tddd|tddd|tddd|tddd |td dd |td dd |tddd|tddd|tddd|tddddS)NrrrFrsrsisisr2rHlrsrs s  s rIr#s rtest2zLongTests.test2sM q!,,g666 q!,,k::: q!,,o>>> ua00+>>> ua002EFFF ua00+>>> |Q779TUUU |Q779\]]] |R88:efff |R88:ijjjjjrcH|ttddS)Nr)rr)rr#s r test_err1zLongTests.test_err1s  *mR88888rN)r r r rJrNrPr rrrDrDsGggg k k k99999rrDcfg}|ttz }|ttz }|SN)rrrD)configtestss r get_testsrUs0 E _Y ' ''E _Y ' ''E Lr__main__cBtjtSrR)unittest TestSuiterUr rrrZsH&y{{33rsuite) defaultTest)r mathrXCrypto.Util.py3compatCrypto.SelfTest.st_commonr Crypto.UtilrCrypto.Util.numberr ExceptionrTestCaserrDrUr r[mainr rrres?221 ####555555,,,,,,)))))i))) m7m7m7m7m7!m7m7m7`99999!9996  z 3 3EHMg&&&&&&r