+
    '(j~                         R t ^ RIt^ RIt^ RIHt ^ RI5 ^ RIHt  ! R R]P                  4      t	 ! R R]	4      t
 ! R	 R
]P                  4      t/ 3R lt]R8X  d   R t]P                  ! RR7       R# R# )zSelf-test for Math.NumbersN)list_test_cases)*)IntegerNativec                   ^  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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$R" t%R# t&R$ t'R% t(R& t)R' t*R( t+R) t,R* t-R+ t.R, t/R- t0R. t1R/ t2R0 t3R1 t4R2 t5R3 t6R4 t7R5 t8R6t9V t:R7# )8TestIntegerBasec                    \        R 4      h)zTo be implemented)NotImplementedErrorselfs   &V/home/ubuntu/cf-venv/lib/python3.14/site-packages/Crypto/SelfTest/Math/test_Numbers.pysetUpTestIntegerBase.setUp0   s    !"566    c                .    \        V P                  V4      # N)mapInteger)r
   args   &*r   IntegersTestIntegerBase.Integers3   s    4<<%%r   c                   V P                   pV! ^4      pV! V4      pV! R4      pV P                  \        VR4       V! R4      pV! R4      pV! R4      pV! R4      pV! R4      p	V P                  W"4       V P                  V^4       V P                  W#4       V P                  VR4       V P                  VR4       V P                  VR4       V P                  VR4       V P                  VR4       V P                  V	R4       V P	                  W%8H  4       V! V4      pV P                  W'4       V P	                  V! ^ 4      R8H  4       R# )	   g      ?  l    l    Nl    d(	 l d(	 )r   assertRaises
