mirror of
https://github.com/python/cpython.git
synced 2025-11-24 04:17:38 +00:00
[3.14] gh-136134: imaplib: fix CRAM-MD5 on FIPS-only environments (GH-136615) (#138054)
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
Some checks are pending
Tests / (push) Blocked by required conditions
Tests / Sanitizers (push) Blocked by required conditions
Tests / Cross build Linux (push) Blocked by required conditions
Tests / Windows MSI (push) Blocked by required conditions
Tests / Change detection (push) Waiting to run
Tests / Docs (push) Blocked by required conditions
Tests / Check if the ABI has changed (push) Blocked by required conditions
Tests / Check if Autoconf files are up to date (push) Blocked by required conditions
Tests / Check if generated files are up to date (push) Blocked by required conditions
Tests / Ubuntu SSL tests with OpenSSL (push) Blocked by required conditions
Tests / Android (aarch64) (push) Blocked by required conditions
Tests / Android (x86_64) (push) Blocked by required conditions
Tests / WASI (push) Blocked by required conditions
Tests / Hypothesis tests on Ubuntu (push) Blocked by required conditions
Tests / Address sanitizer (push) Blocked by required conditions
Tests / CIFuzz (push) Blocked by required conditions
Tests / All required checks pass (push) Blocked by required conditions
Lint / lint (push) Waiting to run
This commit is contained in:
parent
bfce393614
commit
d574f83206
4 changed files with 49 additions and 31 deletions
|
|
@ -21,7 +21,7 @@ Public functions: Internaldate2tuple
|
|||
# GET/SETANNOTATION contributed by Tomas Lindroos <skitta@abo.fi> June 2005.
|
||||
# IDLE contributed by Forest <forestix@nom.one> August 2024.
|
||||
|
||||
__version__ = "2.59"
|
||||
__version__ = "2.60"
|
||||
|
||||
import binascii, errno, random, re, socket, subprocess, sys, time, calendar
|
||||
from datetime import datetime, timezone, timedelta
|
||||
|
|
@ -725,9 +725,17 @@ class IMAP4:
|
|||
def _CRAM_MD5_AUTH(self, challenge):
|
||||
""" Authobject to use with CRAM-MD5 authentication. """
|
||||
import hmac
|
||||
pwd = (self.password.encode('utf-8') if isinstance(self.password, str)
|
||||
else self.password)
|
||||
return self.user + " " + hmac.HMAC(pwd, challenge, 'md5').hexdigest()
|
||||
|
||||
if isinstance(self.password, str):
|
||||
password = self.password.encode('utf-8')
|
||||
else:
|
||||
password = self.password
|
||||
|
||||
try:
|
||||
authcode = hmac.HMAC(password, challenge, 'md5')
|
||||
except ValueError: # HMAC-MD5 is not available
|
||||
raise self.error("CRAM-MD5 authentication is not supported")
|
||||
return f"{self.user} {authcode.hexdigest()}"
|
||||
|
||||
|
||||
def logout(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue