ó
írUc           @   s5   d  Z  d d l m Z d   Z d   Z d   Z d S(   s}   Core mathematical operations.

This is the actual core RSA implementation, which is only defined
mathematically on integers.
i˙˙˙˙(   t
   is_integerc         C   s-   t  |   r d  St d | |  j f   d  S(   Ns   %s should be an integer, not %s(   R    t	   TypeErrort	   __class__(   t   vart   name(    (    s)   c:\Python27\lib\site-packages\rsa\core.pyt
   assert_int   s    c         C   sw   t  |  d  t  | d  t  | d  |  d k  rB t d   n  |  | k rg t d |  | f   n  t |  | |  S(   s@   Encrypts a message using encryption key 'ekey', working modulo nt   messaget   ekeyt   ni    s'   Only non-negative numbers are supporteds#   The message %i is too long for n=%i(   R   t
   ValueErrort   OverflowErrort   pow(   R   R   R   (    (    s)   c:\Python27\lib\site-packages\rsa\core.pyt   encrypt_int!   s    c         C   s=   t  |  d  t  | d  t  | d  t |  | |  } | S(   sL   Decrypts a cypher text using the decryption key 'dkey', working
    modulo nt
   cyphertextt   dkeyR   (   R   R   (   R   R   R   R   (    (    s)   c:\Python27\lib\site-packages\rsa\core.pyt   decrypt_int0   s
    N(   t   __doc__t   rsa._compatR    R   R   R   (    (    (    s)   c:\Python27\lib\site-packages\rsa\core.pyt   <module>   s   		