challenge.c File Reference

Challenge related functions

More...

#include "../../data_lump.h"
#include "../../mem/mem.h"
#include "../../parser/digest/digest.h"
#include "../../pvar.h"
#include "../../str.h"
#include "../../ut.h"
#include "../../mod_fix.h"
#include "auth_mod.h"
#include "common.h"
#include "challenge.h"
#include "nonce.h"
#include "index.h"
#include "api.h"

Include dependency graph for challenge.c:

Go to the source code of this file.

Defines

#define DIGEST_MD5   ", algorithm=MD5"
#define DIGEST_MD5_LEN   (sizeof(DIGEST_MD5)-1)
#define DIGEST_NONCE   "\", nonce=\""
#define DIGEST_NONCE_LEN   (sizeof(DIGEST_NONCE)-1)
#define DIGEST_REALM   ": Digest realm=\""
#define DIGEST_REALM_LEN   (sizeof(DIGEST_REALM)-1)
#define MESSAGE_401   "Unauthorized"
#define MESSAGE_407   "Proxy Authentication Required"
#define PROXY_AUTH_CHALLENGE   "Proxy-Authenticate"
#define QOP_PARAM   ", qop=\"auth\""
#define QOP_PARAM_LEN   (sizeof(QOP_PARAM)-1)
#define STALE_PARAM   ", stale=true"
#define STALE_PARAM_LEN   (sizeof(STALE_PARAM)-1)
#define WWW_AUTH_CHALLENGE   "WWW-Authenticate"

Functions

static char * build_auth_hf (int _stale, str *_realm, int *_len, int _qop, char *_hf_name)
 Create {WWW,Proxy}-Authenticate header field.
static int challenge (struct sip_msg *_msg, gparam_p _realm, int _qop, int _code, char *_message, char *_challenge_msg)
 Create and send a authentification challenge.
int consume_credentials (struct sip_msg *_m, char *_s1, char *_s2)
 Remove used credentials from a SIP message header.
int proxy_challenge (struct sip_msg *_msg, char *_realm, char *_qop)
 Challenge a user to send credentials using Proxy-Authorize header field.
int www_challenge (struct sip_msg *_msg, char *_realm, char *_qop)
 Challenge a user to send credentials using WWW-Authorize header field.

Variables

static str auth_400_err = str_init(MESSAGE_400)
static str auth_500_err = str_init(MESSAGE_500)


Detailed Description

Challenge related functions

Definition in file challenge.c.


Define Documentation

#define DIGEST_MD5   ", algorithm=MD5"

Definition at line 77 of file challenge.c.

Referenced by build_auth_hf().

#define DIGEST_MD5_LEN   (sizeof(DIGEST_MD5)-1)

Definition at line 78 of file challenge.c.

Referenced by build_auth_hf().

#define DIGEST_NONCE   "\", nonce=\""

Definition at line 75 of file challenge.c.

Referenced by build_auth_hf().

#define DIGEST_NONCE_LEN   (sizeof(DIGEST_NONCE)-1)

Definition at line 76 of file challenge.c.

Referenced by build_auth_hf().

#define DIGEST_REALM   ": Digest realm=\""

Definition at line 73 of file challenge.c.

Referenced by build_auth_hf().

#define DIGEST_REALM_LEN   (sizeof(DIGEST_REALM)-1)

Definition at line 74 of file challenge.c.

Referenced by build_auth_hf().

#define MESSAGE_401   "Unauthorized"

Definition at line 65 of file challenge.c.

Referenced by www_challenge().

#define MESSAGE_407   "Proxy Authentication Required"

Definition at line 58 of file challenge.c.

Referenced by proxy_challenge().

#define PROXY_AUTH_CHALLENGE   "Proxy-Authenticate"

Definition at line 59 of file challenge.c.

Referenced by proxy_challenge(), and srv_response().

#define QOP_PARAM   ", qop=\"auth\""

Definition at line 69 of file challenge.c.

Referenced by build_auth_hf().

#define QOP_PARAM_LEN   (sizeof(QOP_PARAM)-1)

Definition at line 70 of file challenge.c.

Referenced by build_auth_hf().

#define STALE_PARAM   ", stale=true"