ValueErrorassertEqualassertFalse)
r
   r   v1v2v3v4v5v6v7v8s
   &         r   test_init_and_equality&TestIntegerBase.test_init_and_equality6   s6   ,,R[R[R[*gs3V_WV_Z '( R  R X&Y'V$Z(/0" R[ t+,r   c                    V P                  R^R,          4      w  rV P                  \        V4      R4       V P                  \        V4      ^R,          4       R# )r     Ni)r   r   intr
   r   r   s   &  r   test_conversion_to_int&TestIntegerBase.test_conversion_to_intW   sD    sAI.R#&R!t),r   c                    V P                  ^R^R,          4      w  rpV P                  V^8H  4       V P                  VR8H  4       V P                  V^8H  4       V P                  V^R,          8H  4       R# )r   r)   Nir   
assertTruer   r
   r   r   r    s   &   r   test_equality_with_ints'TestIntegerBase.test_equality_with_ints\   sb    ]]2sAI6
b!c	"r"a4i(r   c                *   V P                  ^^ R^R,          4      w  rr4V P                  \        V4      R8H  4       V P                  \        V4      R8H  4       V P                  \        V4      R8H  4       V P                  \        V4      R8H  4       R# )   r)   200z-20.  10715086071862673209484250490600018105614048117055336074437503883703510511249361224931983788156958581275946729175531468251871452856923140435984577574698574803934567774824230985421074605062371141877954182153046474983581941267398767559165543946077062914571196477686542167660429831652624386837205668069376Ni)r   r0   strr
   r   r   r    r!   s   &    r   test_conversion_to_str&TestIntegerBase.test_conversion_to_strc   sz    r1c19=B4(B3'B5()B  $T  T  	Ur   c                    V P                  R^^P,          4      w  rV P                  \        V4      R4       V P                  \        V4      R4       R# )   zInteger(-1)z"Integer(1208925819614629174706176)N)r   r   reprr+   s   &  r   	test_reprTestIntegerBase.test_reprj   sA    r1b5)b=1b#GHr   c                   V P                   pV! ^ 4      pV P                  RVP                  4       4       V! ^4      pV P                  RVP                  4       4       V! R4      pV P                  RVP                  4       4       V P                  RVP                  ^4      4       V P                  \        VP                  ^4       V P                  RVP                  RR7      4       V P                  R	VP                  ^RR7      4       V! R
4      pV P                  RVP                  4       4       V P                  RVP                  RR7      4       V P                  RVP                  ^
4      4       V P                  RVP                  ^
RR7      4       V P                  \        VP                  ^4       V! R4      pV P                  \        VP                  4       V P                  \        VP                  RR7       R# )           i  s   s    s   little	byteorders    l   ";3oUs	    "s	   "̻ s
     "s
   "̻  bittleN)r   r   to_bytesr   r   )r
   r   v0r   r   r    r!   s   &      r   test_conversion_to_bytes(TestIntegerBase.test_conversion_to_byteso   s   ,,QZ"++-0T]"++-0V_bkkm4"++a.9*bkk15bkkHk&EF"++a8+*LM)*@"++-P@x8	:DR	*DR8<	>*bkk15S\*bkk2*bkkXFr   c                D   V P                   pVP                  R 4      pV P                  \        W!4      4       V P	                  ^ V4       VP                  R4      pV P	                  ^V4       VP                  R4      pV P	                  RV4       VP                  RR4      pV P	                  ^V4       VP                  RRR7      pV P	                  ^V4       VP                  RRR7      pV P	                  RV4       V P                  \        VP                  RR	4       R
# )rE   s    s   r   bigrH   rG         	rJ   N)r   
from_bytesr0   
isinstancer   r   r   )r
   r   r   r   r    r!   r"   r#   s   &       r   test_conversion_from_bytes*TestIntegerBase.test_conversion_from_bytes   s   ,,(
2/0B,B,$U3Bu=Bx@$*g&8&8'8Lr   c                b   V P                  ^Y^Y^ZR4      w  rr4V P                  W8g  4       V P                  V^Z8g  4       V P                  W8g  4       V P                  V^Y8g  4       V P                  W8g  4       V P                  WA8g  4       V P                  V P                  ^ 4      R8g  4       R# )Y   N)r   r0   r   r   r:   s   &    r   test_inequalityTestIntegerBase.test_inequality   s    r2r26!b!"r"!!Q4/0r   c                l   V P                  ^^^RR4      w  rr4pV P                  W8  4       V P                  V^8  4       V P                  W8  4       V P                  V^8  4       V P                  WA8  4       V P                  W8  4       V P                  W8  4       V P                  WQ8  4       R#    NrZ      r/   r
   r   r   r    r!   r"   s   &     r   test_less_thanTestIntegerBase.test_less_than   s    !]]2r2r7C R !b! ! !r   c                l   V P                  ^^^RR4      w  rr4pV P                  W8*  4       V P                  V^8*  4       V P                  W8*  4       V P                  V^8*  4       V P                  W8*  4       V P                  W8*  4       V P                  W8*  4       V P                  WQ8*  4       R# )r_   Nr`   r/   ra   s   &     r   test_less_than_or_equal'TestIntegerBase.test_less_than_or_equal   s    !]]2r2r7C!b!!b!!"!"r   c                   V P                  ^^^RR4      w  rr4pV P                  W18  4       V P                  V^8  4       V P                  W8  4       V P                  W8  4       V P                  V^8  4       V P                  W8  4       V P                  WA8  4       V P                  WQ8  4       V P                  W8  4       R# r^   r/   ra   s   &     r   test_more_thanTestIntegerBase.test_more_than   s    !]]2r2r7C R !!b! ! !r   c                   V P                  ^^^R4      w  rr4V P                  W18  4       V P                  V^8  4       V P                  W8  4       V P                  W8  4       V P                  V^8  4       V P                  WA8  4       R# )r_   Nre   r/   r:   s   &    r   test_more_than_or_equal'TestIntegerBase.test_more_than_or_equal   st    r2r26!b!!!b!"r   c                $   V P                  ^ ^
RR4      w  rr4V P                  V4       V P                  \        V4      4       V P                  V4       V P                  \        V4      4       V P                  V4       V P                  V4       R# )rD   Nr   r`   )r   r   boolr0   r:   s   &    r   	test_boolTestIntegerBase.test_bool   sn    q"b':b"R!r   c                N   V P                  ^^d,          ) R^ ^^^d,          4      w  rr4pV P                  VP                  4       4       V P                  VP                  4       4       V P                  VP                  4       4       V P                  VP                  4       4       R# )   N)r   r0   is_negativer   ra   s   &     r   test_is_negative TestIntegerBase.test_is_negative   sy    !]]AH9b!Q3G()())*)*r   c                ~   V P                  ^^ZR4      w  rpV P                  \        W,           V P                  4      4       V P	                  W,           ^a4       V P	                  V^Z,           ^a4       V P	                  W,           ^ 4       V P	                  VR,           ^ 4       V P	                  VR,           R4       R# )   Nr`   i  r   r0   rU   r   r   r1   s   &   r   test_additionTestIntegerBase.test_addition   s    ]]1b"-

27DLL9:"%b"%!$rA&g{3r   c                ~   V P                  ^^ZR4      w  rpV P                  \        W,
          V P                  4      4       V P	                  W!,
          ^S4       V P	                  V^,
          ^S4       V P	                  W#,
          ^a4       V P	                  VR,
          ^4       V P	                  VR,
          R4       R# )ry   Nrz   r`   ir{   r1   s   &   r   test_subtraction TestIntegerBase.test_subtraction   s    ]]1b"-

27DLL9:"%a$"%rB'g{3r   c                P   V P                  ^^RR4      w  rr4V P                  \        W,          V P                  4      4       V P	                  W,          ^4       V P	                  V^,          ^4       V P	                  VR,          R4       V P	                  VR,          R4       R# )   Nr`   rZ   i   r{   r:   s   &    r   test_multiplication#TestIntegerBase.test_multiplication  s    q!R9
27DLL9:"%a$b"%g}5r   c                  a V P                  ^^^^P,          4      w  orV P                  \        SV,          V P                  4      4       V P	                  VS,          ^4       V P	                  V^,          ^4       V P	                  VR,          R4       V P	                  V^^O,          ,          ^4       V P                  \        V3R l4       R# )rs   c                     < S ^ ,          # rD    r   s   r   <lambda>0TestIntegerBase.test_floor_div.<locals>.<lambda>  s	    R1Wr   Nrt   )r   r0   rU   r   r   r   ZeroDivisionErrorr
   r   r    r   s   &  @r   test_floor_divTestIntegerBase.test_floor_div  s    ]]1ab1
B
28T\\:;r1%q!$r2&qBw*+_=r   c                  a V P                  ^^R4      w  orV P                  \        SV,          V P                  4      4       V P	                  SV,          ^4       V P	                  S^,          ^4       V P	                  V^,          ^4       V P	                  SR,          ^4       V P                  \        V3R l4       V P                  \        V3R l4       R# )r   c                     < S ^ ,          # r   r   r   s   r   r   0TestIntegerBase.test_remainder.<locals>.<lambda>  s	    R!Vr   c                     < S R,          # )   r   r   s   r   r   r     s	    b2gr   Nre   r`   )r   r0   rU   r   r   r   r   r   r   s   &  @r   test_remainderTestIntegerBase.test_remainder  s    ]]2q"-
B
27DLL9:b!$a#a#gr*+^<*o6r   c                   V P                  ^^R4      w  rpV P                  \        W,          V P                  4      4       V P	                  W,          ^@4       V P	                  \        W4      ^@4       V P	                  V^,          ^@4       V P	                  \        V^4      ^@4       V P	                  V^,          ^4       V P	                  V^,          R4       V P                  \        \
        VR4       R# )r   Nr   rZ   rt   )r   r0   rU   r   r   powr   r   r1   s   &   r   test_simple_exponentiation*TestIntegerBase.test_simple_exponentiation!  s    ]]1a,

28T\\:;2&Rb)q"%RR(q!$q"%*c2r2r   c           	        V P                  ^^^4      w  rpV P                  \        \        WV4      V P                  4      4       V P                  \        WV4      ^4       V P                  \        V^V4      ^4       V P                  \        W^4      ^4       V P                  \        V^^4      ^4       V P                  \        V^ ^4      ^4       V P                  \        V^^^P,          4      ^4       V P                  \        V^^P,          R4      R4       V P                  \        \        V^^ 4       V P                  \        \        V^R4       V P                  \        \        VR^4       R# )r   i\ iE  Nre   rt   )	r   r0   rU   r   r   r   r   r   r   r1   s   &   r   test_modular_exponentiation+TestIntegerBase.test_modular_exponentiation-  s&   ]]2q"-

3rr?DLLABRR!,RR!,RR!,RR!,RR!,RQ"W-r2Rb5159+S"a;*c2q"5*c2r15r   c                    V P                  ^4      pVP                  ^4       V P                  V^4       V P                  ^4      pVP                  ^^4       V P                  V^4       R# )r   N)r   inplace_powr   r
   r   s   & r   test_inplace_exponentiation+TestIntegerBase.test_inplace_exponentiation=  sV    \\!_
qR \\!_
q"Qr   c                   V P                  ^^d,          ) R^ ^^^d,          4      w  rr4pV P                  \        V4      ^^d,          4       V P                  \        V4      ^4       V P                  \        V4      ^ 4       V P                  \        V4      ^4       V P                  \        V4      ^^d,          4       R#    Nr   )r   r   absra   s   &     r   test_absTestIntegerBase.test_absF  s    !]]AH9b!QSIR!s(+R!$R!$R!$R!s(+r   c                P   V P                  R^ ^1^
^d,          4      w  rr4V P                  \        VP                  4       V P	                  VP                  4       ^ 4       V P	                  VP                  4       ^4       V P	                  VP                  4       ^
^2,          4       R# r   )r   r   r   sqrtr   r:   s   &    r   	test_sqrtTestIntegerBase.test_sqrtN  sx    r1b"c':*bgg.A&A&BF+r   c                v   V P                  \        V P                  ^4      P                  ^ 4       V P                  \        V P                  ^4      P                  R4       V P                  ^ 4      P                  ^4      ^ 8X  g   Q hV P                  ^4      P                  ^4      R9   g   Q hR FV  p\	        ^ V4       FC  pV^,          V,          pV P                  V4      P                  V4      pWBW,
          39   d   KC  Q h	  KX  	  V P                  \        V P                  ^4      P                  ^4       V P                  \        V P                  ^4      P                  ^
4       V P                  R4      P                  ^4      R9   g   Q hV P                  ^4      P                  ^4      R9   g   Q hR# )   Nr?   )r>   r   )   r_         r         %   )   +   /   5   r   )r   ry   )r   r   r   r   range)r
   pisquareress   &    r   test_sqrt_module TestIntegerBase.test_sqrt_moduleV  sh    	*dll1o&:&:A>*dll1o&:&:B? ||A##A&!+++||A##A&&000 BA1a[All6*//2!%j((( ! B 	*dll1o&:&:B? 	*dll1o&:&:B? ||F#((,666||F#((,666r   c                .   V P                  ^
^4      w  rW,          pV P                  V^4       V^
,          pV P                  V^(4       VR,          pV P                  V^'4       V^R,          ,          pV P                  V^'^R,          ,           4       R# )
   r)   Nr?   r   r   r+   s   &  r   test_in_place_add!TestIntegerBase.test_in_place_addq  s    r2&
R 
bR 
bR 
a4iR!t)^,r   c                   V P                  ^
^4      w  rW,          pV P                  VR4       VR,          pV P                  V^Z4       VR,          pV P                  VR4       VR,          pV P                  VR4       R# )r   i_ ij'  Niiiʠi`yr   r+   s   &  r   test_in_place_sub!TestIntegerBase.test_in_place_sub}  sv    r2&
S!
d
R 
eV$
gU#r   c                .   V P                  ^^4      w  rW,          pV P                  V^4       V^,          pV P                  V^4       VR,          pV P                  VR4       V^R,          ,          pV P                  VR^R,          ,          4       R# )rs   r)   Nr   ir   r+   s   &  r   test_in_place_mul!TestIntegerBase.test_in_place_mul  s    q!$
R 
aR 
bS!
a4iSAI./r   c                  a  S P                  ^^4      w  rW,          pS P                  V^4       V^R,          ,          pS P                  V^4       V^,          pS P                  V^ 4       V 3R lpS P                  \        V4       R# )r5   r)   c                  <   < SP                  ^	4      p V ^ ,          p R# )	   Nr   )r    r
   s    r   t0TestIntegerBase.test_in_place_modulus.<locals>.t  s    aB!GBr   N)r   r   r   r   )r
   r   r   r   s   f   r   test_in_place_modulus%TestIntegerBase.test_in_place_modulus  sz    r1%
