ff ZdZddlZddlmZddlmZddlmZmZm Z m Z ddl m Z m Z mZGddejZGd d eZGd d eZGd dejZdddefdddefdddefdddefgZeD]\ZZZZedeeddddpgZeeD]\ZZeed ddkr e d!Zn.eejZej e ejd"zksJeed#ddkr e!d$eed%ddkr e d!Z"n.eej#Z"ej$e ej#d"zksJeej%e"efd&Z&e'ed'eefze&אifd(Z(e)d)krddlZd*Z*ej+d+,dSdS)-z7Self-test suite for Crypto.Hash.cSHAKE128 and cSHAKE256N)load_test_vectors)list_test_cases) cSHAKE128 cSHAKE256SHAKE128SHAKE256)bbchrtobytesc>eZdZdZdZdZdZdZdZdZ dZ d S) cSHAKETestcddlm}||dd||dd||dddS)Nr) _left_encodesss)Crypto.Hash.cSHAKE128r assertEqual)selfrs /builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/SelfTest/Hash/test_cSHAKE.pytest_left_encodezcSHAKETest.test_left_encode(sv666666 a+666 a+666 c**O<<<<<cddlm}||ddd||ddd||ddd ||d dd ||d dd ||ddd||ddd||ddddS)Nr)_bytepadrsAsAsAAsAAsAAAsAAAsAAAAsAAAAsAAAAAsAAAAAsAAAAAAsAAAAAAsAAAAAAAs AAAAAAA)rrr)rrs r test_bytepadzcSHAKETest.test_bytepad.s1222222 #q))+>??? $**,<=== %++];;; &!,,.HIII '1--/FGGG (A..0DEEE )Q//1BCCC *a002PQQQQQrc|j}|jtd}|jtd}||d|d|d||d|d|j}|d}|jtd}|jtd}|||d|||d|jtd}|jtdtd}|jtdtd}||d|d|d||d|ddS)N90)data )customfoo)r"r)cshakenewr updateassertNotEqualreadr)rxof1xof2xof3refs rtest_new_positivezcSHAKETest.test_new_positive9s"{  {AdGG,,{  ''$00 DIIbMM499R==999 "  2 " 666{  iimm{aee,,{ahh// diimm,,, C2///{ahh//{ahhQtWW=={ahh//66qww?? DIIbMM499R==999 "  2 " 66666rctddztddzg}|j}||d|d|d}|j}||d|dz||d|dS)Nr i,rr)r r$r%r&r(r)rpieceshdigests r test_updatezcSHAKETest.test_updateSsr((S.$r((S.1 KOO   ""6!9--- KOO   VAY&''' V,,,,,rcz|j}|t|jddS)Nstring)r$r% assertRaises TypeErrorr&)rr2s rtest_update_negativezcSHAKETest.test_update_negative\s3 KOO   )QXy99999rc "|j}|d}|t |t t d|t|ddS)NZr3) r$r%r( assertTrue isinstancetyper rlen)rr2r3s r test_digestzcSHAKETest.test_digest`sp KOO    64( +<+<==>>> Vb)))))rc|j}|td|d|t |jtddS)Nrrrrr;ttt)r$r%r&r r(r7r8)rmacs rtest_update_after_readz!cSHAKETest.test_update_after_readhs`koo 1V99   )SZ5:::::rc tdD]r}|jd}|jd}|||||sdS)N@sTEST)ranger$r%shakerr()r digest_lenr)r*s r test_shakezcSHAKETest.test_shakens|)) K KJ;??7++D:>>'**D   TYYz22DIIj4I4I J J J J K KrN) __name__ __module__ __qualname__rrr-r4r9r@rErKrrr r &s=== R R R7774---:::***;;; KKKKKrr ceZdZeZeZdS) cSHAKE128TestN)rLrMrNrr$rrIrOrrrQrQv F EEErrQceZdZeZeZdS) cSHAKE256TestN)rLrMrNrr$rrIrOrrrTrT{rRrrTceZdZdS) cSHAKEVectorsN)rLrMrNrOrrrVrVsDrrVzShortMsgSamples_cSHAKE128.txtzShort Message Samples cSHAKE128 128_cshakezShortMsgSamples_cSHAKE256.txtzShort Message Samples cSHAKE256 256_cshakezCustomMsgSamples_cSHAKE128.txtz Custom Message Samples cSHAKE128custom_128_cshakezCustomMsgSamples_cSHAKE256.txtz Custom Message Samples cSHAKE256custom_256_cshake)HashSHA3c t|SNintxs rrcs s1vvrc t|Sr^r_ras rrcrc Arc t|Sr^r_ras rrcrcrer)r?nlenslenr?r!rgzUnsupported cSHAKE test vectorrhc|||}|t|}|||dS)N)rr")r%r(r?r)rrresultr" test_classhobjr3s rnew_testrnsJ>>tF>;;DYYs6{{++F   VV , , , , ,rz test_%s_%dcg}|ttz }|ttz }|ttz }|Sr^)rrQrTrV)configtestss r get_testsrrsB E _] + ++E _] + ++E _] + ++E Lr__main__cBtjtSr^)unittest TestSuiterrrOrrrcrcsH&y{{33rsuite) defaultTest),__doc__ruCrypto.SelfTest.loaderrCrypto.SelfTest.st_commonr Crypto.HashrrrrCrypto.Util.py3compatr r r TestCaser rQrTrV vector_filesfiledescrtagrl test_vectors enumerateidxtvgetattrrmsgr? ValueErrorr"srhmdrnsetattrrrrLrwmainrOrrrs6>=444444555555@@@@@@@@@@@@2222222222MKMKMKMKMK"MKMKMK`J J      H%   12SUaclm02SUaclm13UWjluv13UWjluv %1DD D%j$$%5tU-=-=.>.>.>.>&@&@AAGEG 9\**DDR 72ua A % %1R55DD726??D6SS[[]**** 72vq ! !Q & &*=>> > 72vq ! !Q & &QrUUFFWRT]]F7cc"$iik)))) $RU6j - - - -  |sCj8(CCCC'D, zOOO 3 3EHMg&&&&&&r