IIUC libmd5-rfc preceded libgcrypt in setup by a few years. But now that we're using libgcrypt for gpg/s-expr, I think it only makes sense that we use it as well for MD5 hashing. (FWIW, this also shaves 2.5KB off the stripped, uncompressed binary.) Patch attached.
Yaakov
2012-11-08 Yaakov Selkowitz <yselkowitz@...> * Makefile.am (EXTRA_DIST): Remove libmd5-rfc files. (setup_SOURCES): Ditto. * download.cc: Remove unused include. * csu_util/MD5Sum.cc: Port from libmd5-rfc to libgcrypt. * csu_util/MD5Sum.h: Ditto. * libmd5-rfc/*: Remove. Index: Makefile.am =================================================================== RCS file: /cvs/cygwin-apps/setup/Makefile.am,v retrieving revision 2.87 diff -u -p -r2.87 Makefile.am --- Makefile.am 1 Jun 2012 15:51:56 -0000 2.87 +++ Makefile.am 8 Nov 2012 06:56:17 -0000 @@ -49,8 +49,6 @@ EXTRA_DIST = \ choose-rtarrow.bmp \ choose-spin.bmp \ cygwin.ico \ - libmd5-rfc/README \ - libmd5-rfc/md5main.c \ setup.exe.manifest \ tree-minus.bmp \ tree-plus.bmp @@ -274,9 +272,7 @@ setup_SOURCES = \ csu_util/rfc1738.cc \ csu_util/rfc1738.h \ csu_util/version_compare.cc \ - csu_util/version_compare.h \ - libmd5-rfc/md5.c \ - libmd5-rfc/md5.h + csu_util/version_compare.h # autoload code does not optimize properly with gcc-4.x autoload.o: CFLAGS += -O0 Index: download.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/download.cc,v retrieving revision 2.55 diff -u -p -r2.55 download.cc --- download.cc 29 Apr 2011 12:43:59 -0000 2.55 +++ download.cc 8 Nov 2012 06:56:17 -0000 @@ -51,7 +51,6 @@ static const char *cvsid = #include "Exception.h" #include "getopt++/BoolOption.h" -#include "csu_util/MD5Sum.h" using namespace std; Index: csu_util/MD5Sum.cc =================================================================== RCS file: /cvs/cygwin-apps/setup/csu_util/MD5Sum.cc,v retrieving revision 1.2 diff -u -p -r1.2 MD5Sum.cc --- csu_util/MD5Sum.cc 8 Apr 2008 23:50:54 -0000 1.2 +++ csu_util/MD5Sum.cc 8 Nov 2012 06:56:17 -0000 @@ -16,10 +16,6 @@ #include <string.h> #include <stdexcept> -namespace libmd5_rfc { -#include "../libmd5-rfc/md5.h" -} - MD5Sum::MD5Sum(const MD5Sum& source) { *this = source; @@ -33,7 +29,7 @@ MD5Sum::operator= (const MD5Sum& source) internalData = 0; if (source.internalData) { - internalData = new libmd5_rfc::md5_state_s; + internalData = new gcry_md_hd_t; *internalData = *(source.internalData); } return *this; @@ -56,9 +52,9 @@ void MD5Sum::begin() { if (internalData) delete internalData; - internalData = new libmd5_rfc::md5_state_s; + internalData = new gcry_md_hd_t; state = Accumulating; - libmd5_rfc::md5_init(internalData); + gcry_md_open(internalData, GCRY_MD_MD5, 0); } void @@ -67,7 +63,7 @@ MD5Sum::append(const unsigned char* data if (!internalData) throw new std::logic_error("MD5Sum::append() called on an object not " "in the 'Accumulating' state"); - libmd5_rfc::md5_append(internalData, data, nbytes); + gcry_md_write(*internalData, data, nbytes); } void @@ -76,7 +72,7 @@ MD5Sum::finish() if (!internalData) throw new std::logic_error("MD5Sum::finish() called on an object not " "in the 'Accumulating' state"); - libmd5_rfc::md5_finish(internalData, digest); + memcpy(digest, gcry_md_read(*internalData, GCRY_MD_MD5), 16); state = Set; delete internalData; internalData = 0; } Index: csu_util/MD5Sum.h =================================================================== RCS file: /cvs/cygwin-apps/setup/csu_util/MD5Sum.h,v retrieving revision 1.1 diff -u -p -r1.1 MD5Sum.h --- csu_util/MD5Sum.h 22 Nov 2004 18:15:34 -0000 1.1 +++ csu_util/MD5Sum.h 8 Nov 2012 06:56:17 -0000 @@ -16,7 +16,7 @@ #define SETUP_MD5SUM_H /* - * A C++ wrapper for the libmd5-rfc library, which additionally provides + * A C++ wrapper for the libgcrypt library, which additionally provides * storage and comparison of MD5 checksums. * * An MD5Sum may be given a value in one of two ways: @@ -27,10 +27,8 @@ */ #include <string> - -namespace libmd5_rfc { - struct md5_state_s; -}; +#include "win32.h" +#include <gcrypt.h> class MD5Sum { @@ -54,7 +52,7 @@ class MD5Sum private: enum { Empty, Accumulating, Set } state; unsigned char digest[16]; - libmd5_rfc::md5_state_s* internalData; + gcry_md_hd_t* internalData; }; #endif /* SETUP_MD5SUM_H */