ff04ZdZddlZddlZddlmZddlmZddlmZddl m Z m Z ddlm Z ddl mZdd lmZdd lmZd d d de fd ddde fd ddde fd ddde fdd dde fdddde fdddde fdddd e fd!d d"d#e fd!dd$d%e fd!dd&d'e fd!dd(d)e fd*d d+d,e fd*d-d.d/e fd*d0d1d2e fd*d3d4d5e fd6d d7d8e fd6d-d9d:e fd6d0d;de fgad?ZGd@dAejZGdBdCejZGdDdEejZGdFdGejZifdHZedIkrddlZdJZejdKLdSdS)Mz$Self-test suite for Crypto.Hash.CMACN) unhexlify)tobytes)CMAC)AESDES3)SHAKE128)strxor)list_test_cases)load_test_vectors_wycheproof 2b7e151628aed2a6abf7158809cf4f3c bb1d6929e95937287fa37d129b756746z RFC 4493 #1 6bc1bee22e409f96e93d7e117393172a 070a16b46b4d4144f79bdd9dd04a287cz RFC 4493 #2P6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411 dfa66747de9ae63030ca32611497c827z RFC 4493 #3ڀ6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710 51f0bebf7e3b9d92fc49741779363cfez RFC 4493 #408e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b d17ddf46adaacde531cac483de7a9367zNIST SP 800 38B D.2 Example 5 9e99a7bf31e710900662f65e617c5184zNIST SP 800 38B D.2 Example 6 8a1de5be2eb31aad089a82e6ee908b0ezNIST SP 800 38B D.2 Example 7 a1d5df0eed790f794d77589659f39a11zNIST SP 800 38B D.2 Example 8@603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4 028962f61b7bf89efc6b551f4667d983zNIST SP 800 38B D.3 Example 9 28a7023f452e8f82bd4bf28d8c37c35czNIST SP 800 38B D.3 Example 10 aaf3d8f1de5640c232f5b169b9c911e6zNIST SP 800 38B D.3 Example 11 e1992190549f6ed5696a2c056c315410zNIST SP 800 38B D.3 Example 1208aa83bf8cbda10620bc1bf19fbb6cd58bc313d4a371ca8b5b7a688e122ffaf95zNIST SP 800 38B D.4 Example 136bc1bee22e409f968e8f293136283797zNIST SP 800 38B D.4 Example 14(6bc1bee22e409f96e93d7e117393172aae2d8a57743ddbe0ce2dc2edzNIST SP 800 38B D.4 Example 15@6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5133e6b1092400eae5zNIST SP 800 38B D.4 Example 16 4cf15134a2850dd58a3d10ba80570d38bd2ebf9a3ba00361zNIST SP 800 38B D.7 Example 174ff2ab813c53ce83zNIST SP 800 38B D.7 Example 1862dd1b471902bd4ezNIST SP 800 38B D.7 Example 1931b1e431dabc4eb8zNIST SP 800 38B D.7 Example 20cltjt||S)Ndata)rnewrread)taglengths /builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/SelfTest/Hash/test_CMAC.pyget_tag_randomr4s) z2TestCMAC.test_internal_caching.. s9@@@k!AlN"23@@@r5rr>N) r4rr/rdigestrangelenupdate assertEqual)selfr;ref_macchunksmacchunkrKr9s @@r3test_internal_cachingzTestCMAC.test_internal_cachings%]C88 UB''(3K3???FFHH@ 4 4L@@@@@As;//>>@@@F(3#...C " " 5!!!!   Wcjjll 3 3 3 3 4 4r5cPd}d}tj||ddt}|}|t |j|ddtj||t}tj||ddtd}|||||dd|||dS)Nsrrrrttts4444444444444444rMT)r>update_after_digest)rr/rrN assertRaises TypeErrorrQrR)rSr=r;hdig1dig2h2s r3test_update_after_digestz!TestCMAC.test_update_after_digests HS#bqb'S 1 1 1xxzz )QXs122w777xSC0007799Xc3rr7ct L L L d+++ #abb' d+++++r5N)__name__ __module__ __qualname__rXrbrHr5r3r7r7s2444&,,,,,r5r7ceZdZdZdS)ByteArrayTestscd}d}t|}t|}tj||t}tj||t}d|dd<d|dd<|||t|}t|}tj|t}tj|t}||||d|dd<|||dS)N0000000000000000rMr?) bytearrayrr/rrRrNrQ)rSr;r.key_badata_bah1ras r3runTestzByteArrayTests.runTest(s*3D// Xc43 / / / Xfg 5 5 5rr   biikk2223D// XcS ) ) ) XcS ) ) ) $ '  biikk22222r5NrcrdrerprHr5r3rgrg&s#33333r5rgceZdZdZdS)MemoryViewTestscd}d}d}d}||fD]S}||}||}tj||t}tj||t} |jsd|dd<d|dd<||| ||}tj|t}tj|t} ||| ||jsd|dd<||| UdS)Nrirjc t|SN) memoryviewr-s r3 get_mv_roz*MemoryViewTests.runTest..get_mv_roJsd## #r5c:tt|Srv)rwrlr-s r3 get_mv_rwz*MemoryViewTests.runTest..get_mv_rwMsioo.. .r5rMrkr?)rr/rreadonlyrRrNrQ) rSr;r.rxrzget_mvkey_mvdata_mvroras r3rpzMemoryViewTests.runTestEsv $ $ $ / / /!), 7 7FVC[[FfTllG#ts333B&'S999B# &$rr %   RYY[["))++ 6 6 6fTllG#---B#---B IIdOOO IIg   # &%   RYY[["))++ 6 6 6 6- 7 7r5NrqrHr5r3rsrsCs#!7!7!7!7!7r5rsc8eZdZdZdZdZdZdZdZdZ dS) TestVectorsWycheproofc`tj|||_d|_dS)NNone)unittestTestCase__init___wycheproof_warnings_id)rSwycheproof_warningss r3rzTestVectorsWycheproof.__init__ks,""4((($7!r5c@d}tdddd|i|_dS)Nc|ddzS)NtagSizerH)groups r3 filter_tagz/TestVectorsWycheproof.setUp..filter_tagrs#q( (r5)Hash wycheproofzaes_cmac_test.jsonzWycheproof CMACtag_size) group_tag)r tv)rSrs r3setUpzTestVectorsWycheproof.setUppsA ) ) )//E/C/@:Dj9QSSSr5c|jSrv)r)rSs r3shortDescriptionz&TestVectorsWycheproof.shortDescriptionzs xr5c~|jr3|jr.ddl}|d|jd|jddSdSdS)NrzWycheproof warning: z ())warningrwarningswarnrcomment)rSrrs r3rzTestVectorsWycheproof.warn}sd : R$3 R OOO MMM4888RZZZP Q Q Q Q Q R R R Rr5cdt|jz|_ tj|j|jt|j }nA#t$r4}t|jdvrdt|vrYd}~dS|d}~wwxYw|j r2| ||j||dSdS)NzWycheproof MAC creation Test #r>mac_lenr< key length)stridrrr/r;r=rrrN ValueErrorrPvalidrRr1r)rSrr1es r3test_create_macz%TestVectorsWycheproof.test_create_macs3c"%jj@ (2626S"+NNNUUWWCC   26{{,..<3q663I3IG  8    S"& ) ) ) IIbMMMMM  s>A B''BBBcdt|jz|_ tj|j|jt|j}nA#t$r4}t|jdvrdt|vrYd}~dS|d}~wwxYw | |j |j sJ||dS#t$r |j rJYdSwxYw)Nz"Wycheproof MAC verification Test #rrr)rrrrr/r;r=rrrrPverifyr1rr)rSrrVrs r3test_verify_macz%TestVectorsWycheproof.test_verify_macs7#be**D (2626S"+NNNCC   26{{,..<3q663I3IG   JJrv   8OO8 IIbMMMMM    x  <    s/,A B 'BBB  CCCcn|jD],}||||-dSrv)rrr)rSrs r3rpzTestVectorsWycheproof.runTestsH' % %B   $ $ $   $ $ $ $ % %r5N) rcrdrerrrrrrrprHr5r3rris SSSRRR   "%%%%%r5rcddl}ddlm}|d}g}tD]?}t |}t |d|d<||@|td|}|t|tt|t|t|gz }|S)Nrr?)make_mac_testsrrZrMr)typescommonrget test_datalistdictappendrrgr r7rsr)configrrrparams_test_datarowttestss r3 get_testsrsLLL&&&&&& **%:;;## IIad###!"""" N4)9 : :E LL!!""" LL**+++ LL""### $%899 ;;E Lr5__main__cBtjtSrv)r TestSuiterrHr5r3rsH&y{{33r5suite) defaultTest)__doc__jsonrbinasciirCrypto.Util.py3compatr Crypto.Hashr Crypto.CipherrrrCrypto.Util.strxorr Crypto.SelfTest.st_commonr Crypto.SelfTest.loaderr rr4rr7rgrsrrrcrmainrHr5r3rsD+* ))))))######## %%%%%%555555?????? + *  +**  +  +  + + +    *'  **'    +'   + +'   + *'  +**(  +  +(  + + +(    (   (    (     (    (  (    (    (  qC  L888%,%,%,%,%,x %,%,%,P33333X&333:#7#7#7#7#7h'#7#7#7L;%;%;%;%;%H-;%;%;%|, zOOO 3 3EHMg&&&&&&r5