+
    '(jBS                     4   ^ RI t ^ RIHtHt ^ RIHt ^ RIHtHt ^ RI	H
t
Ht ^ RIHtHt ^ RIHt R t ! R	 R
] P$                  4      t ! R R] P$                  4      t ! R R] P$                  4      t/ 3R lt]R8X  d   R t] P2                  ! RR7       R# R# )    N)hexlify	unhexlify)list_test_cases)tobytesbchr)AESDES3)SHAKE128SHA256)Counterc                 `    \         P                  ! \        V 4      R 7      P                  V4      # ))data)r
   newr   read)taglengths   &&T/home/ubuntu/cf-venv/lib/python3.14/site-packages/Crypto/SelfTest/Cipher/test_CTR.pyget_tag_randomr   (   s     <<WS\*//77    c                   6  a  ] tR t^+t o ]! R^4      t]! R^4      t]! R^4      t]! R^4      t]	P                  ! ^ ]R7      t]	P                  ! ^@]R7      tR tR tR tR	 tR
 tR tR tR tR tR tR t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# )CtrTestskey_128key_192nonce_32nonce_64prefixc                p   \         P                  ! V P                  \         P                  V P                  R 7      p\        RR4      pVP                  V4      p\         P                  ! V P                  \         P                  V P                  R 7      pVP                  V4      pV P                  W$4       R# )counter	plaintextNi@  )	r   r   r   MODE_CTRctr_128r   encryptdecryptassertEqualselfcipherptctpt2s   &    r   test_loopback_128CtrTests.test_loopback_1284   st    s||T\\JK2^^Bs||T\\JnnR !r   c                p   \         P                  ! V P                  \         P                  V P                  R 7      p\        RR4      pVP                  V4      p\         P                  ! V P                  \         P                  V P                  R 7      pVP                  V4      pV P                  W$4       R# )r   r!   Ni   )	r	   r   r   r"   ctr_64r   r$   r%   r&   r'   s   &    r   test_loopback_64CtrTests.test_loopback_64=   st    $,,t{{KK1^^B$,,t{{KnnR !r   c                   V P                  \        \        P                  V P                  \
        P                  4       V P                  \        \
        P                  V P                  \
        P                  V P                  4       R # N)	assertRaises	TypeErrorr	   r   r   r   r"   r   r#   r(   s   &r   test_invalid_counter_parameter'CtrTests.test_invalid_counter_parameterF   sJ    )TXXt||S\\J 	)SWWdllCLL$,,Wr   c                |   \         P                  ! V P                  \         P                  V P                  R 7      pV P                  VP                  V P                  4       \        P                  ! V P                  \        P                  V P                  R 7      pV P                  VP                  V P                  4       \        P                  ! ^@V P                  V P                  R7      p\        P                  ! V P                  \        P                  VR 7      pV P                  \        VR4      4       R# )r   )r   suffixnonceN)r	   r   r   r"   r0   r&   r<   r   r   r   r#   r   r   assertFalsehasattr)r(   r)   r    s   &  r   test_nonce_attributeCtrTests.test_nonce_attributeM   s    $,,t{{Kt}}5 s||T\\Jt}}5 ++bt}}Ms||WE12r   c           	        \         P                  ! V P                  \         P                  V P                  R 7      pV P                  VP                  V P                  4       \        P                  ! ^@V P                  ^ R7      p\         P                  ! V P                  \         P                  VR7      pV P                  VP                  VP                  4       \        RR4      pV P                  VP                  V4      VP                  V4      4       \         P                  ! V P                  \         P                  4      P                  p\         P                  ! V P                  \         P                  4      P                  pV P                  WV4       V P                  \        V4      ^4       \         P                  ! V P                  \         P                  RR 7      pV P                  RVP                  4       VP                  R4       V P                  \        \         P                  V P                  \         P                  V P                  V P                  R7       R# )	r<   r   initial_valuer   r!      r   )r    r<   Ns,  000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)r   r   r   r"   r   r&   r<   r   r   r$   assertNotEquallenr5   r6   r#   )r(   cipher1r    cipher2r*   nonce1nonce2r)   s   &       r   test_nonce_parameterCtrTests.test_nonce_parameter[   s   ''$,,DMMJ6++baH''$,,gF6K/,goob.AB s||4::s||4::F+Va( s||3?fll+x  	)SWWdllCLL"&,,dmm 	 	Er   c           	        \         P                  ! V P                  \         P                  V P                  R R7      p\
        P                  ! ^@V P                  R R7      p\         P                  ! V P                  \         P                  VR7      p\        RR4      pV P                  VP                  V4      VP                  V4      4       \         P                  ! V P                  \         P                  R R7      p\
        P                  ! ^@VP                  R R7      p\         P                  ! V P                  \         P                  VR7      p\        RR4      pV P                  VP                  V4      VP                  V4      4       V P                  \        \         P                  V P                  \         P                  V P                  ^ R7       R# )	  r<   rD   rC   r   r!   rE   rD   )r    rD   N)r   r   r   r"   r   r   r   r&   r$   r<   r5   r6   r#   )r(   rH   r    rI   r*   s   &    r   test_initial_value_parameter%CtrTests.test_initial_value_parameterv   s4   ''$,, $VE++bfM''$,,gFK/,goob.AB ''$,,(.0++bfM''$,,gFK/,goob.AB 	)SWWdllCLL"&,,a 	 	Ar   c           	        \         P                  ! V P                  \         P                  V P                  RR7      p\         P                  ! V P                  \         P                  V P                  RR7      p\        RR4      pV P                  VP                  V4      VP                  V4      4       V P                  \        \         P                  V P                  \         P                  RR7       V P                  \        \         P                  V P                  \         P                  V P                  R	R7       V P                  \        \         P                  V P                  \         P                  R
R7       V P                  \        \         P                  V P                  \         P                  V P                  RR7       R# )    rP   rO   r!   rE   rQ   N         s   55555555555555555s	   555555555s   555555555555555s   5555555)
r   r   r   r"   r   r   r&   r$   r5   
ValueError)r(   rH   rI   r*   s   &   r   "test_initial_value_bytes_parameter+CtrTests.test_initial_value_bytes_parameter   s4   ''$,, $(=? ''$,, $VEK/,goob.AB 	*cggt||S\\(/ 	 	1*cggt||S\\ $V 	 	E 	*cggt||S\\(/ 	 	1*cggt||S\\ $V 	 	Er   c           	     V   V P                  \        \        P                  V P                  \        P
                  \        P                  ! ^x4      R7       V P                  \        \        P                  V P                  \        P
                  \        P                  ! ^4      R7       R# )x   r   N)r5   rW   r   r   r   r"   r   r7   s   &r   test_iv_with_matching_length%CtrTests.test_iv_with_matching_length   sh    *cggt||S\\")++c"2 	 	4*cggt||S\\")++c"2 	 	4r   c                    \         P                  ! V P                  \         P                  V P                  R 7      pV P                  VP                  \         P                  4       R# r   N)r   r   r   r"   r#   r&   
block_sizer(   r)   s   & r   test_block_size_128CtrTests.test_block_size_128   s:    s||T\\J**CNN;r   c                    \         P                  ! V P                  \         P                  V P                  R 7      pV P                  VP                  \         P                  4       R# r_   )r	   r   r   r"   r0   r&   r`   ra   s   & r   test_block_size_64CtrTests.test_block_size_64   s:    $,,t{{K**DOO<r   c                ~   R .^d,          p\         P                  ! V P                  \         P                  V P                  R7      pV Uu. uF  q2P                  V4      NK  	  pp\         P                  ! V P                  \         P                  V P                  R7      pV P                  RP                  V4      VP                  RP                  V4      4      4       \         P                  ! V P                  \         P                  V P                  R7      pV Uu. uF  q2P                  V4      NK  	  pp\         P                  ! V P                  \         P                  V P                  R7      pV P                  RP                  V4      VP                  RP                  V4      4      4       R# u upi u upi s   7777777r   r   N)r   r   r   r"   r#   r$   r&   joinr(   
plaintextsr)   xciphertextss   &    r   test_unaligned_data_128 CtrTests.test_unaligned_data_128   s   !^c)
s||T\\J3=?:aq):?s||T\\J+.sxx
?S0TUs||T\\J3=?:aq):?s||T\\J+.sxx
?S0TU @
 @   
