nonce.c File Reference

Nonce related functions

More...

#include <time.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#include "../../md5.h"
#include "../../dprint.h"
#include "../../ut.h"
#include "../../timer.h"
#include "nonce.h"
#include "index.h"
#include "auth_mod.h"

Include dependency graph for nonce.c:

Go to the source code of this file.

Functions

void calc_nonce (char *_nonce, int _expires, int _index, str *_secret)
 Calculate nonce value.
int check_nonce (str *_nonce, str *_secret)
 Check nonce value received from user agent.
static time_t get_nonce_expires (str *_n)
 Get expiry time from nonce string.
int get_nonce_index (str *_n)
 Get index from nonce string.
static int hex2integer (char *_s)
 Convert hex string to integer.
static void integer2hex (char *_d, int _s)
int is_nonce_stale (str *_n)
 Check if a nonce is stale.


Detailed Description

Nonce related functions

Definition in file nonce.c.


Function Documentation

void calc_nonce ( char *  _nonce,
int  _expires,
int  _index,
str _secret 
)

Calculate nonce value.

Calculate nonce value value. The nonce value consists of the expires time (in seconds since 1.1 1970) and a secret phrase.

Parameters:
_nonce nonce value
_expires expires value
_index nonce index
_secret secret

Definition at line 110 of file nonce.c.

References integer2hex(), _str::len, MD5Init(), MD5Update(), nonce_reuse, _str::s, string2hex(), and U_MD5Final().

Referenced by build_auth_hf(), and check_nonce().

int check_nonce ( str _nonce,
str _secret 
)

Check nonce value received from user agent.

Parameters:
_nonce nonce value
_secret secret phrase
Returns:
0 when nonce is valid, -1 on errors, positive if nonce not valid

Definition at line 163 of file nonce.c.

References calc_nonce(), get_nonce_expires(), get_nonce_index(), _str::len, LM_DBG, NONCE_LEN, nonce_reuse, _str::s, and ZSW.

Referenced by pre_auth().

static time_t get_nonce_expires ( str _n  )  [inline, static]

Get expiry time from nonce string.

Parameters:
_n nonce string
Returns:
expiry time

Definition at line 151 of file nonce.c.

References hex2integer(), and _str::s.

Referenced by check_nonce(), and is_nonce_stale().

int get_nonce_index ( str _n  ) 

Get index from nonce string.

Parameters:
_n nonce string
Returns:
nonce index

Definition at line 140 of file nonce.c.

References hex2integer(), and _str::s.

Referenced by check_nonce(), and post_auth().

static int hex2integer ( char *  _s  )  [inline, static]

Convert hex string to integer.

Parameters:
_s hex string
Returns:
integer value, can be 0

Definition at line 81 of file nonce.c.

Referenced by get_nonce_expires(), and get_nonce_index().

static void integer2hex ( char *  _d,
int  _s 
) [inline, static]

Convert an integer to its hex representation, destination array must be at least 8 bytes long, this string is NOT zero terminated

Definition at line 48 of file nonce.c.

References s.

Referenced by calc_nonce().

int is_nonce_stale ( str _n  ) 

Check if a nonce is stale.

Parameters:
_n nonce string
Returns:
1 if the nonce is stale, 0 otherwise

Definition at line 199 of file nonce.c.

References get_nonce_expires(), and _str::s.

Referenced by post_auth().


Generated on Wed May 23 20:00:41 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6