Skip to content
Myr

Clarify digest hash method names

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Idan Gazit · committed by Idan Gazit · parent 365c64f · Browse files · 1 file+9 added−9 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−9 removed

  • other:+9 added−9 removed

1 file+9 added−9 removed

modified:requests/auth.py+9 added-9 removed
72 unmodified lines
7374 algorithm = algorithm.upper()75 # lambdas assume digest modules are imported at the top level76 if algorithm == 'MD5':77 def h(x):77 def md5_utf8(x):78 if isinstance(x, str):79 x = x.encode('utf-8')80 return hashlib.md5(x).hexdigest()81 H = h81 hash_utf8 = md5_utf882 elif algorithm == 'SHA':83 def h(x):83 def sha_utf8(x):84 if isinstance(x, str):85 x = x.encode('utf-8')86 return hashlib.sha1(x).hexdigest()87 H = h87 hash_utf8 = sha_utf888 # XXX MD5-sess89 KD = lambda s, d: H("%s:%s" % (s, d))89 KD = lambda s, d: hash_utf8("%s:%s" % (s, d))9091 if H is None:91 if hash_utf8 is None:92 return None9394 # XXX not implemented yet95 entdig = None
18 unmodified lines
114 s += time.ctime().encode('utf-8')115 s += randombytes(8)116117 cnonce = (hashlib.sha1(s).hexdigest()[:16])118 noncebit = "%s:%s:%s:%s:%s" % (nonce, ncvalue, cnonce, qop, H(A2))119 respdig = KD(H(A1), noncebit)118 noncebit = "%s:%s:%s:%s:%s" % (nonce, ncvalue, cnonce, qop, hash_utf8(A2))119 respdig = KD(hash_utf8(A1), noncebit)120 elif qop is None:121 respdig = KD(H(A1), "%s:%s" % (nonce, H(A2)))121 respdig = KD(hash_utf8(A1), "%s:%s" % (nonce, hash_utf8(A2)))122 else:123 # XXX handle auth-int.124 return None125
23 unmodified lines