Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deprecate sha1_* functions #172

Merged
merged 2 commits into from
Apr 1, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Mark sha1.h functions as deprecated
  • Loading branch information
jelmer committed Feb 3, 2023
commit fde781d2e9b8a54ea50ec5a8f54afe34fbc81e33
5 changes: 4 additions & 1 deletion lib/sha1.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,11 @@ char *sha1_random_uuid(sha1_state_t * context)
guint8 dig[SHA1_HASH_SIZE];
char *ret = g_new0(char, 40); /* 36 chars + \0 */
int i, p;
gsize digest_len = SHA1_HASH_SIZE;

g_checksum_get_digest(*context, dig, &digest_len);
g_checksum_free(*context);

sha1_finish(context, dig);
for (p = i = 0; i < 16; i++) {
if (i == 4 || i == 6 || i == 8 || i == 10) {
ret[p++] = '-';
Expand Down
14 changes: 10 additions & 4 deletions lib/sha1.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@
#include <glib.h>
#include <gmodule.h>

#ifdef __GNUC__
#define __SHA1_NON_PUBLIC_DEPRECATION__ __attribute__((deprecated("sha1.h will be removed from Bitlbee's public API. Please use another library (such as GLib's gchecksum) instead")))
#else
#define __SHA1_NON_PUBLIC_DEPRECATION__
#endif

#define SHA1_HASH_SIZE 20

typedef GChecksum *sha1_state_t;

void sha1_init(sha1_state_t *);
void sha1_append(sha1_state_t *, const guint8 *, unsigned int);
void sha1_finish(sha1_state_t *, guint8 digest[SHA1_HASH_SIZE]);
void sha1_hmac(const char *, size_t, const char *, size_t, guint8 digest[SHA1_HASH_SIZE]);
void sha1_init(sha1_state_t *) __SHA1_NON_PUBLIC_DEPRECATION__;
void sha1_append(sha1_state_t *, const guint8 *, unsigned int) __SHA1_NON_PUBLIC_DEPRECATION__;
void sha1_finish(sha1_state_t *, guint8 digest[SHA1_HASH_SIZE]) __SHA1_NON_PUBLIC_DEPRECATION__;
void sha1_hmac(const char *, size_t, const char *, size_t, guint8 digest[SHA1_HASH_SIZE]) ;
char *sha1_random_uuid(sha1_state_t *);

#endif