Changeset 1bdc669 for protocols/jabber/sasl.c
- Timestamp:
- 2023-02-23T23:48:10Z (21 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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.