ó
j4Vdc           @   sØ   d  Z  d Z d d l Z d d l Z d d l Z d d l Te j d k  rU d „  Z n e Z d e j f d „  ƒ  YZ	 d	 e j f d
 „  ƒ  YZ
 d e j f d „  ƒ  YZ d e j f d „  ƒ  YZ d d „ Z d „  Z d S(   s&   Self-testing for PyCrypto hash moduless   $Id$iÿÿÿÿN(   t   *i  c          K   s
   |  j  ƒ  S(   N(   t   copy(   t   kwargs(    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyt   dict&   s    t   HashDigestSizeSelfTestc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s/   t  j j |  ƒ | |  _ | |  _ | |  _ d  S(   N(   t   unittestt   TestCaset   __init__t   hashmodt   expectedt   description(   t   selfR   R
   R	   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyR   .   s    		c         C   s   |  j  S(   N(   R
   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyt   shortDescription4   s    c         C   sq   |  j  t |  j d ƒ ƒ |  j |  j j |  j ƒ |  j j ƒ  } |  j  t | d ƒ ƒ |  j | j |  j ƒ d  S(   Nt   digest_size(   t
   failUnlesst   hasattrR   t   assertEqualsR   R	   t   new(   R   t   h(    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyt   runTest7   s
    (   t   __name__t
   __module__R   R   R   (    (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyR   ,   s   		t   HashSelfTestc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s8   t  j j |  ƒ | |  _ | |  _ | |  _ | |  _ d  S(   N(   R   R   R   R   R	   t   inputR
   (   R   R   R
   R	   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyR   A   s
    			c         C   s   |  j  S(   N(   R
   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyR   H   s    c         C   sR  |  j  j ƒ  } | j |  j ƒ t j | j ƒ  ƒ } | j ƒ  } |  j  j |  j ƒ } | j ƒ  } t j | j ƒ  ƒ } |  j |  j	 | ƒ t
 j d d k rÅ |  j |  j	 | ƒ |  j |  j	 | ƒ n2 |  j |  j	 j ƒ  | ƒ |  j |  j	 j ƒ  | ƒ |  j |  j	 | ƒ | j ƒ  } | j |  j ƒ t j | j ƒ  ƒ } |  j |  j	 | ƒ d  S(   Ni    i   (   R   R   t   updateR   t   binasciit   b2a_hext   digestt	   hexdigestt   assertEqualR	   t   syst   version_infot   decode(   R   R   t   out1t   out2t   out3t   out4t   h2t   out5(    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyR   K   s$    (   R   R   R   R   R   (    (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyR   ?   s   		t   HashTestOIDc           B   s   e  Z d  „  Z d „  Z RS(   c         C   s&   t  j j |  ƒ | |  _ | |  _ d  S(   N(   R   R   R   R   t   oid(   R   R   R(   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyR   h   s    	c         C   sx   |  j  j ƒ  } |  j d  k r^ y d } | j } Wn t k
 rJ d } n X|  j | d ƒ n |  j | j |  j ƒ d  S(   Ni    i   (   R   R   R(   t   Nonet   AttributeErrorR   (   R   R   t   raisedt   a(    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyR   m   s    
(   R   R   R   R   (    (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyR'   g   s   	t   MACSelfTestc           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   sJ   t  j j |  ƒ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   N(	   R   R   R   R   t   expected_dictR   t   keyt   hashmodsR
   (   R   R   R
   R.   R   R/   R0   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyR   {   s    					c         C   s   |  j  S(   N(   R
   (   R   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyR   „   s    c         C   sÂ  x»|  j  j ƒ  D]ª} |  j | } t j t |  j ƒ ƒ } t j t |  j ƒ ƒ } t d j |  j  | j	 ƒ  ƒ ƒ } |  j
 j | d | ƒ} | j | ƒ t j | j ƒ  ƒ } | j ƒ  } |  j
 j | | | ƒ } | j ƒ  }	 t j | j ƒ  ƒ }
 | j ƒ  } | j t d ƒ ƒ t j | j ƒ  ƒ } |  j | | ƒ t j d d k rn|  j | | ƒ |  j | |	 ƒ n, |  j | j ƒ  | ƒ |  j | j ƒ  |	 ƒ |  j | |
 ƒ |  j | | ƒ q Wd  S(   Nt    t	   digestmods   blah blah blahi    i   (   R.   t   keysR0   R   t   a2b_hext   bR/   R   t   joint   splitR   R   R   R   R   R   R   R   R   R   R    (   R   t   hashnameR   R/   t   dataR	   R   R!   R"   R#   R$   R%   R&   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyR   ‡   s.    "(   R   R   R   R   R   (    (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyR-   y   s   			c         C   s  g  } x§ t  t | ƒ ƒ D]“ } | | } t t | d d !ƒ \ } }	 t | ƒ d k  rf t |	 ƒ }
 n | d j d ƒ }
 d | | d |
 f } | j t |  | | |	 ƒ ƒ q W| d  k	 rË t | ƒ } n  d | | d f } | j t	 |  | | ƒ ƒ | j t
 |  | ƒ ƒ | S(   Ni    i   i   s   latin-1s
   %s #%d: %si   s   %s #%d: digest_size(   t   ranget   lent   mapR5   t   reprt   encodet   appendR   R)   R   R'   (   t   modulet   module_namet	   test_dataR   R(   t   testst   it   rowR	   R   R
   t   name(    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyt   make_hash_testsª   s    
 c      	   C   s|   g  } xo t  t | ƒ ƒ D][ } | | } | \ } } }	 }
 d | | d |
 f } | j t |  | |	 | | | ƒ ƒ q W| S(   Ns
   %s #%d: %si   (   R:   R;   R?   R-   (   R@   RA   RB   R0   RC   RD   RE   R/   R9   t   resultsR
   RF   (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyt   make_mac_tests¼   s    
&(   t   __doc__t   __revision__R   R   R   t   Crypto.Util.py3compatt
   hexversionR   R   R   R   R'   R-   R)   RG   RI   (    (    (    si   /var/www/html/phendo-backend/phendo_python/env/lib/python2.7/site-packages/Crypto/SelfTest/Hash/common.pyt   <module>   s   
(1