+
    '(j\O                        ^ RI t ^ RIt^ RIt^ RIHtHt ^ RIHtHtH	t	 ^ RI
Ht ^ RIHt ^ RIHt  ! R R]P                   4      t ! R	 R
]P                   4      t ! R R]P                   4      t ! R R]P                   4      t ! R R]P                   4      t ! R R]P                   4      t/ 3R lt]R8X  d   ^ RItR t]P4                  ! RR7       R# R# )    N)hexlify	unhexlify)btobytesbchr)strxor_c)list_test_cases)ChaCha20c                   \   a  ] tR t^+t o R tR tR tR tR tR t	R t
R tR	 tR
 tRtV tR# )ChaCha20Testc                   \         P                  ! \        R 4      ^ ,          RR7      pV P                  VP                  R4       \         P                  ! \        R 4      ^ ,          RR7      pV P                  VP                  R4       R# )0keynonceNs   00000000s   000000000000)r
   newr   assertEqualr   )selfciphers   & Y/home/ubuntu/cf-venv/lib/python3.14/site-packages/Crypto/SelfTest/Cipher/test_ChaCha20.pytest_new_positiveChaCha20Test.test_new_positive-   sZ    !C&)6:x0!C&)7;y1    c                \   \         P                  pV P                  \        V4       V P                  \        V\	        R 4      R7       V P                  \
        V\	        R 4      ^,          \	        R 4      R7       V P                  \
        V\	        R 4      \	        R 4      ^ ,          R7       R# )r   )r   )r   r   N)r
   r   assertRaises	TypeErrorr   
ValueError)r   r   s   & r   test_new_negativeChaCha20Test.test_new_negative3   sz    ll)S))S#7*c3qvF*c3QsVBYGr   c                8   \         P                  ! \        ^4      ^ ,          R7      p\         P                  ! \        ^4      ^ ,          R7      pV P                  \	        VP
                  4      ^4       V P                  VP
                  VP
                  4       R# )   )r   N)r
   r   r   r   lenr   assertNotEqual)r   cipher1cipher2s   &  r   test_default_nonceChaCha20Test.test_default_nonce:   s_    ,,47R<0,,47R<0W]]+Q/GMM7==9r   c                    RpRp\         P                  ! WR7      pV P                  W#P                  4       Rp\         P                  ! WR7      pV P                  WEP                  4       R# )   Ar   N    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAs   PPPPPPPPs   QQQQQQQQQQQQr
   r   r   r   )r   r   nonce1r$   nonce2r%   s   &     r   
test_nonceChaCha20Test.test_nonce@   sQ    ,,35/,,35/r   c                   \         P                  ! \        R4      ^ ,          \        R4      ^,          R7      pVP                  \        R4      4       V P	                  \
        VP                  \        R4      4       \         P                  ! \        R4      ^ ,          \        R4      ^,          R7      pVP                  \        R4      4       V P	                  \
        VP                  \        R4      4       R# )zFVerify that a cipher cannot be used for both decrypting and encrypting56r   89N)r
   r   r   encryptr   r   decrypt)r   c1c2s   &  r   test_eiter_encrypt_or_decrypt*ChaCha20Test.test_eiter_encrypt_or_decryptK   s     \\afrk3!<


1S6)RZZ38\\afrk3!<


