Module Name:    src
Committed By:   christos
Date:           Wed Jun 29 18:42:18 UTC 2016

Modified Files:
        src/external/bsd/ntp: Makefile.inc
        src/external/bsd/ntp/dist/include: ntp_md5.h
        src/external/bsd/ntp/dist/libntp: a_md5encrypt.c
        src/external/bsd/ntp/dist/ntpd: ntp_control.c ntp_proto.c
        src/external/bsd/ntp/dist/sntp: crypto.c
        src/external/bsd/ntp/include: config.h

Log Message:
Fix MKCRYPTO=no build


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/external/bsd/ntp/Makefile.inc
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/ntp/dist/include/ntp_md5.h
cvs rdiff -u -r1.5 -r1.6 src/external/bsd/ntp/dist/libntp/a_md5encrypt.c
cvs rdiff -u -r1.16 -r1.17 src/external/bsd/ntp/dist/ntpd/ntp_control.c
cvs rdiff -u -r1.12 -r1.13 src/external/bsd/ntp/dist/ntpd/ntp_proto.c
cvs rdiff -u -r1.10 -r1.11 src/external/bsd/ntp/dist/sntp/crypto.c
cvs rdiff -u -r1.17 -r1.18 src/external/bsd/ntp/include/config.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/external/bsd/ntp/Makefile.inc
diff -u src/external/bsd/ntp/Makefile.inc:1.15 src/external/bsd/ntp/Makefile.inc:1.16
--- src/external/bsd/ntp/Makefile.inc:1.15	Tue Dec 23 14:11:14 2014
+++ src/external/bsd/ntp/Makefile.inc	Wed Jun 29 14:42:17 2016
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.15 2014/12/23 19:11:14 christos Exp $
+#	$NetBSD: Makefile.inc,v 1.16 2016/06/29 18:42:17 christos Exp $
 
 .if !defined(NTP_MAKEFILE_INC)
 NTP_MAKEFILE_INC=yes
@@ -58,7 +58,7 @@ version.c: ${LIBNTP}/libntp.a ${.CURDIR}
 .endif # defined(PROG)
 
 .if ${MKCRYPTO:Uno} != "no"
-CPPFLAGS+=-DOPENSSL
+CPPFLAGS+=-DOPENSSL -DAUTOKEY -DUSE_OPENSSL_CRYPTO_RAND
 .endif
 
 .if ${MKINET6:Uno} != "no"

Index: src/external/bsd/ntp/dist/include/ntp_md5.h
diff -u src/external/bsd/ntp/dist/include/ntp_md5.h:1.5 src/external/bsd/ntp/dist/include/ntp_md5.h:1.6
--- src/external/bsd/ntp/dist/include/ntp_md5.h:1.5	Fri Jan  8 16:35:35 2016
+++ src/external/bsd/ntp/dist/include/ntp_md5.h	Wed Jun 29 14:42:17 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ntp_md5.h,v 1.5 2016/01/08 21:35:35 christos Exp $	*/
+/*	$NetBSD: ntp_md5.h,v 1.6 2016/06/29 18:42:17 christos Exp $	*/
 
 /*
  * ntp_md5.h: deal with md5.h headers
@@ -25,12 +25,12 @@
 # endif
 
   typedef MD5_CTX			EVP_MD_CTX;
-# define EVP_get_digestbynid(t)		NULL
+# define EVP_get_digestbynid(t)		((t) ? NULL : NULL)
 # define EVP_md5()			NULL
 # define EVP_MD_CTX_init(c)
 # define EVP_MD_CTX_set_flags(c, f)
-# define EVP_DigestInit(c, dt)		(MD5Init(c), 1)
-# define EVP_DigestInit_ex(c, dt, i)	(MD5Init(c), 1)
+# define EVP_DigestInit(c, dt)		(MD5Init(c), (dt ? 1 : 1))
+# define EVP_DigestInit_ex(c, dt, i)	(MD5Init(c), (dt ? 1 : 1))
 # define EVP_DigestUpdate(c, p, s)	MD5Update(c, (const void *)(p), \
 						  s)
 # define EVP_DigestFinal(c, d, pdl)	\

Index: src/external/bsd/ntp/dist/libntp/a_md5encrypt.c
diff -u src/external/bsd/ntp/dist/libntp/a_md5encrypt.c:1.5 src/external/bsd/ntp/dist/libntp/a_md5encrypt.c:1.6
--- src/external/bsd/ntp/dist/libntp/a_md5encrypt.c:1.5	Sun May  1 19:32:00 2016
+++ src/external/bsd/ntp/dist/libntp/a_md5encrypt.c	Wed Jun 29 14:42:17 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: a_md5encrypt.c,v 1.5 2016/05/01 23:32:00 christos Exp $	*/
+/*	$NetBSD: a_md5encrypt.c,v 1.6 2016/06/29 18:42:17 christos Exp $	*/
 
 /*
  *	digest support for NTP, MD5 and with OpenSSL more
@@ -36,15 +36,11 @@ MD5authencrypt(
 	 * was creaded.
 	 */
 	INIT_SSL();
