ó
‹wÛjc           @   sà   d  d l  Z  d  d l Z d  d l Z d  d l Z d  d l m 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 e j f d „  ƒ  YZ d „  Z e d k rÜ 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 j g  t d d ƒ D] } t  | ƒ ^ qv ƒ t  d ƒ d d ƒ | t  d ƒ d d d ƒ | t  d	 ƒ d d d ƒ | t  d	 ƒ d d d ƒ d  S(   Nc            s8   t  j |  | ƒ } ˆ  j | j ƒ  j ƒ  | j ƒ  ƒ d  S(   N(   t   hmact   HMACt   assertEqualt	   hexdigestt   upper(   t   keyt   datat   digestt   h(   t   self(    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/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   i(    (   R   s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_md5_vectors   s,    1c            sô   ‡  f d †  } | t  d ƒ d d d ƒ | d d d ƒ | t  d	 ƒ d t  d
 ƒ d d ƒ | d j g  t d d ƒ D] } t  | ƒ ^ qv ƒ t  d ƒ d d ƒ | t  d ƒ d d d ƒ | t  d	 ƒ d d d ƒ | t  d	 ƒ d d d ƒ d  S(   Nc            sA   t  j |  | d t j ƒ} ˆ  j | j ƒ  j ƒ  | j ƒ  ƒ d  S(   Nt	   digestmod(   R   R   t   hashlibt   sha1R   R   R   (   R   R   R	   R
   (   R   (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   shatest0   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   s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_sha_vectors/   s,    1c      	      s×  ‡  ‡ f d †  } | d d, d d d i d t  j 6d	 t  j 6d
 t  j 6d t  j 6ƒ | d d d d d i d t  j 6d t  j 6d t  j 6d t  j 6ƒ | d d- d d d d i d t  j 6d t  j 6d t  j 6d t  j 6ƒ | d d j g  t d d. ƒ D] } t | ƒ ^ qõ ƒ d d d d i d t  j 6d t  j 6d t  j 6d  t  j 6ƒ | d d d! d d" d i d# t  j 6d$ t  j 6d% t  j 6d& t  j 6ƒ | d d d! d d' d i d( t  j 6d) t  j 6d* t  j 6d+ t  j 6ƒ d  S(/   Nc            s<   t  j |  | d ˆ  ƒ} ˆ j | j ƒ  j ƒ  | ˆ  ƒ d  S(   NR   (   R   R   R   R   t   lower(   R   R   t
   hexdigestsR
   (   t   hashfuncR   (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   hmactestR   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*   t   x(    (   R)   R   s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   _rfc4231_test_casesQ   sV    









7









c         C   s   |  j  t j ƒ d  S(   N(   RI   R   RC   (   R   (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_sha224_rfc4231Á   s    c         C   s   |  j  t j ƒ d  S(   N(   RI   R   RD   (   R   (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_sha256_rfc4231Ä   s    c         C   s   |  j  t j ƒ d  S(   N(   RI   R   RE   (   R   (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_sha384_rfc4231Ç   s    c         C   s   |  j  t j ƒ d  S(   N(   RI   R   RF   (   R   (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_sha512_rfc4231Ê   s    c         C   s¸   d t  f d „  ƒ  Y} t j ƒ  �� t j d t ƒ |  j t ƒ �( t j d d d | ƒ|  j d ƒ Wd  QXd | _	 |  j t ƒ �( t j d d d | ƒ|  j d	 ƒ Wd  QXWd  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  j | Œ  |  _ |  j j |  _ d  S(   N(   R   R   t   _xt   digest_size(   R   t   args(    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   __init__Ð   s    c         S   s   |  j  j | ƒ d  S(   N(   RO   t   update(   R   t   v(    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyRS   Ó   s    c         S   s   |  j  j ƒ  S(   N(   RO   R	   (   R   (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyR	   Õ   s    (   t   __name__t
   __module__t   __doc__RR   RS   R	   (    (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyRN   Î   s   		t   errort   at   bR   s)   Expected warning about missing block_sizei   s'   Expected warning about small block_size(
   t   objectt   warningst   catch_warningst   simplefiltert   RuntimeWarningt   assertRaisesR   R   t   failt
   block_size(   R   RN   (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_legacy_block_size_warningsÍ   s    
	(
   RU   RV   R   R&   RI   RJ   RK   RL   RM   Rc   (    (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/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  j d ƒ } Wn |  j d ƒ n Xd  S(   Ni    R   s+   Standard constructor call raised exception.(   R   R   Ra   (   R   t   failedR
   (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_normalç   s
    c         C   s1   y t  j d d ƒ } Wn |  j d ƒ n Xd  S(   NR   s
   hash this!s5   Constructor call with text argument raised exception.(   R   R   Ra   (   R   R
   (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_withtextï   s    c         C   s7   y t  j d d t j ƒ } Wn |  j d ƒ n Xd  S(   NR   R   s4   Constructor call with hashlib.sha1 raised exception.(   R   R   R   R   Ra   (   R   R
   (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_withmoduleö   s    (   RU   RV   Rf   Rg   Rh   (    (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyRd   å   s   		t   SanityTestCasec           B   s   e  Z d  „  Z d „  Z RS(   c         C   s,   t  j d ƒ } |  j | j t j k ƒ d  S(   NR   (   R   R   t
   assertTruet   digest_consR   t   md5(   R   R
   (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_default_is_md5ÿ   s    c         C   s_   yD t  j d ƒ } | j d ƒ | j ƒ  } | j ƒ  } | j ƒ  } Wn |  j 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   RS   R	   R   t   copyRa   (   R   R
   t   digt   h2(    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_exercise_all_methods  s    (   RU   RV   Rm   Rq   (    (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyRi   ý   s   	t   CopyTestCasec           B   s#   e  Z d  „  Z d „  Z d „  Z RS(   c         C   s‹   t  j d ƒ } | j ƒ  } |  j | j | j k d ƒ |  j t | j ƒ t | j ƒ k d ƒ |  j t | j ƒ t | j ƒ k 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   Rn   Rj   Rk   t   typet   innert   outer(   R   t   h1Rp   (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_attributes  s    !!c         C   s‘   t  j d ƒ } | j ƒ  } |  j t | ƒ t | ƒ k d ƒ |  j t | j ƒ t | j ƒ k d ƒ |  j t | j ƒ t | j ƒ k 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   Rn   Rj   t   idRt   Ru   (   R   Rv   Rp   (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_realcopy  s    "!!c         C   sp   t  j d ƒ } | j d ƒ | j ƒ  } |  j | j ƒ  | j ƒ  k d ƒ |  j | j ƒ  | j ƒ  k 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   RS   Rn   Rj   R	   R   (   R   Rv   Rp   (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_equality)  s    (   RU   RV   Rw   Ry   Rz   (    (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyRr     s   		t   CompareDigestTestCasec           B   s   e  Z d  „  Z RS(   c         C   sš  d \ } } |  j  t t j | | ƒ d \ } } |  j  t t j | | ƒ d \ } } |  j  t t j | | ƒ d \ } } |  j  t t j | | ƒ d \ } } |  j  t t j | | ƒ d \ } } |  j t j | | ƒ ƒ d \ } } |  j t j | | ƒ ƒ d \ } } |  j t j | | ƒ ƒ d \ } } |  j t j | | ƒ ƒ d \ } } |  j t j | | ƒ ƒ d \ } } |  j t j | | ƒ ƒ t d ƒ t d ƒ } } |  j t j | | ƒ ƒ t d ƒ t d ƒ } } |  j t j | | ƒ ƒ t d ƒ t d ƒ } } |  j t j | | ƒ ƒ t d ƒ d } } |  j t j | | ƒ ƒ |  j t j | | ƒ ƒ t d ƒ d } } |  j t j | | ƒ ƒ |  j t j | | ƒ ƒ t d ƒ d } } |  j t j | | ƒ ƒ |  j t j | | ƒ ƒ d \ } } |  j t j | | ƒ ƒ d \ } } |  j t j | | ƒ ƒ d \ } } |  j t j | | ƒ ƒ d \ } } |  j  t t j | | ƒ d \ } } |  j  t t j | | ƒ d  \ } } |  j  t t j | | ƒ d! \ } } |  j  t t j | | ƒ d" \ } } |  j t j | | ƒ ƒ t j ƒ  � d t	 f d „  ƒ  Y} Wd  QX| d ƒ | d ƒ } } |  j t j | | ƒ ƒ | d ƒ d } } |  j t j | | ƒ ƒ | d ƒ | d ƒ } } |  j t j | | ƒ ƒ t j ƒ  � d t
 f d „  ƒ  Y} Wd  QX| d ƒ | d ƒ } } |  j t j | | ƒ ƒ | d ƒ d } } |  j t j | | ƒ ƒ | d ƒ | d ƒ } } |  j t j | | ƒ ƒ d  S(#   Nid   iÈ   t   foobaru   foobart   foos   Þ­¾ïs   Þ­t   foobazs   «­êi   s   fooÃ¤t   mystrc           B   s   e  Z d  „  Z RS(   c         S   s   t  S(   N(   t   False(   R   t   other(    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   __eq__‹  s    (   RU   RV   R‚   (    (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyR   Š  s   t   mybytesc           B   s   e  Z d  „  Z RS(   c         S   s   t  S(   N(   R€   (   R   R�   (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyR‚   —  s    (   RU   RV   R‚   (    (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyRƒ   –  s   (   id   iÈ   (   id   R|   (   R|   iÈ   (   u   foobarR|   (   R|   u   foobar(   R|   R}   (   s   Þ­¾ïs   Þ­(   R|   R~   (   s   Þ­¾ïs   «­ê(   R|   R|   (   s   Þ­¾ïs   Þ­¾ï(   R|   R|   (   R}   R|   (   R|   R~   (   u   foobarR|   (   R|   u   foobar(   R|   i   (   id   iÈ   (   s   fooÃ¤s   fooÃ¤(   R`   t	   TypeErrorR   t   compare_digestt   assertFalseRj   t	   bytearrayR    t   check_py3k_warningst   strt   bytes(   R   RY   RZ   R   Rƒ   (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   test_compare_digest6  sŠ    (   RU   RV   R‹   (    (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyR{   4  s   c           C   s   t  j t t t t t ƒ d  S(   N(   R    t   run_unittestR   Rd   Ri   Rr   R{   (    (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt	   test_main¢  s    t   __main__(   R   R   t   unittestR\   t   testR    t   TestCaseR   Rd   Ri   Rr   R{   R�   RU   (    (    (    s„   /home/sim/yocto/scarthgap/build/tmp/work/x86_64-linux/python-native/2.7.18/recipe-sysroot-native/usr/lib/python2.7/test/test_hmac.pyt   <module>   s   Ü#n		