F5F:c                ~   R .^d,          p\         P                  ! V P                  \        P                  V P
                  R7      pV Uu. uF  q2P                  V4      NK  	  pp\         P                  ! V P                  \        P                  V P
                  R7      pV P                  RP                  V4      VP                  RP                  V4      4      4       \         P                  ! V P                  \        P                  V P
                  R7      pV Uu. uF  q2P                  V4      NK  	  pp\         P                  ! V P                  \        P                  V P
                  R7      pV P                  RP                  V4      VP                  RP                  V4      4      4       R# u upi u upi rh   )	r	   r   r   r   r"   r0   r$   r&   ri   rj   s   &    r   test_unaligned_data_64CtrTests.test_unaligned_data_64   s   !^c)
$,,dkkJ3=?:aq):?$,,dkkJ+.sxx
?S0TU$,,dkkJ3=?:aq):?$,,dkkJ+.sxx
?S0TU @
 @rp   c           	        V P                  \        \        P                  V P                  \        P
                  ^V P                  R7       V P                  \        \        P                  V P                  \        P
                  V P                  ^R7       \        P                  ! V P                  \        P
                  V P                  RR7       R# )   r   )r    unknownF)r    	use_aesniN)r5   r6   r   r   r   r"   r#   r7   s   &r   test_unknown_parameters CtrTests.test_unknown_parameters   s    )SWWdllCLLT\\ 	 	3)SWWdllCLL"&,, 	 	; 	cllDLLERr   c                    R Fa  p\         P                  ! V P                  \         P                  V P                  R7      p\        W!4      ! R4      pV P                  VR4       Kc  	  R# )r$   r   r   N)r$   r%   )r   r   r   r"   r#   getattrr&   )r(   funcr)   results   &   r   test_null_encryption_decryption(CtrTests.test_null_encryption_decryption   sI    (DWWT\\3<<NFV*3/FVS) )r   c                   \         P                  ! V P                  \         P                  V P                  R 7      pVP                  R4       V P                  \        VP                  R4       \         P                  ! V P                  \         P                  V P                  R 7      pVP                  R4       V P                  \        VP
                  R4       R# )r   r   N)	r   r   r   r"   r#   r$   r5   r6   r%   ra   s   & r   test_either_encrypt_or_decrypt'CtrTests.test_either_encrypt_or_decrypt   s    s||T\\Js)V^^S9s||T\\Js)V^^S9r   c                   \         P                  ! ^\        ^	4      ^,          R7      pRp\        P                  ! V P                  \        P
                  VR7      pVP                  RV,          4       V P                  \        VP                  R4       \        P                  ! V P                  \        P
                  VR7      pV P                  \        VP                  RV^,           ,          4       \        P                  ! V P                  \        P
                  VR7      pVP                  RV,          4       V P                  \        VP                  R4       \        P                  ! V P                  \        P
                  VR7      pV P                  \        VP                  RV^,           ,          4       R# )   r   i   r      9N)
