ffkdZddlZddlmZmZddlmZddlmZddl m Z m Z ddl m Z mZmZmZGdd ejZGd d eZGd d eZGddejZedddddipgZeeD]G\ZZejdkr e dZneejZeejfdZeedezeHedddddipgZ ee D]G\ZZejdkr e dZneejZeejfdZeedezeHifdZ!e"dkrddlZdZ#ej$d !dSdS)"z5Self-test suite for Crypto.Hash.SHAKE128 and SHAKE256N)hexlify unhexlify)load_test_vectors)list_test_cases)SHAKE128SHAKE256)bbchrbordtobytesc,eZdZdZdZdZdZdZdS) SHAKETestc|j}|jtd}|jtd}||d|d|d||d|ddS)N90data )shakenewr updateassertNotEqualread assertEqual)selfxof1xof2xof3s /builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/SelfTest/Hash/test_SHAKE.pytest_new_positivezSHAKETest.test_new_positive,sz~~z~~1T77~++z~~&&qww// DIIbMM499R==999 "  2 " 66666ctddztddzg}|j}||d|d|d}|j}||d|dz||d|dS)Nri,r)r rrrrr)rpieceshdigests r test_updatezSHAKETest.test_update6sr((S.$r((S.1 JNN   ""6!9--- JNN   VAY&''' V,,,,,r cz|j}|t|jddS)Nstring)rr assertRaises TypeErrorr)rr&s rtest_update_negativezSHAKETest.test_update_negative?s3 JNN   )QXy99999r c "|j}|d}|t |t t d|t|ddS)NZr') rrr assertTrue isinstancetyper rlen)rr&r's r test_digestzSHAKETest.test_digestCsp JNN    64( +<+<==>>> Vb)))))r c|j}|td|d|t |jtddS)Nrrrrr/ttt)rrrr rr+r,)rmacs rtest_update_after_readz SHAKETest.test_update_after_readKs`jnn 1V99   )SZ5:::::r N)__name__ __module__ __qualname__rr(r-r4r9r rrr*s_777---:::***;;;;;r rceZdZeZdS) SHAKE128TestN)r:r;r<rrr=r rr?r?Rr r?ceZdZeZdS) SHAKE256TestN)r:r;r<rrr=r rrBrBVr@r rBceZdZdS) SHAKEVectorsN)r:r;r<r=r rrDrDZsDr rD)HashSHA3zShortMsgKAT_SHAKE128.txtzShort Messages KAT SHAKE128r3c t|SNintxs rrMa 3q66r ctj|}|t|}|||dSNr)rrrr3rrrresulthobjr's rnew_testrUiG|&&&3v;;'' (((((r z test_128_%dzShortMsgKAT_SHAKE256.txtzShort Messages KAT SHAKE256c t|SrHrIrKs rrMrMtrNr ctj|}|t|}|||dSrQ)rrrr3rrRs rrUrU|rVr z test_256_%dcg}|ttz }|ttz }|ttz }|SrH)rr?rBrD)configtestss r get_testsr\sB E _\ * **E _\ * **E _\ * **E Lr __main__cBtjtSrH)unittest TestSuiter\r=r rrMrMsH&y{{33r suite) defaultTest)%__doc__r_binasciirrCrypto.SelfTest.loaderrCrypto.SelfTest.st_commonr Crypto.HashrrCrypto.Util.py3compatr r r r TestCaserr?rBrDtest_vectors_128 enumerateidxtvr3rmsgmdrUsetattrtest_vectors_256r\r:ramainr=r rrss ><;''''''''444444555555********888888888888%;%;%;%;%;!%;%;%;P99     8$   %$%59>DBD y)** 9 9GC v{{quuwrv ))))  GL-#-x8888%$%59>DBD y)** 9 9GC v{{quuwrv ))))  GL-#-x8888 zOOO 3 3EHMg&&&&&&r