Q
a4iQ
aQ	 	+Q/r   c                   V P                  ^^1R4      w  rpV P                  \        W,          V P                  4      4       V P	                  W,          ^04       V P	                  V^1,          ^04       V P	                  W,          ^4       V P	                  VR,          ^4       V P	                  VR,          R4       V P	                  V^R,          ^1,           ,          ^14       R# )   r)   Nr{   r1   s   &   r   test_andTestIntegerBase.test_and  s    ]]4t4

27DLL9:$'dD)$'dD)dD)qDy4/0$7r   c                v   V P                  ^@^R4      w  rpV P                  \        W,          V P                  4      4       V P	                  W,          ^4       V P	                  V^,          ^4       V P	                  W#,          R4       V P	                  V^R,          ,          ^R,          ^,           4       R# )@   r)   Nr   ir{   r1   s   &   r   test_orTestIntegerBase.test_or  s    ]]4t4

27DLL9:$'dD)$'a4idT)9:r   c                  a V P                  ^^R4      w  orV P                  S^ ,	          S4       V P                  \        SV,	          V P                  4      4       V P                  SV,	          ^4       V P                  S^,	          ^4       V P                  \        V3R l4       V P                  S^R,          ,	          ^ 4       V P                  V^,	          R4       V P                  V^R,          ,	          R4       R# )   c                     < S R,	          # r>   r?   r   r   s   r   r   2TestIntegerBase.test_right_shift.<locals>.<lambda>  	    bBhr   r)   NrZ   r?   r   r   r0   rU   r   r   r   r   s   &  @r   test_right_shift TestIntegerBase.test_right_shift  s    ]]4E2
Bq"%
28T\\:;r4(q$'*&67T	*A.q%(T	*B/r   c                  a  S P                  ^^R4      w  rpV^ ,          pS P                  V^4       V^,          pS P                  V^4       W,          pS P                  V^4       V^,          pS P                  VR4       V 3R lpS P                  \        V4       V 3R lpS P                  ^ V! 4       4       V 3R lpS P                  RV! 4       4       R# )r   c                  <   < SP                  ^4      p V R,          p R#    Nr?   r   r!   r
   s    r   l4TestIntegerBase.test_in_place_right_shift.<locals>.l      d#B2IBr   c                  J   < SP                  ^4      p V ^R,          ,          p V # )r   r)   r   r   s    r   m15TestIntegerBase.test_in_place_right_shift.<locals>.m1  s$    d#B19BIr   c                  J   < SP                  R4      p V ^R,          ,          p V # )r>   r)   r?   r   r   s    r   m25TestIntegerBase.test_in_place_right_shift.<locals>.m2  s$    b!B19BIr   Nr   rZ   r?   r   r   r   r   )r
   r   r   r    r   r   r   s   f      r   test_in_place_right_shift)TestIntegerBase.test_in_place_right_shift  s    ]]4E2

