Ñò
à"Ic           @   sÉ   d  d k  Z  d  d k Z d  d k Z d  d k Z d  d k l Z d e i f d „  ƒ  YZ d e i f d „  ƒ  YZ d e i f d „  ƒ  YZ	 d	 e i f d
 „  ƒ  YZ
 d „  Z e d j o e ƒ  n d S(   iÿÿÿÿN(   t   test_supportt   TestVectorsTestCasec           B   sP   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   c            sü   ‡  f d †  } | t  d ƒ d d d ƒ | d d d ƒ | t  d	 ƒ d t  d
 ƒ d d ƒ | d i g  } t d d ƒ D] } | t  | ƒ qz ~ ƒ t  d ƒ d d ƒ | t  d ƒ d d d ƒ | t  d	 ƒ d d d ƒ | t  d	 ƒ d d d ƒ d  S(   Nc            s8   t  i |  | ƒ } ˆ  i | i ƒ  i ƒ  | i ƒ  ƒ d  S(   N(   t   hmact   HMACt   assertEqualt	   hexdigestt   upper(   t   keyt   datat   digestt   h(   t   self(    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   md5test   s    i   i   s   Hi Theret    9294727A3638BB1C13F48EF8158BFC9Dt   Jefes   what do ya want for nothing?t    750c783e6ab0b503eaa86e310a5db738iª   iÝ   i2   t    56be34521d144c88dbb8c733f0e8b3f6t    i   i   iÍ   t    697eaf0aca3a3aea3a75164746ffaa79i   s   Test With Truncationt    56461ef2342edc00f9bab995690efd4ciP   s6   Test Using Larger Than Block-Size Key - Hash Key Firstt    6b1ab7fe4bd7bf8f0b62e6ce61b9d0cdsI   Test Using Larger Than Block-Size Key and Larger Than One Block-Size Datat    6f630fad67cda0ee1fb1f562db3aa53e(   t   chrt   joint   range(   R   R   t   _[1]t   i(    (   R   s+   /mit/python/lib/python2.6/test/test_hmac.pyt   test_md5_vectors	   s,    9c            sü   ‡  f d †  } | t  d ƒ d d d ƒ | d d d ƒ | t  d	 ƒ d t  d
 ƒ d d ƒ | d i g  } t d d ƒ D] } | t  | ƒ qz ~ ƒ t  d ƒ d d ƒ | t  d ƒ d d d ƒ | t  d	 ƒ d d d ƒ | t  d	 ƒ d d d ƒ d  S(   Nc            sA   t  i |  | d t i ƒ} ˆ  i | i ƒ  i ƒ  | i ƒ  ƒ d  S(   Nt	   digestmod(   R   R   t   hashlibt   sha1R   R   R   (   R   R   R	   R
   (   R   (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   shatest.   s    i   i   s   Hi Theret(   b617318655057264e28bc0b6fb378c8ef146be00R   s   what do ya want for nothing?t(   effcdf6ae5eb2fa2d27416d5f184df9c259a7c79iª   iÝ   i2   t(   125d7342b9ac11cd91a39af48aa17b4f63f175d3R   i   i   iÍ   t(   4c9007f4026250c6bc8414f9bf50c86c2d7235dai   s   Test With Truncationt(   4c1a03424b55e07fe7f27be1d58bb9324a9a5a04iP   s6   Test Using Larger Than Block-Size Key - Hash Key Firstt(   aa4ae5e15272d00e95705637ce8a3b55ed402112sI   Test Using Larger Than Block-Size Key and Larger Than One Block-Size Datat(   e8e99d0f45237d786d6bbaa7965c7808bbff1a91(   R   R   R   (   R   R   R   R   (    (   R   s+   /mit/python/lib/python2.6/test/test_hmac.pyt   test_sha_vectors-   s,    9c            sß  ‡  ‡ f d †  } | d d, d d d h d t  i 6d	 t  i 6d
 t  i 6d t  i 6ƒ | d d d d d h d t  i 6d t  i 6d t  i 6d t  i 6ƒ | d d- d d d d h d t  i 6d t  i 6d t  i 6d t  i 6ƒ | d d i g  } t d d. ƒ D] } | t | ƒ qù ~ ƒ d d d d h d t  i 6d t  i 6d t  i 6d  t  i 6ƒ | d d d! d d" d h d# t  i 6d$ t  i 6d% t  i 6d& t  i 6ƒ | d d d! d d' d h d( t  i 6d) t  i 6d* t  i 6d+ t  i 6ƒ d  S(/   Nc            s<   t  i |  | d ˆ ƒ} ˆ  i | i ƒ  i ƒ  | ˆ ƒ d  S(   NR   (   R   R   R   R   t   lower(   R   R   t
   hexdigestsR
   (   R   t   hashfunc(    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   hmactestP   s    R   s   i   R   s   Hi ThereR)   t8   896fb1128abbdf196832107cd49df33f47b4b1169912ba4f53684b22t@   b0344c61d8db38535ca8afceaf0bf12b881dc200c9833da726e9376c2e32cff7t`   afd03944d84895626b0825f4ab46907f15f9dadbe4101ec682aa034c7cebc59cfaea9ea9076ede7f4af152e8b2fa9cb6t€   87aa7cdea5ef619d4ff0b4241a1d6cb02379f4e2ce4ec2787ad0b30545e17cdedaa833b7d6b8a702038b274eaea3f4e4be9d914eeb61f1702e696c203a126854R   s   what do ya want for nothing?t8   a30e01098bc6dbbf45690f3a7e9e6d0f8bbea2a39e6148008fd05e44t@   5bdcc146bf60754e6a042426089575c75a003f089d2739839dec58b964ec3843t`   af45d2e376484031617f78d2b58a6b1b9c7ef464f5a01b47e42ec3736322445e8e2240ca5e69e2c78b3239ecfab21649t€   164b7a7bfcf819e2e395fbe73b56e0a387bd64222e831fd610270cd7ea2505549758bf75c05a994a6d034f65f8f0e6fdcaeab1a34d4a6b4b636e070a38bce737s   ªs   Ýi2   t8   7fb3cb3588c6c1f6ffa9694d7d6ad2649365b0c1f65d69d1ec8333eat@   773ea91e36800e46854db8ebd09181a72959098b3ef8c122d9635514ced565fet`   88062608d3e6ad8a0aa2ace014c8a86f0aa635d947ac9febe83ef4e55966144b2a5ab39dc13814b94e3ab6e101a34f27t€   fa73b0089d56a284efb0f0756c890be9b1b5dbdd8ee81a3655f83e33b2279d39bf3e848279a722c806b485a47e67c807b946a337bee8942674278859e13292fbR   i   i   s   Ít8   6c11506874013cac6a2abc1bb382627cec6a90d86efc012de7afec5at@   82558a389a443c0ea4cc819899f2083a85f0faa3e578f8077a2e3ff46729665bt`   3e8a69b7783c25851933ab6290af6ca77a9981480850009cc5577c6e1f573b4e6801dd23c4a7d679ccf8a386c674cffbt€   b0ba465637458c6990e5a8c5f61d4af7e576d97ff94b872de76f8050361ee3dba91ca5c11aa25eb4d679275cc5788063a5f19741120c4f2de2adebeb10a298ddiƒ   s6   Test Using Larger Than Block-Size Key - Hash Key Firstt8   95e9a0db962095adaebe9b2d6f0dbce2d499f112f2d2b7273fa6870et@   60e431591ee0b67f0d8a26aacbf5b77f8e0bc6213728c5140546040f0ee37f54t`   4ece084485813e9088d2c63a041bc5b44f9ef1012a2b588f3cd11f05033ac4c60c2ef6ab4030fe8296248df163f44952t€   80b24263c7c1a3ebb71493c1dd7be8b49b46d1f41b4aeec1121b013783f8f3526b56d037e05f2598bd0fd2215d6a1e5295e64f73f63f0aec8b915a985d786598s˜   This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.t8   3a854166ac5d9f023f54d517d0b39dbd946770db9c2b95c9f6f565d1t@   9b09ffa71b942fcb27635fbcd5b0e944bfdc63644f0713938a7f51535c3a35e2t`   6617178e941f020d351e2f254e8fd32c602420feb0b8fb9adccebb82461e99c5a678cc31e799176d3860e6110c46523et€   e37b6a775dc87dbaa4dfa9f96e5e3ffddebd71f8867289865df5a32d20cdc944b6022cac3c4982b10d5eeb55c3e4de15134676fb6de0446065c97440fa8c6a58s   s   ªªªªªªªªªªªªªªªªªªªªi   (   R   t   sha224t   sha256t   sha384t   sha512R   t   xrangeR   (   R   R*   R+   R   t   x(    (   R   R*   s+   /mit/python/lib/python2.6/test/test_hmac.pyt   _rfc4231_test_casesO   sV    









?









c         C   s   |  i  t i ƒ d  S(   N(   RJ   R   RD   (   R   (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   test_sha224_rfc4231¿   s    c         C   s   |  i  t i ƒ d  S(   N(   RJ   R   RE   (   R   (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   test_sha256_rfc4231Â   s    c         C   s   |  i  t i ƒ d  S(   N(   RJ   R   RF   (   R   (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   test_sha384_rfc4231Å   s    c         C   s   |  i  t i ƒ d  S(   N(   RJ   R   RG   (   R   (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   test_sha512_rfc4231È   s    c         C   sË   d t  f d „  ƒ  Y} t i ƒ  i i ƒ  z— t i d t ƒ y t i d d d | ƒWn t j
 o n X|  i	 d ƒ d | _
 y t i d d d | ƒWn t j
 o n X|  i	 d	 ƒ Wd  QXd  S(
   Nt   MockCrazyHashc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s#   Ain't no block_size attribute here.c         W   s%   t  i | Œ  |  _ |  i i |  _ d  S(   N(   R   R   t   _xt   digest_size(   R   t   args(    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   __init__Î   s    c         S   s   |  i  i | ƒ d  S(   N(   RP   t   update(   R   t   v(    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyRT   Ñ   s    c         S   s   |  i  i ƒ  S(   N(   RP   R	   (   R   (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyR	   Ó   s    (   t   __name__t
   __module__t   __doc__RS   RT   R	   (    (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyRO   Ì   s   		t   errort   at   bR   s)   Expected warning about missing block_sizei   s'   Expected warning about small block_size(   t   objectt   warningst   catch_warningst   __exit__t	   __enter__t   simplefiltert   RuntimeWarningR   R   t   failt
   block_size(   R   RO   (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   test_legacy_block_size_warningsË   s    
	(
   RV   RW   R   R'   RJ   RK   RL   RM   RN   Re   (    (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyR      s   	$	"	p				t   ConstructorTestCasec           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s4   d } y t  i d ƒ } Wn |  i d ƒ n Xd  S(   Ni    R   s+   Standard constructor call raised exception.(   R   R   Rc   (   R   t   failedR
   (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   test_normalë   s
    c         C   s1   y t  i d d ƒ } Wn |  i d ƒ n Xd  S(   NR   s
   hash this!s5   Constructor call with text argument raised exception.(   R   R   Rc   (   R   R
   (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   test_withtextó   s    c         C   s7   y t  i d d t i ƒ } Wn |  i d ƒ n Xd  S(   NR   R   s4   Constructor call with hashlib.sha1 raised exception.(   R   R   R   R   Rc   (   R   R
   (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   test_withmoduleú   s    (   RV   RW   Rh   Ri   Rj   (    (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyRf   é   s   		t   SanityTestCasec           B   s   e  Z d  „  Z d „  Z RS(   c         C   s,   t  i d ƒ } |  i | i t i j ƒ d  S(   NR   (   R   R   t
   failUnlesst   digest_consR   t   md5(   R   R
   (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   test_default_is_md5  s    c         C   s_   yD t  i d ƒ } | i d ƒ | i ƒ  } | i ƒ  } | i ƒ  } Wn |  i d ƒ n Xd  S(   Ns   my secret keys   compute the hash of this text!s3   Exception raised during normal usage of HMAC class.(   R   R   RT   R	   R   t   copyRc   (   R   R
   t   digt   h2(    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   test_exercise_all_methods	  s    (   RV   RW   Ro   Rs   (    (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyRk     s   	t   CopyTestCasec           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s‹   t  i d ƒ } | i ƒ  } |  i | i | i j d ƒ |  i t | i ƒ t | i ƒ j d ƒ |  i t | i ƒ t | i ƒ j d ƒ d  S(   NR   s    digest constructors don't match.s   Types of inner don't match.s   Types of outer don't match.(   R   R   Rp   Rl   Rm   t   typet   innert   outer(   R   t   h1Rr   (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   test_attributes  s    !!c         C   s‘   t  i d ƒ } | i ƒ  } |  i t | ƒ t | ƒ j d ƒ |  i t | i ƒ t | i ƒ j d ƒ |  i t | i ƒ t | i ƒ j d ƒ d  S(   NR   s"   No real copy of the HMAC instance.s&   No real copy of the attribute 'inner'.s&   No real copy of the attribute 'outer'.(   R   R   Rp   Rl   t   idRv   Rw   (   R   Rx   Rr   (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   test_realcopy"  s    "!!c         C   sp   t  i d ƒ } | i d ƒ | i ƒ  } |  i | i ƒ  | i ƒ  j d ƒ |  i | i ƒ  | i ƒ  j d ƒ d  S(   NR   s   some random texts-   Digest of copy doesn't match original digest.s3   Hexdigest of copy doesn't match original hexdigest.(   R   R   RT   Rp   Rl   R	   R   (   R   Rx   Rr   (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   test_equality-  s    (   RV   RW   Ry   R{   R|   (    (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyRt     s   		c           C   s   t  i t t t t ƒ d  S(   N(   R    t   run_unittestR   Rf   Rk   Rt   (    (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt	   test_main7  s
    t   __main__(   R   R   t   unittestR]   t   testR    t   TestCaseR   Rf   Rk   Rt   R~   RV   (    (    (    s+   /mit/python/lib/python2.6/test/test_hmac.pyt   <module>   s   â"	