From: Harlan Stenn Date: Mon, 9 Jun 2003 08:35:19 +0000 (-0400) Subject: [Bug 87] Use md5 from the OS if available. X-Git-Tag: NTP_4_1_80_RC1~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6b882aad35eb716d1cce397a7ade7139f9d485e4;p=thirdparty%2Fntp.git [Bug 87] Use md5 from the OS if available. bk: 3ee446c7mqPD1RFVBt5V-v3_Kt1AvQ --- diff --git a/configure.in b/configure.in index f2f099427..ea6ed93b0 100644 --- a/configure.in +++ b/configure.in @@ -226,6 +226,9 @@ AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent, , , -lsocket)) AC_CHECK_FUNC(openlog, , AC_CHECK_LIB(gen, openlog, , AC_CHECK_LIB(syslog, openlog, , , -lsocket))) +AC_CHECK_LIB(md5, MD5Init, , + AC_CHECK_LIB(md, MD5Init)) +AC_CHECK_FUNCS(MD5Init) dnl HMS: What a hack... AC_CHECK_HEADERS(readline/history.h readline/readline.h) case "$ac_cv_header_readline_history_h$ac_cv_header_readline_readline_h" in @@ -258,8 +261,9 @@ esac AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt)) AC_HEADER_STDC -AC_CHECK_HEADERS(bstring.h errno.h fcntl.h ieeefp.h math.h memory.h netdb.h) -AC_CHECK_HEADERS(poll.h) +AC_CHECK_HEADERS(bstring.h errno.h fcntl.h ieeefp.h math.h) +AC_CHECK_HEADERS(md5.h) +AC_CHECK_HEADERS(memory.h netdb.h poll.h) AC_CHECK_HEADERS(sched.h sgtty.h stdlib.h string.h termio.h) AC_CHECK_HEADERS(termios.h timepps.h timex.h unistd.h) case "$host" in diff --git a/include/Makefile.am b/include/Makefile.am index 1f92409ba..8f8b934af 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -34,6 +34,7 @@ noinst_HEADERS = \ ntp_io.h \ ntp_machine.h \ ntp_malloc.h \ + ntp_md5.h \ ntp_proto.h \ ntp_refclock.h \ ntp_request.h \ diff --git a/include/ntp_md5.h b/include/ntp_md5.h new file mode 100644 index 000000000..bb6985a2f --- /dev/null +++ b/include/ntp_md5.h @@ -0,0 +1,9 @@ +/* + * ntp_md5.h: deal with md5.h headers + */ + +#ifdef HAVE_MD5_H +# include +#else +# include "rsa_md5.h" +#endif diff --git a/include/rsa_md5.h b/include/rsa_md5.h index 63928dd4f..824164760 100644 --- a/include/rsa_md5.h +++ b/include/rsa_md5.h @@ -37,12 +37,12 @@ typedef struct { UINT4 state[4]; /* state (ABCD) */ UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ unsigned char buffer[64]; /* input buffer */ -} ntp_MD5_CTX; +} MD5_CTX; -void MD5Init PROTO_LIST ((ntp_MD5_CTX *)); +void MD5Init PROTO_LIST ((MD5_CTX *)); void MD5Update PROTO_LIST - ((ntp_MD5_CTX *, unsigned char *, unsigned int)); -void MD5Final PROTO_LIST ((unsigned char [16], ntp_MD5_CTX *)); + ((MD5_CTX *, unsigned char *, unsigned int)); +void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *)); #ifdef __cplusplus } diff --git a/libntp/Makefile.am b/libntp/Makefile.am index 84a2adac4..75b5505b1 100644 --- a/libntp/Makefile.am +++ b/libntp/Makefile.am @@ -33,4 +33,3 @@ noinst_HEADERS = lib_strbuf.h log.h EXTRA_DIST = README - diff --git a/libntp/a_md5encrypt.c b/libntp/a_md5encrypt.c index 0e2799016..ad7abf86c 100644 --- a/libntp/a_md5encrypt.c +++ b/libntp/a_md5encrypt.c @@ -26,7 +26,7 @@ #include "ntp_stdlib.h" #include "ntp.h" #include "global.h" -#include "rsa_md5.h" +#include "ntp_md5.h" /* * MD5authencrypt - generate MD5 message authenticator @@ -40,7 +40,7 @@ MD5authencrypt( int length /* packet length */ ) { - ntp_MD5_CTX md5; + MD5_CTX md5; u_char digest[16]; /* @@ -68,7 +68,7 @@ MD5authdecrypt( int size /* MAC size */ ) { - ntp_MD5_CTX md5; + MD5_CTX md5; u_char digest[16]; /* @@ -91,7 +91,7 @@ MD5authdecrypt( u_int32 addr2refid(struct sockaddr_storage *addr) { - ntp_MD5_CTX md5; + MD5_CTX md5; u_char digest[16]; u_int32 addr_refid; diff --git a/libntp/md5c.c b/libntp/md5c.c index e6327c9b6..07eec6c2f 100644 --- a/libntp/md5c.c +++ b/libntp/md5c.c @@ -24,7 +24,8 @@ */ #include "global.h" -#include "rsa_md5.h" +#ifndef HAVE_MD5INIT +#include "ntp_md5.h" /* Constants for MD5Transform routine. */ @@ -98,7 +99,7 @@ static unsigned char PADDING[64] = { */ void MD5Init( - ntp_MD5_CTX *context /* context */ + MD5_CTX *context /* context */ ) { context->count[0] = context->count[1] = 0; @@ -117,7 +118,7 @@ MD5Init( */ void MD5Update ( - ntp_MD5_CTX *context, /* context */ + MD5_CTX *context, /* context */ unsigned char *input, /* input block */ unsigned int inputLen /* length of input block */ ) @@ -162,7 +163,7 @@ MD5Update ( void MD5Final ( unsigned char digest[16], /* message digest */ - ntp_MD5_CTX *context /* context */ + MD5_CTX *context /* context */ ) { unsigned char bits[8]; @@ -348,3 +349,6 @@ MD5_memset ( for (i = 0; i < len; i++) ((char *)output)[i] = (char)value; } +#else +int md5_bs; +#endif