+
    '(jC                        R t ^ RIt^ RIHtHtHt ^ RIHt ^ RIH	t	  ! R R4      t
]
3R lt ! R R	]P                  4      t ! R
 R]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 ! R R]P                  4      t]! 4       3R ltR tR# )z&Self-testing for PyCrypto hash modulesN)a2b_hexb2a_hexhexlify)b)strxor_cc                       ] tR t^!tRtR# )
_NoDefault N)__name__
__module____qualname____firstlineno____static_attributes__r	       R/home/ubuntu/cf-venv/lib/python3.14/site-packages/Crypto/SelfTest/Cipher/common.pyr   r   !   s    $r   r   c                X     W,          pY T#   \          d    T\        J d   h Tu # i ; i)zAGet an item from a dictionary, and remove it from the dictionary.)KeyErrorr   )dkdefaultretvals   &&& r   _extractr   "   s;    
 	
M  j s    ))c                   >   a  ] tR t^.t o R tR tR tR tR tRt	V t
R# )CipherSelfTestc                   \         P                  P                  V 4       Wn        VP	                  4       p\        VR 4      V n        \        \        VR4      4      V n        \        \        VR4      4      V n	        \        \        VR4      4      V n
        \        VRR4      V n        \        VRR4      V n        \        VRR4      V n        V P                  '       d   \        V P                  4      V n        \        VRR4      p\        V4      V n        Ve~   \!        V P                  R	V,           4      V n        \        VR
R4      V n        V P$                  f   \        VRR4      V n        V P$                  e   \        V P$                  4      V n        MARV n        \        VR
R4      V n        V P$                  e   \        V P$                  4      V n        W n        R# descriptionkey	plaintext
ciphertextmodule_nameN
assoc_datamacmodeMODE_ivnonceunittestTestCase__init__modulecopyr   r   r   r   r   r   r    r!   r"   str	mode_namegetattrr#   r%   extra_paramsselfr+   paramsr#   s   &&& r   r*   CipherSelfTest.__init__0   si   ""4( #FM:Xfe,-8FK89HV\:;#FM4@"6<>FE40???{DH-TWt^<DIvtT2DGww"67D9ww"DGG* DIvtT2DGww"DGG*"r   c                    V P                   # N)r   r2   s   &r   shortDescriptionCipherSelfTest.shortDescriptionV   s    r   c                0   V P                   P                  4       p\        V P                  4      p. pV P                  e   V P                  .pV P
                  e   V\        V P
                  4      .,          pV P                  P                  ! V.VO5/ VB # r6   r0   r,   r   r   r#   r%   r+   newr2   r3   r   	old_styles   &   r   _newCipherSelfTest._newY   {    ""'')dhh	99 ))I777477+--I{{s9Y9&99r   c                    \        V P                  R V,           4      '       g   R# V P                  \        V P                  R V,           4      8H  # )r$   F)hasattrr+   r#   r/   )r2   names   &&r   isModeCipherSelfTest.isModee   s8    t{{GDL11yyGDKK>>>r   c                   \        V P                  4      p\        V P                  4      p. pV P                  '       d.   V P                   Uu. uF  p\        \	        V4      4      NK  	  ppR pR p\        ^4       F  pV P                  4       pV P                  4       p	V F%  p
VP                  V
4       V	P                  V
4       K'  	  \        VP                  V4      4      p\        V	P                  V4      4      pV'       d#   V P                  W[4       V P                  Wl4       YreK  	  V P                  V P                  V4       V P                  V P                  V4       V P                  '       d\   \        XP                  4       4      pV P                  V P                  V4       X	P                  \        V P                  4      4       R # R # u upi r6   )r   r   r   r!   r   ranger?   updater   encryptdecryptassertEqualr"   digestverify)r2   r   r   r!   xctpticipherdeciphercompctXptXr"   s   &             r   runTestCipherSelfTest.runTestj   se   DNN+	T__-

???26//B/Q71Q4=/JB qAYY[Fyy{H #d#% # &..34C(**:67C  )  ) " 	"-,888&--/*CTXXs+OOGDHH-. ; Cs   Gr!   r   r   r0   r%   r   r"   r#   r.   r+   r    r   N)r
   r   r   r   r*   r8   r?   rE   rX   r   __classdictcell____classdict__s   @r   r   r   .   s$     $#L 
:?
%/ %/r   r   c                   ,   a  ] tR t^t o R tR tRtV tR# )CipherStreamingSelfTestc                r    V P                   pV P                  e   VRV P                  : R2,          pV: R2# )Nz in z modez# should behave like a stream cipher)r    r#   r.   )r2   descs   & r   r8   (CipherStreamingSelfTest.shortDescription   s1    99 T^^55D:>@@r   c           	        \        V P                  4      p\        V P                  4      p. pV P                  4       p\	        ^ \        V4      ^4       F,  pVP                  VP                  WV^,            4      4       K.  	  \        \        R4      P                  V4      4      pV P                  V P                  V4       . pV P                  4       p\	        ^ \        V4      ^4       F,  pVP                  VP                  W%V^,            4      4       K.  	  \        \        R4      P                  V4      4      pV P                  V P                  V4       R# )     N)r   r   r   r?   rH   lenappendrJ   r   r   joinrL   )r2   r   r   ct3rS   rR   pt3s   &      r   rX   CipherStreamingSelfTest.runTest   s   DNN+	T__-

 q#i.!,AJJv~~i!A#&678 -aejjo&#. q#j/1-AJJv~~j1Q3&789 . aejjo&-r   r	   N)r
   r   r   r   r8   rX   r   r[   r\   s   @r   r_   r_      s     A. .r   r_   c                   2   a  ] tR t^t o R tR tR tRtV tR# )RoundtripTestc                4   ^ RI Hp \        P                  P	                  V 4       Wn        VP                  VP                  4      V n        \        VR,          4      V n
        ^d\        VR,          4      ,          V n        VP                  RR4      V n        R# )rd   )Randomr   r   r    N)Cryptoro   r(   r)   r*   r+   get_random_bytes
