ó
/<õ\c           @` sĖ  d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l m Z e j e j	  d e
 f d     Y Z e j e j	  d e
 f d     Y Z e j e j	  d e
 f d	     Y Z e j e j	  d
 e
 f d     Y Z e j e j	  d e
 f d     Y Z d   Z d   Z d   Z e j e  e j e  d e
 f d     Y  Z e j e  e j e  d e
 f d     Y  Z e j e  d e
 f d     Y Z e j e  e j e  d e
 f d     Y  Z e j e  e j e  d e
 f d     Y  Z e j e  e j e  d e
 f d     Y  Z e j e  e j e  d e
 f d     Y  Z e j e  e j e  e j e  d e
 f d      Y   Z d S(!   i    (   t   absolute_importt   divisiont   print_functionN(   t   utilst   Modec           B` s,   e  Z e j d     Z e j d    Z RS(   c         C` s   d S(   s@   
        A string naming this mode (e.g. "ECB", "CBC").
        N(    (   t   self(    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyt   name   t    c         C` s   d S(   sq   
        Checks that all the necessary invariants of this (mode, algorithm)
        combination are met.
        N(    (   R   t	   algorithm(    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyt   validate_for_algorithm   R   (   t   __name__t
   __module__t   abct   abstractpropertyR   t   abstractmethodR	   (    (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR      s   t   ModeWithInitializationVectorc           B` s   e  Z e j d     Z RS(   c         C` s   d S(   sP   
        The value of the initialization vector for this mode as bytes.
        N(    (   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyt   initialization_vector    R   (   R
   R   R   R   R   (    (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR      s   t   ModeWithTweakc           B` s   e  Z e j d     Z RS(   c         C` s   d S(   s@   
        The value of the tweak for this mode as bytes.
        N(    (   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyt   tweak)   R   (   R
   R   R   R   R   (    (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR   '   s   t   ModeWithNoncec           B` s   e  Z e j d     Z RS(   c         C` s   d S(   s@   
        The value of the nonce for this mode as bytes.
        N(    (   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyt   nonce2   R   (   R
   R   R   R   R   (    (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR   0   s   t   ModeWithAuthenticationTagc           B` s   e  Z e j d     Z RS(   c         C` s   d S(   sP   
        The value of the tag supplied to the constructor of this mode.
        N(    (   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyt   tag;   R   (   R
   R   R   R   R   (    (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR   9   s   c         C` s1   | j  d k r- | j d k r- t d   n  d  S(   Ni   t   AESs=   Only 128, 192, and 256 bit keys are allowed for this AES mode(   t   key_sizeR   t
   ValueError(   R   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyt   _check_aes_key_lengthB   s    c         C` sG   t  |  j  d | j k rC t d j t  |  j  |  j    n  d  S(   Ni   s   Invalid IV size ({}) for {}.(   t   lenR   t
   block_sizeR   t   formatR   (   R   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyt   _check_iv_lengthI   s    	c         C` s   t  |  |  t |  |  d  S(   N(   R   R   (   R   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyt   _check_iv_and_key_lengthP   s    t   CBCc           B` s,   e  Z d  Z d   Z e j d  Z e Z RS(   R    c         C` s   t  j d |  | |  _ d  S(   NR   (   R   t   _check_bytesliket   _initialization_vector(   R   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyt   __init__Z   s    R"   (	   R
   R   R   R#   R   t   read_only_propertyR   R   R	   (    (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR    U   s   	t   XTSc           B` s/   e  Z d  Z d   Z e j d  Z d   Z RS(   R%   c         C` s>   t  j d |  t |  d k r1 t d   n  | |  _ d  S(   NR   i   s!   tweak must be 128-bits (16 bytes)(   R   R!   R   R   t   _tweak(   R   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR#   g   s    R&   c         C` s"   | j  d k r t d   n  d  S(   Ni   i   s\   The XTS specification requires a 256-bit key for AES-128-XTS and 512-bit key for AES-256-XTS(   i   i   (   R   R   (   R   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR	   q   s    (   R
   R   R   R#   R   R$   R   R	   (    (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR%   b   s   	t   ECBc           B` s   e  Z d  Z e Z RS(   R'   (   R
   R   R   R   R	   (    (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR'   y   s   t   OFBc           B` s,   e  Z d  Z d   Z e j d  Z e Z RS(   R(   c         C` s   t  j d |  | |  _ d  S(   NR   (   R   R!   R"   (   R   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR#      s    R"   (	   R
   R   R   R#   R   R$   R   R   R	   (    (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR(      s   	t   CFBc           B` s,   e  Z d  Z d   Z e j d  Z e Z RS(   R)   c         C` s   t  j d |  | |  _ d  S(   NR   (   R   R!   R"   (   R   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR#      s    R"   (	   R
   R   R   R#   R   R$   R   R   R	   (    (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR)      s   	t   CFB8c           B` s,   e  Z d  Z d   Z e j d  Z e Z RS(   R*   c         C` s   t  j d |  | |  _ d  S(   NR   (   R   R!   R"   (   R   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR#      s    R"   (	   R
   R   R   R#   R   R$   R   R   R	   (    (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR*      s   	t   CTRc           B` s/   e  Z d  Z d   Z e j d  Z d   Z RS(   R+   c         C` s   t  j d |  | |  _ d  S(   NR   (   R   R!   t   _nonce(   R   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR#   ¬   s    R,   c         C` sT   t  |  |  t |  j  d | j k rP t d j t |  j  |  j    n  d  S(   Ni   s   Invalid nonce size ({}) for {}.(   R   R   R   R   R   R   R   (   R   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR	   ²   s    	(   R
   R   R   R#   R   R$   R   R	   (    (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR+   §   s   	t   GCMc           B` sP   e  Z d  Z d Z d Z d d d  Z e j d  Z	 e j d	  Z
 d
   Z RS(   R-   i   i'   i   i   i@   i   c         C` s“   t  j d |  t |  d k r1 t d   n  | |  _ | d  k	 r t  j d |  | d k  rq t d   n  t |  | k  r t d j |    q n  | |  _ | |  _	 d  S(   NR   i    s-   initialization_vector must be at least 1 byteR   i   s   min_tag_length must be >= 4s.   Authentication tag must be {} bytes or longer.(
   R   R!   R   R   R"   t   Nonet   _check_bytesR   t   _tagt   _min_tag_length(   R   R   R   t   min_tag_length(    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR#   Ā   s    		R0   R"   c         C` s   t  |  |  d  S(   N(   R   (   R   R   (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR	   Ł   s    I       I ’’’   Ią’’’   l            l            N(   R
   R   R   t   _MAX_ENCRYPTED_BYTESt   _MAX_AAD_BYTESR.   R#   R   R$   R   R   R	   (    (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyR-   ŗ   s   (   t
   __future__R    R   R   R   t   sixt   cryptographyR   t   add_metaclasst   ABCMetat   objectR   R   R   R   R   R   R   R   t   register_interfaceR    R%   R'   R(   R)   R*   R+   R-   (    (    (    sK   lib/python2.7/site-packages/cryptography/hazmat/primitives/ciphers/modes.pyt   <module>   sP   			