ó
/<õ\c           @` sb   d  d l  m Z m Z m Z d  d l m Z d  d l m Z d Z d Z	 d e
 f d „  ƒ  YZ d S(	   i    (   t   absolute_importt   divisiont   print_function(   t   InvalidSignature(   t   constant_timei   i    t   _Poly1305Contextc           B` s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C` sH  | |  _  |  j  j j | ƒ } |  j  j j |  j  j j |  j  j j | t | ƒ ƒ } |  j  j | |  j  j j k ƒ |  j  j j	 | |  j  j j
 ƒ |  _ |  j  j j ƒ  } |  j  j | |  j  j j k ƒ |  j  j j	 | |  j  j j ƒ |  _ |  j  j j |  j |  j  j j |  j  j j |  j  j j |  j ƒ } |  j  j | d k ƒ d  S(   Ni   (   t   _backendt   _ffit   from_buffert   _libt   EVP_PKEY_new_raw_private_keyt   NID_poly1305t   NULLt   lent   openssl_assertt   gct   EVP_PKEY_freet	   _evp_pkeyt   Cryptography_EVP_MD_CTX_newt   Cryptography_EVP_MD_CTX_freet   _ctxt   EVP_DigestSignInit(   t   selft   backendt   keyt   key_ptrt   evp_pkeyt   ctxt   res(    (    sL   lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/poly1305.pyt   __init__   s     	c         C` sS   |  j  j j | ƒ } |  j  j j |  j | t | ƒ ƒ } |  j  j | d k ƒ d  S(   Ni    (   R   R   R   R	   t   EVP_DigestSignUpdateR   R   R   (   R   t   datat   data_ptrR   (    (    sL   lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/poly1305.pyt   update*   s    c         C` s–   |  j  j j d t ƒ } |  j  j j d ƒ } |  j  j j |  j | | ƒ } |  j  j | d k ƒ |  j  j | d t k ƒ |  j  j j | ƒ | d  S(   Ns   unsigned char[]s   size_t *i    (	   R   R   t   newt   _POLY1305_TAG_SIZER	   t   EVP_DigestSignFinalR   R   t   buffer(   R   t   buft   outlenR   (    (    sL   lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/poly1305.pyt   finalize1   s    c         C` s1   |  j  ƒ  } t j | | ƒ s- t d ƒ ‚ n  d  S(   Ns!   Value did not match computed tag.(   R(   R   t   bytes_eqR   (   R   t   tagt   mac(    (    sL   lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/poly1305.pyt   verify9   s    (   t   __name__t
   __module__R   R!   R(   R,   (    (    (    sL   lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/poly1305.pyR      s   			N(   t
   __future__R    R   R   t   cryptography.exceptionsR   t   cryptography.hazmat.primitivesR   R#   t   _POLY1305_KEY_SIZEt   objectR   (    (    (    sL   lib/python2.7/site-packages/cryptography/hazmat/backends/openssl/poly1305.pyt   <module>   s
   