ffM dZddlZddlmZddlmZmZddlmZm Z m Z m Z m Z m Z mZmZmZmZmZmZee e e e e eeeeee ZdZdZgdd ed d fdd ed dfdd eddfddedddfdded dfddeddfd d!ed"d#d$fd%d&ed' d(fd)d&ed*d+fd,d-ed.d/d0fd,d1ed2d3d4fdd ed56d7fdded86d9fdded:6d;fd d!ed<6d=fd>d-ed?6d@fd>dAedB6dCfddedDEdFfddedGHdIfddedJKdLfdedMedNOdPfedQedRedSOdTfddedUOdVfd d!edWOdXfd)edYedZOd[fd,ed\ed]Od^fd,ed_ed`Odafdbedceddedffdgedhediedjfdkedledmednfdoedcedpqdrfdsedhedtqdufdvedledwqdxfdyedcedz{d|fd}edhed~{dfdedled{dfdedceddfdedheddfdsedleddfaGddejZGddejZGddejZGddejZifdZedkrdZ ej!ddSdS)z$Self-test suite for Crypto.Hash.HMACN)hexlify)tostrtobytes) HMACMD5SHA1SHA256SHA224SHA384SHA512 RIPEMD160SHA3_224SHA3_256SHA3_384SHA3_512) rrr r r r r rrrrcTttt|SN)rrr)texts /builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/SelfTest/Hash/test_HMAC.pyxlr-s '' ( (( 0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b4869205468657265 9294727a3638bb1c13f48ef8158bfc9d) default_hashzdefault-is-MD5)rzRFC 2202 #1-MD5 (HMAC-MD5)(0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b(b617318655057264e28bc0b6fb378c8ef146be00)rzRFC 2202 #1-SHA1 (HMAC-SHA1)4a65666587768617420646f2079612077616e7420666f72206e6f7468696e673f 750c783e6ab0b503eaa86e310a5db738(effcdf6ae5eb2fa2d27416d5f184df9c259a7c79)rrzRFC 2202 #2 (HMAC-MD5/SHA1) aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd 56be34521d144c88dbb8c733f0e8b3f6zRFC 2202 #3-MD5 (HMAC-MD5)(aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(125d7342b9ac11cd91a39af48aa17b4f63f175d3zRFC 2202 #3-SHA1 (HMAC-SHA1)20102030405060708090a0b0c0d0e0f10111213141516171819dcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd 697eaf0aca3a3aea3a75164746ffaa79(4c9007f4026250c6bc8414f9bf50c86c2d7235dazRFC 2202 #4 (HMAC-MD5/SHA1) 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c(546573742057697468205472756e636174696f6e 56461ef2342edc00f9bab995690efd4czRFC 2202 #5-MD5 (HMAC-MD5)(0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c(4c1a03424b55e07fe7f27be1d58bb9324a9a5a04zRFC 2202 #5-SHA1 (HMAC-SHA1)ڠaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374 6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd(aa4ae5e15272d00e95705637ce8a3b55ed402112zRFC 2202 #6 (HMAC-MD5/SHA1)ڒ54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b657920616e64204c6172676572205468616e204f6e6520426c6f636b2d53697a652044617461 6f630fad67cda0ee1fb1f562db3aa53e(e8e99d0f45237d786d6bbaa7965c7808bbff1a91zRFC 2202 #7 (HMAC-MD5/SHA1)zc b0344c61d8db38535ca8afceaf0bf12b 881dc200c9833da726e9376c2e32cff7 )r zRFC 4231 #1 (HMAC-SHA256)zc 5bdcc146bf60754e6a042426089575c7 5a003f089d2739839dec58b964ec3843 zRFC 4231 #2 (HMAC-SHA256)zc 773ea91e36800e46854db8ebd09181a7 2959098b3ef8c122d9635514ced565fe zRFC 4231 #3 (HMAC-SHA256)zc 82558a389a443c0ea4cc819899f2083a 85f0faa3e578f8077a2e3ff46729665b zRFC 4231 #4 (HMAC-SHA256)aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaazc 60e431591ee0b67f0d8a26aacbf5b77f 8e0bc6213728c5140546040f0ee37f54 zRFC 4231 #6 (HMAC-SHA256)05468697320697320612074657374207573696e672061206c6172676572207468616e20626c6f636b2d73697a65206b657920616e642061206c6172676572207468616e20626c6f636b2d73697a6520646174612e20546865206b6579206e6565647320746f20626520686173686564206265666f7265206265696e6720757365642062792074686520484d414320616c676f726974686d2ezc 9b09ffa71b942fcb27635fbcd5b0e944 bfdc63644f0713938a7f51535c3a35e2 zRFC 4231 #7 (HMAC-SHA256)8a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44)r z!RFC 4634 8.4 SHA224 (HMAC-SHA224)`af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649)r z!RFC 4634 8.4 SHA384 (HMAC-SHA384)ڀ164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737)r z!RFC 4634 8.4 SHA512 (HMAC-SHA512)zHi There(24cb4bd67d20fc1a5d2ed7732dcc39377f0a5668)r zRFC 2286 #1 (HMAC-RIPEMD)Jefezwhat do ya want for nothing?(dda6c0213a485a9e24f4742064a7f033b43c4069zRFC 2286 #2 (HMAC-RIPEMD)(b0b105360de759960ab4f35298e116e295d8e7c1zRFC 2286 #3 (HMAC-RIPEMD)(d5ca862f4d21d5e610e18b4cf1beb97a4365ecf4zRFC 2286 #4 (HMAC-RIPEMD)zTest With Truncation(7619693978f91d90539ae786500ff3d8e0518e39zRFC 2286 #5 (HMAC-RIPEMD)z6Test Using Larger Than Block-Size Key - Hash Key First(6466ca07ac5eac29e1bd523e5ada7605b791fd8bzRFC 2286 #6 (HMAC-RIPEMD)zITest Using Larger Than Block-Size Key and Larger Than One Block-Size Data(69ea60798d71616cce5fd0871e23754cd75d5a0azRFC 2286 #7 (HMAC-RIPEMD)8000102030405060708090a0b0c0d0e0f101112131415161718191a1bz"Sample message for keylenblocklen8078695eecc227c636ad31d063a15dd05a7e819a66ec6d8de1e193e59zNIST CSRC Sample #3 (SHA3-224)@000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f@4fe8e202c4f058e8dddc23d8c34e467343e23555e24fc2f025d598f558f67205)rzNIST CSRC Sample #1 (SHA3-256)000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f8081828384858687@68b94e2e538a9be4103bebb5aa016d47961d4d1aa906061313b557f8af2c3faazNIST CSRC Sample #2 (SHA3-256)P000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fa0a1a2a3a4a5a6a7@9bcf2c238e235c3ce88404e813bd2f3a97185ac6f238c63d6229a00b07974258zNIST CSRC Sample #3 (SHA3-256)`000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f`d588a3c51f3f2d906e8298c1199aa8ff6296218127f6b38a90b6afe2c5617725bc99987f79b22a557b6520db710b7f42)rzNIST CSRC Sample #1 (SHA3-384)000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f6061626364656667`a27d24b592e8c8cbf6d4ce6fc5bf62d8fc98bf2d486640d9eb8099e24047837f5f3bffbe92dcce90b4ed5b1e7e44fa90zNIST CSRC Sample #2 (SHA3-384)0000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f404142434445464748494a4b4c4d4e4f505152535455565758595a5b5c5d5e5f606162636465666768696a6b6c6d6e6f707172737475767778797a7b7c7d7e7f808182838485868788898a8b8c8d8e8f9091929394959697`e5ae4c739f455279368ebf36d4f5354c95aa184c899d3870e460ebc288ef1f9470053f73f7c6da2a71bcaec38ce7d6aczNIST CSRC Sample #3 (SHA3-384)ڀ000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3fڀ4efd629d6c71bf86162658f29943b1c308ce27cdfa6db0d9c3ce81763f9cbce5f7ebe9868031db1a8f8eb7b6b95e5c5e3f657a8996c86a2f6527e307f0213196)rzNIST CSRC Sample #1 (SHA3-512)ڐ000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f4041424344454647ڀ544e257ea2a3e5ea19a590e6a24b724ce6327757723fe2751b75bf007d80f6b360744bf1b7a88ea585f9765b47911976d3191cf83c039f5ffab0d29cc9d9b6dazNIST CSRC Sample #2 (SHA3-512)ڀ5f464f5e5b7848e3885e49b2c385f0694985d0e38966242dc4a5fe3fea4b37d46b65ceced5dcf59438dd840bab22269f0ba7febdb9fcf74602a35666b2a32915zNIST CSRC Sample #3 (SHA3-512)c$eZdZdZdZdZdZdS)HMAC_Module_and_Instance_TestzTest the HMAC construction and verify that it does not matter if you initialize it with a hash module or with an hash instance. See https://bugs.launchpad.net/pycrypto/+bug/1209399 c`tj|||_d|_dS)zTInitialize the test with a dictionary of hash modules indexed by their namesN)unittestTestCase__init__hashmods description)selfrbs rraz&HMAC_Module_and_Instance_Test.__init__s0 ""4(((  rc|jSr)rc)rds rshortDescriptionz.HMAC_Module_and_Instance_Test.shortDescriptions rcVd}d}|jD]\}}|d|z|_tj|||}tj|||}|||dS)NssdzTest HMAC in combination with )rbitemsrcrnewdigest assertEqual)rdkeypayloadhashnamehashmodonetwos rrunTestz%HMAC_Module_and_Instance_Test.runTests%!%!4!4!6!6 ' ' Hg?(JD (31188::C(377>>@@C   S# & & & &  ' 'rN)__name__ __module__ __qualname____doc__rarfrrrrr\r\sK    ' ' ' ' 'rr\ceZdZdZdS) HMAC_Nonecd}tj|dt}tj|dt}|||dS)Nsr)rrirrjrk)rdrlrprqs rrrzHMAC_None.runTestsahsC&&--//hsD$''..00 c"""""rNrsrtrurrrwrrryrys######rryceZdZdZdS)ByteArrayTestscd}d}t|}t|}tj||}tj||}d|dd<d|dd<|||t|}t|}tj|}tj|}||||d|dd<|||dS)N0000000000000000) bytearrayrrirkrjupdate)rdrldatakey_badata_bah1h2s rrrzByteArrayTests.runTests3D// Xc4  Xfg & &rr   biikk2223D// Xc]] Xc]] $ '  biikk22222rNr{rwrrr}r}s#33333rr}ceZdZdZdS)MemoryViewTestscd}d}d}d}||fD]7}||}||}tj||}tj||} |jsd|dd<d|dd<||| ||}tj|}tj|} ||| ||jsd|dd<||| 9dS)Nrrc t|Sr) memoryviewrs r get_mv_roz*MemoryViewTests.runTest..get_mv_rosd## #rc:tt|Sr)rrrs r get_mv_rwz*MemoryViewTests.runTest..get_mv_rwsioo.. .rrr)rrireadonlyrkrjr) rdrlrrrget_mvkey_mvdata_mvrrs rrrzMemoryViewTests.runTests^ $ $ $ / / /!), 7 7FVC[[FfTllG#t$$B&'**B# &$rr %   RYY[["))++ 6 6 6fTllG#B#B IIdOOO IIg   # &%   RYY[["))++ 6 6 6 6- 7 7rNr{rwrrrrs#!7!7!7!7!7rrcxddl}ddlm}g}tD]}|dD]l}t |}|d||d<|tt|||m|td|}|tt|t|t|t|S)Nrr)make_mac_tests) digestmodr)typescommonr test_datakeyslistappenddictglobalsrr\ hash_modulesryr}r)configrr exp_test_datarowmodnamettestss r get_testsrs'LLL&&&&&& M$$1v{{}} $ $GS Aq6'?AaD HHTGIIg$6777 8 8 8   # # # #  $ N4 7 7E LL.|<<=== LL LL!!""" LL""### Lr__main__cBtjtSr)r_ TestSuiterrwrrr#sH&y{{33rsuite) defaultTest)"rvr_binasciirCrypto.Util.py3compatrr Crypto.Hashrrrr r r r r rrrrrrrrrr`r\ryr}rrrsrmainrwrrrs 2+*00000000AAAAAAAAAAAAAAAAAAAAAAAAAAAA t$v!&'%% :::  )))g  <===g  3444$&g  <===&(g *B 3; = = =% '+g 8 3444$&9g D <===&(Eg P: 3; = = =% 'Qg ^2 3444$&_g l2 <===&(mg x 9 3; = = =% 'yg H  3; = = =% 'Ig \0      $ %]g pB      $ %qg D      $ %Eg X:      $ %Yg v 9      $%wg L =      $ %Mg f ' NOOO+ -gg t ' vwww+ -ug B ' W X X X+ -Cg P0R ^^ T>??? "Qg \RZZR&'' T>??? "]g h0 T>??? "ig t: T>??? "ug @0R T>??? "Ag LR@AA T>??? "Mg XRSTT T>??? "Yg f #  /00 PQQQ( eg t +  /00 PQQQ( sg P #  /00 PQQQ(Og t +  /00 XYYY( sg B   /00 XYYY( Ag ^   /00 XYYY(]g B  +  /00 xyyy( A g R    /00 xyyy( Q g j   /00 xyyy(i g L  +  /00 Y Z Z Z(K g ^    /00 Y Z Z Z( ] g r    /00 Y Z Z Z( q g  T '''''H$5'''@#####!###33333X&333:#7#7#7#7#7h'#7#7#7L4 z 3 3EHMg&&&&&&r