§
    ÈtºfÜ  ã                   óH   — d Z ddlmZ ddlmZmZ eeedœZ	 d	d„Zd„ Zd„ Z	dS )
z^
Calculations for HTTP Digest authentication.

@see: U{http://www.faqs.org/rfcs/rfc2617.html}
é    )Úhexlify)Úmd5Úsha1)s   md5ó   md5-sesss   shaNc                 óÂ  — |r|s|s|rt          d¦  «        ‚|€Ÿt          |          ¦   «         }|                     |¦  «         |                     d¦  «         |                     |¦  «         |                     d¦  «         |                     |¦  «         t          |                     ¦   «         ¦  «        }n|}| dk    ržt          |          ¦   «         }|                     |¦  «         |                     d¦  «         |                     |¦  «         |                     d¦  «         |                     |¦  «         t          |                     ¦   «         ¦  «        }|S )a:  
    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 L{None} and are ignored.
    zPpreHA1 is incompatible with the pszUserName, pszRealm, and pszPassword argumentsNó   :r   )Ú	TypeErrorÚ
algorithmsÚupdater   Údigest)	ÚpszAlgÚpszUserNameÚpszRealmÚpszPasswordÚpszNonceÚ	pszCNonceÚpreHA1ÚmÚHA1s	            úS/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/twisted/cred/_digest.pyÚcalcHA1r   !   sG  € ð& ð 
�;ð 
 (ð 
¨kð 
Ýð2ñ
ô 
ð 	
ð
 €~å�vÔÑ Ô ˆØ	�Š�ÑÔÐØ	�Š�‰ŒˆØ	�Š�ÑÔÐØ	�Š�‰ŒˆØ	�Š�ÑÔÐÝ�a—h’h‘j”jÑ!Ô!ˆˆð ˆà�ÒÐÝ�vÔÑ Ô ˆØ	�Š�‰ŒˆØ	�Š�‰ŒˆØ	�Š�ÑÔÐØ	�Š�‰ŒˆØ	�Š�ÑÔÐÝ�a—h’h‘j”jÑ!Ô!ˆà€Jó    c                 óJ  — t          |          ¦   «         }|                     |¦  «         |                     d¦  «         |                     |¦  «         |dk    r*|                     d¦  «         |                     |¦  «         t          |                     ¦   «         ¦  «        S )aõ  
    Compute H(A2) from RFC 2617.

    @param algo: 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 L{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-int©r
   r   r   r   )ÚalgoÚ	pszMethodÚpszDigestUriÚpszQopÚ
pszHEntityr   s         r   ÚcalcHA2r    S   s‰   € õ 	�4ÔÑÔ€AØ‡H‚HˆYÑÔÐØ‡H‚HˆT�N„N€NØ‡H‚Hˆ\ÑÔÐØ�ÒÐØ	�Š�‰ŒˆØ	�Š�ÑÔÐÝ�1—8’8‘:”:ÑÔÐr   c                 óF  — t          |         ¦   «         }|                     | ¦  «         |                     d¦  «         |                     |¦  «         |                     d¦  «         |r€|r~|                     |¦  «         |                     d¦  «         |                     |¦  «         |                     d¦  «         |                     |¦  «         |                     d¦  «         |                     |¦  «         t          |                     ¦   «         ¦  «        }|S )a�  
    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   ÚHA2r   r   ÚpszNonceCountr   r   r   ÚrespHashs	            r   ÚcalcResponser%   k   sî   € õ 	�4ÔÑÔ€AØ‡H‚HˆS�M„M€MØ‡H‚HˆT�N„N€NØ‡H‚HˆXÑÔÐØ‡H‚HˆT�N„N€NØð ˜ð Ø	�Š�ÑÔÐØ	�Š�‰ŒˆØ	�Š�ÑÔÐØ	�Š�‰ŒˆØ	�Š�ÑÔÐØ	�Š�‰ŒˆØ‡H‚HˆS�M„M€MÝ�q—x’x‘z”zÑ"Ô"€HØ€Or   )N)
Ú__doc__Úbinasciir   Úhashlibr   r   r
   r   r    r%   © r   r   ú<module>r*      s˜   ðð
ð ð Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ð Ð ð
 ð Øðð €
ð" MQð/ð /ð /ð /ðdð ð ð0ð ð ð ð r   