qT"
qT"
	T"
qU#	 	*a(	 	BD!	 	RT"r   c                  a V P                  ^^R4      w  orV P                  S^ ,          S4       V P                  \        SV,          V P                  4      4       V P                  SV,          ^ 4       V P                  S^,          ^ 4       V P                  V^,          R4       V P                  \        V3R l4       V P                  \        V3R l4       R# )r   c                     < S R,          # r   r   r   s   r   r   2TestIntegerBase._test_left_shift.<locals>.<lambda>  r   r   c                  $   < S ^R,          ,          # )r   r)   r   r   s   r   r   r     s    bQ$Y.?r   Nr   r   r   s   &  @r   _test_left_shift TestIntegerBase._test_left_shift  s    ]]4E2
Bq"%
28T\\:;r4(q$'q%(*&67*&?@r   c                z  a  S P                  ^^R4      w  rpV^ ,          pS P                  V^4       V^,          pS P                  V^ 4       W,          pS P                  V^@4       V^,          pS P                  VR4       V 3R lpS P                  \        V4       V 3R lpS P                  \        V4       R# )r   c                  <   < SP                  ^4      p V R,          p R# r   r   r   s    r   r   3TestIntegerBase.test_in_place_left_shift.<locals>.l  r   r   c                  J   < SP                  ^4      p V ^R,          ,          p R# )r   r)   Nr   r   s    r   m3TestIntegerBase.test_in_place_left_shift.<locals>.m  s    d#B19Br   Nr   r   r   )r
   r   r   r    r   r  s   f     r   test_in_place_left_shift(TestIntegerBase.test_in_place_left_shift  s    ]]4E2