r   r   r   r   r   r"   r$   r5   OverflowErrorr%   )r(   r    	max_bytesr)   s   &   r   test_wrap_aroundCtrTests.test_wrap_around   s   ++aQ"5	s||WEti'(->s||WE-Q9OPs||WEti'(->s||WE-Q9OPr   c                r   RpRp\         P                  ! V P                  \         P                  V P                  VR7      pVP                  V4      p\         P                  ! V P                  \         P                  \        V P                  4      \        V4      R7      pVP                  \        V4      4      pV P                  WF4       V P                  VP                  VP                  4       \         P                  ! V P                  \         P                  V P                  VR7      pVP                  V4      p\         P                  ! V P                  \         P                  \        V P                  4      \        V4      R7      p	V	P                  \        V4      4      p
V P                  W4       R# )   1rP   Ns   1111111111111111rV   )
r   r   r   r"   r   r$   	bytearrayr&   r<   r%   )r(   r   ivrH   ref1rI   ref2cipher3ref3cipher4ref4s   &          r   test_bytearrayCtrTests.test_bytearray   s.   & ''$,, $(*, t$''$,, )$-- 8(1"7 y/$6 ''$,, $(*, t$''$,, )$-- 8(1"7 y/$r   c                    \         P                  ! R\         P                  RR7      pVP                  RR,          4      p\        P                  ! V4      P                  4       pV P                  VR4       R# )   Ar   rB      Bi@B @96204fc470476561a3a8f3b6fe6d24be85c87510b638142d1d0fb90989f8a6a6Ns    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA)r   r   r"   r$   r   	hexdigestr&   )r(   r)   r+   digests   &   r   test_very_long_dataCtrTests.test_very_long_data  sQ    CLL<^^D7N+B))+!cdr   c                <   Rp\         P                  ! R\         P                  V P                  R7      pVP	                  V4      p\        ^4      p\         P                  ! R\         P                  V P                  R7      pVP	                  WR7      pV P                  W44       V P                  VR4       \         P                  ! R\         P                  V P                  R7      pVP                  W4R7      pV P                  W4       V P                  VR4       R#    5rB   outputNs   55555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555555   4444444444444444)r   r   r"   r   r$   r   r&   r%   )r(   r*   r)   r+   r   ress   &     r   test_output_paramCtrTests.test_output_param  s    #,,dmmD^^B3#,,dmmDnnRn/$d##,,dmmDnnRn/$d#r   c                   Rp\         P                  ! R\         P                  V P                  R7      pVP	                  V4      p\        \        ^4      4      p\         P                  ! R\         P                  V P                  R7      pVP	                  WR7       V P                  W44       \         P                  ! R\         P                  V P                  R7      pVP                  W4R7       V P                  W4       R# r   )	r   r   r"   r   r$   
memoryviewr   r&   r%   )r(   r*   r)   r+   r   s   &    r   test_output_param_memoryview%CtrTests.test_output_param_memoryview(  s    #,,dmmD^^BIcN+#,,dmmDr)$#,,dmmDr)$r   c                |   ^pRV,          p\         P                  ! R\         P                  V P                  R7      pVP	                  V4      p\         P                  ! R\         P                  V P                  R7      pV P                  \        VP                  VRV,          R7       \         P                  ! R\         P                  V P                  R7      pV P                  \        VP                  VRV,          R7       \        V^,
          4      p\         P                  ! R\         P                  V P                  R7      pV P                  \        VP                  W%R7       \         P                  ! R\         P                  V P                  R7      pV P                  \        VP                  WER7       R# )   r   rB      0r   Nr   )
r   r   r"   r   r$   r5   r6   r%   r   rW   )r(   LEN_PTr*   r)   r+   shorter_outputs   &     r   test_output_param_negCtrTests.test_output_param_neg7  s   F]#,,dmmD^^B#,,dmmD)V^^RvN#,,dmmD)V^^RvN"6A:.#,,dmmD*fnnbP#,,dmmD*fnnbPr    N)$__name__
__module____qualname____firstlineno__r   r   r   r   r   r   r   r0   r#   r-   r1   r8   r?   rL   rR   rX   r\   rb   re   rn   rr   rx   r~   r   r   r   r   r   r   r   __static_attributes____classdictcell____classdict__s   @r   r   r   +   s     Y+GY+Gj!,Hj!,H[[H-Fkk"X.G""X3E6A*E,4<=V
VS*:Q&%>e$"%Q Qr   r   c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )SP800TestVectorsiK  zMClass exercising the CTR test vectors found in Section F.5
of NIST SP 800-38Ac                   RpRpRp\         P                  ! ^\        R4      RR7      p\        V4      p\        V4      p\        V4      p\        P                  ! V\        P                  VR7      pV P                  VP                  V4      V4       \        P                  ! V\        P                  VR7      pV P                  VP                  V4      V4       R# )	 6bc1bee22e409f96e93d7e117393172a 2b7e151628aed2a6abf7158809cf4f3cf0f1f2f3f4f5f6f7f8f9fafbfcfd  nbitsr   rD   r   Nڀ6bc1bee22e409f96e93d7e117393172aae2d8a571e03ac9c9eb76fac45af8e5130c81c46a35ce411e5fbc1191a0a52eff69f2445df4f9b17ad2b417be66c3710ڀ874d6191b620e3261bef6864990db6ce9806f66b7970fdff8617187bb9fffdff5ae4df3edbd5d35e5b4f09020db03eab1e031dda2fbe03d1792170a0f3009ceer   r   r   r   r"   r&   r$   r%   r(   r!   
ciphertextkeyr    r)   s   &     r   test_aes_128SP800TestVectors.test_aes_128O  s    ;	;
 ;"+45S+T28: ni(	z*
