a
    ‘dbx  ã                   @   s,   d Z ddlmZ dd„ Zdd„ Zdd„ Zd	S )
z}Core mathematical operations.

This is the actual core RSA implementation, which is only defined
mathematically on integers.
é    )Ú
is_integerc                 C   s"   t | ƒrd S td|| jf ƒ‚d S )Nz%s should be an integer, not %s)r   Ú	TypeErrorÚ	__class__)ÚvarÚname© r   úY/home/tom/ab/renpy-build/tmp/install.linux-x86_64/lib/python3.9/site-packages/rsa/core.pyÚ
assert_int   s    r	   c                 C   sR   t | dƒ t |dƒ t |dƒ | dk r.tdƒ‚| |krFtd| |f ƒ‚t| ||ƒS )z@Encrypts a message using encryption key 'ekey', working modulo nÚmessageÚekeyÚnr   z'Only non-negative numbers are supportedz#The message %i is too long for n=%i)r	   Ú
ValueErrorÚOverflowErrorÚpow)r
   r   r   r   r   r   Úencrypt_int!   s    


r   c                 C   s.   t | dƒ t |dƒ t |dƒ t| ||ƒ}|S )zHDecrypts a cypher text using the decryption key 'dkey', working modulo nÚ
cyphertextÚdkeyr   )r	   r   )r   r   r   r
   r   r   r   Údecrypt_int1   s
    


r   N)Ú__doc__Zrsa._compatr   r	   r   r   r   r   r   r   Ú<module>   s   