qT"
qT"
	T"
qU#	 	*a(	 	*a(r   c                   V P                  R R^4      w  rpV P                  VP                  ^ 4      ^ 4       V P                  VP                  ^4      ^4       V P                  VP                  V4      ^4       V P                  VP                  ^4      ^4       V P                  VP                  ^	4      ^ 4       V P                  \        VP                  R4       V P                  VP                  ^R,          4      ^ 4       V P                  \        VP                  R4       V P                  \        VP                  ^ 4       V P                  \        VP                  ^4       V P                  \        VP                  R4       R# )i  r)   Nrt   r?   i  )r   r   get_bitr   r   r1   s   &   r   test_get_bitTestIntegerBase.test_get_bit  s   ]]5"a0
A*A*B+A*A**bjj"5AI.2*bjj"5*bjj!4*bjj!4*bjj(;r   c                   V P                  ^ ^^RR4      w  rr4pV P                  VP                  4       4       V P                  VP                  4       4       V P                  VP                  4       4       V P                  VP                  4       4       V P                  VP                  4       4       V P                  VP	                  4       4       V P                  VP	                  4       4       V P                  VP	                  4       4       V P                  VP	                  4       4       V P                  VP	                  4       4       R# )rD   Nre   i)r   r0   is_evenr   is_oddra   s   &     r   test_odd_evenTestIntegerBase.test_odd_even  s    !]]1aR=

%

%&

%&%%		$%		$r   c                4   V P                  ^ ^RR4      w  rr4V P                  VP                  4       ^4       V P                  VP                  4       ^4       V P                  VP                  4       ^	4       V P                  \        VP                  4       R# )rD   rR   NrK   )r   r   size_in_bitsr   r   r:   s   &    r   test_size_in_bits!TestIntegerBase.test_size_in_bits  ss    q!UC8*A.*A.*A.*boo6r   c                   V P                  ^ ^^RRR4      w  rr4rVV P                  VP                  4       ^4       V P                  VP                  4       ^4       V P                  VP                  4       ^4       V P                  VP                  4       ^4       V P                  VP                  4       ^4       V P                  \        VP
                  4       R# )rD   i  i   Nr   )r   r   size_in_bytesr   r   r  r
   r   r   r    r!   r"   r#   s   &      r   test_size_in_bytes"TestIntegerBase.test_size_in_bytes  s    !%q!T5'2!N))+Q/))+Q/))+Q/))+Q/))+Q/*boo6r   c                   V P                  V P                  R4      P                  4       4       V P                  V P                  ^ 4      P                  4       4       V P                  V P                  ^4      P                  4       4       V P                  V P                  ^4      P                  4       4       V P                  V P                  ^4      P                  4       4       V P                  V P                  ^4      P                  4       4       V P                  V P                  R4      P                  4       4       V P                  V P                  R4      P                  4       4       \	        ^dR4       Ft  pV P                  V P                  V^,          ^,           4      P                  4       4       V P                  V P                  V^,          4      P                  4       4       Kv  	  R# )r   r)   Nr   i  i  )r   r   is_perfect_squarer0   r   )r
   xs   & r   test_perfect_square#TestIntegerBase.test_perfect_square'  sP   b);;=>Q99;<Q99;<a::<=a::<=Q99;<U+==?@g.@@BCsD!AT\\!Q$q&1CCEFOODLLA.@@BC "r   c                *   V P                  ^R^4      w  rpVP                  ^4       VP                  ^4       VP                  ^^P,          4       V P                  \        VP                  ^4       V P                  \        VP                  V4       R# )   Ni)r   fail_if_divisible_byr   r   r1   s   &   r   test_fail_if_divisible_by)TestIntegerBase.test_fail_if_divisible_by6  sz    ]]2sA.
 	"
"
R( 	*b&=&=qA*b&=&=rBr   c                |   V P                  ^^^4      w  rpVP                  W#4       V P                  V^
4       VP                  V^4       V P                  V^4       VP                  ^V4       V P                  V^4       VP                  ^R4       V P                  V^4       VP                  R^4       V P                  V^4       VP                  ^^R,          4       V P                  V^^R,          ,           4       VP                  ^R,          ^4       V P                  V^^R,          ,           4       R# )r   r)     Nr   )r   multiply_accumulater   r1   s   &   r   test_multiply_accumulate(TestIntegerBase.test_multiply_accumulateB  s   ]]1a+

r&R 
r1%R 
q"%R 
q"%R 
r1%R 
q!t),R!t)^,
qDy!,R!t)^,r   c                b   V P                  ^^4      w  rVP                  V4       V P                  V^4       VP                  ^	4       V P                  V^	4       VP                  R4       V P                  VR4       VP                  ^R,          4       V P                  V^R,          4       R# )rs   r)   Nr   )r   setr   r+   s   &  r   test_setTestIntegerBase.test_setS  s    q!$
r
Q
q	Q
r
R 
qDyQ$Y'r   c                   V P                  ^^R^ RR4      w  rr4rVV P                  \        VP                  V4      V P                  4      4       V P                  VP                  V4      ^4       V P                  VP                  ^4      ^4       V P                  VP                  ^4      ^4       V P                  VP                  R4      R4       V P                  VP                  R4      R4       V P                  \        VP                  ^
4       V P                  \        VP                  R4       V P                  \        VP                  ^
4       V P                  \        VP                  ^ 4       R# )	r   i ii  iiKS~i&  i  Nrt   )	r   r0   rU   inverser   r   r   r   r   r  s   &      r   test_inverseTestIntegerBase.test_inverse^  s   !%q!RFD!I
2::b>4<<@AB+A*A*H-x8D)40*bjj"5*bjj"5*bjj"5+RZZ;r   c                t    V P                  ^^4      w  rVP                  V4       V P                  V^4       R# )r   N)r   inplace_inverser   r+   s   &  r   test_inplace_inverse$TestIntegerBase.test_inplace_inversem  s2    q!$
2Qr   c                   V P                  ^^
^R4      w  rr4V P                  \        VP                  V4      V P                  4      4       V P                  VP                  V4      ^4       V P                  VP                  ^
4      ^4       V P                  VP                  V4      ^4       V P                  VP                  R4      ^4       V P                  VP                  ^4      ^4       R# r   Nr   )r   r0   rU   gcdr   r   r:   s   &    r   test_gcdTestIntegerBase.test_gcds  s    q"b"5
266":t||<=Q'Q'Q'Q'A&r   c                n   V P                  ^^
^R^ 4      w  rr4pV P                  \        VP                  V4      V P                  4      4       V P                  VP                  V4      ^4       V P                  VP                  ^
4      ^4       V P                  VP                  V4      ^f4       V P                  VP                  R4      ^4       V P                  VP                  ^4      ^4       V P                  VP                  ^ 4      ^ 4       V P                  VP                  ^ 4      ^ 4       R# r6  )r   r0   rU   lcmr   r   ra   s   &     r   test_lcmTestIntegerBase.test_lcm|  s    !]]1b"b!<
266":t||<=R(R(S)Q'A&A&A&r   c           
        RpV P                   P                  p\        ^^4       F  pV P                  V! V^4      ^4       K  	  \        ^^^4       F  pV P                  V! ^V4      ^4       K  	  V P	                  \
        V^R4       V P	                  \
        V^R4       V P	                  \
        V^^ 4       V P	                  \
        V^ ^ 4       V P	                  \
        V^^4       V P	                  \
        V^^4       V P	                  \
        V^^4       V P	                  \
        V^^4       V F  pV P                  V! V^ ,          V^,          4      V^,          4       V P                  V! V P                  V^ ,          4      V^,          4      V^,          4       V P                  V! V^ ,          V P                  V^,          4      4      V^,          4       K  	  R# )r%  Nr?   ))r%  r>   r>   )r   -   r>   )      r?   )r   rA  r>   )ib  i  r?   )r%  i&  r?   )r   l   -& r?   r   )r   jacobi_symbolr   r   r   r   )r
   datajskntvs   &     r   test_jacobi_symbol"TestIntegerBase.test_jacobi_symbol  s    \\'' q"AR1Xq) q"aAR1Xq) ! 	*b!R0*b!R0*b!Q/*b!Q/*b!Q/*b!Q/*b!Q/*b!Q/BR1r!u-r!u5RRU 3RU;RUCR1t||BqE':;RUC r   c                   ^. RO3^. RO3^. RO3^	. RO3^. RO3^. RO3^. RO3^. R	O3^. R