1S6)RZZ38r   c                :   \        R 4      R,          p\        P                  ! \        R4      ^ ,          \        R4      ^,          R7      p\        P                  ! \        R4      ^ ,          \        R4      ^,          R7      pVP                  V4      pV P	                  VP                  V4      V4       V P	                  VP                  \        R4      4      \        R4      4       V P	                  VP                  \        R4      4      \        R4      4       R# )Ai   r1   r2   r    N)r   r
   r   r5   r   r6   )r   ptr7   r8   cts   &    r   test_round_tripChaCha20Test.test_round_tripV   s    sVd]\\afrk3!<\\afrk3!<ZZ^B,AbE*AbE2AbE*AbE2r   c           	        ^ RI Hp Rp\        V4      p\        R4      p\	        V4      V8  d(   WAP                  V4      P                  4       ,          pK7  \        P
                  ! \        R4      ^ ,          \        R4      ^,          R7      pVP                  V4      p\        P
                  ! \        R4      ^ ,          \        R4      ^,          R7      p\        P
                  ! \        R4      ^ ,          \        R4      ^,          R7      p^ p	V Fm  p
V P                  VP                  WiW,            4      WIW,            4       V P                  VP                  WIW,            4      WiW,            4       W,          p	Ko  	  R# )zCVerify that an arbitrary number of bytes can be encrypted/decrypted)SHA1r=   7tr   N)r!                     )Crypto.HashrC   sumr   r"   r   digestr
   r5   r   r6   )r   rC   segmentstotalr>   r$   r?   r%   cipher3idxsegments   &          r   test_streamingChaCha20Test.test_streaming`   s   $+HrU"go((2,%%''B,,1S6B;afqjA__R ,,1S6B;afqjA,,1S6B;afqjAGW__RCK-@A2#+CVWW__RCK-@A2#+CVWNC  r   c                   \         P                  ! \        R 4      ^ ,          \        R4      ^,          R7      pRp\        R4      ^@,          pVP                  \        R4      V,          4       VP                  V4      p\         P                  ! \        R 4      ^ ,          \        R4      ^,          R7      pVP	                  V4       VP                  V4      pV P                  WF4       R# )r4   er   1r   Ni  )r
   r   r   r5   seekr   )r   r$   offsetr>   ct1r%   ct2s   &      r   	test_seekChaCha20Test.test_seekv   s    ,,1S6B;afqjAsVb[#(oob!,,1S6B;afqjAVoob!"r   c                |   \        ^ 4      \        ^4      ,           \        ^ 4      ^,          ,           p\        ^ 4      ^,          p\        P                  ! WR7      pVP                  ^4       \	        \        R4      4      pVP                  \        ^ 4      \        V4      ,          4      pV P                  WE4       R# )r   r   ڀ72d54dfbf12ec44b362692df94137f328fea8da73990265ec1bbbea1ae9af0ca13b25aa26cb4a648cb9b9d1be65b2c0924a66c54d545ec1b7374f4872e99f096N)	r   r
   r   rY   r   r   r5   r"   r   )r   r   r   r   expected_key_streamr?   s   &     r   test_seek_tvChaCha20Test.test_seek_tv   s     1gS	!DGbL0Q!#3F'/)  ^^DGc*=&>>?,1r   c                `   . ROpV F  p\        V^ ,          4      p\        V^,          4      pV^,          ^@,          p\        V^,          4      p\        V^,          4      p\        P                  ! W4R7      pV^ 8w  d   VP                  V4       VP	                  V4      p	W8X  d   K  Q h	  R# )00r   N))@0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000r   ڀ00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ڀ76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc8b770dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11cc387b669b2ee6586)@0000000000000000000000000000000000000000000000000000000000000001000000000000000000000002r!     416e79207375626d697373696f6e20746f20746865204945544620696e74656e6465642062792074686520436f6e7472696275746f7220666f72207075626c69636174696f6e20617320616c6c206f722070617274206f6620616e204945544620496e7465726e65742d4472616674206f722052464320616e6420616e792073746174656d656e74206d6164652077697468696e2074686520636f6e74657874206f6620616e204945544620616374697669747920697320636f6e7369646572656420616e20224945544620436f6e747269627574696f6e222e20537563682073746174656d656e747320696e636c756465206f72616c2073746174656d656e747320696e20494554462073657373696f6e732c2061732077656c6c206173207772697474656e20616e6420656c656374726f6e696320636f6d6d756e69636174696f6e73206d61646520617420616e792074696d65206f7220706c6163652c207768696368206172652061646472657373656420746f  a3fbf07df3fa2fde4f376ca23e82737041605d9f4f4f57bd8cff2c1d4b7955ec2a97948bd3722915c8f3d337f7d370050e9e96d647b7c39f56e031ca5eb6250d4042e02785ececfa4b4bb5e8ead0440e20b6e8db09d881a7c6132f420e52795042bdfa7773d8a9051447b3291ce1411c680465552aa6c405b7764d5e87bea85ad00f8449ed8f72d0d662ab052691ca66424bc86d2df80ea41f43abf937d3259dc4b2d0dfb48a6c9139ddd7f76966e928e635553ba76c5c879d7b35d49eb2e62b0871cdac638939e25e8a1e0ef9d5280fa8ca328b351c3c765989cbcf3daa8b6ccc3aaf9f3979c92b3720fc88dc95ed84a1be059c6499b9fda236e7e818b04b0bc39c1e876b193bfe5569753f88128cc08aaa9b63d1a16f80ef2554d7189c411f5869ca52c5b83fa36ff216b9c1d30062bebcfd2dc5bce0911934fda79a86f6e698ced759c3ff9b6477338f3da4f9cd8514ea9982ccafb341b2384dd902f3d1ab7ac61dd29c6f21ba5b862f3730e37cfdc4fd806c22f221)@1c9240a5eb55d38af333888604f6b5f0473917c1402b80099dca5cbc207075c0rk   *   2754776173206272696c6c69672c20616e642074686520736c6974687920746f7665730a446964206779726520616e642067696d626c6520696e2074686520776162653a0a416c6c206d696d737920776572652074686520626f726f676f7665732c0a416e6420746865206d6f6d65207261746873206f757467726162652e62e6347f95ed87a45ffae7426f27a1df5fb69110044c0d73118effa95b01e5cf166d3df2d721caf9b21e5fb14c616871fd84c54f9d65b283196c7fe4f60553ebf39c6402c42234e32a356b3e764312a61a5532055716ead6962568f87d3f3f7704c6a8d1bcd1bf4d50d6154b6da731b187b58dfd728afa36757a797ac188d1)r   r
   r   rY   r5   )
