ff"dZddlZddlmZmZddlmZddlmZddl m Z ddl m Z m Z mZGdd ejZGd d ejZed d dddipgZeed ddddipgz ZeeD]G\ZZejdkr e dZne ejZeejfdZeedezeHed ddddipgZeed ddddipgz ZeeD]G\ZZejdkr e dZne ejZeejfdZeedezeHed dd dd!ipgZeed d"d#dd$ipgz ZeeD]G\ZZejdkr e dZne ejZeejfd%Zeed&ezeHed d'd(dd)ipgZeed d*d+dd,ipgz ZeeD]G\ZZejdkr e dZne ejZeejfd-Zeed.ezeHifd/Ze d0krddlZd1Z!ej"d23dSdS)4z&Self-test suite for Crypto.Hash.keccakN)hexlify unhexlify)load_test_vectors)list_test_cases)keccak)btobytesbchrc>eZdZdZdZdZdZdZdZdZ dZ d S) KeccakTestcdD]g}tj|}||j|dz|}||j|dzhdD]a}tj|}||j||}||j|bdS)N) digest_bits) 0@ digest_bytes)rnew assertEqual digest_size)selfrhobjhobj2rs /builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/SelfTest/Hash/test_keccak.pytest_new_positivezKeccakTest.test_new_positive,s/ B BK:+666D   T-{a/? @ @ @HHJJE   U. q0@ A A A A, > >L:<888D   T-| < < <HHJJE   U. = = = =  > >c*tjtdd}tjdtd}|||dS)Nr)datarr)rrrdigestupdater)rdigest1digest2s r!test_new_positive2zKeccakTest.test_new_positive2<sv*!F))"===DDFF*"---44QvYY??FFHH '*****r#c|ttjtjd}|ttjdd|ttjd|ttjd|ttjd|ttjd|ttjd|ttjd dS) Nrrr)rrrrAi) assertRaises TypeErrorrr ValueErrorrhs r!test_new_negativezKeccakTest.test_new_negativeBs )VZ000 J3 ' ' ' )VZ+-*-  / / / *fjqAAA *fjqAAA *fjrBBB *fja@@@ *fja@@@ *fjcBBBBBr#ctddztddzg}tjd}||d|d|}tjd}||d|dz|||dS) N i,rrrr-)r rrr(r'r)rpiecesr3r's r! test_updatezKeccakTest.test_updateVsr((S.$r((S.1 JB ' ' ' ""6!9--- JB ' ' ' VAY&''' V,,,,,r#crtjd}|t|jddS)Nrrstring)rrr/r0r(r2s r!test_update_negativezKeccakTest.test_update_negative_s4 JB ' ' ' )QXy99999r#c "tjd}|}||||t |t tddS)Nrrr')rrr'r assertTrue isinstancetyper)rr3r's r! test_digestzKeccakTest.test_digestcsq JB ' ' ' V,,,  64( +<+<==>>>>>r#ctjd}|}|}|t |t |||||t|tddS)Nrrr') rrr' hexdigestrrr r?r@rA)rmacr'rDs r!test_hex_digestzKeccakTest.test_hex_digestlsjS)))MMOO  ')*<*<=== )444  9d8nn==>>>>>r#cBtd}tjd|dd}|}|t |j|ddtjd|}tjd|ddd}|||||dd|||dS)Nrrrrtttrrr&T)rr&update_after_digest)rrrr'r/r0r(r)rmsgr3dig1dig2s r!test_update_after_digestz#KeccakTest.test_update_after_digestxs iLL J3S!W 5 5 5xxzz )QXs122w777zc444;;== J3S!W$ O O O T*** QRR T*****r#N) __name__ __module__ __qualname__r"r+r4r:r=rBrFrOr#r!r r *s>>> +++ CCC(---:::??? ? ? ?+++++r#r ceZdZdS) KeccakVectorsN)rPrQrRrSr#r!rUrUsDr#rU)HashrzShortMsgKAT_224.txtzShort Messages KAT 224lenc t|SNintxs r!r^ #a&&r#zLongMsgKAT_224.txtzLong Messages KAT 224c t|SrYrZr\s r!r^r^r_r#ctjd|}|||dS)NrrJrrrr'rr&resultrs r!new_testrf:zc555 /////r#z test_224_%dzShortMsgKAT_256.txtzShort Messages KAT 256c t|SrYrZr\s r!r^r^ CFFr#zLongMsgKAT_256.txtzLong Messages KAT 256c t|SrYrZr\s r!r^r^rir#ctjd|}|||dS)NrrJrcrds r!rfrfrgr#z test_256_%dzShortMsgKAT_384.txtzShort Messages KAT 384c t|SrYrZr\s r!r^r^r_r#zLongMsgKAT_384.txtzLong Messages KAT 384c t|SrYrZr\s r!r^r^r_r#ctjd|}|||dS)NrrJrcrds r!rfrfrgr#z test_384_%dzShortMsgKAT_512.txtzShort Messages KAT 512c t|SrYrZr\s r!r^r^r_r#zLongMsgKAT_512.txtzLong Messages KAT 512c t|SrYrZr\s r!r^r^r_r#ctjd|}|||dS)NrrJrcrds r!rfrfrgr#z test_512_%dcfg}|ttz }|ttz }|SrY)rr rU)configtestss r! get_testsrus0 E _Z ( ((E _] + ++E Lr#__main__cBtjtSrY)unittest TestSuiterurSr#r!r^r^sH&y{{33r#suite) defaultTest)#__doc__rxbinasciirrCrypto.SelfTest.loaderrCrypto.SelfTest.st_commonr Crypto.HashrCrypto.Util.py3compatrr r TestCaser rUtest_vectors_224 enumerateidxtvrWr&rLmdrfsetattrtest_vectors_256test_vectors_384test_vectors_512rurPrzmainrSr#r!rs%>-,''''''''4444445555552222222222]+]+]+]+]+"]+]+]+@     H%   &%&8 5 8!&(8(8 9;;A?A %%&8 4 7!&(8(8 9;;A?AA y)** : :GC v{{quuwrv 0000 GM=3.9999&%&8 5 8"'*:*: <??ECE %%&8 4 7"'*:*: <??ECEE y)** : :GC v{{quuwrv 0000 GM=3.9999 &%&8 5 8!&(8(8 9;;A?A %%&8 4 7!&(8(8 9;;A?AA y)** : :GC v{{quuwrv 0000 GM=3.9999&%&8 5 8!&(8(8 9;;A?A %%&8 4 7!&(8(8 9;;A?AA y)** : :GC v{{quuwrv 0000 GM=3.9999 zOOO 3 3EHMg&&&&&&r#