O3^. RO3^. RO3^. RO3^. RO3^. RO3.pV P                   P                  pV F(  w  r4V F  w  rVV P                  V! WS4      V4       K  	  K*  	  R# )rs   N)r>   r>   r   r?   rs   rD   r   r>   r   r?   r   rD   ry   r>   r@  r?   r   rD   r   r>   r   r?   r   rD   r_   r>      r?      rD   r   r>   r   r?      rD   r   r>   r5   r?   rA  rD      r>   r   r?      rD      r>      r?      rD      r>   r   r?      rD   )rK  rL  rs   r?   rN  r   rD   r   r>   ry   r?   rR  r   r>   r   rD   r   r>   r   r?   r_   r?   rY  r>   rZ  r\  r]  r_  r?   r`  r5   rD   rA  r>   rd  r?   re  rg  r>   ri  rD   rk  r>   rm  r?   ro  r?   r   r>   rq  )rK  r   r>   rs  rN  rO  r   r?   ry   rD   r@  r>   rw  r   r?   ry  rz  r{  rY  rD   r[  r>   r\  r]  r_  r>   r   r?   ra  rb  rc  r   r>   rg  r?   rh  rj  r  ro  rD   r  rr  r>   )rK  r  rM  rN  r   r>   rP  rQ  r  rS  rT  ry  rV  rW  r|  rZ  r\  r   r>   r^  r`  r5   r>   rb  rc  r  rf  rh  r  rl  rn  r  rq  )rK  rL  rs   r>   rN  r  r  rv  rR  rw  r  )r   rD   r   r>   r{  r|  r  r\  r]  r}  r  r  rA  r?   )rd  rD   r  r  rh  r  rm  r>   r  rp  rr  r?   )rK  rL  r  rN  rO  r  rv  rR  rw  rT  rU  r  )r_   rD   r|  r[  r?   r\  r  r}  r  ra  r  rc  r  r  rh  )rk  rD   r  r  r  r  )rK  r  rM  rN  rt  rP  rv  r  rS  rx  rU  rV  r{  rX  rZ  r\  r  r^  r`  r~  rb  r  r  rf  r  rj  rl  r  rp  rq  )rK  r  rs  rN  rO  r  rv  r  rw  r  rU  rz  rW  rX  r  r\  )r   rD   r  r`  ra  r  r  re  r  rh  r  r  r  rp  r  )rK  rL  rs  rN  r  ru  rQ  rR  rw  r  ry  rz  r{  rX  r  r\  r  r}  )r   rD   r  r  r  r  r  rh  r  r  rn  rp  r  )rK  rL  rM  rN  r  rP  r  rR  rS  r  rU  rV  r{  r  rZ  r\  r  r^  r  r  rb  rc  re  rf  rh  r  rl  r  rp  rq  )rK  r  r  rN  rO  ru  rv  r  rw  r  rU  r  rW  rX  r  r\  r]  r  r  ra  r  r  )r   rD   r  rh  r  r  r  r  r  )rK  r  r  rN  rt  ru  rQ  r  rw  rx  ry  r  rW  r|  rZ  r\  r  r  r`  r~  r  rc  r  r  r  r  r  rn  r  rq  )rK  rL  rs  rN  r  ru  rQ  rR  rw  r  rU  rz  rW  rX  r  r\  r]  r}  r  r  r  rc  r  r  rh  rj  r  rn  )r   rD   r  )r   rB  r   )r
   rG  rD  rF  kjrE  js   &      r   test_jacobi_symbol_wikipedia,TestIntegerBase.test_jacobi_symbol_wikipedia  s      `  a  b  c  b  c  V  W  e  f  d  e  _  `  f  g  d  e  _  `  d  e  W  X  a  b  e  f" \\''EA  A1-  r   c                b    V P                  ^4      w  pV P                  \        V4      R4       R# )r   0x10N)r   r   hexr   s   & r   test_hexTestIntegerBase.test_hex  s&    mmD!R&)r   c                X   V P                   P                  pV! ^^^4      pV P                  VR4       V! R^^4      pV P                  VR4       V! ^R^4      pV P                  VR4       V! ^^^4      pV P                  VR4       V! ^^^4      pV P                  VR4       ^R,          ^,
          p^^d,          p^^d,          pRpV P                  Wa! WEV4      4       V P                  \        V^^^ 4       V P                  \
        V^^R4       V P                  \
        V^^^4       R# )r      i   s@   (ynpqB,f)Z*r}q:'z8%	[CUE2:Nr   ir?   )r   _mult_modulo_bytesr   r   r   r   )r
   modmultr   modulust1t2expects   &      r   test_mult_modulo_bytes&TestIntegerBase.test_mult_modulo_bytes  s(   ,,11aBg&fa$g&a$g&fa$g&a$g&S&1*WW H!9:+WaA>*gq!R8*gq!Q7r   r   N);__name__
__module____qualname____firstlineno__r   r   r&   r,   r2   r;   rA   rN   rV   r[   rb   rf   ri   rl   rp   rv   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r
  r  r  r  r  r"  r'  r+  r/  r3  r8  r<  rH  r  r  r  __static_attributes____classdictcell____classdict__s   @r   r   r   .   s    7&-B-
)UI
G>M0	1
"
#"#+446>	7
36  ,,76
-
$
008;
0#2A)(< %77D
C-"	(< '	'!DF.4*8 8r   r   c                   &   a  ] tR tRt o R tRtV tR# )TestIntegerInti  c                    \         V n        R # r   )r   r   r	   s   &r   r   TestIntegerInt.setUp  s	    $r   r   Nr  r  r  r  r   r  r  r  s   @r   r  r    s     % %r   r  c                   8   a  ] tR tRt o R tR tR tR tRtV t	R# )testIntegerRandomi  c                v   \        R 4       FB  p\        P                  ! ^R7      pV P                  V^8  4       V P                  VR8  4       KD  	  \        RR4       FW  p\        P                  ! VR7      pV P                  V^V^,
          ,          8  4       V P                  V^V,          8  4       KY  	  R# )r)   )
exact_bitsrR   r`   N  )r   r   randomr   )r
   _a
