(connection, authkey: bytes)
| 985 | |
| 986 | |
| 987 | def answer_challenge(connection, authkey: bytes): |
| 988 | if not isinstance(authkey, bytes): |
| 989 | raise ValueError( |
| 990 | "Authkey must be bytes, not {0!s}".format(type(authkey))) |
| 991 | message = connection.recv_bytes(256) # reject large message |
| 992 | if not message.startswith(_CHALLENGE): |
| 993 | raise AuthenticationError( |
| 994 | f'Protocol error, expected challenge: {message=}') |
| 995 | message = message[len(_CHALLENGE):] |
| 996 | if len(message) < _MD5ONLY_MESSAGE_LENGTH: |
| 997 | raise AuthenticationError(f'challenge too short: {len(message)} bytes') |
| 998 | digest = _create_response(authkey, message) |
| 999 | connection.send_bytes(digest) |
| 1000 | response = connection.recv_bytes(256) # reject large message |
| 1001 | if response != _WELCOME: |
| 1002 | raise AuthenticationError('digest sent was rejected') |
| 1003 | |
| 1004 | # |
| 1005 | # Support for using xmlrpclib for serialization |
no test coverage detected
searching dependent graphs…