Strophe: Message digests

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 Returns an allocated string which represents SHA1 message digest in hexadecimal notation. 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 Can be called repeatedly. More...
void | xmpp_sha1_final (xmpp_sha1_t *sha1)
| Finish SHA1 computation Don't call xmpp_sha1_update() after this function. More...
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. More...
char * | xmpp_sha1_to_string_alloc (xmpp_sha1_t *sha1)
| Return message digest rendered as a string Returns an allocated 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

  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_new()

xmpp_sha1_t* xmpp_sha1_new | ( | xmpp_ctx_t * | ctx | ) |

Create new SHA1 object.

Parameters

  ctx | a Strophe context onject

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