pyxmpp.sasl.digest_md5

Package pyxmpp :: Package sasl :: Module digest_md5 |
[hide private]

# Module digest_md5

source code

DIGEST-MD5 authentication mechanism for PyXMPP SASL implementation.

Normative reference:
  - RFC 2831

Classes | [hide private]
| DigestMD5ClientAuthenticator Provides PLAIN SASL authentication for a client.
| DigestMD5ServerAuthenticator Provides DIGEST-MD5 SASL authentication for a server.

Functions | [hide private]
`str` |
_unquote(s) Unquote quoted value from DIGEST-MD5 challenge or response. | source code
`str` |
_quote(s) Prepare a string for quoting for DIGEST-MD5 challenge or response. | source code
`str` |
_h_value(s) H function of the DIGEST-MD5 algorithm (MD5 sum). | source code
`str` |
_kd_value(k, s) KD function of the DIGEST-MD5 algorithm. | source code
`str` |
_make_urp_hash(username, realm, passwd) Compute MD5 sum of username:realm:password. | source code
`str` |
_compute_response(urp_hash, nonce, cnonce, nonce_count, authzid, digest_uri) Compute DIGEST-MD5 response value. | source code
`str` |
_compute_response_auth(urp_hash, nonce, cnonce, nonce_count, authzid, digest_uri) Compute DIGEST-MD5 rspauth value. | source code

Variables | [hide private]
| quote_re = `re.compile(r'`(?<!`\\`)`\\`(`.`)`')`
| _param_re = `re.compile(r'^`(?P<``var``>``[^`=`]``+``)`=`(?P<``val``>``(`"`(``(``[``^`"\\`]``+``)``|``...``
| __package__ = ``'``pyxmpp.sasl``'``

Imports: b2a_hex, re, logging, hashlib, ClientAuthenticator, ServerAuthenticator, Response, Challenge, Success, Failure, to_utf8, from_utf8

Function Details | [hide private]

### _unquote(s) | source code
Unquote quoted value from DIGEST-MD5 challenge or response. If `s` doesn't start or doesn't end with '"' then return it unchanged, remove the quotes and escape backslashes otherwise. Parameters: `s` (: `str`) - : a quoted string. Returns: `str` the unquoted string.

### _quote(s) | source code
Prepare a string for quoting for DIGEST-MD5 challenge or response. Don't add the quotes, only escape '"' and "" with backslashes. Parameters: `s` (: `str`) - : a raw string. Returns: `str` `s` with '"' and "" escaped using "".

### _h_value(s) | source code
H function of the DIGEST-MD5 algorithm (MD5 sum). Parameters: `s` (: `str`) - : a string. Returns: `str` MD5 sum of the string.

### _kd_value(k, s) | source code
KD function of the DIGEST-MD5 algorithm. Parameters: `k` (: `str`) - : a string. `s` (: `str`) - : a string. Returns: `str` MD5 sum of the strings joined with ':'.

### _make_urp_hash(username, realm, passwd) | source code
Compute MD5 sum of username:realm:password. Parameters: `username` (: `str`) - : a username. `realm` (: `str`) - : a realm. `passwd` (: `str`) - : a password. Returns: `str` the MD5 sum of the parameters joined with ':'.

### _compute_response(urp_hash, nonce, cnonce, nonce_count, authzid, digest_uri) | source code
Compute DIGEST-MD5 response value. Parameters: `urp_hash` (: `str`) - : MD5 sum of username:realm:password. `nonce` (: `str`) - : nonce value from a server challenge. `cnonce` - : cnonce value from the client response. `nonce_count` (: `int`) - : nonce count value. `authzid` (: `str`) - : authorization id. `digest_uri` (: `str`) - : digest-uri value. Returns: `str` the computed response value.

### _compute_response_auth(urp_hash, nonce, cnonce, nonce_count, authzid, digest_uri) | source code
Compute DIGEST-MD5 rspauth value. Parameters: `urp_hash` (: `str`) - : MD5 sum of username:realm:password. `nonce` (: `str`) - : nonce value from a server challenge. `cnonce` - : cnonce value from the client response. `nonce_count` (: `int`) - : nonce count value. `authzid` (: `str`) - : authorization id. `digest_uri` (: `str`) - : digest-uri value. Returns: `str` the computed rspauth value.

Variables Details | [hide private]

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