Strophe 0.12
XMPP client library
Functions
Message digests

Functions

char * xmpp_sha1 (xmpp_ctx_t *ctx, const unsigned char *data, size_t len)
 Compute SHA1 message digest. More...
 
void xmpp_sha1_digest (const unsigned char *data, size_t len, unsigned char *digest)
 Compute SHA1 message digest. More...
 
xmpp_sha1_t * xmpp_sha1_new (xmpp_ctx_t *ctx)
 Create new SHA1 object. More...
 
void xmpp_sha1_free (xmpp_sha1_t *sha1)
 Destroy SHA1 object. More...
 
void xmpp_sha1_update (xmpp_sha1_t *sha1, const unsigned char *data, size_t len)
 Update SHA1 context with the next portion of data. More...
 
void xmpp_sha1_final (xmpp_sha1_t *sha1)
 Finish SHA1 computation. More...
 
char * xmpp_sha1_to_string (xmpp_sha1_t *sha1, char *s, size_t slen)
 Return message digest rendered as a string. More...
 
char * xmpp_sha1_to_string_alloc (xmpp_sha1_t *sha1)
 Return message digest rendered as a string. More...
 
void xmpp_sha1_to_digest (xmpp_sha1_t *sha1, unsigned char *digest)
 Stores message digest to a user's buffer. More...
 

Detailed Description

Function Documentation

◆ xmpp_sha1()

char * xmpp_sha1 ( xmpp_ctx_t *  ctx,
const unsigned char *  data,
size_t  len 
)

Compute SHA1 message digest.

Returns an allocated string which represents SHA1 message digest in hexadecimal notation. The string must be freed with xmpp_free().

Parameters
ctxa Strophe context object
databuffer for digest computation
lensize of the data buffer
Returns
an allocated string or NULL on allocation error

◆ xmpp_sha1_digest()

void xmpp_sha1_digest ( const unsigned char *  data,
size_t  len,
unsigned char *  digest 
)

Compute SHA1 message digest.

Stores digest in user's buffer which must be at least XMPP_SHA1_DIGEST_SIZE bytes long.

Parameters
databuffer for digest computation
lensize of the data buffer
digestoutput buffer of XMPP_SHA1_DIGEST_SIZE bytes

◆ xmpp_sha1_new()

xmpp_sha1_t * xmpp_sha1_new ( xmpp_ctx_t *  ctx)

Create new SHA1 object.

SHA1 object is used to compute SHA1 digest of a buffer that is split in multiple chunks or provided in stream mode. A single buffer can be processed by short functions xmpp_sha1() and xmpp_sha1_digest(). Follow the next use-case for xmpp_sha1_t object:

xmpp_sha1_t *sha1 = xmpp_sha1_new(ctx);
// Repeat update for all chunks of data
xmpp_sha1_update(sha1, data, len);
char *digest = xmpp_sha1_to_string_alloc(sha1);
xmpp_sha1_t * xmpp_sha1_new(xmpp_ctx_t *ctx)
Create new SHA1 object.
Definition: crypto.c:121
void xmpp_sha1_update(xmpp_sha1_t *sha1, const unsigned char *data, size_t len)
Update SHA1 context with the next portion of data.
Definition: crypto.c:154
void xmpp_sha1_free(xmpp_sha1_t *sha1)
Destroy SHA1 object.
Definition: crypto.c:140
void xmpp_sha1_final(xmpp_sha1_t *sha1)
Finish SHA1 computation.
Definition: crypto.c:167
char * xmpp_sha1_to_string_alloc(xmpp_sha1_t *sha1)
Return message digest rendered as a string.
Definition: crypto.c:200
Parameters
ctxa Strophe context object
Returns
new SHA1 object

◆ xmpp_sha1_free()

void xmpp_sha1_free ( xmpp_sha1_t *  sha1)

Destroy SHA1 object.

Parameters
sha1a SHA1 object

◆ xmpp_sha1_update()

void xmpp_sha1_update ( xmpp_sha1_t *  sha1,
const unsigned char *  data,
size_t  len 
)

Update SHA1 context with the next portion of data.

Can be called repeatedly.

Parameters
sha1a SHA1 object
datapointer to a buffer to be hashed
lensize of the data buffer

◆ xmpp_sha1_final()

void xmpp_sha1_final ( xmpp_sha1_t *  sha1)

Finish SHA1 computation.

Don't call xmpp_sha1_update() after this function. Retrieve resulting message digest with xmpp_sha1_to_string() or xmpp_sha1_to_digest().

Parameters
sha1a SHA1 object

◆ xmpp_sha1_to_string()

char * xmpp_sha1_to_string ( xmpp_sha1_t *  sha1,
char *  s,
size_t  slen 
)

Return message digest rendered as a string.

Stores the string to a user's buffer and returns the buffer. Call this function after xmpp_sha1_final().

Parameters
sha1a SHA1 object
soutput string
slensize reserved for the string including '\0'
Returns
pointer s or NULL if resulting string is bigger than slen bytes

◆ xmpp_sha1_to_string_alloc()

char * xmpp_sha1_to_string_alloc ( xmpp_sha1_t *  sha1)

Return message digest rendered as a string.

Returns an allocated string. Free the string by calling xmpp_free() using the Strophe context which is passed to xmpp_sha1_new(). Call this function after xmpp_sha1_final().

Parameters
sha1a SHA1 object
Returns
an allocated string

◆ xmpp_sha1_to_digest()

void xmpp_sha1_to_digest ( xmpp_sha1_t *  sha1,
unsigned char *  digest 
)

Stores message digest to a user's buffer.

Parameters
sha1a SHA1 object
digestoutput buffer of XMPP_SHA1_DIGEST_SIZE bytes