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

## 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

  ctx | a Strophe context object
  data | buffer for digest computation
  len | size 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

  data | buffer for digest computation
  len | size of the data buffer
  digest | output 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);
xmpp_sha1_final(sha1);
char *digest = xmpp_sha1_to_string_alloc(sha1);
xmpp_sha1_free(sha1);
xmpp_sha1_new
xmpp_sha1_t * xmpp_sha1_new(xmpp_ctx_t *ctx)
Create new SHA1 object.
Definition crypto.c:120
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.
Definition crypto.c:153
xmpp_sha1_free
void xmpp_sha1_free(xmpp_sha1_t *sha1)
Destroy SHA1 object.
Definition crypto.c:139
xmpp_sha1_final
void xmpp_sha1_final(xmpp_sha1_t *sha1)
Finish SHA1 computation.
Definition crypto.c:166
xmpp_sha1_to_string_alloc
char * xmpp_sha1_to_string_alloc(xmpp_sha1_t *sha1)
Return message digest rendered as a string.
Definition crypto.c:199

Parameters

  ctx | a Strophe context object

Returns
  new SHA1 object

## ◆ xmpp_sha1_free()

void xmpp_sha1_free | ( | xmpp_sha1_t * | sha1 | ) |

Destroy SHA1 object.

Parameters

  sha1 | a 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

  sha1 | a SHA1 object
  data | pointer to a buffer to be hashed
  len | size 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

  sha1 | a 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

  sha1 | a SHA1 object
  s | output string
  slen | size 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 using the Strophe context which is passed to xmpp_sha1_new(). Call this function after xmpp_sha1_final().

Parameters

  sha1 | a 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

  sha1 | a SHA1 object
  digest | output buffer of XMPP_SHA1_DIGEST_SIZE bytes