r   tvstvr   r   rZ   r>   	ct_expectr   r?   s
   &         r   test_rfc7539ChaCha20Test.test_rfc7539   s    Y
v BBqE"Cbe$EURZF2a5!B!"Q%(I\\c7F{F##B?#? r    N)__name__
__module____qualname____firstlineno__r   r   r&   r.   r9   r@   rT   r]   rb   ru   __static_attributes____classdictcell____classdict__s   @r   r   r   +   s?     2H:	0	93,#2 i$ i$r   r   c                   2   a  ] tR tRt o R tR tR tRtV tR# )XChaCha20Testi  c                    ^ RI Hp Rp\        VP                  RR4      4      pRp\        VP                  RR4      4      pV! W#4      pRp\        VP                  RR4      4      pV P	                  WE4       R# )	r   )
_HChaCha20s_   00:01:02:03:04:05:06:07:08:09:0a:0b:0c:0d:0e:0f:10:11:12:13:14:15:16:17:18:19:1a:1b:1c:1d:1e:1f   :r   s/   00:00:00:09:00:00:00:4a:00:00:00:00:31:41:59:27sG   82413b42 27b27bfe d30e4250 8a877d73 a0f9e4d5 8a74a853 c12ec413 26d3ecdc    N)Crypto.Cipher.ChaCha20r   r   replacer   )r   r   r   r   subkeyexpecteds   &     r   test_hchacha20XChaCha20Test.test_hchacha20  so     	6pD#./B%--c23C']X--dC89*r   c                r    RpRp\         P                  ! WR7      pV P                  W#P                  4       R# )r)   r   Nr*   s   PPPPPPPPPPPPPPPPPPPPPPPPr+   )r   r   r   r   s   &   r   r.   XChaCha20Test.test_nonce  s,    #3-r   c                z   R p\        VP                  RR4      P                  RR4      4      p\        R4      p\        R4      pRp\        VP                  RR4      P                  RR4      4      p\        P                  ! W#R7      pVP	                  ^@4       VP                  V4      pV P                  WF4       R# )	s
  
                5468652064686f6c65202870726f6e6f756e6365642022646f6c652229206973
                20616c736f206b6e6f776e2061732074686520417369617469632077696c6420
                646f672c2072656420646f672c20616e642077686973746c696e6720646f672e
                2049742069732061626f7574207468652073697a65206f662061204765726d61
                6e20736865706865726420627574206c6f6f6b73206d6f7265206c696b652061
                206c6f6e672d6c656767656420666f782e205468697320686967686c7920656c
                757369766520616e6420736b696c6c6564206a756d70657220697320636c6173
                736966696564207769746820776f6c7665732c20636f796f7465732c206a6163
                6b616c732c20616e6420666f78657320696e20746865207461786f6e6f6d6963
                2066616d696c792043616e696461652e   
