Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/dhcpcd/dist Import dhcpcd-7.0.0-rc3 with the fo...



details:   https://anonhg.NetBSD.org/src/rev/aadd0cea9b28
branches:  trunk
changeset: 356645:aadd0cea9b28
user:      roy <roy%NetBSD.org@localhost>
date:      Sat Oct 07 14:05:36 2017 +0000

description:
Import dhcpcd-7.0.0-rc3 with the following noteable changes:
  *  Fixed handling RA's from multiple routers
  *  Fixed changing to a better route based on gateway
  *  IPv6 default route is now deleted when config is not persistent
  *  Use hmac(3) if available in libc to reduce binary size

Fixes PR bin/52554

diffstat:

 external/bsd/dhcpcd/dist/compat/crypt/hmac.c         |  191 +++++++++++++++++++
 external/bsd/dhcpcd/dist/compat/crypt/hmac.h         |   40 +++
 external/bsd/dhcpcd/dist/compat/crypt/md5.h          |    2 +-
 external/bsd/dhcpcd/dist/compat/strlcpy.c            |   51 +++++
 external/bsd/dhcpcd/dist/compat/strlcpy.h            |   24 ++
 external/bsd/dhcpcd/dist/configure                   |   50 ++++-
 external/bsd/dhcpcd/dist/src/auth.c                  |   31 +-
 external/bsd/dhcpcd/dist/src/defs.h                  |    2 +-
 external/bsd/dhcpcd/dist/src/dhcp6.c                 |   14 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.8.in             |    6 +-
 external/bsd/dhcpcd/dist/src/dhcpcd.conf             |    4 +-
 external/bsd/dhcpcd/dist/src/if-linux.c              |    5 +
 external/bsd/dhcpcd/dist/src/ipv4.c                  |    5 +-
 external/bsd/dhcpcd/dist/src/ipv6.c                  |   25 +-
 external/bsd/dhcpcd/dist/src/ipv6nd.c                |   21 +-
 external/bsd/dhcpcd/dist/src/ipv6nd.h                |    3 -
 external/bsd/dhcpcd/dist/src/route.c                 |   30 +--
 external/bsd/dhcpcd/dist/tests/crypt/Makefile        |   13 +-
 external/bsd/dhcpcd/dist/tests/crypt/test_hmac_md5.c |   48 ++--
 external/bsd/dhcpcd/dist/tests/eloop-bench/Makefile  |   12 +-
 20 files changed, 451 insertions(+), 126 deletions(-)

diffs (truncated from 1134 to 300 lines):

