1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

[svn] Use Solaris's libmd5 when available.

Published in <sxsn11kbssm.fsf@florida.arsdigita.de>.
This commit is contained in:
hniksic 2001-11-17 20:36:21 -08:00
parent 09b0fe29a8
commit d408dec0bd
10 changed files with 100 additions and 37 deletions

View File

@ -1,3 +1,7 @@
2001-11-18 Hrvoje Niksic <hniksic@arsdigita.com>
* configure.in: Check for Solaris libmd5.
2001-11-18 Hrvoje Niksic <hniksic@arsdigita.com>
* po/: Installed ja.po, et.po, he.po, fr.po, da.po, uk.po, es.po,

View File

@ -63,14 +63,15 @@ AC_ARG_ENABLE(debug,
DEBUG=$enableval, DEBUG=yes)
test x"${DEBUG}" = xyes && AC_DEFINE(DEBUG)
wget_need_md5=no
case "${USE_OPIE}${USE_DIGEST}" in
*yes*)
MD5_OBJ='md5$o'
wget_need_md5=yes
esac
if test x"$USE_OPIE" = xyes; then
OPIE_OBJ='ftp-opie$o'
fi
AC_SUBST(MD5_OBJ)
AC_SUBST(OPIE_OBJ)
dnl
@ -180,6 +181,23 @@ dnl
dnl Checks for libraries.
dnl
dnl
dnl Use the md5 lib if available (Solaris).
dnl
if test x$wget_need_md5 = xyes
then
AC_DEFINE(HAVE_MD5)
AC_CHECK_LIB(md5, MD5Update, [
AC_DEFINE(HAVE_SOLARIS_MD5)
LIBS="-lmd5 $LIBS"
], [
MD5_OBJ='gnu-md5$o'
AC_DEFINE(HAVE_BUILTIN_MD5)
])
fi
AC_SUBST(MD5_OBJ)
dnl On Solaris, -lnsl is needed to use gethostbyname. On "NCR MP-RAS
dnl 3.0", however, gethostbyname is in libc, but -lnsl is still needed
dnl to use -lsocket, as well as for functions such as inet_ntoa. We

View File

@ -1,3 +1,18 @@
2001-11-18 Hrvoje Niksic <hniksic@arsdigita.com>
* md5.h: Renamed to gnu-md5.h.
* md5.c: Renamed to gnu-md5.c.
* http.c: Ditto.
* ftp-opie.c: Use the new macros.
* sysdep.h: Define md5-related macros.
* config.h.in: Define HAVE_SOLARIS_MD5 or HAVE_BUILTIN_MD5
depending on which md5 implementation is used.
2001-11-18 Hrvoje Niksic <hniksic@arsdigita.com>
* res.c (res_register_specs): Initialize OLD and HP_OLD to appease

View File

@ -146,7 +146,7 @@ cookies$o: wget.h cookies.h hash.h url.h utils.h
fnmatch$o: wget.h fnmatch.h
ftp-basic$o: wget.h utils.h rbuf.h connect.h host.h
ftp-ls$o: wget.h utils.h ftp.h url.h
ftp-opie$o: wget.h md5.h
ftp-opie$o: wget.h
ftp$o: wget.h utils.h url.h rbuf.h retr.h ftp.h connect.h host.h fnmatch.h netrc.h
getopt$o: wget.h getopt.h
hash$o: wget.h utils.h hash.h
@ -155,11 +155,11 @@ host$o: wget.h utils.h host.h url.h hash.h
html-parse$o: wget.h html-parse.h
html-url$o: wget.h html-parse.h url.h utils.h
html$o: wget.h url.h utils.h ftp.h
http$o: wget.h utils.h url.h host.h rbuf.h retr.h headers.h cookies.h connect.h fnmatch.h netrc.h md5.h
http$o: wget.h utils.h url.h host.h rbuf.h retr.h headers.h cookies.h connect.h fnmatch.h netrc.h
init$o: wget.h utils.h init.h host.h recur.h netrc.h
log$o: wget.h utils.h
main$o: wget.h utils.h getopt.h init.h retr.h recur.h host.h cookies.h
md5$o: wget.h md5.h
gnu-md5$o: wget.h gnu-md5.h
mswindows$o: wget.h url.h
netrc$o: wget.h utils.h netrc.h init.h
rbuf$o: wget.h rbuf.h connect.h

View File

@ -204,6 +204,15 @@ char *alloca ();
/* Define if all libs needed for ssl support are existing */
#undef HAVE_SSL
/* Define if we're compiling in support for MD5. */
#undef HAVE_MD5
/* Define if we're using Solaris libmd5. */
#undef HAVE_SOLARIS_MD5
/* Define if we're using builtin (GNU) md5.c. */
#undef HAVE_BUILTIN_MD5
/* First a gambit to see whether we're on Solaris. We'll
need it below. */
#ifdef __sun

View File