block_sizer%   r   r   r   getr    )r2   r+   r3   ro   s   &&& r   r*   RoundtripTest.__init__   so    !""4())&*;*;<VE]#q!455!::mT:r   c                "    V P                   : R 2# )z6 .decrypt() output of .encrypt() should not be garbled)r    r7   s   &r   r8   RoundtripTest.shortDescription   s    QUQaQaccr   c                ~   V P                   P                  pV P                   P                  \        V P                  4      V4      pVP                  V P                  4      pV P                   P                  \        V P                  4      V4      pVP                  V4      pV P                  V P                  V4       R # r6   )	r+   MODE_ECBr<   r   r   rJ   r   rK   rL   )r2   r#   encryption_cipherr   decryption_cipherdecrypted_plaintexts   &     r   rX   RoundtripTest.runTest   s     {{## KKOOGDHH,=tD&..t~~>
 KKOOGDHH,=tD/77
C)<=r   )r%   r   r+   r    r   N)	r
   r   r   r   r*   r8   rX   r   r[   r\   s   @r   rm   rm      s     ;d> >r   rm   c                   8   a  ] tR t^t o R tR tR tR tRtV t	R# )IVLengthTestc                ~    \         P                  P                  V 4       Wn        \	        VR ,          4      V n        R# r   Nr(   r)   r*   r+   r   r   r2   r+   r3   s   &&&r   r*   IVLengthTest.__init__   +    ""4(VE]#r   c                    R # )zTCheck that all modes except MODE_ECB and MODE_CTR require an IV of the proper lengthr	   r7   s   &r   r8   IVLengthTest.shortDescription   s    er   c           	         V P                  \        V P                  P                  \	        V P
                  4      V P                  P                  \        R 4      4       R# )re   N)assertRaises	TypeErrorr+   r<   r   r   rx   r   r7   s   &r   rX   IVLengthTest.runTest   s:    )T[[__gdhh6G$$ae	-r   c                <    R V P                   P                  ,          # ) )r+   rr   r7   s   &r   _dummy_counterIVLengthTest._dummy_counter   s    dkk,,,,r   r   r+   N)
r
   r   r   r   r*   r8   rX   r   r   r[   r\   s   @r   r~   r~      s     $
f-- -r   r~   c                   ,   a  ] tR t^t o R tR tRtV tR# )NoDefaultECBTestc                ~    \         P                  P                  V 4       Wn        \	        VR ,          4      V n        R# r   r   r   s   &&&r   r*   NoDefaultECBTest.__init__   r   r   c                    V P                  \        V P                  P                  \	        V P
                  4      4       R # r6   )r   r   r+   r<   r   r   r7   s   &r   rX   NoDefaultECBTest.runTest   s%    )T[[__gdhh6GHr   r   Nr
   r   r   r   r*   rX   r   r[   r\   s   @r   r   r      s     $
I Ir   r   c                   ,   a  ] tR t^t o R tR tRtV tR# )BlockSizeTestc                    \         P                  P                  V 4       Wn        \	        \        VR ,          4      4      V n        R# r   )r(   r)   r*   r+   r   r   r   r   s   &&&r   r*   BlockSizeTest.__init__   s0    ""4(1VE]+,r   c                    V P                   P                  V P                  V P                   P                  4      pV P	                  VP
                  V P                   P
                  4       R # r6   )r+   r<   r   rx   rL   rr   )r2   rS   s   & r   rX   BlockSizeTest.runTest   sD    4;;+?+?@**DKK,B,BCr   r   Nr   r\   s   @r   r   r      s     -