-#if defined(OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x0090700fL
 	if (!EVP_DigestInit(&ctx, EVP_get_digestbynid(type))) {
 		msyslog(LOG_ERR,
 		    "MAC encrypt: digest init failed");
 		return (0);
 	}
-#else
-	EVP_DigestInit(&ctx, EVP_get_digestbynid(type));
-#endif
 	EVP_DigestUpdate(&ctx, key, cache_secretsize);
 	EVP_DigestUpdate(&ctx, (u_char *)pkt, length);
 	EVP_DigestFinal(&ctx, digest, &len);
@@ -77,15 +73,11 @@ MD5authdecrypt(
 	 * was created.
 	 */
 	INIT_SSL();
-#if defined(OPENSSL) && OPENSSL_VERSION_NUMBER >= 0x0090700fL
 	if (!EVP_DigestInit(&ctx, EVP_get_digestbynid(type))) {
 		msyslog(LOG_ERR,
 		    "MAC decrypt: digest init failed");
 		return (0);
 	}
-#else
-	EVP_DigestInit(&ctx, EVP_get_digestbynid(type));
-#endif
 	EVP_DigestUpdate(&ctx, key, cache_secretsize);
 	EVP_DigestUpdate(&ctx, (u_char *)pkt, length);
 	EVP_DigestFinal(&ctx, digest, &len);
@@ -122,14 +114,12 @@ addr2refid(sockaddr_u *addr)
 	/* MD5 is not used as a crypto hash here. */
 	EVP_MD_CTX_set_flags(&ctx, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
 #endif
-	if (!EVP_DigestInit_ex(&ctx, EVP_md5(), NULL)) {
+#endif
+	if (!EVP_DigestInit(&ctx, EVP_md5())) {
 		msyslog(LOG_ERR,
 		    "MD5 init failed");
 		exit(1);
 	}
-#else
-	EVP_DigestInit(&ctx, EVP_md5());
-#endif
 
 	EVP_DigestUpdate(&ctx, (u_char *)PSOCK_ADDR6(addr),
 	    sizeof(struct in6_addr));

Index: src/external/bsd/ntp/dist/ntpd/ntp_control.c
diff -u src/external/bsd/ntp/dist/ntpd/ntp_control.c:1.16 src/external/bsd/ntp/dist/ntpd/ntp_control.c:1.17
--- src/external/bsd/ntp/dist/ntpd/ntp_control.c:1.16	Sun May  1 19:32:00 2016
+++ src/external/bsd/ntp/dist/ntpd/ntp_control.c	Wed Jun 29 14:42:17 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ntp_control.c,v 1.16 2016/05/01 23:32:00 christos Exp $	*/
+/*	$NetBSD: ntp_control.c,v 1.17 2016/06/29 18:42:17 christos Exp $	*/
 
 /*
  * ntp_control.c - respond to mode 6 control messages and send async
@@ -1653,6 +1653,7 @@ ctl_putuint(
 	ctl_putdata(buffer, (unsigned)( cp - buffer ), 0);
 }
 
+#ifdef AUTOKEY
 /*
  * ctl_putcal - write a decoded calendar data into the response
  */
@@ -1679,6 +1680,7 @@ ctl_putcal(
 
 	return;
 }
+#endif
 
 /*
  * ctl_putfs - write a decoded filestamp into the response
@@ -3662,7 +3664,9 @@ static u_int32 derive_nonce(
 		last_salt_update = current_time;
 	}
 
-	EVP_DigestInit(&ctx, EVP_get_digestbynid(NID_md5));
+	if (!EVP_DigestInit(&ctx, EVP_get_digestbynid(NID_md5))) {
+		msyslog(LOG_NOTICE, "Error in EVP_DigestInit");
+	}
 	EVP_DigestUpdate(&ctx, salt, sizeof(salt));
 	EVP_DigestUpdate(&ctx, &ts_i, sizeof(ts_i));
 	EVP_DigestUpdate(&ctx, &ts_f, sizeof(ts_f));

Index: src/external/bsd/ntp/dist/ntpd/ntp_proto.c
diff -u src/external/bsd/ntp/dist/ntpd/ntp_proto.c:1.12 src/external/bsd/ntp/dist/ntpd/ntp_proto.c:1.13
--- src/external/bsd/ntp/dist/ntpd/ntp_proto.c:1.12	Fri Jun  3 16:39:02 2016
+++ src/external/bsd/ntp/dist/ntpd/ntp_proto.c	Wed Jun 29 14:42:17 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: ntp_proto.c,v 1.12 2016/06/03 20:39:02 christos Exp $	*/
+/*	$NetBSD: ntp_proto.c,v 1.13 2016/06/29 18:42:17 christos Exp $	*/
 
 /*
  * ntp_proto.c - NTP version 4 protocol machinery
@@ -3976,7 +3976,7 @@ peer_xmit(
 		    ntoa(&peer->srcadr), peer->hmode, xkeyid, sendlen,
 		    peer->keynumber));
 #else	/* !AUTOKEY follows */
-	DPRINTF(1, ("peer_xmit: at %ld %s->%s mode %d keyid %08x len %d\n",
+	DPRINTF(1, ("peer_xmit: at %ld %s->%s mode %d keyid %08x len %zu\n",
 		    current_time, peer->dstadr ?
 		    ntoa(&peer->dstadr->sin) : "-",
 		    ntoa(&peer->srcadr), peer->hmode, xkeyid, sendlen));

Index: src/external/bsd/ntp/dist/sntp/crypto.c
diff -u src/external/bsd/ntp/dist/sntp/crypto.c:1.10 src/external/bsd/ntp/dist/sntp/crypto.c:1.11
--- src/external/bsd/ntp/dist/sntp/crypto.c:1.10	Sun May  1 19:32:01 2016
+++ src/external/bsd/ntp/dist/sntp/crypto.c	Wed Jun 29 14:42:17 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: crypto.c,v 1.10 2016/05/01 23:32:01 christos Exp $	*/
+/*	$NetBSD: crypto.c,v 1.11 2016/06/29 18:42:17 christos Exp $	*/
 
 #include <config.h>
 #include "crypto.h"
@@ -28,7 +28,9 @@ make_mac(
 
 	INIT_SSL();
 	key_type = keytype_from_text(cmp_key->type, NULL);
-	EVP_DigestInit(&ctx, EVP_get_digestbynid(key_type));
+	if (!EVP_DigestInit(&ctx, EVP_get_digestbynid(key_type))) {
+		msyslog(LOG_DEBUG, "EVP_DigestInit failed");
+	}
 	EVP_DigestUpdate(&ctx, (const u_char *)cmp_key->key_seq, (u_int)cmp_key->key_len);
 	EVP_DigestUpdate(&ctx, pkt_data, (u_int)pkt_size);
 	EVP_DigestFinal(&ctx, digest, &len);

Index: src/external/bsd/ntp/include/config.h
diff -u src/external/bsd/ntp/include/config.h:1.17 src/external/bsd/ntp/include/config.h:1.18
--- src/external/bsd/ntp/include/config.h:1.17	Fri Jun  3 16:39:03 2016
+++ src/external/bsd/ntp/include/config.h	Wed Jun 29 14:42:17 2016
@@ -8,7 +8,8 @@
 /* #undef ADJTIME_IS_ACCURATE */
 
 /* Support NTP Autokey protocol? */
-#define AUTOKEY 1
+/* in the Makefile */
+/* #undef AUTOKEY */
 
 /* why not HAVE_P_S? */
 /* #undef CALL_PTHREAD_SETCONCURRENCY */
@@ -1611,7 +1612,8 @@ typedef unsigned int	uintptr_t;
 /* #undef USE_FSETOWNCTTY */
 
 /* Use OpenSSL's crypto random functions */
-#define USE_OPENSSL_CRYPTO_RAND 1
+/* In Makefile */
+/* #undef USE_OPENSSL_CRYPTO_RAND */
 
 /* OK to use snprintb()? */
 #define USE_SNPRINTB 1

Reply via email to