[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.144.4.249: ~ $
�

1�Dgk,���dZddlmZddlmZddlmZdZdZdd�Z	d�Z
dd	lmZ
ee
dd
���Zdd�Zd�Zd
�ZdS)zHFunctions to create and test prime numbers.

:undocumented: __package__
�)�Random)�Integer)�
iter_range�Nc��t|t��st|��}|dvrtS|���rtStd��}t|dz
��}|�tj��j}t|��}d}|���r|dz}|dz
}|����t|��D]�}d}|||fvr4tj	d|dz
|���}d|cxkr	|dz
ksnJ�|||fv�4t|||��}	|	||fvr�Vtd|��D],}
t|	d|��}	|	|krn|	|krtccS�-tcS��tS)a:Perform a Miller-Rabin primality test on an integer.

    The test is specified in Section C.3.1 of `FIPS PUB 186-4`__.

    :Parameters:
      candidate : integer
        The number to test for primality.
      iterations : integer
        The maximum number of iterations to perform before
        declaring a candidate a probable prime.
      randfunc : callable
        An RNG function where bases are taken from.

    :Returns:
      ``Primality.COMPOSITE`` or ``Primality.PROBABLY_PRIME``.

    .. __: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
    �r���rNrr	)�
min_inclusive�
max_inclusive�randfunc)�
isinstancer�PROBABLY_PRIME�is_even�	COMPOSITEr�new�readr�random_range�pow)�	candidate�
iterationsr�one�	minus_one�m�a�i�base�z�js           �w/builddir/build/BUILD/imunify360-venv-2.4.0/opt/imunify360/venv/lib64/python3.11/site-packages/Crypto/Math/Primality.py�miller_rabin_testr"-s���(�i��)�)�'��I�&�&�	��L� � �����������
�!�*�*�C��	�A�
�&�&�I����:�<�<�$��	�	���A�	�A�
�)�)�+�+��	�a���	�Q����)�)�+�+���
�
#�
#�������s�I�&�&�&��'�a�"+�a�-�%�'�'�'�D���-�-�-�-�	�A�
�-�-�-�-�-�-�	�s�I�&�&�&�
��a��#�#����i� � � ���A�q�!�!�	�	�A��A�q�)�$�$�A��I�~�~����C�x�x� � � � � � ������	���c���t|t��st|��}|dvrtS|���s|���rt
Sd�}|��D]6}|||fvr�
tj||��}|dkr	t
cS|dkrn�7|dz}|���dz
}td��}td��}td��}td��}	t|dz
dd��D�]F}
|�	|��||z}||z}|	�	|��|	|z}	|	|z}	|	�
||��|	���r|	|z
}	|	dz}	|	|z}	|�|
��r�|�	|��||	z
}|���r||z
}|dz}||z}|�	|	��|�
||��|���r||z
}|dz}||z}��|�	|��|�	|	����H|dkrtSt
S)a_Perform a Lucas primality test on an integer.

    The test is specified in Section C.3.3 of `FIPS PUB 186-4`__.

    :Parameters:
      candidate : integer
        The number to test for primality.

    :Returns:
      ``Primality.COMPOSITE`` or ``Primality.PROBABLY_PRIME``.

    .. __: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
    rc3�>K�d}	|V�|dkr|dz
}n|dz}|}�)NrTrr	�)�values r!�	alternatezlucas_test.<locals>.alternate�sB������	��K�K�K��q�y�y���
�����
���F�E�
	r#r���r)
