Package pyxmpp2 :: Package sasl :: Module digest_md5
[hide private]

Module digest_md5

DIGEST-MD5 authentication mechanism for PyXMPP SASL implementation.

Normative reference:
Classes [hide private]
  DigestMD5ClientAuthenticator
Provides PLAIN SASL authentication for a client.
  DigestMD5ServerAuthenticator
Provides DIGEST-MD5 SASL authentication for a server.
Functions [hide private]
bytes
_unquote(data)
Unquote quoted value from DIGEST-MD5 challenge or response.
bytes
_quote(data)
Prepare a string for quoting for DIGEST-MD5 challenge or response.
bytes
_h_value(data)
H function of the DIGEST-MD5 algorithm (MD5 sum).
bytes
_kd_value(k_val, s_val)
KD function of the DIGEST-MD5 algorithm.
bytes
_make_urp_hash(username, realm, passwd)
Compute MD5 sum of username:realm:password.
bytes
_compute_response(urp_hash, nonce, cnonce, nonce_count, authzid, digest_uri)
Compute DIGEST-MD5 response value.
bytes
_compute_response_auth(urp_hash, nonce, cnonce, nonce_count, authzid, digest_uri)
Compute DIGEST-MD5 rspauth value.
Variables [hide private]
  logger = logging.getLogger("pyxmpp2.sasl.digest_md5")
  QUOTE_RE = re.compile(r'(?<!\\)\\(.)')
  PARAM_RE = re.compile(r'^(?P<var>[^=]+)=(?P<val>("(([^"\\]+)|(...
Function Details [hide private]

_unquote(data)

 

Unquote quoted value from DIGEST-MD5 challenge or response.

If data doesn't start or doesn't end with '"' then return it unchanged, remove the quotes and escape backslashes otherwise.

Parameters:
  • data (bytes) - a quoted string.
Returns: bytes
the unquoted string.

_quote(data)

 

Prepare a string for quoting for DIGEST-MD5 challenge or response.

Don't add the quotes, only escape '"' and "" with backslashes.

Parameters:
  • data (bytes) - a raw string.
Returns: bytes
data with '"' and "" escaped using "".

_h_value(data)

 
H function of the DIGEST-MD5 algorithm (MD5 sum).
Parameters:
  • data (bytes) - a byte string.
Returns: bytes
MD5 sum of the string.

_kd_value(k_val, s_val)

 
KD function of the DIGEST-MD5 algorithm.
Parameters:
  • k_val (bytes) - a byte string.
  • s_val (bytes) - a byte string.
Returns: bytes
MD5 sum of the strings joined with ':'.

_make_urp_hash(username, realm, passwd)

 
Compute MD5 sum of username:realm:password.
Parameters:
  • username (bytes) - a username.
  • realm (bytes) - a realm.
  • passwd (bytes) - a password.
Returns: bytes
the MD5 sum of the parameters joined with ':'.

_compute_response(urp_hash, nonce, cnonce, nonce_count, authzid, digest_uri)

 
Compute DIGEST-MD5 response value.
Parameters:
  • urp_hash (bytes) - MD5 sum of username:realm:password.
  • nonce (bytes) - nonce value from a server challenge.
  • cnonce - cnonce value from the client response.
  • nonce_count (int) - nonce count value.
  • authzid (bytes) - authorization id.
  • digest_uri (bytes) - digest-uri value.
Returns: bytes
the computed response value.

_compute_response_auth(urp_hash, nonce, cnonce, nonce_count, authzid, digest_uri)

 
Compute DIGEST-MD5 rspauth value.
Parameters:
  • urp_hash (bytes) - MD5 sum of username:realm:password.
  • nonce (bytes) - nonce value from a server challenge.
  • cnonce - cnonce value from the client response.
  • nonce_count (int) - nonce count value.
  • authzid (bytes) - authorization id.
  • digest_uri (bytes) - digest-uri value.
Returns: bytes
the computed rspauth value.

Variables Details [hide private]

PARAM_RE

Value:
re.compile(r'^(?P<var>[^=]+)=(?P<val>("(([^"\\]+)|(\\")|(\\\\))+")|([^\
",]+))(\s*,\s*(?P<rest>.*))?$')