Changeset 1bdc669 for lib


Ignore:
Timestamp:
2023-02-23T23:48:10Z (21 months ago)
Author:
GitHub <noreply@…>
Branches:
master
Children:
93d4d8f
Parents:
7342cae
git-author:
Jelmer Vernooij <jelmer@…> (23-02-23 23:48:10)
git-committer:
GitHub <noreply@…> (23-02-23 23:48:10)
Message:

Migrate internal users of md5.h to using GChecksum directly (#169)

  • Use GChecksum directly rather than md5 wrapper
  • Mark md5 functions as deprecated.
  • Migrate more users of md5.h to GChecksum
Location:
lib
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • lib/md5.c

    r7342cae r1bdc669  
    2828void md5_digest_keep(md5_state_t *ctx, guint8 digest[MD5_HASH_SIZE])
    2929{
    30         md5_state_t copy = g_checksum_copy(*ctx);
     30        gsize digest_len = MD5_HASH_SIZE;
     31        GChecksum *copy = g_checksum_copy(*ctx);
    3132
    32         md5_finish(&copy, digest);
     33        g_checksum_get_digest(copy, digest, &digest_len);
     34        g_checksum_free(copy);
    3335}
    3436
  • lib/md5.h

    r7342cae r1bdc669  
    88typedef GChecksum *md5_state_t;
    99
    10 
    1110#define MD5_HASH_SIZE 16
    1211
    13 void md5_init(md5_state_t *);
    14 void md5_append(md5_state_t *, const guint8 *, unsigned int);
    15 void md5_finish(md5_state_t *, guint8 digest[MD5_HASH_SIZE]);
    16 void md5_digest_keep(md5_state_t *, guint8 digest[MD5_HASH_SIZE]);
    17 void md5_free(md5_state_t *);
     12#ifdef __GNUC__
     13#define __MD5_NON_PUBLIC_DEPRECATION__ __attribute__((deprecated("md5.h will be removed from Bitlbee's public API. Please use another library (such as GLib's gchecksum) instead")))
     14#else
     15#define __MD5_NON_PUBLIC_DEPRECATION__
     16#endif
     17
     18void md5_init(md5_state_t *) __MD5_NON_PUBLIC_DEPRECATION__;
     19void md5_append(md5_state_t *, const guint8 *, unsigned int) __MD5_NON_PUBLIC_DEPRECATION__;
     20void md5_finish(md5_state_t *, guint8 digest[MD5_HASH_SIZE]) __MD5_NON_PUBLIC_DEPRECATION__;
     21void md5_digest_keep(md5_state_t *, guint8 digest[MD5_HASH_SIZE]) __MD5_NON_PUBLIC_DEPRECATION__;
     22void md5_free(md5_state_t *) __MD5_NON_PUBLIC_DEPRECATION__;
    1823
    1924#endif
  • lib/misc.c

    r7342cae r1bdc669  
    3434#include "nogaim.h"
    3535#include "base64.h"
    36 #include "md5.h"
    3736#include <stdio.h>
    3837#include <stdlib.h>
     
    4746#endif
    4847
    49 #include "md5.h"
    5048#include "ssl_client.h"
    5149
     
    576574int md5_verify_password(char *password, char *hash)
    577575{
    578         md5_byte_t *pass_dec = NULL;
    579         md5_byte_t pass_md5[16];
    580         md5_state_t md5_state;
     576        guint8 *pass_dec = NULL;
     577        guint8 pass_md5[16];
     578        GChecksum *md5_state;
     579        gsize digest_len = MD5_HASH_SIZE;
    581580        int ret = -1, i;
    582581
    583582        if (base64_decode(hash, &pass_dec) == 21) {
    584                 md5_init(&md5_state);
    585                 md5_append(&md5_state, (md5_byte_t *) password, strlen(password));
    586                 md5_append(&md5_state, (md5_byte_t *) pass_dec + 16, 5);  /* Hmmm, salt! */
    587                 md5_finish(&md5_state, pass_md5);
     583                md5_state = g_checksum_new(G_CHECKSUM_MD5);
     584                g_checksum_update(md5_state, (guint8 *) password, strlen(password));
     585                g_checksum_update(md5_state, (guint8 *) pass_dec + 16, 5);  /* Hmmm, salt! */
     586                g_checksum_get_digest(md5_state, pass_md5, &digest_len);
     587                g_checksum_free(md5_state);
    588588
    589589                for (i = 0; i < 16; i++) {
Note: See TracChangeset for help on using the changeset viewer.