rrrr�is_perfect_squarer�
jacobi_symbol�size_in_bitsr�set�multiply_accumulate�is_odd�get_bit)rr(�D�js�K�r�U_i�V_i�U_temp�V_temprs           r!�
lucas_testr9ws����i��)�)�'��I�&�&�	��L� � ���������i�9�9�;�;��������Y�[�[������Q�B�����
�
"�1�i�
0�
0��
��7�7�����
��8�8��E��	�A�
�A�	�����1��A��!�*�*�C�
�!�*�*�C�
�Q�Z�Z�F�
�Q�Z�Z�F�
��A��r�2�
&�
&�!�!��	�
�
�3�����#�
���)����
�
�3�����#�
���!����"�"�3��,�,�,��=�=�?�?�	 ��i��F��1����)����9�9�Q�<�<�	��G�G�F�O�O�O��6�M�C��z�z�|�|�
!��y� ���A�I�C��9��C��G�G�F�O�O�O��#�#�F�A�.�.�.��z�z�|�|�
!��y� ���A�I�C��9��C�C��G�G�F�O�O�O��G�G�F�O�O�O�O�
�a�x�x����r#)�
sieve_base�dc�\��|�tj��j}t|t��st	|��}t|��tvrtS	t|j	t��n#t$r
tcYSwxYwd}|����	tt�fd�|����dd}n#t$rd}YnwxYwt!|||���tkrtSt#|��tkrtStS)a�Test if a number is prime.

    A number is qualified as prime if it passes a certain
    number of Miller-Rabin tests (dependent on the size
    of the number, but such that probability of a false
    positive is less than 10^-30) and a single Lucas test.

    For instance, a 1024-bit candidate will need to pass
    4 Miller-Rabin tests.

    :Parameters:
      candidate : integer
        The number to test for primality.
      randfunc : callable
        The routine to draw random bytes from to select Miller-Rabin bases.
    :Returns:
      ``PROBABLE_PRIME`` if the number if prime with very high probability.
      ``COMPOSITE`` if the number is a composite.
      For efficiency reasons, ``COMPOSITE`` is also returned for small primes.
    N)
)���)i�)i��)i�
)il�)i��)izr)i��)i�r
)itr	c����|dkS)Nrr&)�x�bit_sizes �r!�<lambda>z%test_probable_prime.<locals>.<lambda>s���h��1��o�r#rr�r)rrrrr�int�_sieve_baser�map�fail_if_divisible_by�
ValueErrorrr,�list�filter�
IndexErrorr"r9)rr�	mr_ranges�
mr_iterationsrGs    @r!�test_probable_primerT�s_���,���:�<�<�$���i��)�)�'��I�&�&�	��9�~�~��$�$�����I�*�K�8�8�8�8��������������'�I��%�%�'�'�H���V�$=�$=�$=�$=�$-�/�/�0�0�01�3�34�6�
�
�������
�
�
�������M�"*�,�,�,�/8�9�9����)���	�)�)����s$�A9�9B
�B
�',C�C#�"C#c��|�dd��}|�dd��}|�dd���}|r$td|���z���|�td���|dkrtd	���|�tj��j}t}|tkr@tj||�
��dz}||��s�0t||��}|tk�@|S)axGenerate a random probable prime.

    The prime will not have any specific properties
    (e.g. it will not be a *strong* prime).

    Random numbers are evaluated for primality until one
    passes all tests, consisting of a certain number of
    Miller-Rabin tests with random bases followed by
    a single Lucas test.

    The number of Miller-Rabin iterations is chosen such that
    the probability that the output number is a non-prime is
    less than 1E-30 (roughly 2^{-100}).

    This approach is compliant to `FIPS PUB 186-4`__.

    :Keywords:
      exact_bits : integer
        The desired size in bits of the probable prime.
        It must be at least 160.
      randfunc : callable
        An RNG function where candidate primes are taken from.
      prime_filter : callable
        A function that takes an Integer as parameter and returns
        True if the number can be passed to further primality tests,
        False if it should be immediately discarded.

    :Return:
        A probable prime in the range 2^exact_bits > p > 2^(exact_bits-1).

    .. __: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
    �
exact_bitsNr�prime_filterc��dS)NTr&)rFs r!rHz)generate_probable_prime.<locals>.<lambda><s���r#�Unknown parameters: zMissing exact_bits parameter�zPrime number is not big enough.�rVrr)
�poprN�keysrrrrr�randomrT)�kwargsrVrrW�resultrs      r!�generate_probable_primeras��D���L�$�/�/�J��z�z�*�d�+�+�H��:�:�n�n�n�=�=�L�
�A��/�&�+�+�-�-�?�@�@�@����7�8�8�8��C����:�;�;�;����:�<�<�$��
�F�
�I�
�
��N�j�,4�6�6�6�89�:�	��|�I�&�&�	��$�Y��9�9���I�
�
��r#c��|�dd��}|�dd��}|r$td|���z���|�tj��j}t}|tkrQt|dz
|���}|dzdz}|���|kr�@t||���}|tk�Q|S)	a�Generate a random, probable safe prime.

    Note this operation is much slower than generating a simple prime.

    :Keywords:
      exact_bits : integer
        The desired size in bits of the probable safe prime.
      randfunc : callable
        An RNG function where candidate primes are taken from.

    :Return:
        A probable safe prime in the range
        2^exact_bits > p > 2^(exact_bits-1).
    rVNrrYrr[r	rI)
r\rNr]rrrrrar,rT)r_rVrr`�qrs      r!�generate_probable_safe_primerdRs��� ���L�$�/�/�J��z�z�*�d�+�+�H�
�A��/�&�+�+�-�-�?�@�@�@����:�<�<�$��
�F�
�I�
�
�#�z�A�~��Q�Q�Q����E�A�I�	��!�!�#�#�z�1�1��$�Y��B�B�B���I�
�
��r#)N)�__doc__�Cryptor�Crypto.Math.Numbersr�Crypto.Util.py3compatrrrr"r9�Crypto.Util.numberr:�_sieve_base_larger-rKrTrardr&r#r!�<module>rks���>��
������'�'�'�'�'�'�,�,�,�,�,�,�
�	���G�G�G�G�T^�^�^�B?�>�>�>�>�>��c�#�D�S�D�)�*�*��7�7�7�7�t7�7�7�t����r#

Filemanager

Name Type Size Permission Actions
Numbers.cpython-311.pyc File 831 B 0644
Primality.cpython-311.pyc File 11.54 KB 0644
_IntegerBase.cpython-311.pyc File 15.06 KB 0644
_IntegerCustom.cpython-311.pyc File 3.6 KB 0644
_IntegerGMP.cpython-311.pyc File 34.79 KB 0644
_IntegerNative.cpython-311.pyc File 16.89 KB 0644
__init__.cpython-311.pyc File 227 B 0644