ff ddlZddlmZmZddlmZddlmZddlm Z m Z Gddej Z Gdd e Z Gd d e ZGd d ej ZifdZedkrdZejddSdS)N) unhexlifyhexlify)tobytes)list_test_cases) TupleHash128 TupleHash256cPeZdZdZdZdZdZdZdZdZ dZ d Z d Z d Z d S) TupleHashTestc&|jj|i|SN) TupleHashnew)selfargskwargss /builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/SelfTest/Hash/test_TupleHash.pyrzTupleHashTest.new s!t~!426222c|}|jj|jfD]z}tdddD],}||}||jdz|-tddD])}||}||j|*{|}||j|jdS)N@i digest_bits digest_bytes)rr range assertEqual digest_size default_bytes)rhnew_funcdbitshobjdbytess rtest_new_positivezTupleHashTest.test_new_positives HHJJ*AE1 ; ;Hr8Q// > >xE222  !1A!5u====7++ ; ;xV444  !16:::: ;uuww )4+=>>>>>rc|}|jj|jfD]}|t||j|j|t |d|t ||jdz|t ||jdz |t ||jdz dS)N)rrrrrr)rr assertRaises TypeError minimum_bytes minimum_bits ValueError)rr r!s rtest_new_negativezTupleHashTest.test_new_negatives HHJJ*AE1 B BH   i+/+=*.*;  = = =   j(  C C C   j(*.*;a*?  A A A   j(*.*;a*?  A A A   j(*.*r?)rmacr0rFs rtest_hex_digestzTupleHashTest.test_hex_digest[shhjjMMOO  ')*<*<=== )444  9d8nn==>>>>>rcNd}t|}|}|}||||d|dd<|||dS)Nr() bytearrayrr4rr0)rdatadata_bah1h2s rtest_bytearrayzTupleHashTest.test_bytearraygsD// XXZZ XXZZ $ '  biikk22222rcnd}d}d}||fD]}||}|}|}|||||jsd|dd<|||dS)NrJc t|Sr ) memoryviewrMs r get_mv_roz0TupleHashTest.test_memoryview..get_mv_rozsd## #rc:tt|Sr )rTrLrUs r get_mv_rwz0TupleHashTest.test_memoryview..get_mv_rw}sioo.. .rrKr()rr4readonlyrr0)rrMrVrXget_mvdata_mvrOrPs rtest_memoryviewzTupleHashTest.test_memoryviewvs $ $ $ / / /!), 7 7FfTllGBB IIdOOO IIg   # &%   RYY[["))++ 6 6 6 6 7 7rN)__name__ __module__ __qualname__rr%r.r2r8r;r@rDrHrQr\rrr r s333??? B B B:::((($555 ===555 ? ? ? 3 3 377777rr c"eZdZeZdZdZdZdZdS)TupleHash128TestrrN) r]r^r_rr r+rr, default_bitsr`rrrbrb'IMMLLLLrrbc"eZdZeZdZdZdZdZdS)TupleHash256TestrrrcN) r]r^r_rr r+rr,rdr`rrrgrgrerrgc feZdZddddefddddefddd d efddd d efddd defddddefgZdZdZdS)NISTExampleTestVectors)00 01 0210 11 12 13 14 15z^C5 D8 78 6C 1A FB 9B 82 11 1A B3 4B 65 B2 C0 048F A6 4E 6D 48 E2 63 26 4C E1 70 7D 3F FC 8E D1zKMAC128 Sample #1 NISTz My Tuple Appz^75 CD B2 0F F4 DB 11 54 E8 41 D7 58 E2 41 60 C54B AE 86 EB 8C 13 E7 F5 F4 0E B3 55 88 E9 6D FBzKMAC128 Sample #2 NIST)rjrkz20 21 22 23 24 25 26 27 28z^E6 0F 20 2C 89 A2 63 1E DA 8D 4C 58 8C A5 FD 07F3 9E 51 51 99 8D EC CF 97 3A DB 38 04 BB 6E 84zKMAC128 Sample #3 NISTzCF B7 05 8C AC A5 E6 68 F8 1A 12 A2 0A 21 95 CE97 A9 25 F1 DB A3 E7 44 9A 56 F8 22 01 EC 60 7311 AC 26 96 B1 AB 5E A2 35 2D F1 42 3B DE 7B D4BB 78 C9 AE D1 A8 53 C7 86 72 F9 EB 23 BB E1 94zKMAC256 Sample #4 NISTz14 7C 21 91 D5 ED 7E FD 98 DB D9 6D 7A B5 A1 1692 57 6F 5F E2 A5 06 5F 3E 33 DE 6B BA 9F 3A A1C4 E9 A0 68 A2 89 C6 1C 95 AA B3 0A EE 1E 41 0B0B 60 7D E3 62 0E 24 A4 E3 BF 98 52 A1 D4 36 7EzKMAC256 Sample #5 NISTz45 00 0B E6 3F 9B 6B FD 89 F5 47 17 67 0F 69 A9BC 76 35 91 A4 F0 5C 50 D6 88 91 A7 44 BC C6 E7D6 D5 B5 E8 2C 01 8D A9 99 ED 35 B0 BB 49 C9 678E 52 6A BD 8E 85 C1 3E D2 54 02 1D B9 E7 90 CEzKMAC256 Sample #6 NISTc g}|jD]}dgt|z}g|d<|dD]>}|dt|dd?t |d|d<t|ddd|d<|d|d<|d|d<||||_dS)Nr rlr() test_datar1appendrreplacer)rtdtv_intv_outr:s rsetUpzNISTExampleTestVectors.setUps ^  EVc%jj(FF1I( E Eq   6>>#r+B+B!C!CDDDDa))F1I!%("2"23";";< $     > $     > $     > %     > %     > %  {NI` <<<<rsz''''''''))))))55555522222222B7B7B7B7B7H%B7B7B7J}}i<i<i<i<i