summaryrefslogtreecommitdiff
path: root/libsoup/soup-auth-digest.c
diff options
context:
space:
mode:
authorDan Winship <danw@src.gnome.org>2005-08-01 14:48:22 +0000
committerDan Winship <danw@src.gnome.org>2005-08-01 14:48:22 +0000
commitd5221a3d40ed2e16ed687075cf8a309d0ec59601 (patch)
treeae5d45f9b3493f7c34d666e4c508f55c342b963d /libsoup/soup-auth-digest.c
parent80e5930c51e9a0ca4405d1143e36e705960c0b9c (diff)
downloadlibsoup-d5221a3d40ed2e16ed687075cf8a309d0ec59601.tar.gz
Finalize a SoupMD5Context and write out the digest in hex digits.
* libsoup/soup-md5-utils.c (soup_md5_final_hex): Finalize a SoupMD5Context and write out the digest in hex digits. * libsoup/soup-auth-digest.c (authenticate, compute_response): * libsoup/soup-server-auth.c (check_digest_passwd): Use that, rather than duplicating the code in both places here. Patch from Wim Lewis.
Diffstat (limited to 'libsoup/soup-auth-digest.c')
-rw-r--r--libsoup/soup-auth-digest.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/libsoup/soup-auth-digest.c b/libsoup/soup-auth-digest.c
index 0397a280..593ce278 100644
--- a/libsoup/soup-auth-digest.c
+++ b/libsoup/soup-auth-digest.c
@@ -243,16 +243,6 @@ get_realm (SoupAuth *auth)
}
static void
-digest_hex (guchar *digest, guchar hex[33])
-{
- guchar *s, *p;
-
- /* lowercase hexify that bad-boy... */
- for (s = digest, p = hex; p < hex + 32; s++, p += 2)
- sprintf (p, "%.2x", *s);
-}
-
-static void
authenticate (SoupAuth *auth, const char *username, const char *password)
{
SoupAuthDigestPrivate *priv = SOUP_AUTH_DIGEST_GET_PRIVATE (auth);
@@ -300,8 +290,7 @@ authenticate (SoupAuth *auth, const char *username, const char *password)
}
/* hexify A1 */
- soup_md5_final (&ctx, d);
- digest_hex (d, priv->hex_a1);
+ soup_md5_final_hex (&ctx, priv->hex_a1);
}
static gboolean
@@ -314,7 +303,6 @@ static char *
compute_response (SoupAuthDigestPrivate *priv, SoupMessage *msg)
{
guchar hex_a2[33], o[33];
- guchar d[16];
SoupMD5Context md5;
char *url;
const SoupUri *uri;
@@ -338,8 +326,7 @@ compute_response (SoupAuthDigestPrivate *priv, SoupMessage *msg)
}
/* now hexify A2 */
- soup_md5_final (&md5, d);
- digest_hex (d, hex_a2);
+ soup_md5_final_hex (&md5, hex_a2);
/* compute KD */
soup_md5_init (&md5);
@@ -373,9 +360,7 @@ compute_response (SoupAuthDigestPrivate *priv, SoupMessage *msg)
}
soup_md5_update (&md5, hex_a2, 32);
- soup_md5_final (&md5, d);
-
- digest_hex (d, o);
+ soup_md5_final_hex (&md5, o);
return g_strdup (o);
}