MCPcopy Index your code
hub / github.com/RustPython/RustPython / _get_digest_name_and_payload

Function _get_digest_name_and_payload

Lib/multiprocessing/connection.py:849–872  ·  view source on GitHub ↗

Returns a digest name and the payload for a response hash. If a legacy protocol is detected based on the message length or contents the digest name returned will be empty to indicate legacy mode where MD5 and no digest prefix should be sent.

(message)

Source from the content-addressed store, hash-verified

847
848
849def _get_digest_name_and_payload(message): # type: (bytes) -> tuple[str, bytes]
850 """Returns a digest name and the payload for a response hash.
851
852 If a legacy protocol is detected based on the message length
853 or contents the digest name returned will be empty to indicate
854 legacy mode where MD5 and no digest prefix should be sent.
855 """
856 # modern message format: b"{digest}payload" longer than 20 bytes
857 # legacy message format: 16 or 20 byte b"payload"
858 if len(message) in _LEGACY_LENGTHS:
859 # Either this was a legacy server challenge, or we're processing
860 # a reply from a legacy client that sent an unprefixed 16-byte
861 # HMAC-MD5 response. All messages using the modern protocol will
862 # be longer than either of these lengths.
863 return '', message
864 if (message.startswith(b'{') and
865 (curly := message.find(b'}', 1, _MAX_DIGEST_LEN+2)) > 0):
866 digest = message[1:curly]
867 if digest in _ALLOWED_DIGESTS:
868 payload = message[curly+1:]
869 return digest.decode('ascii'), payload
870 raise AuthenticationError(
871 'unsupported message length, missing digest prefix, '
872 f'or unsupported digest: {message=}')
873
874
875def _create_response(authkey, message):

Callers 2

_create_responseFunction · 0.85
_verify_challengeFunction · 0.85

Calls 5

lenFunction · 0.85
AuthenticationErrorClass · 0.85
startswithMethod · 0.45
findMethod · 0.45
decodeMethod · 0.45

Tested by

no test coverage detected