summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libc')
-rw-r--r--usr/src/lib/libc/Makefile.targ5
-rw-r--r--usr/src/lib/libc/amd64/Makefile11
-rw-r--r--usr/src/lib/libc/i386/Makefile.com11
-rw-r--r--usr/src/lib/libc/port/gen/arc4random.c174
-rw-r--r--usr/src/lib/libc/port/gen/arc4random_uniform.c56
-rw-r--r--usr/src/lib/libc/port/gen/explicit_bzero.c21
-rw-r--r--usr/src/lib/libc/port/gen/getentropy.c41
-rw-r--r--usr/src/lib/libc/port/gen/sh_locks.c2
-rw-r--r--usr/src/lib/libc/port/mapfile-vers12
-rw-r--r--usr/src/lib/libc/port/sys/getrandom.c24
-rw-r--r--usr/src/lib/libc/sparc/Makefile.com11
-rw-r--r--usr/src/lib/libc/sparcv9/Makefile.com11
12 files changed, 377 insertions, 2 deletions
diff --git a/usr/src/lib/libc/Makefile.targ b/usr/src/lib/libc/Makefile.targ
index cb01074143..2322885346 100644
--- a/usr/src/lib/libc/Makefile.targ
+++ b/usr/src/lib/libc/Makefile.targ
@@ -288,6 +288,11 @@ $(UNICODEOBJS:%=pics/%): $(SRC)/common/unicode/$$(@F:.o=.c)
$(COMPILE.c) -o $@ $(SRC)/common/unicode/$(@F:.o=.c)
$(POST_PROCESS_O)
+$(CHACHAOBJS:%=pics/%): $(SRC)/common/crypto/chacha/$$(@F:.o=.c)
+ $(COMPILE.c) -I$(SRC)/common/crypto/chacha -DKEYSTREAM_ONLY \
+ -o $@ $(SRC)/common/crypto/chacha/$(@F:.o=.c)
+ $(POST_PROCESS_O)
+
# DTrace rules
pics/%.o: $(LIBCBASE)/../port/threads/%.d $(THREADSOBJS:%=pics/%)
$(COMPILE.d) -C -xlazyload -s $< -o $@ $(THREADSOBJS:%=pics/%)
diff --git a/usr/src/lib/libc/amd64/Makefile b/usr/src/lib/libc/amd64/Makefile
index d9f4e5ddc2..0627569c46 100644
--- a/usr/src/lib/libc/amd64/Makefile
+++ b/usr/src/lib/libc/amd64/Makefile
@@ -89,6 +89,9 @@ FPASMOBJS= \
ATOMICOBJS= \
atomic.o
+CHACHAOBJS= \
+ chacha.o
+
XATTROBJS= \
xattr_common.o
COMOBJS= \
@@ -106,6 +109,8 @@ GENOBJS= \
_getsp.o \
abs.o \
alloca.o \
+ arc4random.o \
+ arc4random_uniform.o \
attrat.o \
byteorder.o \
cuexit.o \
@@ -202,6 +207,7 @@ COMSYSOBJS= \
getpid.o \
getpmsg.o \
getppid.o \
+ getrandom.o \
getrlimit.o \
getuid.o \
gtty.o \
@@ -374,6 +380,7 @@ PORTGEN= \
euclen.o \
event_port.o \
execvp.o \
+ explicit_bzero.o \
fattach.o \
fdetach.o \
fdopendir.o \
@@ -388,6 +395,7 @@ PORTGEN= \
getcwd.o \
getdate_err.o \
getdtblsize.o \
+ getentropy.o \
getenv.o \
getexecname.o \
getgrnam.o \
@@ -925,6 +933,7 @@ MOSTOBJS= \
$(I386FPOBJS) \
$(FPASMOBJS) \
$(ATOMICOBJS) \
+ $(CHACHAOBJS) \
$(XATTROBJS) \
$(COMOBJS) \
$(GENOBJS) \
@@ -1167,6 +1176,8 @@ $(PORTSTDIO_C89:%=pics/%) := \
$(PORTI18N_COND:%=pics/%) := \
CPPFLAGS += -D_WCS_LONGLONG
+pics/arc4random.o := CPPFLAGS += -I$(SRC)/common/crypto/chacha
+
.KEEP_STATE:
all: $(LIBS) $(LIB_PIC)
diff --git a/usr/src/lib/libc/i386/Makefile.com b/usr/src/lib/libc/i386/Makefile.com
index 0c7b9b2c1b..418c469019 100644
--- a/usr/src/lib/libc/i386/Makefile.com
+++ b/usr/src/lib/libc/i386/Makefile.com
@@ -89,6 +89,9 @@ FPASMOBJS= \
ATOMICOBJS= \
atomic.o
+CHACHAOBJS= \
+ chacha.o
+
XATTROBJS= \
xattr_common.o
@@ -113,6 +116,8 @@ GENOBJS= \
_mul64.o \
abs.o \
alloca.o \
+ arc4random.o \
+ arc4random_uniform.o \
byteorder.o \
byteorder64.o \
cuexit.o \
@@ -226,6 +231,7 @@ COMSYSOBJS= \
getpid.o \
getpmsg.o \
getppid.o \
+ getrandom.o \
getrlimit.o \
getuid.o \
gtty.o \
@@ -407,6 +413,7 @@ PORTGEN= \
euclen.o \
event_port.o \
execvp.o \
+ explicit_bzero.o \
fattach.o \
fdetach.o \
fdopendir.o \
@@ -421,6 +428,7 @@ PORTGEN= \
getcwd.o \
getdate_err.o \
getdtblsize.o \
+ getentropy.o \
getenv.o \
getexecname.o \
getgrnam.o \
@@ -961,6 +969,7 @@ MOSTOBJS= \
$(FPOBJS) \
$(FPASMOBJS) \
$(ATOMICOBJS) \
+ $(CHACHAOBJS) \
$(XATTROBJS) \
$(COMOBJS) \
$(DTRACEOBJS) \
@@ -1228,6 +1237,8 @@ $(PORTSTDIO_C89:%=pics/%) := \
$(PORTI18N_COND:%=pics/%) := \
CPPFLAGS += -D_WCS_LONGLONG
+pics/arc4random.o := CPPFLAGS += -I$(SRC)/common/crypto/chacha
+
.KEEP_STATE:
all: $(LIBS) $(LIB_PIC)
diff --git a/usr/src/lib/libc/port/gen/arc4random.c b/usr/src/lib/libc/port/gen/arc4random.c
new file mode 100644
index 0000000000..d82f12bd2a
--- /dev/null
+++ b/usr/src/lib/libc/port/gen/arc4random.c
@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 1996, David Mazieres <dm@uun.org>
+ * Copyright (c) 2008, Damien Miller <djm@openbsd.org>
+ * Copyright (c) 2013, Markus Friedl <markus@openbsd.org>
+ * Copyright (c) 2015 Joyent, Inc.
+ *
+ * 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.
+ */
+
+/*
+ * arc4random(3C), derived from the OpenBSD version.
+ *
+ * To ensure that a parent process and any potential children see a different
+ * state, we mmap the entire arc4_state_t structure and mark that page as
+ * MC_INHERIT_ZERO. That ensures that the data is zeroed, and really the bit we
+ * care about, arc4_init is set to B_FALSE, which will cause the child to
+ * reinitialize it when they first use the interface.
+ */
+
+#include <synch.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <sys/sysmacros.h>
+#include <chacha.h>
+
+#include "thr_uberdata.h"
+
+#define ARC4_KEYSZ 32
+#define ARC4_IVSZ 8
+#define ARC4_BLOCKSZ 64
+#define ARC4_KSBUFSZ (16*ARC4_BLOCKSZ) /* key stream byte size */
+#define ARC4_COUNT 1600000 /* bytes for rekeying */
+
+typedef struct arc4_state {
+ boolean_t arc4_init; /* Initialized? */
+ size_t arc4_have; /* Valid bytes in arc4_buf */
+ size_t arc4_count; /* bytes until reseed */
+ chacha_ctx_t arc4_chacha; /* chacha context */
+ uint8_t arc4_buf[ARC4_KSBUFSZ]; /* keystream blocks */
+} arc4_state_t;
+
+static arc4_state_t *arc4;
+static mutex_t arc4_lock = DEFAULTMUTEX;
+
+static void
+arc4_init(uint8_t *buf, size_t n)
+{
+ if (n < ARC4_KEYSZ + ARC4_IVSZ)
+ abort();
+
+ chacha_keysetup(&arc4->arc4_chacha, buf, ARC4_KEYSZ * 8, 0);
+ chacha_ivsetup(&arc4->arc4_chacha, buf + ARC4_KEYSZ);
+}
+
+static void
+arc4_rekey(uint8_t *data, size_t datalen)
+{
+ /* Fill in the keystream buffer */
+ chacha_encrypt_bytes(&arc4->arc4_chacha, arc4->arc4_buf, arc4->arc4_buf,
+ sizeof (arc4->arc4_buf));
+
+ /* mix in optional user provided data */
+ if (data != NULL) {
+ size_t i, m;
+
+ m = MIN(datalen, ARC4_KEYSZ + ARC4_IVSZ);
+ for (i = 0; i < m; i++)
+ arc4->arc4_buf[i] ^= data[i];
+ }
+
+ /* immediately reinit for backtracking resistence */
+ arc4_init(arc4->arc4_buf, ARC4_KEYSZ + ARC4_IVSZ);
+ explicit_bzero(arc4->arc4_buf, ARC4_KEYSZ + ARC4_IVSZ);
+ arc4->arc4_have = sizeof (arc4->arc4_buf) - ARC4_KEYSZ - ARC4_IVSZ;
+}
+
+static void
+arc4_stir(size_t len)
+{
+ uint8_t rnd[ARC4_KEYSZ + ARC4_IVSZ];
+
+ if (arc4->arc4_count <= len) {
+ if (getentropy(rnd, sizeof (rnd)) == -1)
+ abort();
+
+ if (arc4->arc4_init == B_FALSE) {
+ arc4_init(rnd, sizeof (rnd));
+ arc4->arc4_init = B_TRUE;
+ } else {
+ arc4_rekey(rnd, sizeof (rnd));
+ }
+ explicit_bzero(rnd, sizeof (rnd));
+
+ /* Invalidate the data buffer */
+ arc4->arc4_have = 0;
+ memset(arc4->arc4_buf, 0, sizeof (arc4->arc4_buf));
+ arc4->arc4_count = ARC4_COUNT;
+ }
+
+ if (arc4->arc4_count <= len) {
+ arc4->arc4_count = 0;
+ } else {
+ arc4->arc4_count -= len;
+ }
+}
+
+static void
+arc4_fill(uint8_t *buf, size_t n)
+{
+ if (arc4 == NULL) {
+ size_t pgsz, mapsz;
+ void *a;
+
+ pgsz = sysconf(_SC_PAGESIZE);
+ if (pgsz == -1)
+ abort();
+ mapsz = P2ROUNDUP(sizeof (arc4_state_t), pgsz);
+ a = mmap(NULL, mapsz, PROT_READ | PROT_WRITE,
+ MAP_PRIVATE | MAP_ANON, -1, 0);
+ if (a == MAP_FAILED)
+ abort();
+ if (memcntl(a, mapsz, MC_INHERIT_ZERO, 0, 0, 0) != 0)
+ abort();
+ arc4 = a;
+ }
+
+ arc4_stir(n);
+ while (n > 0) {
+ if (arc4->arc4_have > 0) {
+ uint8_t *keystream;
+ size_t m = MIN(n, arc4->arc4_have);
+
+ keystream = arc4->arc4_buf + sizeof (arc4->arc4_buf) -
+ arc4->arc4_have;
+ memcpy(buf, keystream, m);
+ explicit_bzero(keystream, m);
+ buf += m;
+ n -= m;
+ arc4->arc4_have -= m;
+ }
+ if (arc4->arc4_have == 0)
+ arc4_rekey(NULL, 0);
+ }
+}
+
+uint32_t
+arc4random(void)
+{
+ uint32_t out;
+
+ lmutex_lock(&arc4_lock);
+ arc4_fill((uint8_t *)&out, sizeof (uint32_t));
+ lmutex_unlock(&arc4_lock);
+ return (out);
+}
+
+void
+arc4random_buf(void *buf, size_t n)
+{
+ lmutex_lock(&arc4_lock);
+ arc4_fill(buf, n);
+ lmutex_unlock(&arc4_lock);
+}
diff --git a/usr/src/lib/libc/port/gen/arc4random_uniform.c b/usr/src/lib/libc/port/gen/arc4random_uniform.c
new file mode 100644
index 0000000000..1aa9a622f1
--- /dev/null
+++ b/usr/src/lib/libc/port/gen/arc4random_uniform.c
@@ -0,0 +1,56 @@
+/* $OpenBSD: arc4random_uniform.c,v 1.1 2014/07/12 13:24:54 deraadt Exp $ */
+
+/*
+ * Copyright (c) 2008, Damien Miller <djm@openbsd.org>
+ *
+ * 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 <stdlib.h>
+
+/*
+ * Calculate a uniformly distributed random number less than upper_bound
+ * avoiding "modulo bias".
+ *
+ * Uniformity is achieved by generating new random numbers until the one
+ * returned is outside the range [0, 2**32 % upper_bound). This
+ * guarantees the selected random number will be inside
+ * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound)
+ * after reduction modulo upper_bound.
+ */
+uint32_t
+arc4random_uniform(uint32_t upper_bound)
+{
+ uint32_t r, min;
+
+ if (upper_bound < 2)
+ return 0;
+
+ /* 2**32 % x == (2**32 - x) % x */
+ min = -upper_bound % upper_bound;
+
+ /*
+ * This could theoretically loop forever but each retry has
+ * p > 0.5 (worst case, usually far better) of selecting a
+ * number inside the range we need, so it should rarely need
+ * to re-roll.
+ */
+ for (;;) {
+ r = arc4random();
+ if (r >= min)
+ break;
+ }
+
+ return r % upper_bound;
+}
diff --git a/usr/src/lib/libc/port/gen/explicit_bzero.c b/usr/src/lib/libc/port/gen/explicit_bzero.c
new file mode 100644
index 0000000000..b27b4b9866
--- /dev/null
+++ b/usr/src/lib/libc/port/gen/explicit_bzero.c
@@ -0,0 +1,21 @@
+/* $OpenBSD: explicit_bzero.c,v 1.3 2014/06/21 02:34:26 matthew Exp $ */
+/*
+ * Public domain.
+ * Written by Matthew Dempsky.
+ */
+
+#include <string.h>
+
+#pragma weak __explicit_bzero_hook
+/* ARGSUSED */
+void
+__explicit_bzero_hook(void *buf, size_t len)
+{
+}
+
+void
+explicit_bzero(void *buf, size_t len)
+{
+ (void) memset(buf, 0, len);
+ __explicit_bzero_hook(buf, len);
+}
diff --git a/usr/src/lib/libc/port/gen/getentropy.c b/usr/src/lib/libc/port/gen/getentropy.c
new file mode 100644
index 0000000000..4392727a95
--- /dev/null
+++ b/usr/src/lib/libc/port/gen/getentropy.c
@@ -0,0 +1,41 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright (c) 2015, Joyent, Inc.
+ */
+
+/*
+ * getentropy(3C) is an OpenBSD compatible wrapper around getrandom(2).
+ */
+
+#include <errno.h>
+#include <sys/random.h>
+
+int
+getentropy(void *buf, size_t buflen)
+{
+ int ret;
+
+ if (buflen > 256) {
+ errno = EIO;
+ return (-1);
+ }
+
+ ret = getrandom(buf, buflen, 0);
+ if (ret == -1 || ret != buflen) {
+ if (errno != EFAULT)
+ errno = EIO;
+ return (-1);
+ }
+
+ return (0);
+}
diff --git a/usr/src/lib/libc/port/gen/sh_locks.c b/usr/src/lib/libc/port/gen/sh_locks.c
index 6583efbc9c..cf879195c6 100644
--- a/usr/src/lib/libc/port/gen/sh_locks.c
+++ b/usr/src/lib/libc/port/gen/sh_locks.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "lint.h"
#include <mtlib.h>
#include <sys/types.h>
diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers
index 68eedf25b0..ed666e9b4d 100644
--- a/usr/src/lib/libc/port/mapfile-vers
+++ b/usr/src/lib/libc/port/mapfile-vers
@@ -2861,6 +2861,7 @@ $endif
_getfp;
_getgroupsbymember;
_getlogin_r;
+ getrandom;
_getsp;
__gettsp;
getvmusage;
@@ -3176,6 +3177,17 @@ $if i386
__udivrem64;
$endif
+#
+# The following functions should become public symbols when they get
+# upstreamed to illumos and become part of their own appropriate symbol
+# version.
+#
+ arc4random;
+ arc4random_buf;
+ arc4random_uniform;
+ explicit_bzero;
+ getentropy;
+
# The following functions should not be exported from libc,
# but /lib/libm.so.2, some older versions of the Studio
# compiler/debugger components, and some ancient programs
diff --git a/usr/src/lib/libc/port/sys/getrandom.c b/usr/src/lib/libc/port/sys/getrandom.c
new file mode 100644
index 0000000000..8e59f526a1
--- /dev/null
+++ b/usr/src/lib/libc/port/sys/getrandom.c
@@ -0,0 +1,24 @@
+/*
+ * This file and its contents are supplied under the terms of the
+ * Common Development and Distribution License ("CDDL"), version 1.0.
+ * You may only use this file in accordance with the terms of version
+ * 1.0 of the CDDL.
+ *
+ * A full copy of the text of the CDDL should have accompanied this
+ * source. A copy of the CDDL is also available via the Internet at
+ * http://www.illumos.org/license/CDDL.
+ */
+
+/*
+ * Copyright (c) 2015 Joyent, Inc.
+ */
+
+#include <sys/types.h>
+#include <sys/syscall.h>
+#include <sys/random.h>
+
+int
+getrandom(void *buf, size_t len, int flags)
+{
+ return (syscall(SYS_getrandom, buf, len, flags));
+}
diff --git a/usr/src/lib/libc/sparc/Makefile.com b/usr/src/lib/libc/sparc/Makefile.com
index 71867bf07d..bcd4b79c8b 100644
--- a/usr/src/lib/libc/sparc/Makefile.com
+++ b/usr/src/lib/libc/sparc/Makefile.com
@@ -115,6 +115,9 @@ $(__GNUC)FPASMOBJS += \
ATOMICOBJS= \
atomic.o
+CHACHAOBJS= \
+ chacha.o
+
XATTROBJS= \
xattr_common.o
@@ -138,6 +141,8 @@ GENOBJS= \
_xregs_clrptr.o \
abs.o \
alloca.o \
+ arc4random.o \
+ arc4random_uniform.o \
ascii_strcasecmp.o \
byteorder.o \
cuexit.o \
@@ -246,6 +251,7 @@ COMSYSOBJS= \
getpid.o \
getpmsg.o \
getppid.o \
+ getrandom.o \
getrlimit.o \
getuid.o \
gtty.o \
@@ -438,6 +444,7 @@ PORTGEN= \
euclen.o \
event_port.o \
execvp.o \
+ explicit_bzero.o \
fattach.o \
fdetach.o \
fdopendir.o \
@@ -452,6 +459,7 @@ PORTGEN= \
getcwd.o \
getdate_err.o \
getdtblsize.o \
+ getentropy.o \
getenv.o \
getexecname.o \
getgrnam.o \
@@ -997,6 +1005,7 @@ MOSTOBJS= \
$(FPOBJS) \
$(FPASMOBJS) \
$(ATOMICOBJS) \
+ $(CHACHAOBJS) \
$(XATTROBJS) \
$(COMOBJS) \
$(DTRACEOBJS) \
@@ -1293,6 +1302,8 @@ $(PORTSTDIO_C89:%=pics/%) := \
$(PORTI18N_COND:%=pics/%) := \
CPPFLAGS += -D_WCS_LONGLONG
+pics/arc4random.o := CPPFLAGS += -I$(SRC)/common/crypto/chacha
+
# Files which need extra optimization
pics/getenv.o := sparc_COPTFLAG = -xO4
diff --git a/usr/src/lib/libc/sparcv9/Makefile.com b/usr/src/lib/libc/sparcv9/Makefile.com
index f6628f8899..87fa17b911 100644
--- a/usr/src/lib/libc/sparcv9/Makefile.com
+++ b/usr/src/lib/libc/sparcv9/Makefile.com
@@ -117,6 +117,9 @@ $(__GNUC)FPASMOBJS += \
ATOMICOBJS= \
atomic.o
+CHACHAOBJS= \
+ chacha.o
+
XATTROBJS= \
xattr_common.o
@@ -137,6 +140,8 @@ GENOBJS= \
_xregs_clrptr.o \
abs.o \
alloca.o \
+ arc4random.o \
+ arc4random_uniform.o \
ascii_strcasecmp.o \
byteorder.o \
cuexit.o \
@@ -229,6 +234,7 @@ COMSYSOBJS= \
getpid.o \
getpmsg.o \
getppid.o \
+ getrandom.o \
getrlimit.o \
getuid.o \
gtty.o \
@@ -398,6 +404,7 @@ PORTGEN= \
euclen.o \
event_port.o \
execvp.o \
+ explicit_bzero.o \
fattach.o \
fdetach.o \
fdopendir.o \
@@ -412,6 +419,7 @@ PORTGEN= \
getcwd.o \
getdate_err.o \
getdtblsize.o \
+ getentropy.o \
getenv.o \
getexecname.o \
getgrnam.o \
@@ -940,6 +948,7 @@ MOSTOBJS= \
$(FPOBJS64) \
$(FPASMOBJS) \
$(ATOMICOBJS) \
+ $(CHACHAOBJS) \
$(XATTROBJS) \
$(COMOBJS) \
$(GENOBJS) \
@@ -1216,6 +1225,8 @@ $(PORTPRINT_W:%=pics/%) := \
$(PORTI18N_COND:%=pics/%) := \
CPPFLAGS += -D_WCS_LONGLONG
+pics/arc4random.o := CPPFLAGS += -I$(SRC)/common/crypto/chacha
+
# Files which need extra optimization
pics/getenv.o := sparcv9_COPTFLAG = -xO4