r   r   s@   808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9fs0   404142434445464748494a4b4c4d4e4f5051525354555658s
  
                7d0a2e6b7f7c65a236542630294e063b7ab9b555a5d5149aa21e4ae1e4fbce87
                ecc8e08a8b5e350abe622b2ffa617b202cfad72032a3037e76ffdcdc4376ee05
                3a190d7e46ca1de04144850381b9cb29f051915386b8a710b8ac4d027b8b050f
                7cba5854e028d564e453b8a968824173fc16488b8970cac828f11ae53cabd201
                12f87107df24ee6183d2274fe4c8b1485534ef2c5fbc1ec24bfc3663efaa08bc
                047d29d25043532db8391a8a3d776bf4372a6955827ccb0cdd4af403a7ce4c63
                d595c75a43e045f0cce1f29c8b93bd65afc5974922f214a40b7c402cdb91ae73
                c0b63615cdad0480680f16515a7ace9d39236464328a37743ffc28f4ddb324f4
                d0f5bbdc270c65b1749a6efff1fbaa09536175ccd29fb9e6057b307320d31683
                8a9c71f70b5b5907a66f7ea49aadc409r   N)r   r   r
   r   rY   r5   r   )r   r>   r   ivr?   r   ct_tests   &      r   test_encryptXChaCha20Test.test_encrypt  s    
4 rzz%-55dC@A[\JK
4 rzz%-55dC@A#0B..$%r   rw   N)	rx   ry   rz   r{   r   r.   r   r|   r}   r~   s   @r   r   r     s     +$.#& #&r   r   c                   *   a  ] tR tRt o RtR tRtV tR# )ByteArrayTestiC  +Verify we can encrypt or decrypt bytearraysc                >   R pRpRp\        V4      p\        V4      p\        V4      p\        P                  ! W#R7      pVP                  V4      p\        P                  ! WVR7      p	RVR&   RVR&   V	P                  V4      p
V P	                  W4       V P	                  VP
                  V	P
                  4       \        V4      p\        V4      p\        V4      p\        P                  ! WVR7      pRVR&   RVR&   VP                  V4      pV P	                  W4       R# s   0123r      :Nr!   NNs    99999999999999999999999999999999s   tttttttt)	bytearrayr
   r   r5   r   r   r6   )r   datar   r   data_bakey_banonce_bar$   r?   r%   r   ct_barQ   pt_tests   &             r   runTestByteArrayTest.runTestF  s     D/3U#,,34__T",,6:r
//'*%6 3U#",,6:r
//%('r   rw   Nrx   ry   rz   r{   __doc__r   r|   r}   r~   s   @r   r   r   C       5 (  (r   r   c                   *   a  ] tR tRt o RtR tRtV tR# )MemoryviewTestii  r   c                   R pRpRp\        \        V4      4      p\        \        V4      4      p\        \        V4      4      p\        P                  ! W#R7      pVP	                  V4      p\        P                  ! WVR7      p	RVR&   RVR&   V	P	                  V4      p
V P                  W4       V P                  VP                  V	P                  4       \        \        V4      4      p\        \        V4      4      p\        \        V4      4      p\        P                  ! WVR7      pRVR&   RVR&   VP                  V4      pV P                  W4       R# r   )
memoryviewr   r
   r   r5   r   r   r6   )r   r   r   r   data_mvkey_mvnonce_mvr$   r?   r%   r   ct_mvrQ   r   s   &             r   r   MemoryviewTest.runTestl  s    Yt_-IcN+i./,,34__T",,6:r
