/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * Authors: Jeffrey Stedfast * * Copyright 2001 Ximian, Inc. (www.ximian.com) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include "camel-sasl-cram-md5.h" #include "camel-mime-utils.h" #include "camel-service.h" #include CamelServiceAuthType camel_sasl_cram_md5_authtype = { N_("CRAM-MD5"), N_("This option will connect to the server using a " "secure CRAM-MD5 password, if the server supports it."), "CRAM-MD5", TRUE }; static CamelSaslClass *parent_class = NULL; /* Returns the class for a CamelSaslCramMd5 */ #define CSCM_CLASS(so) CAMEL_SASL_CRAM_MD5_CLASS (CAMEL_OBJECT_GET_CLASS (so)) static GByteArray *cram_md5_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex); static void camel_sasl_cram_md5_class_init (CamelSaslCramMd5Class *camel_sasl_cram_md5_class) { CamelSaslClass *camel_sasl_class = CAMEL_SASL_CLASS (camel_sasl_cram_md5_class); parent_class = CAMEL_SASL_CLASS (camel_type_get_global_classfuncs (camel_sasl_get_type ())); /* virtual method overload */ camel_sasl_class->challenge = cram_md5_challenge; } CamelType camel_sasl_cram_md5_get_type (void) { static CamelType type = CAMEL_INVALID_TYPE; if (type == CAMEL_INVALID_TYPE) { type = camel_type_register (camel_sasl_get_type (), "CamelSaslCramMd5", sizeof (CamelSaslCramMd5), sizeof (CamelSaslCramMd5Class), (CamelObjectClassInitFunc) camel_sasl_cram_md5_class_init, NULL, NULL, NULL); } return type; } /* CRAM-MD5 algorithm: * MD5 ((passwd XOR opad), MD5 ((passwd XOR ipad), timestamp)) */ static GByteArray * cram_md5_challenge (CamelSasl *sasl, GByteArray *token, CamelException *ex) { char *passwd; guchar digest[16], md5asc[33], *s, *p; GByteArray *ret = NULL; guchar ipad[64]; 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) { memcpy (ipad, passwd, pw_len); memcpy (opad, passwd, pw_len); } else { 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; } EVOLUTION_2_9_3&id=7f65dfa168a26419396e3a882fd2ba8f7080ac2e'>s/helixcode/ximian (How I missed this page on the first go-round I don'tAaron Weber2001-04-184-19/+24 * Pull up fix from the branch:Ettore Perazzoli2001-04-185-7/+15 * Updated Spanish translation.Hector Garcia2001-03-222-2/+281 * Updated Spanish TranslationHector Garcia2001-03-161-1/+64 * Removed .oafinfo files -- they are obsolete. Moved pixmaps fromGediminas Paulauskas2001-03-151-0/+2 * create doc/devel/executive-summary/MakefileGediminas Paulauskas2001-03-152-2/+5 * Deleting some files that should not have been added in the first placeHector Garcia2001-03-142-59/+0 * Adding files to help translating evolution guide using a .po wayHector Garcia2001-03-1439-0/+19852 * IMAP subscriptions stuff.Aaron Weber2001-02-232-1/+35 * Advanced search/show all/save search stuff.Aaron Weber2001-02-225-14/+61 * Validated. Verified. Markup fixed in several individual files.Aaron Weber2001-02-165-883/+16 * Added summary of services, with summary service summaries.Aaron Weber2001-02-143-115/+174 * Overhaul. Now accurate and truthful and clear.Aaron Weber2001-02-106-58/+136 * Minor Changes.Aaron Weber2001-02-097-108/+168 * s/contact manager/address book/ and revised text.Aaron Weber2001-02-085-47/+69 * Final docs.Iain Holmes2001-02-023-2/+18 * More docs...Iain Holmes2001-02-027-51/+76 * Wheeee pretty documentationIain Holmes2001-02-0214-0/+1097 * Change (nonexistant) importer.sgml references to evolution-importer.sgmlJohn R. Sheets2001-01-282-12/+17 * Doc updates - FedericoFederico Mena Quintero2001-01-203-228/+228 * create a new cal component alarm (cal_component_add_alarm): add alarm toJP Rosevear2001-01-193-230/+245 * More of Megan's revisions, and Field Chooser functions in the SortAaron Weber2001-01-196-242/+290 * Um, why was the doc directory removed from SUBDIRS?Federico Mena Quintero2001-01-191-18/+18 * Use "typedef enum { ... } Blah;" instead of "typedef enum _Blah Blah; enumFederico Mena Quintero2001-01-184-51/+46 * Some API documentation for the importerIain Holmes2001-01-1816-2/+465 * Ximianified.Federico Mena Quintero2001-01-1713-290/+376 * remove old config messageJP Rosevear2001-01-151-82/+82 * pass -module and -avoid-version to conduit linkerJP Rosevear2001-01-144-168/+144 * Make it work when gtk-doc is not installed.Federico Mena Quintero2001-01-116-0/+91 * More Makefile organization to compileMiguel de Icaza2001-01-1010-121/+71 * Added calendar/gui/alarm-notify/Makefile.Federico Mena Quintero2001-01-102-83/+93 * Remove non-existent fileJP Rosevear2001-01-052-92/+91 * Unconditionally remove the client from the alarm notification system.Federico Mena Quintero2001-01-033-136/+136 * Remove deleted fileJP Rosevear2000-12-234-137/+136 * Alarm trigger queueing for the GUI part.Federico Mena Quintero2000-12-232-11/+11 * Added proper dependency lists to the gtk-doc mess.Federico Mena Quintero2000-12-2016-562/+875 * Alarm instance generation support for the Wombat.Federico Mena Quintero2000-12-195-0/+69 * Revisions as suggested by Dan. Especially to filter dialogs... which stillAaron Weber2000-12-154-125/+189 * make it public-reference.sgml not referenc.sgml here.Larry Ewing2000-12-142-1/+6 * upd.Michael Meeks2000-12-101-1/+5 * upd.Michael Meeks2000-12-051-0/+33 * return NULL if we can't create a view.Michael Meeks2000-12-051-0/+28 * Finished the calendar architecture chapter.Federico Mena Quintero2000-11-302-3/+76 * added some <glossterms>, added linkends to existing glossterms.Aaron Weber2000-11-3010-107/+342 * Added an id for the API reference <part>. Added the FDL <legalnotice>.Federico Mena Quintero2000-11-3011-87/+963 * Fixed validation errors.Aaron Weber2000-11-028-217/+610 * added composer keybindings descriptionRadek Doulik2000-11-022-0/+13 * Add Keybindings, please populateMiguel de Icaza2000-11-021-0/+4 * Actions -> New Directory Server added.Aaron Weber2000-10-265-11/+111 * Re-checked validity of all files. Made minor changes to menuref.sgml,Aaron Weber2000-10-129-67/+99 * Re-took most screenshots; last batch had wrong Sawfish theme.Aaron Weber2000-10-1112-76/+174 * Described Search features.Aaron Weber2000-10-059-180/+410 * Spellcheck. Fixed some wording, and responded to clahey's suggestions--Aaron Weber2000-10-04