aboutsummaryrefslogtreecommitdiffstats
path: root/camel/camel-sasl-cram-md5.c
diff options
context:
space:
mode:
authorJeffrey Stedfast <fejj@ximian.com>2001-03-07 05:34:56 +0800
committerJeffrey Stedfast <fejj@src.gnome.org>2001-03-07 05:34:56 +0800
commit5f97f6226b42d0faf16c3d4ca551c8050f700079 (patch)
tree37b2c9a5a5de73675fb018a9afe98c16cb890690 /camel/camel-sasl-cram-md5.c
parent789ed9286edc7f4455ce5fe87dfe7e33a841c5e7 (diff)
downloadgsoc2013-evolution-5f97f6226b42d0faf16c3d4ca551c8050f700079.tar.gz
gsoc2013-evolution-5f97f6226b42d0faf16c3d4ca551c8050f700079.tar.zst
gsoc2013-evolution-5f97f6226b42d0faf16c3d4ca551c8050f700079.zip
Redone so as to save on memory allocations and speed.
2001-03-06 Jeffrey Stedfast <fejj@ximian.com> * camel-sasl-digest-md5.c (compute_response): Redone so as to save on memory allocations and speed. svn path=/trunk/; revision=8573
Diffstat (limited to 'camel/camel-sasl-cram-md5.c')
-rw-r--r--camel/camel-sasl-cram-md5.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/camel/camel-sasl-cram-md5.c b/camel/camel-sasl-cram-md5.c
index 458517c5d5..d456615f2d 100644
--- a/camel/camel-sasl-cram-md5.c
+++ b/camel/camel-sasl-cram-md5.c
@@ -89,16 +89,16 @@ cram_md5_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex)
guchar opad[64];
MD5Context ctx;
int i, pw_len;
-
+
/* Need to wait for the server */
if (!token)
return NULL;
-
+
g_return_val_if_fail (sasl->service->url->passwd != NULL, NULL);
-
+
memset (ipad, 0, sizeof (ipad));
memset (opad, 0, sizeof (opad));
-
+
passwd = sasl->service->url->passwd;
pw_len = strlen (passwd);
if (pw_len <= 64) {
@@ -108,31 +108,31 @@ cram_md5_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex)
md5_get_digest (passwd, pw_len, ipad);
memcpy (opad, ipad, 16);
}
-
+
for (i = 0; i < 64; i++) {
ipad[i] ^= 0x36;
opad[i] ^= 0x5c;
}
-
+
md5_init (&ctx);
md5_update (&ctx, ipad, 64);
md5_update (&ctx, token->data, token->len);
md5_final (&ctx, digest);
-
+
md5_init (&ctx);
md5_update (&ctx, opad, 64);
md5_update (&ctx, digest, 16);
md5_final (&ctx, digest);
-
+
/* lowercase hexify that bad-boy... */
for (s = digest, p = md5asc; p < md5asc + 32; s++, p += 2)
sprintf (p, "%.2x", *s);
-
+
ret = g_byte_array_new ();
g_byte_array_append (ret, sasl->service->url->user, strlen (sasl->service->url->user));
g_byte_array_append (ret, " ", 1);
g_byte_array_append (ret, md5asc, 32);
-
+
sasl->authenticated = TRUE;
return ret;