bits_values   &   r   test_random_exact_bits(testIntegerRandom.test_random_exact_bits  s    tA$$2AQW%Q#X& 
  h/J$$
;AQZ!^!445Q!Z-/0 0r   c                N   R p\        R4       F=  p\        P                  ! ^R7      pT;'       g    V^8  pV P                  VR8  4       K?  	  V P	                  V4       \        RR4       F5  p\        P                  ! VR7      pV P                  V^V,          8  4       K7  	  R# )Fr)   )max_bitsrR   r`   Nr  )r   r   r  r   r0   )r
   flagr  r  r  s   &    r   test_random_max_bits&testIntegerRandom.test_random_max_bits  s    tA$$a0A??1s7DQV$  	h/J$$j9AQ!Z-/0 0r   c                     ! R  R\         4      pV! 4       p\        P                  ! ^ VR7      pV P                  VP                  ^4       R# )c                   ,   a  ] tR tRt o R tR tRtV tR# )@testIntegerRandom.test_random_bits_custom_rng.<locals>.CustomRNGi  c                    ^ V n         R# )rD   Ncounterr	   s   &r   __init__ItestIntegerRandom.test_random_bits_custom_rng.<locals>.CustomRNG.__init__	  s	     r   c                X    V ;P                   V,          un         \        ^ 4      V,          # r   )r  bchr)r
   sizes   &&r   __call__ItestIntegerRandom.test_random_bits_custom_rng.<locals>.CustomRNG.__call__  s    $Aw~%r   r  N)r  r  r  r  r  r  r  r  r  s   @r   	CustomRNGr    s     !& &r   r  )r  randfuncN)objectr   r  r   r  )r
   r  
