ff&ZdZddlZddlZddlZddlZddlZddlmZmZddl m Z m Z ddl m Z dZGddejZGd d ejZGd d ejZGd dejZGddejZGddejZdifdZdZdS)z&Self-testing for PyCrypto hash modulesN)hexlify unhexlify)btobytes)strxor_ccftjddt|}t|S)Ns\s+)resubrr) hex_stringshorters }/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/SelfTest/Hash/common.pyt2br$s+fWc7:#6#677G W  r c eZdZdZdZdZdS)HashDigestSizeSelfTestc|tj|||_||_||_||_dSN)unittestTestCase__init__hashmodexpected description extra_params)selfrrrrs rrzHashDigestSizeSelfTest.__init__+s=""4(((   &(r c|jSrrrs rshortDescriptionz'HashDigestSizeSelfTest.shortDescription2 r cfd|jvrM|t|jd||jj|j|jjdi|j}|t|d||j|jdS)Ntruncate digest_size)r assertTruehasattrr assertEqualr#rnewrhs rrunTestzHashDigestSizeSelfTest.runTest5s T. . . OOGDL-@@ A A A   T\5t} E E E DL  1 1t0 1 1 =11222  66666r N__name__ __module__ __qualname__rrr+r$r rrr)sA)))   77777r rc eZdZdZdZdZdS) HashSelfTestctj|||_||_||_||_||_dSr) rrrrlowerrinputrr)rrrrr4rs rrzHashSelfTest.__init__@sN""4(((  ((  &(r c|jSrrrs rrzHashSelfTest.shortDescriptionHr r cb|jjdi|j}||jt j|}|}|jj|jfi|j}|}t j|}| |j |tj ddkr7| |j || |j |nZ| |j || |j || |j ||jjdvst|drq|}||jt j|}| |j |dSdS)Nr)zCrypto.Hash.MD5zCrypto.Hash.SHA1r(r$)rr(rupdater4binasciib2a_hexdigest hexdigestr'rsys version_infodecoder-r&)rr*out1out2out3out4h2out5s rr+zHashSelfTest.runTestKs DL  1 1t0 1 1  ++{{}} DL TZ = =4+< = ={{}} ++ ---  A ! # #   T]D 1 1 1   T]D 1 1 1 1   T]1133T : : :   T]1133T : : : --- < (O O OSZ[\^cSdSd OB IIdj ! ! !#BIIKK00D   T]D 1 1 1 1 1 P Or Nr,r$r rr1r1>sA)))   22222r r1ceZdZdZdZdS) HashTestOIDcntj|||_||_||_dSr)rrrroidr)rrrIrs rrzHashTestOID.__init__ls5""4((( (r ct|jjdi|j}||j|jdS)Nr$)rr(rr'rIr)s rr+zHashTestOID.runTestrs? DL  1 1t0 1 1 )))))r Nr-r.r/rr+r$r rrGrGks2))) *****r rGceZdZdZdZdS) ByteArrayTestc`tj|||_||_dSrrrrmodulerrrPrs rrzByteArrayTest.__init__y.""4((( (r cttd}t|}|jj|fi|j}|jj|fi|j}d|dd<|||t|}|jjdi|j}|jjdi|j}||||d|dd<|||dS)Nzr$)r bytearrayrPr(rr'r;r8)rdatabah1rDs rr+zByteArrayTest.runTest~s'  t__ T[_T 7 7T%6 7 7 T[_R 5 54#4 5 52A2 biikk222t__ T[_ 1 1t0 1 1 T[_ 1 1t0 1 1 $ " 2A2 biikk22222r NrKr$r rrMrMws2))) 33333r rMceZdZdZdZdS)MemoryViewTestc`tj|||_||_dSrrOrQs rrzMemoryViewTest.__init__rRr cd}d}d}||fD]1}||}|jj|fi|j}|jj|fi|j}|jsd|dd<|||||}|jjdi|j}|jjdi|j}|||||jsd|dd<|||3dS)Nsc t|Sr) memoryviewrWs r get_mv_roz)MemoryViewTest.runTest..get_mv_rosd## #r c:tt|Sr)r_rVr`s r get_mv_rwz)MemoryViewTest.runTest..get_mv_rwsioo.. .r rTrUr$)rPr(rreadonlyr'r;r8)rrWrarcget_mvmvrYrDs rr+zMemoryViewTest.runTestsr $ $ $ / / / * 7 7FB ;;):;;B 99t'899B; ! 2A2   RYY[["))++ 6 6 6B 554#455B 554#455B IIdOOO IIbMMM; ! 2A2   RYY[["))++ 6 6 6 6) 7 7r NrKr$r rr[r[s2))) 77777r r[c eZdZdZdZdZdS) MACSelfTestctj|||_t ||_t ||_t ||_||_||_ dSr) rrrrPrresultrWkeyparamsr)rrPrrjrWrkrls rrzMACSelfTest.__init__s\""4((( &kk II s88 &r c|jSrrrs rrzMACSelfTest.shortDescriptionr r c|t|j}|jj|jfi|j}||j||j| |t|j d| | |j| |t|jd}|t |j ||t |j d|jj|j|jfi|j}||j| |t|j d|  |jj|j|jfi|j}|}|}|d|| |j|d|| | n#t$$rYnwxYw|t)| t+d|t)| t+d| | | | ddS)Nascii4556sblar )rrjrPr(rkrlr8rWr'r;r?r<verify hexverifyr assertRaises ValueErrorcopyNotImplementedErrorr% isinstancetypeencode)r result_hexr* wrong_macrDh3s rr+zMACSelfTest.runTestsT[))  DKODH 4 4 4 4  ahhjj111 --44W==q{{}}MMM  JT[#..  *ah ::: *ak6::: DKODHdi ? ?4; ? ? ahhjj111 --44W==q{{}}MMM  $)CCt{CCABB IIf      RYY[[$+ 6 6 6 HHV      QXXZZ 5 5 5 5"    D   188::tCyy99:::  1;;==$r((;;<<< AKKMM""" AKKMM((1122222s*CK KKNr,r$r rrhrhsA'''   .3.3.3.3.3r rhc g}tt|D]}||}tt|dd\} } t|dkrt | } n|d} d||dz| fz} |t || | | |d|t|dzfz} |t|| |||$|t||||t|||t|||S)Nrr7 %s #%d: %srUz%s #%d: digest_size) rangelenmaprreprappendr1rrGrMr[) rP module_name test_datar#rIrtestsirowrr4rnames rmake_hash_testsrsE E 3y>> " "PPlAaC115 s88a<<u++KKa&K{AaC== \&$%NNOOOO KY!1C#D DD LL'k<PPQQQ  [l;;<<< LLv|44555 LL 55666 Lr c g}t|D]l\}}t|dkrt|igz\}}}} } n|\}}}} } d||dz| fz} |t || |||| m|S)NrrU) enumeraterlistrrh) rPrrrrrrkrWresultsrrlrs rmake_mac_testsrs EI&&LL3 s88q==8rs2-, '''''''',,,,,,,,'''''' 77777X.777**2*2*2*2*28$*2*2*2Z * * * * *(# * * *33333H%333>%7%7%7%7%7X&%7%7%7P<3<3<3<3<3(#<3<3<3~FJ!#4     r