D Dr   r   c                   6   a  ] tR t^t o RtR tR tR tRtV t	R# )ByteArrayTestz;Verify we can use bytearray's for encrypting and decryptingc                   \         P                  P                  V 4       Wn        VP	                  4       p\        VR 4      V n        \        \        VR4      4      V n        \        \        VR4      4      V n	        \        \        VR4      4      V n
        \        VRR4      V n        \        VRR4      V n        \        VRR4      V n        V P                  '       d   \        V P                  4      V n        \        VRR4      p\        V4      V n        Ve~   \!        V P                  R	V,           4      V n        \        VR
R4      V n        V P$                  f   \        VRR4      V n        V P$                  e   \        V P$                  4      V n        MARV n        \        VR
R4      V n        V P$                  e   \        V P$                  4      V n        W n        R# r   r'   r1   s   &&& r   r*   ByteArrayTest.__init__   i   ""4( #FM:Xfe,-8FK89HV\:;#FM4@"6<>FE40???{DH-TWt^<DIvtT2DGww"67D9ww"DGG* DIvtT2DGww"DGG*"r   c                0   V P                   P                  4       p\        V P                  4      p. pV P                  e   V P                  .pV P
                  e   V\        V P
                  4      .,          pV P                  P                  ! V.VO5/ VB # r6   r;   r=   s   &   r   r?   ByteArrayTest._new  rA   r   c           
     v   \        V P                  4      p\        V P                  4      p. pV P                  '       d7   V P                   Uu. uF   p\	        \        \        V4      4      4      NK"  	  ppV P                  4       pV P                  4       pV F%  pVP                  V4       VP                  V4       K'  	  \        VP                  \	        V4      4      4      p\        VP                  \	        V4      4      4      p	V P                  V P                  V4       V P                  V P                  V	4       V P                  '       de   \        VP                  4       4      p
V P                  V P                  V
4       VP                  \	        \        V P                  4      4      4       R # R # u upi r6   )r   r   r   r!   	bytearrayr   r?   rI   r   rJ   rK   rL   r"   rM   rN   r2   r   r   r!   rO   rS   rT   rU   rP   rQ   r"   s   &          r   rX   ByteArrayTest.runTest#  s9   DNN+	T__-

???=A__M_9WQqT]3_JM99; DMM$OOD!  V^^Ii$89:X%%i
&;<="-,888&--/*CTXXs+OOIgdhh&789 ! N   &F6rZ   N
r
   r   r   r   __doc__r*   r?   rX   r   r[   r\   s   @r   r   r      s     E##J
:: :r   r   c                   6   a  ] tR tRt o RtR tR tR tRtV t	R# )MemoryviewTesti?  z;Verify we can use memoryviews for encrypting and decryptingc                   \         P                  P                  V 4       Wn        VP	                  4       p\        VR 4      V n        \        \        VR4      4      V n        \        \        VR4      4      V n	        \        \        VR4      4      V n
        \        VRR4      V n        \        VRR4      V n        \        VRR4      V n        V P                  '       d   \        V P                  4      V n        \        VRR4      p\        V4      V n        Ve~   \!        V P                  R	V,           4      V n        \        VR
R4      V n        V P$                  f   \        VRR4      V n        V P$                  e   \        V P$                  4      V n        MARV n        \        VR
R4      V n        V P$                  e   \        V P$                  4      V n        W n        R# r   r'   r1   s   &&& r   r*   MemoryviewTest.__init__B  r   r   c                0   V P                   P                  4       p\        V P                  4      p. pV P                  e   V P                  .pV P
                  e   V\        V P
                  4      .,          pV P                  P                  ! V.VO5/ VB # r6   r;   r=   s   &   r   r?   MemoryviewTest._newg  rA   r   c           
     v   \        V P                  4      p\        V P                  4      p. pV P                  '       d7   V P                   Uu. uF   p\	        \        \        V4      4      4      NK"  	  ppV P                  4       pV P                  4       pV F%  pVP                  V4       VP                  V4       K'  	  \        VP                  \	        V4      4      4      p\        VP                  \	        V4      4      4      p	V P                  V P                  V4       V P                  V P                  V	4       V P                  '       de   \        VP                  4       4      p
