Changeset 1bdc669 for protocols/jabber
- Timestamp:
- 2023-02-23T23:48:10Z (22 months ago)
- 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)
- Location:
- protocols/jabber
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/jabber.c
r7342cae r1bdc669 33 33 #include "jabber.h" 34 34 #include "oauth.h" 35 #include "md5.h"36 35 37 36 GSList *jabber_connections; … … 301 300 } 302 301 303 /* This generates an unfinished md5_state_tvariable. Every time we generate302 /* This generates an unfinished g_checksum variable. Every time we generate 304 303 an ID, we finish the state by adding a sequence number and take the hash. */ 305 304 static void jabber_generate_id_hash(struct jabber_data *jd) 306 305 { 307 md5_byte_tbinbuf[4];306 guint8 binbuf[4]; 308 307 char *s; 309 308 310 md5_init(&jd->cached_id_prefix);311 md5_append(&jd->cached_id_prefix, (unsigned char *)jd->username, strlen(jd->username));312 md5_append(&jd->cached_id_prefix, (unsigned char *)jd->server, strlen(jd->server));309 jd->cached_id_prefix = g_checksum_new(G_CHECKSUM_MD5); 310 g_checksum_update(jd->cached_id_prefix, jd->username, strlen(jd->username)); 311 g_checksum_update(jd->cached_id_prefix, jd->server, strlen(jd->server)); 313 312 s = set_getstr(&jd->ic->acc->set, "resource"); 314 md5_append(&jd->cached_id_prefix, (unsigned char *)s, strlen(s));313 g_checksum_update(jd->cached_id_prefix, s, strlen(s)); 315 314 random_bytes(binbuf, 4); 316 md5_append(&jd->cached_id_prefix, binbuf, 4);315 g_checksum_update(jd->cached_id_prefix, binbuf, 4); 317 316 } 318 317 … … 371 370 xt_free(jd->xt); 372 371 373 md5_free(&jd->cached_id_prefix);372 g_checksum_free(jd->cached_id_prefix); 374 373 375 374 g_free(jd->oauth2_access_token); -
protocols/jabber/jabber.h
r7342cae r1bdc669 28 28 29 29 #include "bitlbee.h" 30 #include "md5.h"31 30 #include "xmltree.h" 32 31 … … 105 104 char *gmail_tid; 106 105 107 md5_state_tcached_id_prefix;106 GChecksum *cached_id_prefix; 108 107 GHashTable *node_cache; 109 108 GHashTable *buddies; -
protocols/jabber/jabber_util.c
r7342cae r1bdc669 23 23 24 24 #include "jabber.h" 25 #include "md5.h"26 25 #include "base64.h" 27 26 … … 141 140 struct jabber_data *jd = ic->proto_data; 142 141 struct jabber_cache_entry *entry = g_new0(struct jabber_cache_entry, 1); 143 md5_state_t id_hash; 144 md5_byte_t id_sum[16]; 142 GChecksum *id_hash; 143 gsize digest_len = MD5_HASH_SIZE; 144 guint8 id_sum[MD5_HASH_SIZE]; 145 145 char *id, *asc_hash; 146 146 … … 148 148 149 149 id_hash = jd->cached_id_prefix; 150 md5_append(&id_hash, (md5_byte_t *) &next_id, sizeof(next_id)); 151 md5_digest_keep(&id_hash, id_sum); 150 g_checksum_update(id_hash, (guint8 *) &next_id, sizeof(next_id)); 151 g_checksum_get_digest(id_hash, id_sum, &digest_len); 152 g_checksum_free(id_hash); 153 152 154 asc_hash = base64_encode(id_sum, 12); 153 155 -
protocols/jabber/sasl.c
r7342cae r1bdc669 302 302 if (!(s = sasl_get_part(dec, "rspauth"))) { 303 303 /* See RFC 2831 for for information. */ 304 md5_state_t A1, A2, H; 305 md5_byte_t A1r[16], A2r[16], Hr[16]; 304 GChecksum *A1, *A2, *H; 305 gsize digest_len = MD5_HASH_SIZE; 306 guint8 A1r[16], A2r[16], Hr[16]; 306 307 char A1h[33], A2h[33], Hh[33]; 307 308 int i; … … 327 328 /* Generate the MD5 hash of username:realm:password, 328 329 I decided to call it H. */ 329 md5_init(&H);330 H = g_checksum_new(G_CHECKSUM_MD5); 330 331 s = g_strdup_printf("%s:%s:%s", jd->username, realm, ic->acc->pass); 331 md5_append(&H, (unsigned char *)s, strlen(s));332 g_checksum_update(H, (guint8 *)s, strlen(s)); 332 333 g_free(s); 333 md5_finish(&H, Hr); 334 335 g_checksum_get_digest(H, Hr, &digest_len); 336 g_checksum_free(H); 334 337 335 338 /* Now generate the hex. MD5 hash of H:nonce:cnonce, called A1. */ 336 md5_init(&A1);339 A1 = g_checksum_new(G_CHECKSUM_MD5); 337 340 s = g_strdup_printf(":%s:%s", nonce, cnonce); 338 md5_append(&A1, Hr, 16);339 md5_append(&A1, (unsigned char *)s, strlen(s));341 g_checksum_update(A1, Hr, 16); 342 g_checksum_update(A1, (guint8 *)s, strlen(s)); 340 343 g_free(s); 341 md5_finish(&A1, A1r); 344 g_checksum_get_digest(A1, A1r, &digest_len); 345 g_checksum_free(A1); 342 346 for (i = 0; i < 16; i++) { 343 347 sprintf(A1h + i * 2, "%02x", A1r[i]); … … 345 349 346 350 /* A2... */ 347 md5_init(&A2);351 A2 = g_checksum_new(G_CHECKSUM_MD5); 348 352 s = g_strdup_printf("%s:%s", "AUTHENTICATE", digest_uri); 349 md5_append(&A2, (unsigned char *)s, strlen(s));353 g_checksum_update(A2, (guint8 *)s, strlen(s)); 350 354 g_free(s); 351 md5_finish(&A2, A2r); 355 g_checksum_get_digest(A2, A2r, &digest_len); 356 g_checksum_free(A2); 352 357 for (i = 0; i < 16; i++) { 353 358 sprintf(A2h + i * 2, "%02x", A2r[i]); … … 355 360 356 361 /* Final result: A1:nonce:00000001:cnonce:auth:A2. Let's reuse H for it. */ 357 md5_init(&H);362 H = g_checksum_new(G_CHECKSUM_MD5); 358 363 s = g_strdup_printf("%s:%s:%s:%s:%s:%s", A1h, nonce, "00000001", cnonce, "auth", A2h); 359 md5_append(&H, (unsigned char *)s, strlen(s));364 g_checksum_update(H, (guint8 *)s, strlen(s)); 360 365 g_free(s); 361 md5_finish(&H, Hr); 366 g_checksum_get_digest(H, Hr, &digest_len); 367 g_checksum_free(H); 368 362 369 for (i = 0; i < 16; i++) { 363 370 sprintf(Hh + i * 2, "%02x", Hr[i]);
Note: See TracChangeset
for help on using the changeset viewer.