ff )NddlZddlmZmZmZmZddlmZGddeZdS)N) iter_rangebordbchrABC)Randomc>eZdZejdZejdZejdZejd5dZe ejd6dZ ejdZ ejd Z ejd Z ejd Zejd Zejd ZejdZeZejdZejdZejdZejdZejdZejdZejd7dZejd7dZejdZejd7dZejdZejdZejdZejdZ ejdZ!ejdZ"ejd Z#ejd!Z$ejd"Z%ejd#Z&ejd$Z'ejd%Z(ejd&Z)ejd'Z*ejd(Z+ejd)Z,ejd*Z-ejd+Z.ejd,Z/ejd-Z0ejd.Z1ejd/Z2ejd0Z3e ejd1Z4e d2Z5e6d3Z7e6d4Z8dS)8 IntegerBasecdSNselfs z/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Math/_IntegerBase.py__int__zIntegerBase.__int__) cdSr r r s r__str__zIntegerBase.__str__-rrcdSr r r s r__repr__zIntegerBase.__repr__1rrrbigcdSr r )r block_size byteorders rto_byteszIntegerBase.to_bytes5rrcdSr r ) byte_stringrs r from_byteszIntegerBase.from_bytes9  rcdSr r rterms r__eq__zIntegerBase.__eq__?rrcdSr r r!s r__ne__zIntegerBase.__ne__CrrcdSr r r!s r__lt__zIntegerBase.__lt__GrrcdSr r r!s r__le__zIntegerBase.__le__KrrcdSr r r!s r__gt__zIntegerBase.__gt__OrrcdSr r r!s r__ge__zIntegerBase.__ge__SrrcdSr r r s r __nonzero__zIntegerBase.__nonzero__WrrcdSr r r s r is_negativezIntegerBase.is_negative\rrcdSr r r!s r__add__zIntegerBase.__add__arrcdSr r r!s r__sub__zIntegerBase.__sub__errcdSr r )rfactors r__mul__zIntegerBase.__mul__irrcdSr r rdivisors r __floordiv__zIntegerBase.__floordiv__mrrcdSr r r:s r__mod__zIntegerBase.__mod__qrrNcdSr r rexponentmoduluss r inplace_powzIntegerBase.inplace_powurrcdSr r r@s r__pow__zIntegerBase.__pow__yrrcdSr r r s r__abs__zIntegerBase.__abs__}rrcdSr r rrBs rsqrtzIntegerBase.sqrtrrcdSr r r!s r__iadd__zIntegerBase.__iadd__rrcdSr r r!s r__isub__zIntegerBase.__isub__rrcdSr r r!s r__imul__zIntegerBase.__imul__rrcdSr r r!s r__imod__zIntegerBase.__imod__rrcdSr r r!s r__and__zIntegerBase.__and__rrcdSr r r!s r__or__zIntegerBase.__or__rrcdSr r rposs r __rshift__zIntegerBase.__rshift__rrcdSr r rXs r __irshift__zIntegerBase.__irshift__rrcdSr r rXs r __lshift__zIntegerBase.__lshift__rrcdSr r rXs r __ilshift__zIntegerBase.__ilshift__rrcdSr r )rns rget_bitzIntegerBase.get_bitrrcdSr r r s ris_oddzIntegerBase.is_oddrrcdSr r r s ris_evenzIntegerBase.is_evenrrcdSr r r s r size_in_bitszIntegerBase.size_in_bitsrrcdSr r r s r size_in_byteszIntegerBase.size_in_bytesrrcdSr r r s ris_perfect_squarezIntegerBase.is_perfect_squarerrcdSr r )r small_primes rfail_if_divisible_byz IntegerBase.fail_if_divisible_byrrcdSr r )rabs rmultiply_accumulatezIntegerBase.multiply_accumulaterrcdSr r )rsources rsetzIntegerBase.setrrcdSr r rIs rinplace_inversezIntegerBase.inplace_inverserrcdSr r rIs rinversezIntegerBase.inverserrcdSr r r!s rgcdzIntegerBase.gcdrrcdSr r r!s rlcmzIntegerBase.lcmrrcdSr r )rrrbs r jacobi_symbolzIntegerBase.jacobi_symbolrrcP|dvr|S|dzdkr=t||dzdz|}t|d||krtd|Sd}|dz dz}|dzs|dz }|dz}|dz|d} t||dz dz|}|dkr|dz }$||dz krntd|}t|||}t|||} t||dzdz|} | dkrtd|D]} t| d| z|dkrn| |krtd ||fzt|d|| z dz z|} | }| dz|z}| | dzz|z} | | z|z} | dkt| d||krtd| S) aTonelli-shanks algorithm for computing the square root of n modulo a prime p. n must be in the range [0..p-1]. p must be at least even. The return value r is the square root of modulo p. If non-zero, another solution will also exist (p-r). Note we cannot assume that p is really a prime: if it's not, we can either raise an exception or return the correct value. )rrzCannot compute square rootTrz'Cannot compute square root of %d mod %d)pow ValueError __class__r) rbprootsqzeulermctrirss r_tonelli_shankszIntegerBase._tonelli_shankss(" ;;H q5A::q1q5Q,**D4A!## !=>>>K  UqLq5  FA !GAq5  KKNN ;AEa<++EzzQA~~9:: :  1aLL 1aLL AEa< # #1ff1%%  q!Q$??a''E(Avv !JaQRV!STTTAq1q519~q))AA1qAQTQAQ! A1ff q!Q<<1  9:: :rc |dd}|dd}|dd}|tjj}||t d||t d|p|}|dz dzdz}d|dz|z z }t |dd }| |d|dz zz}|d|zdz z}|t|||dz zS) a!Generate a random natural integer of a certain size. :Keywords: exact_bits : positive integer The length in bits of the resulting random Integer number. The number is guaranteed to fulfil the relation: 2^bits > result >= 2^(bits - 1) max_bits : positive integer The maximum length in bits of the resulting random Integer number. The number is guaranteed to fulfil the relation: 2^bits > result >=0 randfunc : callable A function that returns a random byte string. The length of the byte string is passed as parameter. Optional. If not provided (or ``None``), randomness is read from the system RNG. :Return: a Integer object exact_bitsNmax_bitsrandfuncz3Either 'exact_bits' or 'max_bits' must be specifiedz2'exact_bits' and 'max_bits' are mutually exclusiverr)poprnewreadrrrr) clskwargsrrrbits bytes_neededsignificant_bits_msbmsbs rrandomzIntegerBase.random)s+2ZZ d33 ::j$//::j$//  z||(H  ("2RSS S  !h&:QRR R%Xa1,  L1$4t$;<88A;;q>""  ! 1-12 2C ))Q..~~d3ii((rCrErGrJrLrNrPrRrTrVrZr\r^r`rcrergrirkrmrprtrwryr{r}rrr classmethodrrr rrr r &s,                    \                             H                                                                                                                                        \ >>\>@-F-F[-F^-.-.[-.-.-.rr ) rCrypto.Util.py3compatrrrrCryptorr r rrrs> ============a.a.a.a.a.#a.a.a.a.a.r