(auth_map, password, method="GET", A1=None,
                           **kwargs)
return KD(H_A1, request)
Generates a response respecting the algorithm defined in RFC 2617
Generates a response respecting the algorithm defined in RFC 2617
Generates a response respecting the algorithm defined in RFC 2617
def _computeDigestResponse(auth_map, password, method="GET", A1=None,
                           **kwargs):
    """
    Generates a response respecting the algorithm defined in RFC 2617
    """

    params = auth_map

    algorithm = params.get("algorithm", MD5)

    H = DIGEST_AUTH_ENCODERS[algorithm]

    def KD(secret, data):
        s = secret + ":" + data
        return H(s.encode("utf-8"))

    qop = params.get("qop", None)

    s = _A2(params, method, kwargs)
    H_A2 = H(s.encode("utf-8"))

    if algorithm == MD5_SESS and A1 is not None:
        H_A1 = H(A1.encode("utf-8"))
    else:
        s = _A1(params, password)
        H_A1 = H(s.encode("utf-8"))

    if qop in ("auth", "auth-int"):
        # If the "qop" value is "auth" or "auth-int":
        # request-digest  = <"> < KD ( H(A1),     unq(nonce-value)
        #                              ":" nc-value
        #                              ":" unq(cnonce-value)
        #                              ":" unq(qop-value)
        #                              ":" H(A2)
        #                      ) <">
        request = "%s:%s:%s:%s:%s" % (
            params["nonce"],
            params["nc"],
            params["cnonce"],
            params["qop"],
            H_A2,
        )

    elif qop is None:
        # If the "qop" directive is not present (this construction is
        # for compatibility with RFC 2069):
        # request-digest  =
        #         <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <">
        request = "%s:%s" % (params["nonce"], H_A2)

    return KD(H_A1, request)
def _computeDigestResponse ( auth_map , password , method = "GET" , A1 = None , * * kwargs ) : params = auth_map algorithm = params . get ( "algorithm" , MD5 ) H = DIGEST_AUTH_ENCODERS [ algorithm ] def KD ( secret , data ) : s = secret + ":" + data return H ( s . encode ( "utf-8" ) ) qop = params . get ( "qop" , None ) s = _A2 ( params , method , kwargs ) H_A2 = H ( s . encode ( "utf-8" ) ) if algorithm == MD5_SESS and A1 is not None : H_A1 = H ( A1 . encode ( "utf-8" ) ) else : s = _A1 ( params , password ) H_A1 = H ( s . encode ( "utf-8" ) ) if qop in ( "auth" , "auth-int" ) : # If the "qop" value is "auth" or "auth-int": # request-digest  = <"> < KD ( H(A1),     unq(nonce-value) #                              ":" nc-value #                              ":" unq(cnonce-value) #                              ":" unq(qop-value) #                              ":" H(A2) #                      ) <"> request = "%s:%s:%s:%s:%s" % ( params [ "nonce" ] , params [ "nc" ] , params [ "cnonce" ] , params [ "qop" ] , H_A2 , ) elif qop is None : # If the "qop" directive is not present (this construction is # for compatibility with RFC 2069): # request-digest  = #         <"> < KD ( H(A1), unq(nonce-value) ":" H(A2) ) > <"> request = "%s:%s" % ( params [ "nonce" ] , H_A2 ) return KD ( H_A1 , request )