//'*%6 IcN+i./9R=),,6:r
//%('r   rw   Nr   r~   s   @r   r   r   i  r   r   r   c                   .   a  ] tR tRt o . ROtR tRtV tR# )ChaCha20_AGL_NIRi  c           	     J   V P                    F  w  rp\        P                  ! \        \	        V4      4      \        \	        V4      4      R 7      p\        \	        V4      4      p\	        R4      \        V4      ,          pV P                  VP                  V4      V4       K  	  R# )r    N)rs   r
   r   r   r   r"   r   r5   )r   r   r   streamcr?   r>   s   &      r   r   ChaCha20_AGL_NIR.runTest  so    $(GG S1S6!2)AeH:MNA1V9%B6SW$BQYYr]B/	 %,r   rw   N))rf   0000000000000000   76b8e0ada0f13d90405d6ae55386bd28bdd219b8a08ded1aa836efcc8b770dc7da41597c5157488d7724e03fb8d84a376a43b8f41518a11cc387b669b2ee65869f07e7be5551387a98ba977c732d080dcb0f29a048e3656912c6533e32ee7aed29b721769ce64e43d57133b074d839d531ed1f28510afb45ace10a1f4b794d6f)rj   r      4540f05a9f1fb296d7736e7b208e3c96eb4fe1834688d2604f450952ed432d41bbe2a0b6ea7566d2a5d1e7e20d42af2c53d792b1c43fea817e9ad275ae5469633aeb5224ecf849929b9d828db1ced4dd832025e8018b8160b82284f3c949aa5a8eca00bbb4a73bdad192b5c42f73f2fd4e273644c8b36125a64addeb006c13a0)rf   0000000000000001xde9cba7bf3d69ef5e786dc63973f653a0b49e015adbff7134fcb7df137821031e85a050278a7084527214f73efc7fa5b5277062eb7a0433e445f41e3)rf   0100000000000000ڀef3fdfd6c61578fbf5cf35bd3dd33b8009631634d21e42ac33960bd138e50d32111e4caf237ee53ca8ad6426194a88545ddc497a0b466e7d6bbdb0041b2f586b)@000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f0001020304050607   f798a189f195e66982105ffb640bb7757f579da31602fc93ec01ac56f85ac3c134a4547b733b46413042c9440049176905d3be59ea1c53f15916155c2be8241a38008b9a26bc35941e2444177c8ade6689de95264986d95889fb60e84629c9bd9a5acb1cc118be563eb9b3a4a472f82e09a7e778492b562ef7130e88dfe031c79db9d4f7c7a899151b9a475032b63fc385245fe054e3dd5a97a5f576fe064025d3ce042c566ab2c507b138db853e3d6959660996546cc9c4a6eafdc777c040d70eaf46f76dad3979e5c5360c3317166a1c894c94a371876a94df7628fe4eaaf2ccb27d5aaae0ad7ad0f9d4b6ad3b54098746d4524d38407a6deb3ab78fab78c9)rf   0000000000000002ڀc2c64d378cd536374ae204b9ef933fcd1a8b2288b3dfa49672ab765b54ee27c78a970e0e955c14f3a88e741b97c286f75f8fc299e8148362fa198a39531bed6d)rx   ry   rz   r{   rs   r   r|   r}   r~   s   @r   r   r     s     6
Bp0 0r   r   c                   &   a  ] tR tRt o R tRtV tR# )
TestOutputi  c           	        RpRp\         P                  ! WR7      pRpVP                  V4      p\        \	        V4      4      p\         P                  ! WR7      pVP                  WFR7      pV P                  WV4       V P                  VR4       \         P                  ! WR7      pVP                  WVR7      pV P                  WF4       V P                  VR4       \        \        \	        V4      4      4      p\         P                  ! WR7      pVP                  WFR7       V P                  WV4       \         P                  ! WR7      pVP                  WVR7       V P                  WF4       \         P                  ! WR7      pV P                  \        VP                  VR\	        V4      ,          R7       \         P                  ! WR7      pV P                  \        VP                  VR\	        V4      ,          R7       \        \	        V4      ^,
          4      p\         P                  ! WR7      pV P                  \        VP                  WHR7       \         P                  ! WR7      pV P                  \        VP                  WXR7       R# )   4r   )outputN   0s    44444444444444444444444444444444s   55555555s,  555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555)r
   r   r5   r   r"   r   r6   r   r   r   r   )	r   r   r   r   r>   r?   r   resshorter_outputs	   &        r   r   TestOutput.runTest  s    #3^^B3r7##3nnRn/$d##3nnRn/$d#Ic"g./#3r)$#3r)$#3)V^^RSWM#3)V^^RSWM"3r7Q;/#3*fnnbP#3*fnnbPr   rw   N)rx   ry   rz   r{   r   r|   r}   r~   s   @r   r   r     s     *Q *Qr   r   c                 *   . pV\        \        4      ,          pV\        \        4      ,          pVP                  \	        4       4       VP                  \        4       4       VP                  \        4       4       VP                  \        4       4       V# N)r	   r   r   appendr   r   r   r   )configtestss   & r   	get_testsr     se    E	_\**E	_]++E	LL!#$	LL!	LL!"	LLLr   __main__c                  >    \         P                  ! \        4       4      # r   )unittest	TestSuiter   rw   r   r   <lambda>r     s    H&&y{3r   suite)defaultTest)osrer   binasciir   r   Crypto.Util.py3compatr   r   r   Crypto.Util.strxorr   Crypto.SelfTest.st_commonr	   Crypto.Cipherr
   TestCaser   r   r   r   r   r   r   rx   r   mainrw   r   r   <module>r      s   > 
 	  ' 2 2 ' 5 "S$8$$ S$l?&H%% ?&D#(H%% #(L#(X&& #(LA0x(( A0H,Q"" ,Q^  	 z3EMMg& r   