Strophe  0.8
XMPP client library
Functions | Variables
sasl.c File Reference

SASL authentication. More...

Functions

char * sasl_plain (xmpp_ctx_t *ctx, const char *authid, const char *password)
 generate authentication string for the SASL PLAIN mechanism
static char * _make_string (xmpp_ctx_t *ctx, const char *s, const unsigned len)
 helpers for digest auth
static char * _make_quoted (xmpp_ctx_t *ctx, const char *s)
static hash_t * _parse_digest_challenge (xmpp_ctx_t *ctx, const char *msg)
static void _digest_to_hex (const char *digest, char *hex)
 expand a 16 byte MD5 digest to a 32 byte hex representation
static char * _add_key (xmpp_ctx_t *ctx, hash_t *table, const char *key, char *buf, int *len, int quote)
 append 'key="value"' to a buffer, growing as necessary
char * sasl_digest_md5 (xmpp_ctx_t *ctx, const char *challenge, const char *jid, const char *password)
 generate auth response string for the SASL DIGEST-MD5 mechanism
int base64_encoded_len (xmpp_ctx_t *ctx, const unsigned len)
 Base64 encoding routines.
char * base64_encode (xmpp_ctx_t *ctx, const unsigned char *const buffer, const unsigned len)
int base64_decoded_len (xmpp_ctx_t *ctx, const char *const buffer, const unsigned len)
unsigned char * base64_decode (xmpp_ctx_t *ctx, const char *const buffer, const unsigned len)

Variables

static const char _base64_invcharmap [256]
 Base64 encoding routines.
static const char _base64_charmap [65]
 map of all 6-bit values to their corresponding byte in the base64 alphabet.

Detailed Description

SASL authentication.


Function Documentation

char* sasl_plain ( xmpp_ctx_t *  ctx,
const char *  authid,
const char *  password 
)

generate authentication string for the SASL PLAIN mechanism

low-level sasl routines

static char* _make_string ( xmpp_ctx_t *  ctx,
const char *  s,
const unsigned  len 
) [static]

helpers for digest auth

static char* _make_quoted ( xmpp_ctx_t *  ctx,
const char *  s 
) [static]
static hash_t* _parse_digest_challenge ( xmpp_ctx_t *  ctx,
const char *  msg 
) [static]
static void _digest_to_hex ( const char *  digest,
char *  hex 
) [static]

expand a 16 byte MD5 digest to a 32 byte hex representation

static char* _add_key ( xmpp_ctx_t *  ctx,
hash_t *  table,
const char *  key,
char *  buf,
int *  len,
int  quote 
) [static]

append 'key="value"' to a buffer, growing as necessary

char* sasl_digest_md5 ( xmpp_ctx_t *  ctx,
const char *  challenge,
const char *  jid,
const char *  password 
)

generate auth response string for the SASL DIGEST-MD5 mechanism

int base64_encoded_len ( xmpp_ctx_t *  ctx,
const unsigned  len 
)

Base64 encoding routines.

Implemented according to RFC 3548

char* base64_encode ( xmpp_ctx_t *  ctx,
const unsigned char *const  buffer,
const unsigned  len 
)
int base64_decoded_len ( xmpp_ctx_t *  ctx,
const char *const  buffer,
const unsigned  len 
)
unsigned char* base64_decode ( xmpp_ctx_t *  ctx,
const char *const  buffer,
const unsigned  len 
)

Variable Documentation

const char _base64_invcharmap[256] [static]
Initial value:
 {
    65,65,65,65, 65,65,65,65, 65,65,65,65, 65,65,65,65,
    65,65,65,65, 65,65,65,65, 65,65,65,65, 65,65,65,65,
    65,65,65,65, 65,65,65,65, 65,65,65,62, 65,65,65,63,
    52,53,54,55, 56,57,58,59, 60,61,65,65, 65,64,65,65,
    65, 0, 1, 2,  3, 4, 5, 6,  7, 8, 9,10, 11,12,13,14,
    15,16,17,18, 19,20,21,22, 23,24,25,65, 65,65,65,65,
    65,26,27,28, 29,30,31,32, 33,34,35,36, 37,38,39,40,
    41,42,43,44, 45,46,47,48, 49,50,51,65, 65,65,65,65,
    65,65,65,65, 65,65,65,65, 65,65,65,65, 65,65,65,65,
    65,65,65,65, 65,65,65,65, 65,65,65,65, 65,65,65,65,
    65,65,65,65, 65,65,65,65, 65,65,65,65, 65,65,65,65,
    65,65,65,65, 65,65,65,65, 65,65,65,65, 65,65,65,65,
    65,65,65,65, 65,65,65,65, 65,65,65,65, 65,65,65,65,
    65,65,65,65, 65,65,65,65, 65,65,65,65, 65,65,65,65,
    65,65,65,65, 65,65,65,65, 65,65,65,65, 65,65,65,65,
    65,65,65,65, 65,65,65,65, 65,65,65,65, 65,65,65,65 
}

Base64 encoding routines.

Implemented according to RFC 3548 map of all byte values to the base64 values, or to '65' which indicates an invalid character. '=' is '64'

const char _base64_charmap[65] [static]
Initial value:
 {
    'A','B','C','D', 'E','F','G','H',
    'I','J','K','L', 'M','N','O','P',
    'Q','R','S','T', 'U','V','W','X',
    'Y','Z','a','b', 'c','d','e','f',
    'g','h','i','j', 'k','l','m','n',
    'o','p','q','r', 's','t','u','v',
    'w','x','y','z', '0','1','2','3',
    '4','5','6','7', '8','9','+','/',
    '='
}

map of all 6-bit values to their corresponding byte in the base64 alphabet.

Padding char is the value '64'