Index: libtinymail-camel/camel-lite/camel/providers/nntp/camel-nntp-store-summary.c
===================================================================
--- libtinymail-camel/camel-lite/camel/providers/nntp/camel-nntp-store-summary.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/providers/nntp/camel-nntp-store-summary.c	(working copy)
@@ -29,7 +29,6 @@
 #include <string.h>
 #include <unistd.h>
 
-#include <libedataserver/md5-utils.h>
 #include <libedataserver/e-memory.h>
 
 #include "camel-file-utils.h"
Index: libtinymail-camel/camel-lite/camel/providers/nntp/camel-nntp-utils.c
===================================================================
--- libtinymail-camel/camel-lite/camel/providers/nntp/camel-nntp-utils.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/providers/nntp/camel-nntp-utils.c	(working copy)
@@ -24,8 +24,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <libedataserver/md5-utils.h>
-
 #include "camel-folder-summary.h"
 #include "camel-stream-mem.h"
 #include "camel-exception.h"
@@ -41,8 +39,12 @@
 {
 	int status;
 	CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
-	char digest[16];
+	guint8 *digest;
+	gsize length;
 
+	length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+	digest = g_alloca (length);
+
 	status = camel_nntp_command (nntp_store, ex, NULL,
 				     "XOVER %d-%d",
 				     first_message,
@@ -65,6 +67,7 @@
 			}
 			else {
 				CamelMessageInfo *new_info = camel_folder_summary_info_new(folder->summary);
+				GChecksum *checksum;
 				char **split_line = g_strsplit (line, "\t", 7);
 				char *subject, *from, *date, *message_id, *bytes;
 				char *uid;
@@ -101,7 +104,10 @@
 				new_info->headers.date_received = g_strdup(date);
 #endif
 				new_info->size = atoi(bytes);
-				md5_get_digest(message_id, strlen(message_id), digest);
+				checksum = g_checksum_new (G_CHECKSUM_MD5);
+				g_checksum_update (checksum, (guchar *) message_id, strlen (message_id));
+				g_checksum_get_digest (checksum, digest, &length);
+				g_checksum_free (checksum);
 				memcpy(new_info->message_id.id.hash, digest, sizeof(new_info->message_id.id.hash));
 
 				if (camel_nntp_newsrc_article_is_read (nntp_store->newsrc,
Index: libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-folder.c
===================================================================
--- libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-folder.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-folder.c	(working copy)
@@ -46,8 +46,6 @@
 
 #include <glib/gi18n-lib.h>
 
-#include <libedataserver/md5-utils.h>
-
 #include "camel-data-cache.h"
 #include "camel-exception.h"
 #include "camel-mime-message.h"
@@ -163,17 +161,21 @@
 static int
 cmd_builduid(CamelPOP3Engine *pe, CamelPOP3Stream *stream, void *data)
 {
+	GChecksum *checksum;
 	CamelPOP3FolderInfo *fi = data;
-	MD5Context md5;
-	unsigned char digest[16];
 	struct _camel_header_raw *h;
 	CamelMimeParser *mp;
+	guint8 *digest;
+	gsize length;
 
+	length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+	digest = g_alloca (length);
+
 	/* TODO; somehow work out the limit and use that for proper progress reporting
 	   We need a pointer to the folder perhaps? */
 	camel_operation_progress_count(NULL, fi->id);
 
-	md5_init(&md5);
+	checksum = g_checksum_new (G_CHECKSUM_MD5);
 	mp = camel_mime_parser_new();
 	camel_mime_parser_init_with_stream(mp, (CamelStream *)stream);
 	switch (camel_mime_parser_step(mp, NULL, NULL)) {
@@ -184,8 +186,8 @@
 		while (h) {
 			if (g_ascii_strcasecmp(h->name, "status") != 0
 			    && g_ascii_strcasecmp(h->name, "x-status") != 0) {
-				md5_update(&md5, (const guchar*) h->name, strlen(h->name));
-				md5_update(&md5, (const guchar*) h->value, strlen(h->value));
+				g_checksum_update (checksum, (guchar *) h->name, strlen (h->name));
+				g_checksum_update (checksum, (guchar *) h->value, strlen (h->value));
 			}
 			h = h->next;
 		}
@@ -193,9 +195,11 @@
 		break;
 	}
 	camel_object_unref(mp);
-	md5_final(&md5, digest);
-	fi->uid = g_base64_encode(digest, 16);
+	g_checksum_get_digest (checksum, digest, &length);
+	g_checksum_free (checksum);
 
+	fi->uid = g_base64_encode ((guchar *) digest, length);
+
 	d(printf("building uid for id '%d' = '%s'\n", fi->id, fi->uid));
 
 	return 1;
Index: libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-store.c
===================================================================
--- libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-store.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/providers/pop3/camel-pop3-store.c	(working copy)
@@ -74,8 +74,6 @@
 #endif
 #include "camel-disco-diary.h"
 
-#include <libedataserver/md5-utils.h>
-
 /* Specified in RFC 1939 */
 #define POP3_PORT "110"
 #define POP3S_PORT "995"
@@ -769,8 +767,7 @@
 		g_static_rec_mutex_unlock (store->eng_lock);
 
 	} else if (strcmp(service->url->authmech, "+APOP") == 0 && store->engine->apop) {
-		char *secret, md5asc[33], *d;
-		unsigned char md5sum[16], *s;
+		char *secret, *md5asc, *d;
 
 		d = store->engine->apop;
 
@@ -793,14 +790,10 @@
 
 		secret = g_alloca(strlen(store->engine->apop)+strlen(service->url->passwd)+1);
 		sprintf(secret, "%s%s",  store->engine->apop, service->url->passwd);
-		md5_get_digest(secret, strlen (secret), md5sum);
-
-		for (s = md5sum, d = md5asc; d < md5asc + 32; s++, d += 2)
-			sprintf (d, "%.2x", *s);
-
+ 		md5asc = g_compute_checksum_for_string (G_CHECKSUM_MD5, secret, strlen (secret));
 		pcp = camel_pop3_engine_command_new(store->engine, 0, NULL, NULL, "APOP %s %s\r\n",
 						    service->url->user, md5asc);
-
+ 		g_free (md5asc);
 	} else {
 		CamelServiceAuthType *auth;
 		GList *l;
Index: libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-search.c
===================================================================
--- libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-search.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-search.c	(working copy)
@@ -30,7 +30,6 @@
 
 #include <string.h>
 
-#include <libedataserver/md5-utils.h>	/* md5 hash building */
 #include <libedataserver/e-sexp.h>
 
 #include "camel-mime-utils.h"	/* base64 encoding */
@@ -178,20 +177,27 @@
 static void
 hash_match(char hash[17], int argc, struct _ESExpResult **argv)
 {
-	MD5Context ctx;
-	unsigned char digest[16];
+	GChecksum *checksum;
+	guint8 *digest;
+	gsize length;
 	int state = 0, save = 0;
 	int i;
 
-	md5_init(&ctx);
+	length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+	digest = g_alloca (length);
+
+	checksum = g_checksum_new (G_CHECKSUM_MD5);
 	for (i=0;i<argc;i++) {
 		if (argv[i]->type == ESEXP_RES_STRING)
-			md5_update(&ctx, (const guchar *) argv[i]->value.string, strlen(argv[i]->value.string));
+			g_checksum_update (
+				checksum, (guchar *) argv[i]->value.string,
+				strlen (argv[i]->value.string));
 	}
-	md5_final(&ctx, digest);
+	g_checksum_get_digest (checksum, digest, &length);
+	g_checksum_free (checksum);
 
-	g_base64_encode_step(digest, 12, FALSE, hash, &state, &save);
-	g_base64_encode_close(FALSE, hash, &state, &save);
+	g_base64_encode_step ((guchar *) digest, 12, FALSE, hash, &state, &save);
+	g_base64_encode_close (FALSE, hash, &state, &save);
 
 	for (i=0;i<16;i++) {
 		if (hash[i] == '+')
Index: libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store-summary.c
===================================================================
--- libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store-summary.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/providers/imap/camel-imap-store-summary.c	(working copy)
@@ -29,7 +29,6 @@
 #include <string.h>
 #include <unistd.h>
 
-#include <libedataserver/md5-utils.h>
 #include <libedataserver/e-memory.h>
 
 #include "camel-file-utils.h"
Index: libtinymail-camel/camel-lite/camel/providers/imapp/camel-imapp-folder.c
===================================================================
--- libtinymail-camel/camel-lite/camel/providers/imapp/camel-imapp-folder.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/providers/imapp/camel-imapp-folder.c	(working copy)
@@ -29,7 +29,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include <libedataserver/md5-utils.h>
 #include <libedataserver/e-data-server-util.h>
 
 #include "camel-data-cache.h"
Index: libtinymail-camel/camel-lite/camel/providers/imapp/camel-imapp-store-summary.c
===================================================================
--- libtinymail-camel/camel-lite/camel/providers/imapp/camel-imapp-store-summary.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/providers/imapp/camel-imapp-store-summary.c	(working copy)
@@ -28,7 +28,6 @@
 #include <string.h>
 #include <unistd.h>
 
-#include <libedataserver/md5-utils.h>
 #include <libedataserver/e-memory.h>
 
 #include "camel-file-utils.h"
Index: libtinymail-camel/camel-lite/camel/providers/imap4/camel-imap4-summary.c
===================================================================
--- libtinymail-camel/camel-lite/camel/providers/imap4/camel-imap4-summary.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/providers/imap4/camel-imap4-summary.c	(working copy)
@@ -37,8 +37,6 @@
 
 #include <glib/gi18n-lib.h>
 
-#include <libedataserver/md5-utils.h>
-
 #include "camel-file-utils.h"
 #include "camel-string-utils.h"
 #include "camel-offline-journal.h"
@@ -434,9 +432,13 @@
 {
 	struct _camel_header_references *refs, *irt, *r;
 	CamelSummaryReferences *references;
-	unsigned char md5sum[16];
+	guint8 *digest;
+	gsize length;
 	guint32 i, n;
 
+	length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+	digest = g_alloca (length);
+
 	refs = camel_header_references_decode (refstr);
 	irt = camel_header_references_inreplyto_decode (irtstr);
 
@@ -463,8 +465,14 @@
 	references->size = n;
 
 	for (i = 0, r = refs; r != NULL; i++, r = r->next) {
-		md5_get_digest (r->id, strlen (r->id), md5sum);
-		memcpy (references->references[i].id.hash, md5sum, sizeof (CamelSummaryMessageID));
+		GChecksum *checksum;
+
+		checksum = g_checksum_new (G_CHECKSUM_MD5);
+		g_checksum_update (checksum, (guchar *) r->id, strlen (r->id));
+		g_checksum_get_digest (checksum, digest, &length);
+		g_checksum_free (checksum);
+
+		memcpy (references->references[i].id.hash, digest, sizeof (CamelSummaryMessageID));
 	}
 
 	camel_header_references_list_clear (&refs);
@@ -476,9 +484,13 @@
 decode_envelope (CamelIMAP4Engine *engine, CamelMessageInfo *info, camel_imap4_token_t *token, CamelException *ex)
 {
 	CamelIMAP4MessageInfo *iinfo = (CamelIMAP4MessageInfo *) info;
-	unsigned char md5sum[16];
+	guint8 *digest;
+	gsize length;
 	char *nstring, *msgid;
 
+	length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+	digest = g_alloca (length);
+
 	if (camel_imap4_engine_next_token (engine, token, ex) == -1)
 		return -1;
 
@@ -549,8 +561,14 @@
 
 	if (nstring != NULL) {
 		if ((msgid = camel_header_msgid_decode (nstring))) {
-			md5_get_digest (msgid, strlen (msgid), md5sum);
-			memcpy (iinfo->info.message_id.id.hash, md5sum, sizeof (CamelSummaryMessageID));
+			GChecksum *checksum;
+
+			checksum = g_checksum_new (G_CHECKSUM_MD5);
+			g_checksum_update (checksum, (guchar *) msgid, strlen (msgid));
+			g_checksum_get_digest (checksum, digest, &length);
+			g_checksum_free (checksum);
+
+			memcpy (iinfo->info.message_id.id.hash, digest, sizeof (CamelSummaryMessageID));
 			g_free (msgid);
 		}
 		g_free (nstring);
Index: libtinymail-camel/camel-lite/camel/camel-multipart.c
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-multipart.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/camel-multipart.c	(working copy)
@@ -31,8 +31,6 @@
 #include <time.h>   /* for time */
 #include <unistd.h> /* for getpid */
 
-#include <libedataserver/md5-utils.h>
-
 #include "camel-exception.h"
 #include "camel-mime-part.h"
 #include "camel-multipart.h"
@@ -364,22 +362,35 @@
 set_boundary (CamelMultipart *multipart, const char *boundary)
 {
 	CamelDataWrapper *cdw = CAMEL_DATA_WRAPPER (multipart);
-	char *bgen, digest[16], bbuf[27], *p;
+	char *bgen, bbuf[27], *p;
+	guint8 *digest;
+	gsize length;
 	int state, save;
 
 	g_return_if_fail (cdw->mime_type != NULL);
 
+	length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+	digest = g_alloca (length);
+
 	if (!boundary) {
+		GChecksum *checksum;
+
 		/* Generate a fairly random boundary string. */
 		bgen = g_strdup_printf ("%p:%lu:%lu", (void *) multipart,
 					(unsigned long) getpid(),
 					(unsigned long) time(NULL));
-		md5_get_digest (bgen, strlen (bgen), (unsigned char *) digest);
+
+		checksum = g_checksum_new (G_CHECKSUM_MD5);
+		g_checksum_update (checksum, (guchar *) bgen, strlen (bgen));
+		g_checksum_get_digest (checksum, digest, &length);
+		g_checksum_free (checksum);
+
 		g_free (bgen);
 		strcpy (bbuf, "=-");
 		p = bbuf + 2;
 		state = save = 0;
-		p += g_base64_encode_step ((guchar *) digest, 16, FALSE, p, &state, &save);
+		p += g_base64_encode_step (
+			(guchar *) digest, length, FALSE, p, &state, &save);
 		*p = '\0';
 
 		boundary = bbuf;
Index: libtinymail-camel/camel-lite/camel/camel-vee-folder.c
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-vee-folder.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/camel-vee-folder.c	(working copy)
@@ -29,8 +29,6 @@
 #include <glib.h>
 #include <glib/gi18n-lib.h>
 
-#include <libedataserver/md5-utils.h>
-
 #if defined (DOEPOOLV) || defined (DOESTRV)
 #include <libedataserver/e-memory.h>
 #endif
@@ -377,21 +375,27 @@
 void
 camel_vee_folder_hash_folder(CamelFolder *folder, char buffer[8])
 {
-	MD5Context ctx;
-	unsigned char digest[16];
+	GChecksum *checksum;
+	guint8 *digest;
+	gsize length;
 	int state = 0, save = 0;
 	char *tmp;
 	int i;
 
-	md5_init(&ctx);
+	length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+	digest = g_alloca (length);
+
+	checksum = g_checksum_new (G_CHECKSUM_MD5);
 	tmp = camel_service_get_url((CamelService *)folder->parent_store);
-	md5_update(&ctx, (unsigned char*) tmp, strlen(tmp));
-	g_free(tmp);
-	md5_update(&ctx, (unsigned char*)folder->full_name, strlen(folder->full_name));
-	md5_final(&ctx, digest);
+	g_checksum_update (checksum, (guchar *) tmp, strlen (tmp));
+	g_free (tmp);
+	tmp = folder->full_name;
+	g_checksum_update (checksum, (guchar *) tmp, strlen (tmp));
+	g_checksum_get_digest (checksum, digest, &length);
+	g_checksum_free (checksum);
 
-	g_base64_encode_step(digest, 6, FALSE, buffer, &state, &save);
-	g_base64_encode_close(FALSE, buffer, &state, &save);
+	g_base64_encode_step (digest, 6, FALSE, buffer, &state, &save);
+	g_base64_encode_close (FALSE, buffer, &state, &save);
 
 	for (i=0;i<8;i++) {
 		if (buffer[i] == '+')
Index: libtinymail-camel/camel-lite/camel/camel-multipart-signed.c
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-multipart-signed.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/camel-multipart-signed.c	(working copy)
@@ -37,8 +37,6 @@
 #include <glib.h>
 #include <glib/gi18n-lib.h>
 
-#include <libedataserver/md5-utils.h>
-
 #include "camel-exception.h"
 #include "camel-mime-filter-canon.h"
 #include "camel-mime-filter-crlf.h"
Index: libtinymail-camel/camel-lite/camel/camel-store-summary.c
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-store-summary.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/camel-store-summary.c	(working copy)
@@ -37,7 +37,6 @@
 #include <glib/gi18n-lib.h>
 
 #include <libedataserver/e-memory.h>
-#include <libedataserver/md5-utils.h>
 
 #include "camel-file-utils.h"
 #include "camel-private.h"
Index: libtinymail-camel/camel-lite/camel/camel-sasl-digest-md5.c
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-sasl-digest-md5.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/camel-sasl-digest-md5.c	(working copy)
@@ -33,7 +33,6 @@
 #include <glib/gi18n-lib.h>
 
 #include <libedataserver/e-iconv.h>
-#include <libedataserver/md5-utils.h>
 
 #include "camel-charset-map.h"
 #include "camel-mime-utils.h"
@@ -539,16 +538,6 @@
 	return challenge;
 }
 
-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 ((char *) p, "%.2x", *s);
-}
-
 static char *
 digest_uri_to_string (struct _DigestURI *uri)
 {
@@ -561,72 +550,99 @@
 static void
 compute_response (struct _DigestResponse *resp, const char *passwd, gboolean client, guchar out[33])
 {
-	guchar hex_a1[33], hex_a2[33];
-	guchar digest[16];
-	MD5Context ctx;
-	char *buf;
+	GString *buffer;
+	GChecksum *checksum;
+	guint8 *digest;
+	gsize length;
+	gchar *hex_a1;
+	gchar *hex_a2;
+	gchar *hex_kd;
+	gchar *uri;
 
-	/* compute A1 */
-	md5_init (&ctx);
-	md5_update (&ctx, (const guchar *) resp->username, strlen (resp->username));
-	md5_update (&ctx, (const guchar *) ":", 1);
-	md5_update (&ctx, (const guchar *) resp->realm, strlen (resp->realm));
-	md5_update (&ctx, (const guchar *) ":", 1);
-	md5_update (&ctx, (const guchar *) passwd, strlen (passwd));
-	md5_final (&ctx, digest);
+	buffer = g_string_sized_new (256);
+	length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+	digest = g_alloca (length);
 
-	md5_init (&ctx);
-	md5_update (&ctx, digest, 16);
-	md5_update (&ctx, (const guchar *) ":", 1);
-	md5_update (&ctx, (const guchar *) resp->nonce, strlen (resp->nonce));
-	md5_update (&ctx, (const guchar *) ":", 1);
-	md5_update (&ctx, (const guchar *) resp->cnonce, strlen (resp->cnonce));
-	if (resp->authzid) {
-		md5_update (&ctx, (const guchar *) ":", 1);
-		md5_update (&ctx, (const guchar *) resp->authzid, strlen (resp->authzid));
+	/* Compute A1. */
+
+	g_string_append (buffer, resp->username);
+	g_string_append_c (buffer, ':');
+	g_string_append (buffer, resp->realm);
+	g_string_append_c (buffer, ':');
+	g_string_append (buffer, passwd);
+
+	checksum = g_checksum_new (G_CHECKSUM_MD5);
+	g_checksum_update (
+		checksum, (const guchar *) buffer->str, buffer->len);
+	g_checksum_get_digest (checksum, digest, &length);
+	g_checksum_free (checksum);
+
+	/* Clear the buffer. */
+	g_string_truncate (buffer, 0);
+
+	g_string_append_len (buffer, (gchar *) digest, length);
+	g_string_append_c (buffer, ':');
+	g_string_append (buffer, resp->nonce);
+	g_string_append_c (buffer, ':');
+	g_string_append (buffer, resp->cnonce);
+	if (resp->authzid != NULL) {
+		g_string_append_c (buffer, ':');
+		g_string_append (buffer, resp->authzid);
 	}
 
-	/* hexify A1 */
-	md5_final (&ctx, digest);
-	digest_hex (digest, hex_a1);
+	hex_a1 = g_compute_checksum_for_string (
+		G_CHECKSUM_MD5, buffer->str, buffer->len);
 
-	/* compute A2 */
-	md5_init (&ctx);
+	/* Clear the buffer. */
+	g_string_truncate (buffer, 0);
+
+	/* Compute A2. */
+
 	if (client) {
-		/* we are calculating the client response */
-		md5_update (&ctx, (const guchar *) "AUTHENTICATE:", strlen ("AUTHENTICATE:"));
+		/* We are calculating the client response. */
+		g_string_append (buffer, "AUTHENTICATE:");
 	} else {
-		/* we are calculating the server rspauth */
-		md5_update (&ctx, (const guchar *) ":", 1);
+		/* We are calculating the server rspauth. */
+		g_string_append_c (buffer, ':');
 	}
 
-	buf = digest_uri_to_string (resp->uri);
-	md5_update (&ctx, (const guchar *) buf, strlen (buf));
-	g_free (buf);
+	uri = digest_uri_to_string (resp->uri);
+	g_string_append (buffer, uri);
+	g_free (uri);
 
 	if (resp->qop == QOP_AUTH_INT || resp->qop == QOP_AUTH_CONF)
-		md5_update (&ctx, (const guchar *) ":00000000000000000000000000000000", 33);
+		g_string_append (buffer, ":00000000000000000000000000000000");
 
-	/* now hexify A2 */
-	md5_final (&ctx, digest);
-	digest_hex (digest, hex_a2);
+	hex_a2 = g_compute_checksum_for_string (
+		G_CHECKSUM_MD5, buffer->str, buffer->len);
 
-	/* compute KD */
-	md5_init (&ctx);
-	md5_update (&ctx, (const guchar *) hex_a1, 32);
-	md5_update (&ctx, (const guchar *) ":", 1);
-	md5_update (&ctx, (const guchar *) resp->nonce, strlen (resp->nonce));
-	md5_update (&ctx, (const guchar *) ":", 1);
-	md5_update (&ctx, (const guchar *) resp->nc, 8);
-	md5_update (&ctx, (const guchar *) ":", 1);
-	md5_update (&ctx, (const guchar *) resp->cnonce, strlen (resp->cnonce));
-	md5_update (&ctx, (const guchar *) ":", 1);
-	md5_update (&ctx, (const guchar *) qop_to_string (resp->qop), strlen (qop_to_string (resp->qop)));
-	md5_update (&ctx, (const guchar *) ":", 1);
-	md5_update (&ctx, (const guchar *) hex_a2, 32);
-	md5_final (&ctx, digest);
+	/* Clear the buffer. */
+	g_string_truncate (buffer, 0);
 
-	digest_hex (digest, out);
+	/* Compute KD. */
+
+	g_string_append (buffer, hex_a1);
+	g_string_append_c (buffer, ':');
+	g_string_append (buffer, resp->nonce);
+	g_string_append_c (buffer, ':');
+	g_string_append_len (buffer, resp->nc, 8);
+	g_string_append_c (buffer, ':');
+	g_string_append (buffer, resp->cnonce);
+	g_string_append_c (buffer, ':');
+	g_string_append (buffer, qop_to_string (resp->qop));
+	g_string_append_c (buffer, ':');
+	g_string_append (buffer, hex_a2);
+
+	hex_kd = g_compute_checksum_for_string (
+		G_CHECKSUM_MD5, buffer->str, buffer->len);
+
+	g_strlcpy ((gchar *) out, hex_kd, 33);
+
+	g_free (hex_a1);
+	g_free (hex_a2);
+	g_free (hex_kd);
+
+	g_string_free (buffer, TRUE);
 }
 
 static struct _DigestResponse *
@@ -635,8 +651,14 @@
 {
 	struct _DigestResponse *resp;
 	struct _DigestURI *uri;
-	char *bgen, digest[16];
+	GChecksum *checksum;
+	guint8 *digest;
+	gsize length;
+	gchar *bgen;
 
+	length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+	digest = g_alloca (length);
+
 	resp = g_new0 (struct _DigestResponse, 1);
 	resp->username = g_strdup (user);
 	/* FIXME: we should use the preferred realm */
@@ -651,8 +673,12 @@
 	bgen = g_strdup_printf ("%p:%lu:%lu", (void *) resp,
 				(unsigned long) getpid (),
 				(unsigned long) time (NULL));
-	md5_get_digest (bgen, strlen (bgen), (guchar *) digest);
+	checksum = g_checksum_new (G_CHECKSUM_MD5);
+	g_checksum_update (checksum, (guchar *) bgen, strlen (bgen));
+	g_checksum_get_digest (checksum, digest, &length);
+	g_checksum_free (checksum);
 	g_free (bgen);
+
 	/* take our recommended 64 bits of entropy */
 	resp->cnonce = g_base64_encode ((guchar *) digest, 8);
 
Index: libtinymail-camel/camel-lite/camel/camel-sasl-cram-md5.c
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-sasl-cram-md5.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/camel-sasl-cram-md5.c	(working copy)
@@ -30,8 +30,6 @@
 #include <glib.h>
 #include <glib/gi18n-lib.h>
 
-#include <libedataserver/md5-utils.h>
-
 #include "camel-mime-utils.h"
 #include "camel-sasl-cram-md5.h"
 #include "camel-service.h"
@@ -90,12 +88,14 @@
 static GByteArray *
 cram_md5_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex)
 {
+	GChecksum *checksum;
+	guint8 *digest;
+	gsize length;
 	char *passwd;
-	guchar digest[16], md5asc[33], *s, *p;
+	const gchar *hex;
 	GByteArray *ret = NULL;
 	guchar ipad[64];
 	guchar opad[64];
-	MD5Context ctx;
 	int i, pw_len;
 
 	/* Need to wait for the server */
@@ -104,6 +104,9 @@
 
 	g_return_val_if_fail (sasl->service->url->passwd != NULL, NULL);
 
+	length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+	digest = g_alloca (length);
+
 	memset (ipad, 0, sizeof (ipad));
 	memset (opad, 0, sizeof (opad));
 
@@ -113,8 +116,13 @@
 		memcpy (ipad, passwd, pw_len);
 		memcpy (opad, passwd, pw_len);
 	} else {
-		md5_get_digest (passwd, pw_len, ipad);
-		memcpy (opad, ipad, 16);
+		checksum = g_checksum_new (G_CHECKSUM_MD5);
+		g_checksum_update (checksum, (guchar *) passwd, pw_len);
+		g_checksum_get_digest (checksum, digest, &length);
+		g_checksum_free (checksum);
+
+		memcpy (ipad, digest, length);
+		memcpy (opad, digest, length);
 	}
 
 	for (i = 0; i < 64; i++) {
@@ -122,25 +130,26 @@
 		opad[i] ^= 0x5c;
 	}
 
-	md5_init (&ctx);
-	md5_update (&ctx, ipad, 64);
-	md5_update (&ctx, token->data, token->len);
-	md5_final (&ctx, digest);
+	checksum = g_checksum_new (G_CHECKSUM_MD5);
+	g_checksum_update (checksum, (guchar *) ipad, sizeof (ipad));
+	g_checksum_update (checksum, (guchar *) token->data, token->len);
+	g_checksum_get_digest (checksum, digest, &length);
+	g_checksum_free (checksum);
 
-	md5_init (&ctx);
-	md5_update (&ctx, opad, 64);
-	md5_update (&ctx, digest, 16);
-	md5_final (&ctx, digest);
+	checksum = g_checksum_new (G_CHECKSUM_MD5);
+	g_checksum_update (checksum, (guchar *) opad, sizeof (opad));
+	g_checksum_update (checksum, (guchar *) digest, length);
 
-	/* lowercase hexify that bad-boy... */
-	for (s = digest, p = md5asc; p < md5asc + 32; s++, p += 2)
-		sprintf ((char *) p, "%.2x", *s);
+	/* String is owned by the checksum. */
+	hex = g_checksum_get_string (checksum);
 
 	ret = g_byte_array_new ();
 	g_byte_array_append (ret, (guint8 *) sasl->service->url->user, strlen (sasl->service->url->user));
 	g_byte_array_append (ret, (guint8 *) " ", 1);
-	g_byte_array_append (ret, (guint8 *) md5asc, 32);
+	g_byte_array_append (ret, (guint8 *) hex, strlen (hex));
 
+	g_checksum_free (checksum);
+
 	sasl->authenticated = TRUE;
 
 	return ret;
Index: libtinymail-camel/camel-lite/camel/camel-folder-summary.c
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-folder-summary.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/camel-folder-summary.c	(working copy)
@@ -49,7 +49,6 @@
 
 #include <libedataserver/e-iconv.h>
 #include <libedataserver/e-memory.h>
-#include <libedataserver/md5-utils.h>
 
 
 #include "camel-file-utils.h"
@@ -2175,6 +2174,9 @@
 	const char *prio = NULL;
 	const char *attach = NULL;
 
+	length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+	digest = g_alloca (length);
+
 	mi = (CamelMessageInfoBase *)camel_message_info_new(s);
 	mi->flags |= CAMEL_MESSAGE_INFO_NEEDS_FREE;
 
@@ -2278,7 +2280,13 @@
 
 	msgid = camel_header_msgid_decode(camel_header_raw_find(&h, "message-id", NULL));
 	if (msgid) {
-		md5_get_digest(msgid, strlen(msgid), digest);
+		GChecksum *checksum;
+
+		checksum = g_checksum_new (G_CHECKSUM_MD5);
+		g_checksum_update (checksum, (guchar *) msgid, strlen (msgid));
+		g_checksum_get_digest (checksum, digest, &length);
+		g_checksum_free (checksum);
+
 		memcpy(mi->message_id.id.hash, digest, sizeof(mi->message_id.id.hash));
 		g_free(msgid);
 	}
Index: libtinymail-camel/camel-lite/camel/camel-tcp-stream-ssl.c
===================================================================
--- libtinymail-camel/camel-lite/camel/camel-tcp-stream-ssl.c	(revision 3429)
+++ libtinymail-camel/camel-lite/camel/camel-tcp-stream-ssl.c	(working copy)
@@ -56,8 +56,6 @@
 #include <glib/gi18n-lib.h>
 #include <glib/gstdio.h>
 
-#include <libedataserver/md5-utils.h>
-
 #include "camel-certdb.h"
 #include "camel-file-utils.h"
 #include "camel-operation.h"
@@ -829,25 +827,39 @@
 static char *
 cert_fingerprint(CERTCertificate *cert)
 {
-	unsigned char fp[16];
-	SECItem fpitem;
-	char *fpstr;
-	char *c;
+	GChecksum *checksum;
+	guint8 *digest;
+	gsize length;
+	unsigned char fingerprint[50], *f;
+	int i;
+	const char tohex[16] = "0123456789abcdef";
 
-	PK11_HashBuf (SEC_OID_MD5, fp, cert->derCert.data, cert->derCert.len);
-	fpitem.data = fp;
-	fpitem.len = sizeof (fp);
-	fpstr = CERT_Hexify (&fpitem, 1);
+	length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+	digest = g_alloca (length);
 
-	for (c = fpstr; *c != 0; c++) {
-#ifdef G_OS_WIN32
-		if (*c == ':')
-			*c = '_';
+	checksum = g_checksum_new (G_CHECKSUM_MD5);
+	g_checksum_update (checksum, cert->derCert.data, cert->derCert.len);
+	g_checksum_get_digest (checksum, digest, &length);
+	g_checksum_free (checksum);
+
+	for (i=0,f = fingerprint; i < length; i++) {
+		unsigned int c = digest[i];
+
+		*f++ = tohex[(c >> 4) & 0xf];
+		*f++ = tohex[c & 0xf];
+#ifndef G_OS_WIN32
+		*f++ = ':';
+#else
+		/* The fingerprint is used as a file name, can't have
+		 * colons in file names. Use underscore instead.
+		 */
+		*f++ = '_';
 #endif
-		*c = g_ascii_tolower (*c);
 	}
 
-	return fpstr;
+	fingerprint[47] = 0;
+
+	return g_strdup((char*) fingerprint);
 }
 
 /* lookup a cert uses fingerprint to index an on-disk file */
Index: libtinymail-camel/camel-lite/libedataserver/md5-utils.c
===================================================================
--- libtinymail-camel/camel-lite/libedataserver/md5-utils.c	(revision 3429)
+++ libtinymail-camel/camel-lite/libedataserver/md5-utils.c	(working copy)
@@ -312,12 +312,22 @@
 void
 md5_get_digest (const gchar *buffer, gint buffer_size, guchar digest[16])
 {	
-	MD5Context ctx;
-
-	md5_init (&ctx);
-	md5_update (&ctx, (const guchar*)buffer, buffer_size);
-	md5_final (&ctx, digest);
-	
+ 	GChecksum *checksum;
+ 	guint8 *local_digest;
+ 	gsize length;
+ 
+ 	g_return_if_fail (buffer_size > 1);
+ 	g_return_if_fail (digest != NULL);
+ 
+ 	length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+ 	local_digest = g_alloca (length);
+ 
+ 	checksum = g_checksum_new (G_CHECKSUM_MD5);
+ 	g_checksum_update (checksum, (const guchar *) buffer, buffer_size);
+ 	g_checksum_get_digest (checksum, local_digest, &length);
+ 	g_checksum_free (checksum);
+  
+ 	memcpy (digest, local_digest, length);
 }
 
 
@@ -332,26 +342,25 @@
 void
 md5_get_digest_from_file (const gchar *filename, guchar digest[16])
 {	
-	MD5Context ctx;
-	guchar tmp_buf[1024];
-	gint nb_bytes_read;
-	FILE *fp;
-
-	md5_init (&ctx);
-	fp = g_fopen(filename, "rb");
-
-	if (!fp)
+ 	GMappedFile *mapped_file;
+ 	const gchar *contents;
+ 	gsize length;
+ 	GError *error = NULL;
+ 
+ 	g_return_if_fail (filename != NULL);
+ 	g_return_if_fail (digest != NULL);
+ 
+ 	mapped_file = g_mapped_file_new (filename, FALSE, &error);
+ 	if (mapped_file == NULL) {
+ 		/* XXX No way to report errors with this API. */
+ 		g_warning ("%s", error->message);
 		return;
-
-	while ((nb_bytes_read = fread (tmp_buf, 1, sizeof (tmp_buf), fp)) > 0)
-		md5_update (&ctx, tmp_buf, nb_bytes_read);
-
-	if (ferror(fp)) {
-		fclose(fp);
-		return;
 	}
 
-	md5_final (&ctx, digest);
-
-	fclose (fp);
+ 	contents = g_mapped_file_get_contents (mapped_file);
+ 	length = g_mapped_file_get_length (mapped_file);
+  
+ 	md5_get_digest (contents, length, digest);
+  
+ 	g_mapped_file_free (mapped_file);
 }
Index: libtinymail-camel/camel-lite/libedataserver/md5-utils.h
===================================================================
--- libtinymail-camel/camel-lite/libedataserver/md5-utils.h	(revision 3429)
+++ libtinymail-camel/camel-lite/libedataserver/md5-utils.h	(working copy)
@@ -26,6 +26,10 @@
 #ifndef MD5_UTILS_H
 #define MD5_UTILS_H
 
+/* This API is deprecated.  Use GLib's GChecksum instead. */
+
+#ifndef EDS_DISABLE_DEPRECATED
+
 #include <glib.h>
 
 G_BEGIN_DECLS
@@ -56,4 +60,6 @@
 
 G_END_DECLS
 
+#endif  /* EDS_DISABLE_DEPRECATED */
+
 #endif	/* MD5_UTILS_H */
