evolution-data-server r8594 - in trunk: . camel camel/providers/groupwise camel/providers/imap camel/providers/imap4 camel/providers/imapp camel/providers/nntp camel/providers/pop3 libedataserver
- From: mbarnes svn gnome org
- To: svn-commits-list gnome org
- Subject: evolution-data-server r8594 - in trunk: . camel camel/providers/groupwise camel/providers/imap camel/providers/imap4 camel/providers/imapp camel/providers/nntp camel/providers/pop3 libedataserver
- Date: Thu, 27 Mar 2008 17:05:24 +0000 (GMT)
Author: mbarnes
Date: Thu Mar 27 17:05:23 2008
New Revision: 8594
URL: http://svn.gnome.org/viewvc/evolution-data-server?rev=8594&view=rev
Log:
2008-03-27 Matthew Barnes <mbarnes redhat com>
** Fixes bug #518710
* configure.in:
Bump GLib requirement to 2.16.1.
* camel/camel-folder-summary.c:
* camel/camel-multipart.c:
* camel/camel-sasl-cram-md5.c:
* camel/camel-sasl-digest-md5.c:
* camel/camel-tcp-stream-ssl.c:
* camel/camel-vee-folder.c:
* camel/providers/imap/camel-imap-search.c:
* camel/providers/imap/camel-imap-store-summary.c:
* camel/providers/imap4/camel-imap4-summary.c:
* camel/providers/nntp/camel-nntp-store-summary.c:
* camel/providers/nntp/camel-nntp-utils.c:
* camel/providers/pop3/camel-pop3-folder.c:
* camel/providers/pop3/camel-pop3-store.c:
* libedataserver/e-dbhash.c:
Use GLib's new MD5 Checksum API. The MD5 utilities in
libedataserver are now deprecated.
* camel/camel-multipart-signed.c:
* camel/camel-store-summary.c:
* camel/providers/groupwise/camel-groupwise-store-summary.c:
* camel/providers/imapp/camel-imapp-folder.c:
* camel/providers/imapp/camel-imapp-store-summary.c:
Remove unneeded inclusion of <libedataserver/md5-utils.h>.
* libedataserver/md5-utils.c:
* libedataserver/md5-utils.h:
Deprecate these functions and reimplement them to be wrappers
for GLib's new MD5 Checksum API.
Modified:
trunk/ChangeLog
trunk/camel/ChangeLog
trunk/camel/camel-folder-summary.c
trunk/camel/camel-multipart-signed.c
trunk/camel/camel-multipart.c
trunk/camel/camel-sasl-cram-md5.c
trunk/camel/camel-sasl-digest-md5.c
trunk/camel/camel-store-summary.c
trunk/camel/camel-tcp-stream-ssl.c
trunk/camel/camel-vee-folder.c
trunk/camel/providers/groupwise/ChangeLog
trunk/camel/providers/groupwise/camel-groupwise-store-summary.c
trunk/camel/providers/imap/ChangeLog
trunk/camel/providers/imap/camel-imap-search.c
trunk/camel/providers/imap/camel-imap-store-summary.c
trunk/camel/providers/imap4/ChangeLog
trunk/camel/providers/imap4/camel-imap4-summary.c
trunk/camel/providers/imapp/ChangeLog
trunk/camel/providers/imapp/camel-imapp-folder.c
trunk/camel/providers/imapp/camel-imapp-store-summary.c
trunk/camel/providers/nntp/ChangeLog
trunk/camel/providers/nntp/camel-nntp-store-summary.c
trunk/camel/providers/nntp/camel-nntp-utils.c
trunk/camel/providers/pop3/ChangeLog
trunk/camel/providers/pop3/camel-pop3-folder.c
trunk/camel/providers/pop3/camel-pop3-store.c
trunk/configure.in
trunk/libedataserver/e-dbhash.c
trunk/libedataserver/md5-utils.c
trunk/libedataserver/md5-utils.h
Modified: trunk/camel/camel-folder-summary.c
==============================================================================
--- trunk/camel/camel-folder-summary.c (original)
+++ trunk/camel/camel-folder-summary.c Thu Mar 27 17:05:23 2008
@@ -38,7 +38,6 @@
#include <libedataserver/e-iconv.h>
#include <libedataserver/e-memory.h>
-#include <libedataserver/md5-utils.h>
#include "camel-file-utils.h"
#include "camel-folder-summary.h"
@@ -1730,7 +1729,8 @@
{
CamelMessageInfoBase *mi;
const char *received;
- guchar digest[16];
+ guint8 *digest;
+ gsize length;
struct _camel_header_references *refs, *irt, *scan;
char *msgid;
int count;
@@ -1738,6 +1738,9 @@
CamelContentType *ct = NULL;
const char *content, *charset = NULL;
+ length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+ digest = g_alloca (length);
+
mi = (CamelMessageInfoBase *)camel_message_info_new(s);
if ((content = camel_header_raw_find(&h, "Content-Type", NULL))
@@ -1776,7 +1779,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, -1);
+ 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);
}
@@ -1801,7 +1810,13 @@
count = 0;
scan = refs;
while (scan) {
- md5_get_digest(scan->id, strlen(scan->id), digest);
+ GChecksum *checksum;
+
+ checksum = g_checksum_new (G_CHECKSUM_MD5);
+ g_checksum_update (checksum, (guchar *) scan->id, -1);
+ g_checksum_get_digest (checksum, digest, &length);
+ g_checksum_free (checksum);
+
memcpy(mi->references->references[count].id.hash, digest, sizeof(mi->message_id.id.hash));
count++;
scan = scan->next;
Modified: trunk/camel/camel-multipart-signed.c
==============================================================================
--- trunk/camel/camel-multipart-signed.c (original)
+++ trunk/camel/camel-multipart-signed.c Thu Mar 27 17:05:23 2008
@@ -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"
Modified: trunk/camel/camel-multipart.c
==============================================================================
--- trunk/camel/camel-multipart.c (original)
+++ trunk/camel/camel-multipart.c Thu Mar 27 17:05:23 2008
@@ -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"
@@ -350,22 +348,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, -1);
+ 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;
Modified: trunk/camel/camel-sasl-cram-md5.c
==============================================================================
--- trunk/camel/camel-sasl-cram-md5.c (original)
+++ trunk/camel/camel-sasl-cram-md5.c Thu Mar 27 17:05:23 2008
@@ -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,24 +130,25 @@
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 ((char *) p, "%.2x", *s);
+ 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);
+
+ checksum = g_checksum_new (G_CHECKSUM_MD5);
+ g_checksum_update (checksum, (guchar *) opad, sizeof (opad));
+ g_checksum_update (checksum, (guchar *) digest, length);
+
+ /* 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;
Modified: trunk/camel/camel-sasl-digest-md5.c
==============================================================================
--- trunk/camel/camel-sasl-digest-md5.c (original)
+++ trunk/camel/camel-sasl-digest-md5.c Thu Mar 27 17:05:23 2008
@@ -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;
-
- /* 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);
-
- 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));
+ GString *buffer;
+ GChecksum *checksum;
+ guint8 *digest;
+ gsize length;
+ gchar *hex_a1;
+ gchar *hex_a2;
+ gchar *hex_kd;
+ gchar *uri;
+
+ buffer = g_string_sized_new (256);
+ length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+ digest = g_alloca (length);
+
+ /* 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);
+
+ /* Clear the buffer. */
+ g_string_truncate (buffer, 0);
+
+ /* Compute A2. */
- /* compute A2 */
- md5_init (&ctx);
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);
-
- /* 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);
+ hex_a2 = g_compute_checksum_for_string (
+ G_CHECKSUM_MD5, buffer->str, buffer->len);
- digest_hex (digest, out);
+ /* Clear the buffer. */
+ g_string_truncate (buffer, 0);
+
+ /* 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,7 +651,13 @@
{
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);
@@ -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, -1);
+ 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);
Modified: trunk/camel/camel-store-summary.c
==============================================================================
--- trunk/camel/camel-store-summary.c (original)
+++ trunk/camel/camel-store-summary.c Thu Mar 27 17:05:23 2008
@@ -36,7 +36,6 @@
#include <glib/gstdio.h>
#include <libedataserver/e-memory.h>
-#include <libedataserver/md5-utils.h>
#include "camel-file-utils.h"
#include "camel-private.h"
Modified: trunk/camel/camel-tcp-stream-ssl.c
==============================================================================
--- trunk/camel/camel-tcp-stream-ssl.c (original)
+++ trunk/camel/camel-tcp-stream-ssl.c Thu Mar 27 17:05:23 2008
@@ -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"
@@ -657,13 +655,23 @@
static char *
cert_fingerprint(CERTCertificate *cert)
{
- unsigned char md5sum[16], fingerprint[50], *f;
+ GChecksum *checksum;
+ guint8 *digest;
+ gsize length;
+ unsigned char fingerprint[50], *f;
int i;
const char tohex[16] = "0123456789abcdef";
- md5_get_digest ((const char *) cert->derCert.data, cert->derCert.len, md5sum);
- for (i=0,f = fingerprint; i<16; i++) {
- unsigned int c = md5sum[i];
+ length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+ digest = g_alloca (length);
+
+ 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];
Modified: trunk/camel/camel-vee-folder.c
==============================================================================
--- trunk/camel/camel-vee-folder.c (original)
+++ trunk/camel/camel-vee-folder.c Thu Mar 27 17:05:23 2008
@@ -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, -1);
+ g_free (tmp);
+ tmp = folder->full_name;
+ g_checksum_update (checksum, (guchar *) tmp, -1);
+ 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] == '+')
Modified: trunk/camel/providers/groupwise/camel-groupwise-store-summary.c
==============================================================================
--- trunk/camel/providers/groupwise/camel-groupwise-store-summary.c (original)
+++ trunk/camel/providers/groupwise/camel-groupwise-store-summary.c Thu Mar 27 17:05:23 2008
@@ -33,7 +33,6 @@
#include <unistd.h>
#include <libedataserver/e-memory.h>
-#include <libedataserver/md5-utils.h>
#include "camel-file-utils.h"
#include "camel-private.h"
Modified: trunk/camel/providers/imap/camel-imap-search.c
==============================================================================
--- trunk/camel/providers/imap/camel-imap-search.c (original)
+++ trunk/camel/providers/imap/camel-imap-search.c Thu Mar 27 17:05:23 2008
@@ -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,26 @@
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, -1);
}
- 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] == '+')
Modified: trunk/camel/providers/imap/camel-imap-store-summary.c
==============================================================================
--- trunk/camel/providers/imap/camel-imap-store-summary.c (original)
+++ trunk/camel/providers/imap/camel-imap-store-summary.c Thu Mar 27 17:05:23 2008
@@ -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"
Modified: trunk/camel/providers/imap4/camel-imap4-summary.c
==============================================================================
--- trunk/camel/providers/imap4/camel-imap4-summary.c (original)
+++ trunk/camel/providers/imap4/camel-imap4-summary.c Thu Mar 27 17:05:23 2008
@@ -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, -1);
+ 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;
@@ -546,8 +558,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, -1);
+ 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);
Modified: trunk/camel/providers/imapp/camel-imapp-folder.c
==============================================================================
--- trunk/camel/providers/imapp/camel-imapp-folder.c (original)
+++ trunk/camel/providers/imapp/camel-imapp-folder.c Thu Mar 27 17:05:23 2008
@@ -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"
Modified: trunk/camel/providers/imapp/camel-imapp-store-summary.c
==============================================================================
--- trunk/camel/providers/imapp/camel-imapp-store-summary.c (original)
+++ trunk/camel/providers/imapp/camel-imapp-store-summary.c Thu Mar 27 17:05:23 2008
@@ -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"
Modified: trunk/camel/providers/nntp/camel-nntp-store-summary.c
==============================================================================
--- trunk/camel/providers/nntp/camel-nntp-store-summary.c (original)
+++ trunk/camel/providers/nntp/camel-nntp-store-summary.c Thu Mar 27 17:05:23 2008
@@ -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"
Modified: trunk/camel/providers/nntp/camel-nntp-utils.c
==============================================================================
--- trunk/camel/providers/nntp/camel-nntp-utils.c (original)
+++ trunk/camel/providers/nntp/camel-nntp-utils.c Thu Mar 27 17:05:23 2008
@@ -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,7 +39,11 @@
{
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",
@@ -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, -1);
+ 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,
Modified: trunk/camel/providers/pop3/camel-pop3-folder.c
==============================================================================
--- trunk/camel/providers/pop3/camel-pop3-folder.c (original)
+++ trunk/camel/providers/pop3/camel-pop3-folder.c Thu Mar 27 17:05:23 2008
@@ -33,8 +33,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"
@@ -143,17 +141,21 @@
static void
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)) {
@@ -164,8 +166,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, -1);
+ g_checksum_update (checksum, (guchar *) h->value, -1);
}
h = h->next;
}
@@ -173,8 +175,10 @@
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));
}
Modified: trunk/camel/providers/pop3/camel-pop3-store.c
==============================================================================
--- trunk/camel/providers/pop3/camel-pop3-store.c (original)
+++ trunk/camel/providers/pop3/camel-pop3-store.c Thu Mar 27 17:05:23 2008
@@ -37,8 +37,6 @@
#include <glib/gi18n-lib.h>
-#include <libedataserver/md5-utils.h>
-
#include "camel-data-cache.h"
#include "camel-exception.h"
#include "camel-net-utils.h"
@@ -499,8 +497,7 @@
pcu = camel_pop3_engine_command_new(store->engine, 0, NULL, NULL, "USER %s\r\n", service->url->user);
pcp = camel_pop3_engine_command_new(store->engine, 0, NULL, NULL, "PASS %s\r\n", service->url->passwd);
} 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;
@@ -519,13 +516,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, -1);
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;
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Thu Mar 27 17:05:23 2008
@@ -13,7 +13,7 @@
AM_CONFIG_HEADER(config.h)
# Required Package Versions
-m4_define([glib_minimum_version], [2.15.3])
+m4_define([glib_minimum_version], [2.16.1])
m4_define([gtk_minimum_version], [2.10.0])
m4_define([ORBit_minimum_version], [2.9.8])
m4_define([gnome_vfs_minimum_version], [2.4.0])
Modified: trunk/libedataserver/e-dbhash.c
==============================================================================
--- trunk/libedataserver/e-dbhash.c (original)
+++ trunk/libedataserver/e-dbhash.c Thu Mar 27 17:05:23 2008
@@ -13,7 +13,6 @@
#include <string.h>
#include <fcntl.h>
#include "db.h"
-#include "md5-utils.h"
struct _EDbHashPrivate
{
@@ -59,7 +58,7 @@
}
static void
-md5_to_dbt(const guchar str[16], DBT *dbt)
+md5_to_dbt(const guint8 str[16], DBT *dbt)
{
memset (dbt, 0, sizeof (DBT));
dbt->data = (void*)str;
@@ -72,7 +71,9 @@
DB *db;
DBT dkey;
DBT ddata;
- guchar local_hash[16];
+ GChecksum *checksum;
+ guint8 *digest;
+ gsize length;
g_return_if_fail (edbh != NULL);
g_return_if_fail (edbh->priv != NULL);
@@ -80,14 +81,22 @@
g_return_if_fail (key != NULL);
g_return_if_fail (data != NULL);
+ length = g_checksum_type_get_length (G_CHECKSUM_MD5);
+ digest = g_alloca (length);
+
db = edbh->priv->db;
/* Key dbt */
string_to_dbt (key, &dkey);
+ /* Compute MD5 checksum */
+ checksum = g_checksum_new (G_CHECKSUM_MD5);
+ g_checksum_update (checksum, (guchar *) data, -1);
+ g_checksum_get_digest (checksum, digest, &length);
+ g_checksum_free (checksum);
+
/* Data dbt */
- md5_get_digest (data, strlen (data), local_hash);
- md5_to_dbt (local_hash, &ddata);
+ md5_to_dbt (digest, &ddata);
/* Add to database */
db->put (db, NULL, &dkey, &ddata, 0);
@@ -151,7 +160,8 @@
DB *db;
DBT dkey;
DBT ddata;
- guchar compare_hash[16];
+ guint8 compare_hash[16];
+ gsize length = sizeof (compare_hash);
g_return_val_if_fail (edbh != NULL, FALSE);
g_return_val_if_fail (edbh->priv != NULL, FALSE);
@@ -169,7 +179,12 @@
/* Compare */
if (ddata.data) {
- md5_get_digest (compare_data, strlen (compare_data), compare_hash);
+ GChecksum *checksum;
+
+ checksum = g_checksum_new (G_CHECKSUM_MD5);
+ g_checksum_update (checksum, (guchar *) compare_data, -1);
+ g_checksum_get_digest (checksum, compare_hash, &length);
+ g_checksum_free (checksum);
if (memcmp (ddata.data, compare_hash, sizeof (guchar) * 16))
return E_DBHASH_STATUS_DIFFERENT;
Modified: trunk/libedataserver/md5-utils.c
==============================================================================
--- trunk/libedataserver/md5-utils.c (original)
+++ trunk/libedataserver/md5-utils.c Thu Mar 27 17:05:23 2008
@@ -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, (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,25 +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);
+ contents = g_mapped_file_get_contents (mapped_file);
+ length = g_mapped_file_get_length (mapped_file);
- if (ferror(fp)) {
- fclose(fp);
- return;
- }
- fclose(fp);
+ md5_get_digest (contents, length, digest);
- md5_final (&ctx, digest);
+ g_mapped_file_free (mapped_file);
}
Modified: trunk/libedataserver/md5-utils.h
==============================================================================
--- trunk/libedataserver/md5-utils.h (original)
+++ trunk/libedataserver/md5-utils.h Thu Mar 27 17:05:23 2008
@@ -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 */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]