V P                  V P                  V
4       VP                  \	        \        V P                  4      4      4       R # R # u upi r6   )r   r   r   r!   
memoryviewr   r?   rI   r   rJ   rK   rL   r"   rM   rN   r   s   &          r   rX   MemoryviewTest.runTests  s9   DNN+	T__-

???>BooNo:gadm4oJN99; DMM$OOD!  V^^Jy$9:;X%%j&<=>"-,888&--/*CTXXs+OOJwtxx'89: ! Or   rZ   Nr   r\   s   @r   r   r   ?  s     E##J
:; ;r   r   c           
         . pR p\        \        V4      4       EF  pW&,          p/ p\        V4      ^8X  d   Vw  VR&   VR&   VR&   Mv\        V4      ^8X  d   Vw  VR&   VR&   VR&   VR&   MR\        V4      ^8X  d'   Vw  VR&   VR&   VR&   VR&   p	VP                  V	4       M\        R\        V4      3,          4      hRV9   g   RVR&   VP	                  4       p
\        V
R4      p\        V
R4      p\        V
R4      p\        V
R4      p\        V
RR4      pVe   TpM(VR8X  d   V
'       g   R	V: R
V: 2pMR	V: R
V: RV
: 2pRW^,           V3,          pVVR&   WR&   VP                  V4       V'       g>   V\        W4      \        W4      \        W4      \        W4      \        W4      .,          pRpVP                  \        W4      4       EK  	  V# )Fr   r   r   r   Unsupported tuple size %dr#   ECBNp=, k=, 
%s #%d: %sr    T)rH   rf   rI   AssertionErrorr,   r   rm   r~   r   r   r   rg   r   )r+   r    	test_dataadditional_paramstestsextra_tests_addedrR   rowr3   r0   p2p_keyp_plaintextp_ciphertextp_modep_descriptionr   rD   s   &&&&              r   make_block_testsr     s   E3y>"l s8q=ILFVK &"6uX]`c]VK &"6uvmG\X]nqkVK &"6uvmG\^jMM,' !<C{!JKK"F6N [[]U#r;/L1"f% ]D9$'Ku_RR*5u=K.95"EK{aC== $} +}'( !f-V, 0f-f- E !% 	^F34o #r Lr   c                 d   . pR p\        \        V4      4       EF  pW%,          p/ p\        V4      ^8X  d   Vw  VR&   VR&   VR&   Mv\        V4      ^8X  d   Vw  VR&   VR&   VR&   VR&   MR\        V4      ^8X  d'   Vw  VR&   VR&   VR&   VR&   pVP                  V4       M\        R\        V4      3,          4      hVP	                  4       p	\        V	R4      p
\        V	R4      p\        V	R4      p\        V	RR4      pVe   TpM!V	'       g   RV: RV
: 2pMRV: RV
: R	V	: 2pR
W^,           V3,          pWR&   WR&   V'       g0   V\        W4      .,          pVP                  \        W4      4       RpVP                  \        W4      4       VP                  \        W4      4       EK  	  V# )Fr   r   r   r   r   Nr   r   r   r   r    T)rH   rf   rI   r   r,   r   r   rg   r   r   r_   )r+   r    r   r   r   rR   r   r3   r0   r   r   r   r   r   r   rD   s   &&&             r   make_stream_testsr     s   E3y>"l s8q=ILFVK &"6uX]`c]VK &"6uvmG\X]nqkVK &"6uvmG\^jMM,' !<C{!JKK [[]U#r;/L1 ]D9$'K*5u=K  /:5"EK{aC== $} +} !f- E LL78 $ 	^F34,V<=W #X Lr   )r   r(   binasciir   r   r   Crypto.Util.py3compatr   Crypto.Util.strxorr   r   r   r)   r   r_   rm   r~   r   r   r   r   dictr   r   r	   r   r   <module>r      s   2 -  . . # '  % 	a/X&& a/F.n .@>H%% >0-8$$ -"Ix(( IDH%% DM:H%% M:`M;X&& M;` HLv <|/r   