ó
Â/¾Oc           @   sÅ   d  Z  d Z d d g Z d d l Z e j d d k rW e j d d k rW d d	 l Tn  d d	 l Td d
 l m Z d d l	 m
 Z
 e
 j d k s– t ‚ d e f d „  ƒ  YZ e j Z d d „ Z d S(   sQ   SHA_d-256 hash function implementation.

This module should comply with PEP 247.
s   $Id$t   newt   digest_sizeiÿÿÿÿNi    i   i   (   t   *(   t   b2a_hex(   t   SHA256i    t   _SHAd256c           B   sM   e  Z d  Z e j Z e ƒ  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(   s;   SHA-256, doubled.

    Returns SHA-256(SHA-256(data)).
    c         C   s2   | |  j  k	 r% t d t f ƒ ‚ n  | |  _ d  S(   Ns5   Do not instantiate this class directly.  Use %s.new()(   t	   _internalt   AssertionErrort   __name__t   _h(   t   selft   internal_api_checkt   sha256_hash_obj(    (    s<   lib/python2.7/site-packages/Crypto/Random/Fortuna/SHAd256.pyt   __init__7   s    c         C   s   t  t j |  j j ƒ  ƒ S(   s$   Return a copy of this hashing object(   R   t   SHAd256R   R	   t   copy(   R
   (    (    s<   lib/python2.7/site-packages/Crypto/Random/Fortuna/SHAd256.pyR   =   s    c         C   s:   t  j |  j j ƒ  ƒ j ƒ  } t | ƒ d k s6 t ‚ | S(   s7   Return the hash value of this object as a binary stringi    (   R   R    R	   t   digestt   lenR   (   R
   t   retval(    (    s<   lib/python2.7/site-packages/Crypto/Random/Fortuna/SHAd256.pyR   B   s    c         C   sO   t  |  j ƒ  ƒ } t | ƒ d k s* t ‚ t j d d k rA | S| j ƒ  Sd S(   sH   Return the hash value of this object as a (lowercase) hexadecimal stringi@   i    i   N(   R   R   R   R   t   syst   version_infot   decode(   R
   R   (    (    s<   lib/python2.7/site-packages/Crypto/Random/Fortuna/SHAd256.pyt	   hexdigestI   s
    c         C   s   |  j  j | ƒ d  S(   N(   R	   t   update(   R
   t   data(    (    s<   lib/python2.7/site-packages/Crypto/Random/Fortuna/SHAd256.pyR   S   s    (   R   t
   __module__t   __doc__R   R   t   objectR   R   R   R   R   R   (    (    (    s<   lib/python2.7/site-packages/Crypto/Random/Fortuna/SHAd256.pyR   -   s   						
c         C   sD   |  s t  d ƒ }  n  t t j t j |  ƒ ƒ } t ƒ  d | _ | S(   s#   Return a new SHAd256 hashing objectt    R    (   t   bR   R   R   R    t   globals(   R   t   sha(    (    s<   lib/python2.7/site-packages/Crypto/Random/Fortuna/SHAd256.pyR    Z   s
    (   R   t   __revision__t   __all__R   R   t   Crypto.Util.py21compatt   Crypto.Util.py3compatt   binasciiR   t   Crypto.HashR   R   R   R   R   t   NoneR    (    (    (    s<   lib/python2.7/site-packages/Crypto/Random/Fortuna/SHAd256.pyt   <module>   s   &
*	