Definition at line 71 of file challenge.c.

Referenced by build_auth_hf().

#define STALE_PARAM_LEN   (sizeof(STALE_PARAM)-1)

Definition at line 72 of file challenge.c.

Referenced by build_auth_hf().

#define WWW_AUTH_CHALLENGE   "WWW-Authenticate"

Definition at line 66 of file challenge.c.

Referenced by srv_response(), and www_challenge().


Function Documentation

static char* build_auth_hf ( int  _stale,
str _realm,
int *  _len,
int  _qop,
char *  _hf_name 
) [inline, static]

Create {WWW,Proxy}-Authenticate header field.

Parameters:
_stale 
_realm authentification realm
_len length, will be set
_qop qop value
_hf_name header field name
Returns:
created header field, or 0 on failure

Definition at line 90 of file challenge.c.

References calc_nonce(), CRLF, CRLF_LEN, DIGEST_MD5, DIGEST_MD5_LEN, DIGEST_NONCE, DIGEST_NONCE_LEN, DIGEST_REALM, DIGEST_REALM_LEN, _str::len, LM_DBG, LM_ERR, nonce_expire, NONCE_LEN, nonce_reuse, pkg_malloc, QOP_PARAM, QOP_PARAM_LEN, reserve_nonce_index(), _str::s, secret, STALE_PARAM, and STALE_PARAM_LEN.

Referenced by challenge().

static int challenge ( struct sip_msg _msg,
gparam_p  _realm,
int  _qop,
int  _code,
char *  _message,
char *  _challenge_msg 
) [inline, static]

Create and send a authentification challenge.

Parameters:
_msg SIP message
_realm authentification realm
_qop qop value
_code response code
_message response message
_challenge_msg challenge message
Returns:
0 if challenge could be created and sended, -1 on failure

Definition at line 165 of file challenge.c.

References sip_msg::authorization, build_auth_hf(), fixup_get_svalue(), get_authorized_cred(), get_realm(), HDR_AUTHORIZATION_T, HDR_PROXYAUTH_T, sip_uri::host, _str::len, LM_ERR, hdr_field::parsed, pkg_free, sip_msg::proxy_auth, _str::s, send_resp(), auth_body::stale, and strip_realm().

Referenced by proxy_challenge(), and www_challenge().

int consume_credentials ( struct sip_msg _m,
char *  _s1,
char *  _s2 
)

Remove used credentials from a SIP message header.

Parameters:
_m SIP message
_s1 unused
_s2 unused
Returns:
1 when credentials could be removed, -1 if not found or on failure

Definition at line 269 of file challenge.c.

References sip_msg::authorization, sip_msg::buf, del_lump(), get_authorized_cred(), hdr_field::len, len, LM_ERR, METHOD_ACK, METHOD_CANCEL, hdr_field::name, sip_msg::proxy_auth, and _str::s.

int proxy_challenge ( struct sip_msg _msg,
char *  _realm,
char *  _qop 
)

Challenge a user to send credentials using Proxy-Authorize header field.

Parameters:
_msg SIP message
_realm authentification realm
_qop qop value
Returns:
0 if challenge could be sended, -1 on failure

Definition at line 255 of file challenge.c.

References challenge(), MESSAGE_407, and PROXY_AUTH_CHALLENGE.

int www_challenge ( struct sip_msg _msg,
char *  _realm,
char *  _qop 
)

Challenge a user to send credentials using WWW-Authorize header field.

Parameters:
_msg SIP message
_realm authentification realm
_qop qop value
Returns:
0 if challenge could be sended, -1 on failure

Challenge a user to send credentials using WWW-Authorize header field

Parameters:
_msg SIP message
_realm authentification realm
_qop qop value
Returns:
0 if challenge could be sended, -1 on failure

Definition at line 234 of file challenge.c.

References challenge(), MESSAGE_401, and WWW_AUTH_CHALLENGE.


Variable Documentation

str auth_400_err = str_init(MESSAGE_400) [static]

Definition at line 51 of file challenge.c.

str auth_500_err = str_init(MESSAGE_500) [static]

Definition at line 52 of file challenge.c.


Generated on Mon May 21 16:00:35 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6