diff -r 5e1fe248aa77 -r aadd0cea9b28 external/bsd/dhcpcd/dist/compat/crypt/hmac.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/dhcpcd/dist/compat/crypt/hmac.c      Sat Oct 07 14:05:36 2017 +0000
@@ -0,0 +1,191 @@
+/*     $NetBSD: hmac.c,v 1.1.1.1 2017/10/07 14:05:36 roy Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <string.h>
+#include <stdlib.h>
+
+#include "config.h"
+
+#if defined(HAVE_MD5_H) && !defined(DEPGEN)
+#include <md5.h>
+#endif
+
+#ifdef SHA2_H
+#  include SHA2_H
+#endif
+
+#ifndef __arraycount
+#define        __arraycount(__x)       (sizeof(__x) / sizeof(__x[0]))
+#endif
+
+#if 0
+#include <md2.h>
+#include <md4.h>
+#include <md5.h>
+#include <rmd160.h>
+#include <sha1.h>
+#include <sha2.h>
+#endif
+
+#ifndef MD5_BLOCK_LENGTH
+#define        MD5_BLOCK_LENGTH        64
+#endif
+#ifndef SHA256_BLOCK_LENGTH
+#define        SHA256_BLOCK_LENGTH     64
+#endif
+
+#define HMAC_SIZE      128
+#define HMAC_IPAD      0x36
+#define HMAC_OPAD      0x5C
+
+static const struct hmac {
+       const char *name;
+       size_t ctxsize;
+       size_t digsize;
+       size_t blocksize;
+       void (*init)(void *);
+       void (*update)(void *, const uint8_t *, unsigned int);
+       void (*final)(uint8_t *, void *);
+} hmacs[] = {
+#if 0
+       {
+               "md2", sizeof(MD2_CTX), MD2_DIGEST_LENGTH, MD2_BLOCK_LENGTH,
+               (void *)MD2Init, (void *)MD2Update, (void *)MD2Final,
+       },
+       {
+               "md4", sizeof(MD4_CTX), MD4_DIGEST_LENGTH, MD4_BLOCK_LENGTH,
+               (void *)MD4Init, (void *)MD4Update, (void *)MD4Final,
+       },
+#endif
+       {
+               "md5", sizeof(MD5_CTX), MD5_DIGEST_LENGTH, MD5_BLOCK_LENGTH,
+               (void *)MD5Init, (void *)MD5Update, (void *)MD5Final,
+       },
+#if 0
+       {
+               "rmd160", sizeof(RMD160_CTX), RMD160_DIGEST_LENGTH,
+               RMD160_BLOCK_LENGTH,
+               (void *)RMD160Init, (void *)RMD160Update, (void *)RMD160Final,
+       },
+       {
+               "sha1", sizeof(SHA1_CTX), SHA1_DIGEST_LENGTH, SHA1_BLOCK_LENGTH,
+               (void *)SHA1Init, (void *)SHA1Update, (void *)SHA1Final,
+       },
+       {
+               "sha224", sizeof(SHA224_CTX), SHA224_DIGEST_LENGTH,
+               SHA224_BLOCK_LENGTH,
+               (void *)SHA224_Init, (void *)SHA224_Update,
+               (void *)SHA224_Final,
+       },
+#endif
+       {
+               "sha256", sizeof(SHA256_CTX), SHA256_DIGEST_LENGTH,
+               SHA256_BLOCK_LENGTH,
+               (void *)SHA256_Init, (void *)SHA256_Update,
+               (void *)SHA256_Final,
+       },
+#if 0
+       {
+               "sha384", sizeof(SHA384_CTX), SHA384_DIGEST_LENGTH,
+               SHA384_BLOCK_LENGTH,
+               (void *)SHA384_Init, (void *)SHA384_Update,
+               (void *)SHA384_Final,
+       },
+       {
+               "sha512", sizeof(SHA512_CTX), SHA512_DIGEST_LENGTH,
+               SHA512_BLOCK_LENGTH,
+               (void *)SHA512_Init, (void *)SHA512_Update,
+               (void *)SHA512_Final,
+       },
+#endif
+};
+
+static const struct hmac *
+hmac_find(const char *name)
+{
+       for (size_t i = 0; i < __arraycount(hmacs); i++) {
+               if (strcmp(hmacs[i].name, name) != 0)
+                       continue;
+               return &hmacs[i];
+       }
+       return NULL;
+}
+
+ssize_t
+hmac(const char *name,
+    const void *key, size_t klen,
+    const void *text, size_t tlen,
+    void *digest, size_t dlen)
+{
+       uint8_t ipad[HMAC_SIZE], opad[HMAC_SIZE], d[HMAC_SIZE];
+       const uint8_t *k = key;
+       const struct hmac *h;
+       uint64_t c[32];
+       void *p;
+
+       if ((h = hmac_find(name)) == NULL)
+               return -1;
+
+
+       if (klen > h->blocksize) {
+               (*h->init)(c);
+               (*h->update)(c, k, (unsigned int)klen);
+               (*h->final)(d, c);
+               k = (void *)d;
+               klen = h->digsize;
+       }
+
+       /* Form input and output pads for the digests */
+       for (size_t i = 0; i < sizeof(ipad); i++) {
+               ipad[i] = (i < klen ? k[i] : 0) ^ HMAC_IPAD;
+               opad[i] = (i < klen ? k[i] : 0) ^ HMAC_OPAD;
+       }
+
+       p = dlen >= h->digsize ? digest : d;
+       if (p != digest) {
+               memcpy(p, digest, dlen);
+               memset((char *)p + dlen, 0, h->digsize - dlen);
+       }
+       (*h->init)(c);
+       (*h->update)(c, ipad, (unsigned int)h->blocksize);
+       (*h->update)(c, text, (unsigned int)tlen);
+       (*h->final)(p, c);
+
+       (*h->init)(c);
+       (*h->update)(c, opad, (unsigned int)h->blocksize);
+       (*h->update)(c, digest, (unsigned int)h->digsize);
+       (*h->final)(p, c);
+
+       if (p != digest)
+               memcpy(digest, p, dlen);
+
+       return (ssize_t)h->digsize;
+}
diff -r 5e1fe248aa77 -r aadd0cea9b28 external/bsd/dhcpcd/dist/compat/crypt/hmac.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/dhcpcd/dist/compat/crypt/hmac.h      Sat Oct 07 14:05:36 2017 +0000
@@ -0,0 +1,40 @@
+/*     $NetBSD: hmac.h,v 1.1.1.1 2017/10/07 14:05:36 roy Exp $ */
+
+/*-
+ * Copyright (c) 2016 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef HMAC_H
+#define HMAC_H
+
+#include <sys/types.h>
+
+ssize_t         hmac(const char *, const void *, size_t, const void *, size_t, void *,
+   size_t);
+
+#endif
diff -r 5e1fe248aa77 -r aadd0cea9b28 external/bsd/dhcpcd/dist/compat/crypt/md5.h
--- a/external/bsd/dhcpcd/dist/compat/crypt/md5.h       Sat Oct 07 13:29:28 2017 +0000
+++ b/external/bsd/dhcpcd/dist/compat/crypt/md5.h       Sat Oct 07 14:05:36 2017 +0000
@@ -19,7 +19,7 @@
 #define MD5_H_
 
 #define MD5_DIGEST_LENGTH      16
-#define MD5_BLOCK_LENGTH       64
+#define MD5_BLOCK_LENGTH       64ULL
 
 typedef struct MD5Context {
        uint32_t state[4];      /* state (ABCD) */
diff -r 5e1fe248aa77 -r aadd0cea9b28 external/bsd/dhcpcd/dist/compat/strlcpy.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/dhcpcd/dist/compat/strlcpy.c Sat Oct 07 14:05:36 2017 +0000
@@ -0,0 +1,51 @@
+/*     $OpenBSD: strlcpy.c,v 1.15 2016/10/16 17:37:39 dtucker Exp $    */
+
+/*
+ * Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller%courtesan.com@localhost>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+
+#include "strlcpy.h"
+
+/*
+ * Copy string src to buffer dst of size dsize.  At most dsize-1
+ * chars will be copied.  Always NUL terminates (unless dsize == 0).
+ * Returns strlen(src); if retval >= dsize, truncation occurred.
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t dsize)
+{
+       const char *osrc = src;
+       size_t nleft = dsize;
+
+       /* Copy as many bytes as will fit. */
+       if (nleft != 0) {
+               while (--nleft != 0) {
+                       if ((*dst++ = *src++) == '\0')
+                               break;
+               }
+       }
+
+       /* Not enough room in dst, add NUL and traverse rest of src. */
+       if (nleft == 0) {
+               if (dsize != 0)
+                       *dst = '\0';            /* NUL-terminate dst */



Home | Main Index | Thread Index | Old Index