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

Method _auth_cram_md5

Lib/test/test_smtplib.py:920–938  ·  view source on GitHub ↗
(self, arg=None)

Source from the content-addressed store, hash-verified

918 self.push('334 QnVHZ1liVWdHeQ==')
919
920 def _auth_cram_md5(self, arg=None):
921 if arg is None:
922 self.push('334 {}'.format(sim_cram_md5_challenge))
923 else:
924 logpass = self._decode_base64(arg)
925 try:
926 user, hashed_pass = logpass.split()
927 except ValueError as e:
928 self.push('535 Splitting response {!r} into user and password '
929 'failed: {}'.format(logpass, e))
930 return
931 pwd = sim_auth[1].encode('ascii')
932 msg = self._decode_base64(sim_cram_md5_challenge).encode('ascii')
933 try:
934 valid_hashed_pass = hmac.HMAC(pwd, msg, 'md5').hexdigest()
935 except ValueError:
936 self.push('504 CRAM-MD5 is not supported')
937 return
938 self._authenticated(user, hashed_pass == valid_hashed_pass)
939 # end AUTH related stuff.
940
941 def smtp_EHLO(self, arg):

Callers

nothing calls this directly

Calls 8

_decode_base64Method · 0.95
_authenticatedMethod · 0.95
hexdigestMethod · 0.80
pushMethod · 0.45
formatMethod · 0.45
splitMethod · 0.45
encodeMethod · 0.45
HMACMethod · 0.45

Tested by

no test coverage detected