@ -28,7 +28,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#endif
#include "wget.h"
#include "md5.h"
/* Dictionary for integer-word translations. */
static char Wp[2048][4] = {
@ -2152,16 +2151,16 @@ calculate_skey_response (int sequence, const char *seed, const char *pass)
char key[8];
static char buf[33];
struct md5_ctx ctx;
MD5_CONTEXT_TYPE ctx;
unsigned long results[4]; /* #### this looks 32-bit-minded */
char *feed = (char *) alloca (strlen (seed) + strlen (pass) + 1);
strcpy (feed, seed);
strcat (feed, pass);
md5_init_ctx (&ctx);
md5_process_bytes (feed, strlen (feed), &ctx);
md5_finish_ctx (&ctx, results);
MD5_INIT (&ctx);
MD5_UPDATE (feed, strlen (feed), &ctx);
MD5_FINISH (&ctx, results);
results[0] ^= results[2];
results[1] ^= results[3];
@ -2169,9 +2168,9 @@ calculate_skey_response (int sequence, const char *seed, const char *pass)
while (0 < sequence--)
{
md5_init_ctx (&ctx);
md5_process_bytes (key, 8, &ctx);
md5_finish_ctx (&ctx, results);
MD5_INIT (&ctx);
MD5_UPDATE (key, 8, &ctx);
MD5_FINISH (&ctx, results);
results[0] ^= results[2];
results[1] ^= results[3];
memcpy (key, (char *) results, 8);

View File

@ -39,7 +39,7 @@
/*#endif*/
#include "wget.h"
#include "md5.h"
#include "gnu-md5.h"
#ifdef _LIBC
# include <endian.h>

View File

@ -60,9 +60,6 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
#include "connect.h"
#include "fnmatch.h"
#include "netrc.h"
#if USE_DIGEST
# include "md5.h"
#endif
#ifdef HAVE_SSL
# include "gen_sslfunc.h"
#endif /* HAVE_SSL */
@ -2202,37 +2199,37 @@ digest_authentication_encode (const char *au, const char *user,
/* Calculate the digest value. */
{
struct md5_ctx ctx;
MD5_CONTEXT_TYPE ctx;
unsigned char hash[MD5_HASHLEN];
unsigned char a1buf[MD5_HASHLEN * 2 + 1], a2buf[MD5_HASHLEN * 2 + 1];
unsigned char response_digest[MD5_HASHLEN * 2 + 1];
/* A1BUF = H(user ":" realm ":" password) */
md5_init_ctx (&ctx);
md5_process_bytes (user, strlen (user), &ctx);
md5_process_bytes (":", 1, &ctx);
md5_process_bytes (realm, strlen (realm), &ctx);
md5_process_bytes (":", 1, &ctx);
md5_process_bytes (passwd, strlen (passwd), &ctx);
md5_finish_ctx (&ctx, hash);
MD5_INIT (&ctx);
MD5_UPDATE (user, strlen (user), &ctx);
MD5_UPDATE (":", 1, &ctx);
MD5_UPDATE (realm, strlen (realm), &ctx);
MD5_UPDATE (":", 1, &ctx);
MD5_UPDATE (passwd, strlen (passwd), &ctx);
MD5_FINISH (&ctx, hash);
dump_hash (a1buf, hash);
/* A2BUF = H(method ":" path) */
md5_init_ctx (&ctx);
md5_process_bytes (method, strlen (method), &ctx);
md5_process_bytes (":", 1, &ctx);
md5_process_bytes (path, strlen (path), &ctx);
md5_finish_ctx (&ctx, hash);
MD5_INIT (&ctx);
MD5_UPDATE (method, strlen (method), &ctx);
MD5_UPDATE (":", 1, &ctx);
MD5_UPDATE (path, strlen (path), &ctx);
MD5_FINISH (&ctx, hash);
dump_hash (a2buf, hash);
/* RESPONSE_DIGEST = H(A1BUF ":" nonce ":" A2BUF) */
md5_init_ctx (&ctx);
md5_process_bytes (a1buf, MD5_HASHLEN * 2, &ctx);
md5_process_bytes (":", 1, &ctx);
md5_process_bytes (nonce, strlen (nonce), &ctx);
md5_process_bytes (":", 1, &ctx);
md5_process_bytes (a2buf, MD5_HASHLEN * 2, &ctx);
md5_finish_ctx (&ctx, hash);
MD5_INIT (&ctx);
MD5_UPDATE (a1buf, MD5_HASHLEN * 2, &ctx);
MD5_UPDATE (":", 1, &ctx);
MD5_UPDATE (nonce, strlen (nonce), &ctx);
MD5_UPDATE (":", 1, &ctx);
MD5_UPDATE (a2buf, MD5_HASHLEN * 2, &ctx);
MD5_FINISH (&ctx, hash);
dump_hash (response_digest, hash);
res = (char*) xmalloc (strlen (user)

View File

@ -195,4 +195,25 @@ void *memcpy ();
# define MAP_FAILED ((void *) -1)
#endif
/* Define wrapper macros for different MD5 routines. */
#ifdef HAVE_MD5
#ifdef HAVE_BUILTIN_MD5
# include <gnu-md5.h>
# define MD5_CONTEXT_TYPE struct md5_ctx
# define MD5_INIT(ctx) md5_init_ctx (ctx)
# define MD5_UPDATE(buffer, len, ctx) md5_process_bytes (buffer, len, ctx)
# define MD5_FINISH(ctx, result) md5_finish_ctx (ctx, result)
#endif
#ifdef HAVE_SOLARIS_MD5
# include <md5.h>
# define MD5_CONTEXT_TYPE MD5_CTX
# define MD5_INIT(ctx) MD5Init (ctx)
# define MD5_UPDATE(buffer, len, ctx) MD5Update (ctx, (unsigned char *)(buffer), len)
# define MD5_FINISH(ctx, result) MD5Final ((unsigned char *)(result), ctx)
#endif
#endif /* HAVE_MD5 */
#endif /* SYSDEP_H */