Repository URL to install this package:
| 
      
     
      
        
        
        Version: 
        
         
  
        
    
          
          4.0.105  ▾
        
         
  
      
        
      
  
      
  
     | 
ó
ۍEYc           @` sà   d  d l  m Z m Z m Z d  d l m Z d  d l m Z m	 Z	 d  d l
 m Z d d g Z e	 j
   Z e	 j   Z e	 j   Z e	 j   Z e	 j   Z e	 j   Z d   Z d   Z d	   Z d
   Z d   Z d   Z d
 S(   i    (   t   absolute_importt   divisiont   print_function(   t
   exceptions(   t   ffit   lib(   t   ensuret   crypto_box_keypairt
   crypto_boxc          C` sv   t  j d t  }  t  j d t  } t j |  |  } t | d k d d t j t  j	 |  t  t  j	 | t  f S(   sq   
    Returns a randomly generated public and secret key.
    :rtype: (bytes(public_key), bytes(secret_key))
    s   unsigned char[]i    s   Unexpected library errort   raising(
   R   t   newt   crypto_box_PUBLICKEYBYTESt   crypto_box_SECRETKEYBYTESR   R   R   t   exct   RuntimeErrort   buffer(   t   pkt   skt   rc(    (    sM   /home/tvault/.virtenv/lib/python2.7/site-packages/nacl/bindings/crypto_box.pyR   !   s    
c         C` sì   t  |  t k r$ t j d   n  t  |  t k rH t j d   n  t  |  t k rl t j d   n  d t |  } t j d t  |   } t	 j
 | | t  |  | | |  } t | d k d d t j t j
 | t  |   t S(	   sð   
    Encrypts and returns a message ``message`` using the secret key ``sk``,
    public key ``pk``, and the nonce ``nonce``.
    :param message: bytes
    :param nonce: bytes
    :param pk: bytes
    :param sk: bytes
    :rtype: bytes
    s   Invalid nonce sizes   Invalid public keys   Invalid secret keyt    s   unsigned char[]i    s   Unexpected library errorR	   (   t   lent   crypto_box_NONCEBYTESR
   t
   ValueErrorR   R   t   crypto_box_ZEROBYTESR   R
   R   R   R   R   R   t   crypto_box_BOXZEROBYTES(   t   messaget   nonceR   R   t   paddedt
   ciphertextR   (    (    sM   /home/tvault/.virtenv/lib/python2.7/site-packages/nacl/bindings/crypto_box.pyR   5   s    $
c         C` sì   t  |  t k r$ t j d   n  t  |  t k rH t j d   n  t  |  t k rl t j d   n  d t |  } t j d t  |   } t	 j
 | | t  |  | | |  } t | d k d d t j t j
 | t  |   t S(	   s  
    Decrypts and returns an encrypted message ``ciphertext``, using the secret
    key ``sk``, public key ``pk``, and the nonce ``nonce``.
    :param ciphertext: bytes
    :param nonce: bytes
    :param pk: bytes
    :param sk: bytes
    :rtype: bytes
    s   Invalid nonce sizes   Invalid public keys   Invalid secret keyR   s   unsigned char[]i    s/   An error occurred trying to decrypt the messageR	   (   R   R   R
   R   R   R   R   R   R
   R   t   crypto_box_openR   t   CryptoErrorR   R   (   R   R   R   R   R   t	   plaintextt   res(    (    sM   /home/tvault/.virtenv/lib/python2.7/site-packages/nacl/bindings/crypto_box.pyR   T   s    $
c         C` s   t  |   t k r$ t j d   n  t  |  t k rH t j d   n  t j d t  } t j	 | |  |  } t
 | d k d d t j t j | t  S(   s  
    Computes and returns the shared key for the public key ``pk`` and the
    secret key ``sk``. This can be used to speed up operations where the same
    set of keys is going to be used multiple times.
    :param pk: bytes
    :param sk: bytes
    :rtype: bytes
    s   Invalid public keys   Invalid secret keys   unsigned char[]i    s   Unexpected library errorR	   (
   R   R   R
   R   R   R   R
   t   crypto_box_BEFORENMBYTESR   t   crypto_box_beforenmR   R   R   (   R   R   t   kR   (    (    sM   /home/tvault/.virtenv/lib/python2.7/site-packages/nacl/bindings/crypto_box.pyR"   r   s    
c         C` sÅ   t  |  t k r$ t j d   n  t  |  t k rH t j d   n  d t |  } t j d t  |   } t j	 | | t  |  | |  } t
 | d k d d t j t j | t  |   t
 S(   sÇ   
    Encrypts and returns the message ``message`` using the shared key ``k`` and
    the nonce ``nonce``.
    :param message: bytes
    :param nonce: bytes
    :param k: bytes
    :rtype: bytes
    s
   Invalid nonces   Invalid shared keyR   s   unsigned char[]i    s   Unexpected library errorR	   (   R   R   R
   R   R!   R   R   R
   R   t   crypto_box_afternmR   R   R   R   (   R   R   R#   R   R   R   (    (    sM   /home/tvault/.virtenv/lib/python2.7/site-packages/nacl/bindings/crypto_box.pyR$      s    
!
c         C` sÅ   t  |  t k r$ t j d   n  t  |  t k rH t j d   n  d t |  } t j d t  |   } t j	 | | t  |  | |  } t
 | d k d d t j t j | t  |   t
 S(   sØ   
    Decrypts and returns the encrypted message ``ciphertext``, using the shared
    key ``k`` and the nonce ``nonce``.
    :param ciphertext: bytes
    :param nonce: bytes
    :param k: bytes
    :rtype: bytes
    s
   Invalid nonces   Invalid shared keyR   s   unsigned char[]i    s/   An error occurred trying to decrypt the messageR	   (   R   R   R
   R   R!   R   R   R
   R   t   crypto_box_open_afternmR   R   R   R   (   R   R   R#   R   R   R    (    (    sM   /home/tvault/.virtenv/lib/python2.7/site-packages/nacl/bindings/crypto_box.pyR%   §   s    
N(   t
   __future__R    R   R   t   naclR   R
   t   nacl._sodiumR   R   t   nacl.exceptionsR   t   __all__t   crypto_box_secretkeybytesR   t   crypto_box_publickeybytesR   t   crypto_box_noncebytesR   t   crypto_box_zerobytesR   t   crypto_box_boxzerobytesR   t   crypto_box_beforenmbytesR!   R   R   R   R"   R$   R%   (    (    (    sM   /home/tvault/.virtenv/lib/python2.7/site-packages/nacl/bindings/crypto_box.pyt   <module>   s