ff'ddlZddlmZmZddlmZddlmZmZGddej Z Gddej Z ifd Z e d krd Zejd dSdS)N) unhexlifyhexlify)list_test_cases)strxorstrxor_cc\eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdS) StrxorTestsctd}td}td}|t||||t|||dSNff339a83e5cd4cdf5649383d4ba020573314395bc70ed123c59a7fcb6f12)r assertEqualr)selfterm1term2results /builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/SelfTest/Util/test_strxor.pytest1zStrxorTests.test1+sr122122233 u--v666 u--v66666cRd}|t|||dS)Nr)rr)ress rtest2zStrxorTests.test22s+  B,,,,,rctd}dt|z}|t|||dS)Nr )rlenrr)rr all_zeross rtest3zStrxorTests.test36sF122c%jj(  u--y99999rctd}td}|tt||dS)Nr sff339a83e5cd4cdf564990)r assertRaises ValueErrorrrrrs rtest_wrong_lengthzStrxorTests.test_wrong_length;s>122344 *feU;;;;;rctd}t|}td}td}|t|||dSr )r bytearrayrr)rrterm1_barrs rtest_bytearrayzStrxorTests.test_bytearray@s_122U##122233 %00&99999rctd}t|}td}td}|t|||dSr )r memoryviewrr)rrterm1_mvrrs rtest_memoryviewzStrxorTests.test_memoryviewHs_122e$$122233 %00&99999rctd}td}|dd}|dd}td}tt|}t|||}||d|||||||||dSz3Verify result can be stored in pre-allocated memoryr r Nroutput)rr%rrrrrroriginal_term1original_term2 expected_xorr/rs rtest_output_bytearrayz!StrxorTests.test_output_bytearrayPs122122qqqqqq !899 3u::&&uV444 &&& ... /// /////rctd}td}|dd}|dd}td}ttt|}t |||}||d|||||||||dSr-)rr)r%rrrr0s rtest_output_memoryviewz"StrxorTests.test_output_memoryviewas122122qqqqqq !899 Ic%jj1122uV444 &&& ... /// /////rc6ttd}td}|dd}td}t|||}||d||||||dS1Verify result can be stored in overlapping memoryr r Nrr.)r%rrrrrrr2r3rs r!test_output_overlapping_bytearrayz-StrxorTests.test_output_overlapping_bytearrayrs)$;<<==122qqq !899 uU333 &&&  --- /////rcPtttd}td}|dd}td}t|||}||d||||||dSr8)r)r%rrrr:s r"test_output_overlapping_memoryviewz.StrxorTests.test_output_overlapping_memoryviews9Y/F%G%GHHII122qqq !899 uU333 &&&  --- /////rctd}td}|tt|||dS2Verify result cannot be stored in read-only memoryr r r.N)rr TypeErrorrr"s rtest_output_ro_bytesz StrxorTests.test_output_ro_bytessE122122 )VUE%HHHHHrcttd}td}|tt|||dSr?)r)rr rArr"s rtest_output_ro_memoryviewz%StrxorTests.test_output_ro_memoryviewsM9%<==>>122 )VUE%HHHHHrctd}td}tt|dz }|tt |||dS)** *feU6JJJJJrN)__name__ __module__ __qualname__rrrr#r'r+r4r6r;r=rBrDrHrrr r )s777---::: <<< ::::::000"000" 0 0 0 0 0 0IIIIIIKKKKKrr c\eZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d Zd ZdS) Strxor_cTestsctd}td}|t|d|dSNr be72dbc2a48c0d9e1708Arrr)rrrs rrzStrxor_cTests.test1sD122233 %,,f55555rcltd}|t|d|dS)Nr rrSrrs rrzStrxor_cTests.test2s6122 %++U33333rcN|tddddS)NrZ)rr)rs rrzStrxor_cTests.test3s( #r**C00000rctd}|tt|d|tt|ddS)Nr )rr r!rrUs rtest_wrong_rangezStrxor_cTests.test_wrong_rangesJ122 *hr::: *hs;;;;;rctd}t|}td}|t|d|dSrP)rr%rr)rrr&rs rr'zStrxor_cTests.test_bytearraysQ122U##233 (B//88888rctd}t|}td}|t|d|dSrP)rr)rr)rrr*rs rr+zStrxor_cTests.test_memoryviewsQ122e$$233 (B//88888rc6td}|dd}td}tt|}t|d|}||d||||||dSNr rQrRr.)rr%rrrrrr1expected_resultr/rs rr4z#Strxor_cTests.test_output_bytearrays122qqq#$;<<3u::&&%F333 &&& 111 /////rcPtd}|dd}td}ttt|}t |d|}||d||||||dSr_)rr)r%rrrr`s rr6z$Strxor_cTests.test_output_memoryviews122qqq#$;<<Ic%jj1122%F333 &&& 111 /////rcttd}td}t|d|}||d|||dSr9r rQrRr.N)r%rrrrrr3rs rr;z/Strxor_cTests.test_output_overlapping_bytearraysn)$;<<== !899 %E222 &&&  -----rctttd}td}t|d|}||d|||dSrd)r)r%rrrres rr=z0Strxor_cTests.test_output_overlapping_memoryviewsv9Y/F%G%GHHII !899 %E222 &&&  -----rcltd}|tt|d|dS)r@r rRr.N)rr rArrUs rrBz"Strxor_cTests.test_output_ro_bytess7122 )XubGGGGGrcttd}td}|tt|d|dS)r@r r rRr.N)r)rr rArr"s rrDz'Strxor_cTests.test_output_ro_memoryviewsM9%<==>>122 )XubGGGGGrctd}tt|dz }|tt |d|dS)rFr rGrRr.N)rr%rr r!r)rrr/s rrHz*Strxor_cTests.test_output_incorrect_lengthsN1223u::>** *hr&IIIIIrN)rIrJrKrrrr[r'r+r4r6r;r=rBrDrHrLrrrNrNs666 444111<<< 999999 0 0 0 0 0 0 . . . . . .HHHHHHJJJJJrrNcfg}|ttz }|ttz }|SN)rr rN)configtestss r get_testsrns0 E _[ ) ))E _] + ++E Lr__main__cBtjtSrk)unittest TestSuiternrLrrrssH&y{{33rsuite) defaultTest)rqbinasciirrCrypto.SelfTest.st_commonrCrypto.Util.strxorrrTestCaser rNrnrIrtmainrLrrr{s D''''''''555555////////|K|K|K|K|K(#|K|K|K~dJdJdJdJdJH%dJdJdJN z 3 3EHMg&&&&&&r