source: lib/sha1.h @ 782a6ee

Last change on this file since 782a6ee was 34afea7, checked in by dequis <dx@…>, at 2015-01-31T23:58:57Z

Use glib's GChecksum for md5/sha1

This changes behavior slightly:

  • md5_init()/sha1_init() allocate a GChecksum
  • md5_finish()/sha1_finish() close and free() it
  • md5_digest_keep() was added (no sha1 equivalent needed)

And yes, glib has this concept of "closing" the GChecksum, which means
it can't be used anymore after g_checksum_get_digest().

jabber_cache_add() actually seems to need to do that to generate some
random-ish values, so i kept that working by adding a md5_digest_keep()
function that copies the GChecksum before it gets closed

GChecksum was introduced in glib 2.16, so the configure script version
was bumped. We were already depending on glib 2.16 accidentally
(some post-3.2.2 code uses GHashTableIter)

  • Property mode set to 100644
File size: 437 bytes
RevLine 
[77bfd07]1
2#ifndef _SHA1_H_
3#define _SHA1_H_
4
[34afea7]5#include <glib.h>
[77bfd07]6#include <gmodule.h>
7
[34afea7]8#define SHA1_HASH_SIZE 20
[77bfd07]9
[34afea7]10typedef GChecksum *sha1_state_t;
[77bfd07]11
[34afea7]12void sha1_init(sha1_state_t *);
13void sha1_append(sha1_state_t *, const guint8 *, unsigned int);
14void sha1_finish(sha1_state_t *, guint8 digest[SHA1_HASH_SIZE]);
15void sha1_hmac(const char *, size_t, const char *, size_t, guint8 digest[SHA1_HASH_SIZE]);
16char *sha1_random_uuid(sha1_state_t *);
[77bfd07]17
18#endif
Note: See TracBrowser for help on using the repository browser.