
{PXc           @` s   d  d l  m Z m Z m Z d  d l m Z d  d l m Z m Z m	 Z	 m
 Z
 d  d l m Z d  d l m Z d  d l m Z e j e  d e f d     Y Z d	 S(
   i    (   t   absolute_importt   divisiont   print_function(   t   utils(   t   AlreadyFinalizedt
   InvalidKeyt   UnsupportedAlgorithmt   _Reasons(   t   PBKDF2HMACBackend(   t   constant_time(   t   KeyDerivationFunctiont
   PBKDF2HMACc           B` s#   e  Z d    Z d   Z d   Z RS(   c         C` s   t  | t  s$ t d t j   n  | j |  sT t d j | j  t j   n  t	 |  _
 | |  _ | |  _ t  | t  s t d   n  | |  _ | |  _ | |  _ d  S(   Ns4   Backend object does not implement PBKDF2HMACBackend.s0   {0} is not supported for PBKDF2 by this backend.s   salt must be bytes.(   t
   isinstanceR   R   R   t   BACKEND_MISSING_INTERFACEt   pbkdf2_hmac_supportedt   formatt   namet   UNSUPPORTED_HASHt   Falset   _usedt
   _algorithmt   _lengtht   bytest	   TypeErrort   _saltt   _iterationst   _backend(   t   selft	   algorithmt   lengtht   saltt
   iterationst   backend(    (    sM   /usr/lib/python2.7/dist-packages/cryptography/hazmat/primitives/kdf/pbkdf2.pyt   __init__   s"    						c         C` sg   |  j  r t d   n  t |  _  t | t  s? t d   n  |  j j |  j |  j	 |  j
 |  j |  S(   Ns'   PBKDF2 instances can only be used once.s   key_material must be bytes.(   R   R   t   TrueR   R   R   R   t   derive_pbkdf2_hmacR   R   R   R   (   R   t   key_material(    (    sM   /usr/lib/python2.7/dist-packages/cryptography/hazmat/primitives/kdf/pbkdf2.pyt   derive(   s    			c         C` s4   |  j  |  } t j | |  s0 t d   n  d  S(   Ns   Keys do not match.(   R%   R	   t   bytes_eqR   (   R   R$   t   expected_keyt   derived_key(    (    sM   /usr/lib/python2.7/dist-packages/cryptography/hazmat/primitives/kdf/pbkdf2.pyt   verify7   s    (   t   __name__t
   __module__R!   R%   R)   (    (    (    sM   /usr/lib/python2.7/dist-packages/cryptography/hazmat/primitives/kdf/pbkdf2.pyR      s   		N(   t
   __future__R    R   R   t   cryptographyR   t   cryptography.exceptionsR   R   R   R   t'   cryptography.hazmat.backends.interfacesR   t   cryptography.hazmat.primitivesR	   t"   cryptography.hazmat.primitives.kdfR
   t   register_interfacet   objectR   (    (    (    sM   /usr/lib/python2.7/dist-packages/cryptography/hazmat/primitives/kdf/pbkdf2.pyt   <module>   s   "