pyxmpp.sasl.digest_md5

Package pyxmpp :: Package sasl :: Module digest_md5 |
[show private | hide private]
[frames | no frames]

## Module pyxmpp.sasl.digest_md5

DIGEST-MD5 authentication mechanism for PyXMPP SASL implementation.

Normative reference:
  - RFC 2831

Classes
`DigestMD5ClientAuthenticator` | Provides PLAIN SASL authentication for a client.
`DigestMD5ServerAuthenticator` | Provides DIGEST-MD5 SASL authentication for a server.

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

Variable Summary
`str` | `__revision__` = `'$Id: digest_md5.py 559 2005-03-20 18:01:...`
`SRE_Pattern` | `quote_re` = `(?!\\)\\(.)`
`SRE_Pattern` | `_param_re` = `^([^=]+)=(("(([^"\\]+)|(\\")|(\\\\))+")|([^"...`

Imported modules:
  `logging`, `md5`, `re`
Imported classes:
  `Challenge`, `ClientAuthenticator`, `Failure`, `Response`, `ServerAuthenticator`, `Success`
Imported functions:
  `b2a_hex`, `from_utf8`, `to_utf8`

Function Details

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

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

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

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

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

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

### _unquote(s) 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` - a quoted string. (type=`str`) Returns: the unquoted string. (type=`str`)

Variable Details

    ### __revision__ Type: `str` Value:
        '$Id: digest_md5.py 559 2005-03-20 18:01:06Z jajcus $'

    ### quote_re Type: `SRE_Pattern` Value:
        (?!\\)\\(.)

    ### _param_re Type: `SRE_Pattern` Value:
        ^([^=]+)=(("(([^"\\]+)|(\\")|(\\\\))+")|([^",]+))(,(.*))?$