ó
‚¾^Yc           @   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%   /tmp/pip-build-kpPAdC/rsa/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%   /tmp/pip-build-kpPAdC/rsa/rsa/core.pyt   encrypt_int!   s    c         C   s=   t  |  d ƒ t  | d ƒ t  | d ƒ t |  | | ƒ } | S(   sH   Decrypts a cypher text using the decryption key 'dkey', working modulo nt
   cyphertextt   dkeyR   (   R   R   (   R   R   R   R   (    (    s%   /tmp/pip-build-kpPAdC/rsa/rsa/core.pyt   decrypt_int1   s
    N(   t   __doc__t   rsa._compatR    R   R   R   (    (    (    s%   /tmp/pip-build-kpPAdC/rsa/rsa/core.pyt   <module>   s   		