Authobject to use with CRAM-MD5 authentication.
(self, challenge)
| 721 | |
| 722 | |
| 723 | def _CRAM_MD5_AUTH(self, challenge): |
| 724 | """ Authobject to use with CRAM-MD5 authentication. """ |
| 725 | import hmac |
| 726 | |
| 727 | if isinstance(self.password, str): |
| 728 | password = self.password.encode('utf-8') |
| 729 | else: |
| 730 | password = self.password |
| 731 | |
| 732 | try: |
| 733 | authcode = hmac.HMAC(password, challenge, 'md5') |
| 734 | except ValueError: # HMAC-MD5 is not available |
| 735 | raise self.error("CRAM-MD5 authentication is not supported") |
| 736 | return f"{self.user} {authcode.hexdigest()}" |
| 737 | |
| 738 | |
| 739 | def logout(self): |
nothing calls this directly
no test coverage detected