Current Path : /usr/lib/python2.7/dist-packages/twisted/cred/ |
Current File : //usr/lib/python2.7/dist-packages/twisted/cred/_digest.pyc |
[XMc @ sY d Z d d l m Z m Z i e d 6e d 6e d 6Z d d Z d Z d Z d S( s^ Calculations for HTTP Digest authentication. @see: U{http://www.faqs.org/rfcs/rfc2617.html} i( t md5t sha1R s md5-sesst shac C s | r' | s | s | r' t d n | d k r t | } | j | | j d | j | | j d | j | | j } n | j d } | d k rt | } | j | | j d | j | | j d | j | | j } n | j d S( s: Compute H(A1) from RFC 2617. @param pszAlg: The name of the algorithm to use to calculate the digest. Currently supported are md5, md5-sess, and sha. @param pszUserName: The username @param pszRealm: The realm @param pszPassword: The password @param pszNonce: The nonce @param pszCNonce: The cnonce @param preHA1: If available this is a str containing a previously calculated H(A1) as a hex string. If this is given then the values for pszUserName, pszRealm, and pszPassword must be C{None} and are ignored. sP preHA1 is incompatible with the pszUserName, pszRealm, and pszPassword argumentst :t hexs md5-sessN( t TypeErrort Nonet algorithmst updatet digestt decodet encode( t pszAlgt pszUserNamet pszRealmt pszPasswordt pszNoncet pszCNoncet preHA1t mt HA1( ( s8 /usr/lib/python2.7/dist-packages/twisted/cred/_digest.pyt calcHA1! s( c C sp t | } | j | | j d | j | | d k r] | j d | j | n | j j d S( s Compute H(A2) from RFC 2617. @param pszAlg: The name of the algorithm to use to calculate the digest. Currently supported are md5, md5-sess, and sha. @param pszMethod: The request method. @param pszDigestUri: The request URI. @param pszQop: The Quality-of-Protection value. @param pszHEntity: The hash of the entity body or C{None} if C{pszQop} is not C{'auth-int'}. @return: The hash of the A2 value for the calculation of the response digest. R s auth-intR ( R R R R ( t algot pszMethodt pszDigestUrit pszQopt pszHEntityR ( ( s8 /usr/lib/python2.7/dist-packages/twisted/cred/_digest.pyt calcHA2P s c C s t | } | j | | j d | j | | j d | r | r | j | | j d | j | | j d | j | | j d n | j | | j j d } | S( s Compute the digest for the given parameters. @param HA1: The H(A1) value, as computed by L{calcHA1}. @param HA2: The H(A2) value, as computed by L{calcHA2}. @param pszNonce: The challenge nonce. @param pszNonceCount: The (client) nonce count value for this response. @param pszCNonce: The client nonce. @param pszQop: The Quality-of-Protection value. R R ( R R R R ( R t HA2R R t pszNonceCountR R R t respHash( ( s8 /usr/lib/python2.7/dist-packages/twisted/cred/_digest.pyt calcResponseh s N( t __doc__t twisted.python.hashlibR R R R R R R ( ( ( s8 /usr/lib/python2.7/dist-packages/twisted/cred/_digest.pyt <module> s .