cllG<	2J?cllG<
3Y?r   c                   RpRpRp\         P                  ! ^\        R4      RR7      p\        V4      p\        V4      p\        V4      p\        P                  ! V\        P                  VR7      pV P                  VP                  V4      V4       \        P                  ! V\        P                  VR7      pV P                  VP                  V4      V4       R# )	r   08e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7br   r   r   r   Nr   ڀ1abc932417521ca24f2b0459fe7e6e0b090339ec0aa6faefd5ccc2c6f4ce8e941e36b26bd1ebc670d1bd1d665620abf74f78a7f6d29809585a97daec58c6b050r   r   s   &     r   test_aes_192SP800TestVectors.test_aes_192f  s    ;	;
 K"+45S+T28: ni(	z*
cllG<	2J?cllG<
3Y?r   c                   RpRpRp\         P                  ! ^\        R4      RR7      p\        V4      p\        V4      p\        V4      p\        P                  ! V\        P                  VR7      pV P                  VP                  V4      V4       \        P                  ! V\        P                  VR7      pV P                  VP                  V4      V4       R# )	r   @603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4r   r   r   r   Nr   ڀ601ec313775789a5b7a7f504bbf3d228f443e3ca4d62b59aca84e990cacaf5c52b0930daa23de94ce87017ba2d84988ddfc9c58db67aada613c2dd08457941a6r   r   s   &     r   test_aes_256SP800TestVectors.test_aes_256}  s    ;	;
 ["+45S+T28: ni(	z*
cllG<	2J?cllG<
3Y?r   r   N)
r   r   r   r   __doc__r   r   r   r   r   r   s   @r   r   r   K  s"     @.@.@ @r   r   c            	          a ] tR tRt oRt. t] F-  t]P                  ] U u. uF  p \        V 4      NK  	  up 4       K/  	  R t	Rt
VtR# u up i )RFC3686TestVectorsi  c                   V P                    Fz  w  rr4\        P                  ! ^ VR7      p\        P                  ! V\        P                  VR7      pVP                  V4      pV P                  \        V4      \        V4      4       K|  	  R# )    r   r   N)bindatar   r   r   r"   r$   r&   r   )r(   r*   r+   r   r   r    r)   r}   s   &       r   runTestRFC3686TestVectors.runTest  sa    #'<<BCkk"V4GWWS#,,@F^^B'FWR['&/:	 $0r   r   N)	) 53696e676c6520626c6f636b206d7367 e4095d4fb7a7b3792d6175a3261311b8 ae6852f8121067cc4bf7a5765577f39e000000300000000000000000)@000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f@5104a106168a72d9790d41ee8edad388eb2e1efc46da57c8fce630df9141be28 7e24067817fae0d743d6ce1f32539163006cb6dbc0543b59da48d90b)H000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f20212223Hc1cf48a89f2ffdd9cf4652e9efdb72d74540a42bde6d7836d59a5ceaaef3105325b2072f 7691be035e5020a8ac6e618529f9a0dc00e0017b27777f3f4a1786f0)r    4b55384fe259c9c84e7935a003cbe928016af5b145fc9f579c175f93e3bfb0eed863d06ccfdb785150000004836733c147d6d93cb)r   @453243fc609b23327edfaafa7131cd9f8490701c5ad4a79cfc1fe0ff42f4fb0007c5cb2401b3dc33c19e7340819e0f69c678c3db8e6f6a91a0096b03b020c6eadc2cb500d)r   H96893fc55e5c722f540b7dd1ddf7e758d288bc95c69165884536c811662f2188abee0935002bf391ee8ecb159b959617b0965279bf59b60a786d3e0fe0007bdfd5cbd60278dcc0912)r    145ad01dbf824ec7560863dc71e3e0c0@776beff2851db06f4c8a0542c8696f6c6a81af1eec96b4d37fc1d689e6c1c10400000060db5672c97aa8f0b2)r   @f05e231b3894612c49ee000b804eb2a9b8306b508f839d6a5530831d9344af1c@f6d66d6bd52d59bb0796365879eff886c66dd51a5b6a99744b50590c87a2388400faac24c1585ef15a43d875)r   Heb6c52821d0bbbf7ce7594462aca4faab407df866569fd07f48cc0b583d6071f1ec0e6b8@ff7a617ce69148e4f1726e2f43581de2aa62d9f805532edff1eed687fb54153d001cc5b751a51d70a1c11148)r   r   r   r   r   r   tvappendr   r   r   r   )rl   r   s   0@r   r   r     sL     %
DN Gb1b	!b12 ; ; 2s   A

r   c                     . pV\        \        4      ,          pV\        \        4      ,          pV\        4       .,          pV# r4   )r   r   r   r   )configtestss   & r   	get_testsr    s<    E	_X&&E	_-..E	!#%%ELr   __main__c                  >    \         P                  ! \        4       4      # r4   )unittest	TestSuiter  r   r   r   <lambda>r    s    H&&y{3r   suite)defaultTest)r  binasciir   r   Crypto.SelfTest.st_commonr   Crypto.Util.py3compatr   r   Crypto.Cipherr   r	   Crypto.Hashr
   r   Crypto.Utilr   r   TestCaser   r   r   r  r   r  mainr   r   r   <module>r     s   >  ' 5 / # ( 8]Qx   ]Q@	F@x(( F@R7;** 7;t   z3EMMg& r   