custom_rngr  s   &   r   test_random_bits_custom_rng-testIntegerRandom.test_random_bits_custom_rng  s?    	& 	& [
  BD++Q/r   c                   \         P                  p\        ^4       F2  pV! ^^R7      pT P                  ^Tu;8*  ;'       d    ^8*  Mu 4       K4  	  \        ^4       F2  pV! ^^R7      pT P                  ^Tu;8*  ;'       d    ^8  Mu 4       K4  	  V P	                  \
        V^^^R7       V P	                  \
        V^^R7       R# )   )min_inclusivemax_inclusive)r  max_exclusive)r  r  r  )r  r  N)r   random_ranger   r0   r   r   )r
   funcr  r  s   &   r   test_random_range#testIntegerRandom.test_random_range  s    ))sA1B7AOOALLbL)  sA1B7AOOAKKRK(  	*d!1:; 	 	=*d!1Mr   r   N)
r  r  r  r  r  r  r  r  r  r  r  s   @r   r  r    s      
110N Nr   r  c                   aa . pV\        \        4      ,          p ^ RIHo  ! V3R lR\        4      pV\        V4      ,          p ^ RIHo  ! V3R	 lR
\        4      pV\        V4      ,          pV\        \        4      ,          pV#   \
        \        3 ds   p\        P                  R8X  d%   \        P                  P                  R4        Rp?L\        P                  P                  R\        T4      ,          4        Rp?LRp?ii ; i  \
        \        3 d:   p\        P                  P                  R\        T4      ,          4        Rp?LRp?ii ; i)rD   )
IntegerGMPc                   .   <a  ] tR tRt o V3R ltRtV tR# )!get_tests.<locals>.TestIntegerGMPi+  c                   < SV n         R # r   r   )r
   r  s   &r   r   'get_tests.<locals>.TestIntegerGMP.setUp,  s
    )r   r   Nr  )r  r  s   @r   TestIntegerGMPr  +  s     * *r   r  win32zSkipping GMP tests on Windows
zSkipping GMP tests (%s)
N)IntegerCustomc                   .   <a  ] tR tRt o V3R ltRtV tR# )*get_tests.<locals>.TestIntegerCustomModexpi9  c                   < SV n         R # r   r   )r
   r  s   &r   r   0get_tests.<locals>.TestIntegerCustomModexp.setUp:  s
    ,r   r   Nr  )r  r  s   @r   TestIntegerCustomModexpr  9  s     - -r   r  z"Skipping custom modexp tests (%s)
)r   r  Crypto.Math._IntegerGMPr  r   ImportErrorOSErrorsysplatformstdoutwriter9   Crypto.Math._IntegerCustomr  r  )configtestsr  er  r  r  s   &    @@r   	get_testsr  $  s   E	_^,,ED6	*_ 	* 	00	J<	-o 	- 	!899 
_.//EL% ! D<<7"JJ>??JJ83q6ACC	D ! J

>QGIIJs5   *B	 *D 	D4D/DDE /EE__main__c                  >    \         P                  ! \        4       4      # r   )unittest	TestSuiter  r   r   r   r   r   E  s    H&&y{3r   suite)defaultTest)__doc__r  r  Crypto.SelfTest.st_commonr   Crypto.Util.py3compatCrypto.Math._IntegerNativer   TestCaser   r  r  r  r  r  mainr   r   r   <module>r     s{   D ! 
  5 # 4t
8h'' t
8n%_ %7N)) 7Nr  @ z3EMMg& r   