MCPcopy Index your code
hub / github.com/python/cpython / deliver_challenge

Function deliver_challenge

Lib/multiprocessing/connection.py:966–984  ·  view source on GitHub ↗
(connection, authkey: bytes, digest_name='sha256')

Source from the content-addressed store, hash-verified

964
965
966def deliver_challenge(connection, authkey: bytes, digest_name='sha256'):
967 if not isinstance(authkey, bytes):
968 raise ValueError(
969 "Authkey must be bytes, not {0!s}".format(type(authkey)))
970 assert MESSAGE_LENGTH > _MD5ONLY_MESSAGE_LENGTH, "protocol constraint"
971 message = os.urandom(MESSAGE_LENGTH)
972 message = b'{%s}%s' % (digest_name.encode('ascii'), message)
973 # Even when sending a challenge to a legacy client that does not support
974 # digest prefixes, they'll take the entire thing as a challenge and
975 # respond to it with a raw HMAC-MD5.
976 connection.send_bytes(_CHALLENGE + message)
977 response = connection.recv_bytes(256) # reject large message
978 try:
979 _verify_challenge(authkey, message, response)
980 except AuthenticationError:
981 connection.send_bytes(_FAILURE)
982 raise
983 else:
984 connection.send_bytes(_WELCOME)
985
986
987def answer_challenge(connection, authkey: bytes):

Callers 2

acceptMethod · 0.85
ClientFunction · 0.85

Calls 5

_verify_challengeFunction · 0.85
formatMethod · 0.45
encodeMethod · 0.45
send_bytesMethod · 0.45
recv_bytesMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…