
    g                     L    d Z dededdfdZdedededefd	Zd
edededefdZy)z}Core mathematical operations.

This is the actual core RSA implementation, which is only defined
mathematically on integers.
varnamereturnNc                 X    t        | t              ry t        |d| j                        )Nz should be an integer, not )
isinstanceint	TypeError	__class__)r   r   s     =/var/www/openai/venv/lib/python3.12/site-packages/rsa/core.py
assert_intr      s#    #s
s}}M
NN    messageekeync                     t        | d       t        |d       t        |d       | dk  rt        d      | |kD  rt        d| |fz        t        | ||      S )z@Encrypts a message using encryption key 'ekey', working modulo nr   r   r       z'Only non-negative numbers are supportedz#The message %i is too long for n=%i)r   
ValueErrorOverflowErrorpow)r   r   r   s      r
   encrypt_intr      s`     w	"tVq#{BCC{AWaLPQQwa  r   
cyphertextdkeyc                 h    t        | d       t        |d       t        |d       t        | ||      }|S )zHDecrypts a cypher text using the decryption key 'dkey', working modulo nr   r   r   )r   r   )r   r   r   r   s       r
   decrypt_intr   -   s5     z<(tVq#*dA&GNr   )__doc__r   strr   r   r    r   r
   <module>r      sj   OC Os Ot O! !C !C !C ! C s s s r   