Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/twisted/cred/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/twisted/cred/_digest.pyc


[XMc@sYdZddlmZmZied6ed6ed6Zd	dZdZdZd	S(
s^
Calculations for HTTP Digest authentication.

@see: U{http://www.faqs.org/rfcs/rfc2617.html}
i(tmd5tsha1Rsmd5-sesstshac	Cs|r'|s|s|r'tdn|dkrt|}|j||jd|j||jd|j||j}n|jd}|dkrt|}|j||jd|j||jd|j||j}n|jdS(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.
    sPpreHA1 is incompatible with the pszUserName, pszRealm, and pszPassword argumentst:thexsmd5-sessN(t	TypeErrortNonet
algorithmstupdatetdigesttdecodetencode(	tpszAlgtpszUserNametpszRealmtpszPasswordtpszNoncet	pszCNoncetpreHA1tmtHA1((s8/usr/lib/python2.7/dist-packages/twisted/cred/_digest.pytcalcHA1!s(











cCspt|}|j||jd|j||dkr]|jd|j|n|jjdS(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.
    Rsauth-intR(RRR	R(talgot	pszMethodtpszDigestUritpszQopt
pszHEntityR((s8/usr/lib/python2.7/dist-packages/twisted/cred/_digest.pytcalcHA2Ps




c	Cst|}|j||jd|j||jd|r|r|j||jd|j||jd|j||jdn|j||jjd}|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.
    RR(RRR	R(	RtHA2RRt
pszNonceCountRRRtrespHash((s8/usr/lib/python2.7/dist-packages/twisted/cred/_digest.pytcalcResponsehs










N(	t__doc__ttwisted.python.hashlibRRRRRRR(((s8/usr/lib/python2.7/dist-packages/twisted/cred/_digest.pyt<module>	s	
.