17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
58047c9fbSmcpowers * Common Development and Distribution License (the "License").
68047c9fbSmcpowers * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate *
219d31afc5SKrishna Yenduri * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
227c478bd9Sstevel@tonic-gate * Use is subject to license terms.
23*80d5689fSPatrick Mooney *
24*80d5689fSPatrick Mooney * Copyright 2017 Joyent, Inc.
257c478bd9Sstevel@tonic-gate */
267c478bd9Sstevel@tonic-gate
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate /*
297c478bd9Sstevel@tonic-gate * Random number generator pseudo-driver
307c478bd9Sstevel@tonic-gate *
317c478bd9Sstevel@tonic-gate * This is a lightweight driver which calls in to the Kernel Cryptographic
327c478bd9Sstevel@tonic-gate * Framework to do the real work. Kernel modules should NOT depend on this
337c478bd9Sstevel@tonic-gate * driver for /dev/random kernel API.
347c478bd9Sstevel@tonic-gate *
357c478bd9Sstevel@tonic-gate * Applications may ask for 2 types of random bits:
367c478bd9Sstevel@tonic-gate * . High quality random by reading from /dev/random. The output is extracted
377c478bd9Sstevel@tonic-gate * only when a minimum amount of entropy is available.
387c478bd9Sstevel@tonic-gate * . Pseudo-random, by reading from /dev/urandom, that can be generated any
397c478bd9Sstevel@tonic-gate * time.
407c478bd9Sstevel@tonic-gate */
417c478bd9Sstevel@tonic-gate
427c478bd9Sstevel@tonic-gate #include <sys/types.h>
437c478bd9Sstevel@tonic-gate #include <sys/errno.h>
447c478bd9Sstevel@tonic-gate #include <sys/stat.h>
457c478bd9Sstevel@tonic-gate
467c478bd9Sstevel@tonic-gate #include <sys/file.h>
477c478bd9Sstevel@tonic-gate #include <sys/open.h>
487c478bd9Sstevel@tonic-gate #include <sys/poll.h>
497c478bd9Sstevel@tonic-gate #include <sys/uio.h>
507c478bd9Sstevel@tonic-gate #include <sys/cred.h>
517c478bd9Sstevel@tonic-gate #include <sys/modctl.h>
527c478bd9Sstevel@tonic-gate #include <sys/conf.h>
537c478bd9Sstevel@tonic-gate #include <sys/ddi.h>
547c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
557c478bd9Sstevel@tonic-gate #include <sys/random.h>
567c478bd9Sstevel@tonic-gate #include <sys/crypto/impl.h>
577c478bd9Sstevel@tonic-gate
587c478bd9Sstevel@tonic-gate #define DEVRANDOM 0
597c478bd9Sstevel@tonic-gate #define DEVURANDOM 1
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gate #define HASHSIZE 20 /* Assuming a SHA1 hash algorithm */
627c478bd9Sstevel@tonic-gate #define WRITEBUFSIZE 512 /* Size of buffer for write request */
637c478bd9Sstevel@tonic-gate #define MAXRETBYTES 1040 /* Max bytes returned per read. */
647c478bd9Sstevel@tonic-gate /* Must be a multiple of HASHSIZE */
657c478bd9Sstevel@tonic-gate static dev_info_t *rnd_dip;
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate static int rnd_open(dev_t *, int, int, cred_t *);
687c478bd9Sstevel@tonic-gate static int rnd_close(dev_t, int, int, cred_t *);
697c478bd9Sstevel@tonic-gate static int rnd_read(dev_t, struct uio *, cred_t *);
707c478bd9Sstevel@tonic-gate static int rnd_write(dev_t, struct uio *, cred_t *);
717c478bd9Sstevel@tonic-gate static int rnd_chpoll(dev_t, short, int, short *, struct pollhead **);
727c478bd9Sstevel@tonic-gate static int rnd_attach(dev_info_t *, ddi_attach_cmd_t);
737c478bd9Sstevel@tonic-gate static int rnd_detach(dev_info_t *, ddi_detach_cmd_t);
747c478bd9Sstevel@tonic-gate static int rnd_getinfo(dev_info_t *, ddi_info_cmd_t, void *, void **);
757c478bd9Sstevel@tonic-gate
767c478bd9Sstevel@tonic-gate /* DDI declarations */
777c478bd9Sstevel@tonic-gate static struct cb_ops rnd_cb_ops = {
787c478bd9Sstevel@tonic-gate rnd_open, /* open */
797c478bd9Sstevel@tonic-gate rnd_close, /* close */
807c478bd9Sstevel@tonic-gate nodev, /* strategy */
817c478bd9Sstevel@tonic-gate nodev, /* print */
827c478bd9Sstevel@tonic-gate nodev, /* dump */
837c478bd9Sstevel@tonic-gate rnd_read, /* read */
847c478bd9Sstevel@tonic-gate rnd_write, /* write */
857c478bd9Sstevel@tonic-gate nodev, /* ioctl */
867c478bd9Sstevel@tonic-gate nodev, /* devmap */
877c478bd9Sstevel@tonic-gate nodev, /* mmap */
887c478bd9Sstevel@tonic-gate nodev, /* segmap */
897c478bd9Sstevel@tonic-gate rnd_chpoll, /* chpoll */
907c478bd9Sstevel@tonic-gate ddi_prop_op, /* prop_op */
917c478bd9Sstevel@tonic-gate NULL, /* streamtab */
927c478bd9Sstevel@tonic-gate (D_NEW | D_MP), /* cb_flag */
937c478bd9Sstevel@tonic-gate CB_REV, /* cb_rev */
947c478bd9Sstevel@tonic-gate nodev, /* aread */
957c478bd9Sstevel@tonic-gate nodev /* awrite */
967c478bd9Sstevel@tonic-gate };
977c478bd9Sstevel@tonic-gate
987c478bd9Sstevel@tonic-gate static struct dev_ops rnd_ops = {
997c478bd9Sstevel@tonic-gate DEVO_REV, /* devo_rev, */
1007c478bd9Sstevel@tonic-gate 0, /* refcnt */
1017c478bd9Sstevel@tonic-gate rnd_getinfo, /* get_dev_info */
1027c478bd9Sstevel@tonic-gate nulldev, /* identify */
1037c478bd9Sstevel@tonic-gate nulldev, /* probe */
1047c478bd9Sstevel@tonic-gate rnd_attach, /* attach */
1057c478bd9Sstevel@tonic-gate rnd_detach, /* detach */
1067c478bd9Sstevel@tonic-gate nodev, /* reset */
1077c478bd9Sstevel@tonic-gate &rnd_cb_ops, /* driver operations */
1087c478bd9Sstevel@tonic-gate NULL, /* bus operations */
10919397407SSherry Moore NULL, /* power */
11019397407SSherry Moore ddi_quiesce_not_needed, /* quiesce */
1117c478bd9Sstevel@tonic-gate };
1127c478bd9Sstevel@tonic-gate
1137c478bd9Sstevel@tonic-gate /* Modlinkage */
1147c478bd9Sstevel@tonic-gate static struct modldrv modldrv = {
1157c478bd9Sstevel@tonic-gate &mod_driverops,
11619397407SSherry Moore "random number device",
1177c478bd9Sstevel@tonic-gate &rnd_ops
1187c478bd9Sstevel@tonic-gate };
1197c478bd9Sstevel@tonic-gate
1207c478bd9Sstevel@tonic-gate static struct modlinkage modlinkage = { MODREV_1, { &modldrv, NULL } };
1217c478bd9Sstevel@tonic-gate
1227c478bd9Sstevel@tonic-gate
1237c478bd9Sstevel@tonic-gate /* DDI glue */
1247c478bd9Sstevel@tonic-gate
1257c478bd9Sstevel@tonic-gate int
_init(void)1267c478bd9Sstevel@tonic-gate _init(void)
1277c478bd9Sstevel@tonic-gate {
1287c478bd9Sstevel@tonic-gate return (mod_install(&modlinkage));
1297c478bd9Sstevel@tonic-gate }
1307c478bd9Sstevel@tonic-gate
1317c478bd9Sstevel@tonic-gate int
_fini(void)1327c478bd9Sstevel@tonic-gate _fini(void)
1337c478bd9Sstevel@tonic-gate {
1347c478bd9Sstevel@tonic-gate return (mod_remove(&modlinkage));
1357c478bd9Sstevel@tonic-gate }
1367c478bd9Sstevel@tonic-gate
1377c478bd9Sstevel@tonic-gate int
_info(struct modinfo * modinfop)1387c478bd9Sstevel@tonic-gate _info(struct modinfo *modinfop)
1397c478bd9Sstevel@tonic-gate {
1407c478bd9Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop));
1417c478bd9Sstevel@tonic-gate }
1427c478bd9Sstevel@tonic-gate
1437c478bd9Sstevel@tonic-gate static int
rnd_attach(dev_info_t * dip,ddi_attach_cmd_t cmd)1447c478bd9Sstevel@tonic-gate rnd_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
1457c478bd9Sstevel@tonic-gate {
1467c478bd9Sstevel@tonic-gate if (cmd != DDI_ATTACH)
1477c478bd9Sstevel@tonic-gate return (DDI_FAILURE);
1487c478bd9Sstevel@tonic-gate
1497c478bd9Sstevel@tonic-gate if (ddi_create_minor_node(dip, "random", S_IFCHR, DEVRANDOM,
1507c478bd9Sstevel@tonic-gate DDI_PSEUDO, 0) == DDI_FAILURE) {
1517c478bd9Sstevel@tonic-gate ddi_remove_minor_node(dip, NULL);
1527c478bd9Sstevel@tonic-gate return (DDI_FAILURE);
1537c478bd9Sstevel@tonic-gate }
1547c478bd9Sstevel@tonic-gate if (ddi_create_minor_node(dip, "urandom", S_IFCHR, DEVURANDOM,
1557c478bd9Sstevel@tonic-gate DDI_PSEUDO, 0) == DDI_FAILURE) {
1567c478bd9Sstevel@tonic-gate ddi_remove_minor_node(dip, NULL);
1577c478bd9Sstevel@tonic-gate return (DDI_FAILURE);
1587c478bd9Sstevel@tonic-gate }
1597c478bd9Sstevel@tonic-gate
1607c478bd9Sstevel@tonic-gate rnd_dip = dip;
1617c478bd9Sstevel@tonic-gate
1627c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
1637c478bd9Sstevel@tonic-gate }
1647c478bd9Sstevel@tonic-gate
1657c478bd9Sstevel@tonic-gate static int
rnd_detach(dev_info_t * dip,ddi_detach_cmd_t cmd)1667c478bd9Sstevel@tonic-gate rnd_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
1677c478bd9Sstevel@tonic-gate {
1687c478bd9Sstevel@tonic-gate if (cmd != DDI_DETACH)
1697c478bd9Sstevel@tonic-gate return (DDI_FAILURE);
1707c478bd9Sstevel@tonic-gate
1717c478bd9Sstevel@tonic-gate rnd_dip = NULL;
1727c478bd9Sstevel@tonic-gate ddi_remove_minor_node(dip, NULL);
1737c478bd9Sstevel@tonic-gate
1747c478bd9Sstevel@tonic-gate return (DDI_SUCCESS);
1757c478bd9Sstevel@tonic-gate }
1767c478bd9Sstevel@tonic-gate
1777c478bd9Sstevel@tonic-gate /*ARGSUSED*/
1787c478bd9Sstevel@tonic-gate static int
rnd_getinfo(dev_info_t * dip,ddi_info_cmd_t infocmd,void * arg,void ** result)1797c478bd9Sstevel@tonic-gate rnd_getinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg, void **result)
1807c478bd9Sstevel@tonic-gate {
1817c478bd9Sstevel@tonic-gate int error;
1827c478bd9Sstevel@tonic-gate
1837c478bd9Sstevel@tonic-gate switch (infocmd) {
1847c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2DEVINFO:
1857c478bd9Sstevel@tonic-gate *result = rnd_dip;
1867c478bd9Sstevel@tonic-gate error = DDI_SUCCESS;
1877c478bd9Sstevel@tonic-gate break;
1887c478bd9Sstevel@tonic-gate case DDI_INFO_DEVT2INSTANCE:
1897c478bd9Sstevel@tonic-gate *result = (void *)0;
1907c478bd9Sstevel@tonic-gate error = DDI_SUCCESS;
1917c478bd9Sstevel@tonic-gate break;
1927c478bd9Sstevel@tonic-gate default:
1937c478bd9Sstevel@tonic-gate error = DDI_FAILURE;
1947c478bd9Sstevel@tonic-gate }
1957c478bd9Sstevel@tonic-gate return (error);
1967c478bd9Sstevel@tonic-gate }
1977c478bd9Sstevel@tonic-gate
1987c478bd9Sstevel@tonic-gate /*ARGSUSED3*/
1997c478bd9Sstevel@tonic-gate static int
rnd_open(dev_t * devp,int flag,int otyp,cred_t * credp)2007c478bd9Sstevel@tonic-gate rnd_open(dev_t *devp, int flag, int otyp, cred_t *credp)
2017c478bd9Sstevel@tonic-gate {
2027c478bd9Sstevel@tonic-gate switch (getminor(*devp)) {
2037c478bd9Sstevel@tonic-gate case DEVRANDOM:
2047c478bd9Sstevel@tonic-gate if (!kcf_rngprov_check())
2057c478bd9Sstevel@tonic-gate return (ENXIO);
2067c478bd9Sstevel@tonic-gate break;
2077c478bd9Sstevel@tonic-gate case DEVURANDOM:
2087c478bd9Sstevel@tonic-gate break;
2097c478bd9Sstevel@tonic-gate default:
2107c478bd9Sstevel@tonic-gate return (ENXIO);
2117c478bd9Sstevel@tonic-gate }
2127c478bd9Sstevel@tonic-gate if (otyp != OTYP_CHR)
2137c478bd9Sstevel@tonic-gate return (EINVAL);
2147c478bd9Sstevel@tonic-gate
2157c478bd9Sstevel@tonic-gate if (flag & FEXCL)
2167c478bd9Sstevel@tonic-gate return (EINVAL);
2177c478bd9Sstevel@tonic-gate return (0);
2187c478bd9Sstevel@tonic-gate }
2197c478bd9Sstevel@tonic-gate
2207c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2217c478bd9Sstevel@tonic-gate static int
rnd_close(dev_t dev,int flag,int otyp,cred_t * credp)2227c478bd9Sstevel@tonic-gate rnd_close(dev_t dev, int flag, int otyp, cred_t *credp)
2237c478bd9Sstevel@tonic-gate {
2247c478bd9Sstevel@tonic-gate return (0);
2257c478bd9Sstevel@tonic-gate }
2267c478bd9Sstevel@tonic-gate
2277c478bd9Sstevel@tonic-gate /*ARGSUSED2*/
2287c478bd9Sstevel@tonic-gate static int
rnd_read(dev_t dev,struct uio * uiop,cred_t * credp)2297c478bd9Sstevel@tonic-gate rnd_read(dev_t dev, struct uio *uiop, cred_t *credp)
2307c478bd9Sstevel@tonic-gate {
2317c478bd9Sstevel@tonic-gate size_t len;
2327c478bd9Sstevel@tonic-gate minor_t devno;
2337c478bd9Sstevel@tonic-gate int error = 0;
2347c478bd9Sstevel@tonic-gate int nbytes = 0;
2357c478bd9Sstevel@tonic-gate uint8_t random_bytes[2 * HASHSIZE];
2367c478bd9Sstevel@tonic-gate
2377c478bd9Sstevel@tonic-gate devno = getminor(dev);
2387c478bd9Sstevel@tonic-gate
2397c478bd9Sstevel@tonic-gate while (error == 0 && uiop->uio_resid > 0) {
2407c478bd9Sstevel@tonic-gate len = min(sizeof (random_bytes), uiop->uio_resid);
2417c478bd9Sstevel@tonic-gate switch (devno) {
2427c478bd9Sstevel@tonic-gate case DEVRANDOM:
2437c478bd9Sstevel@tonic-gate error = kcf_rnd_get_bytes(random_bytes, len,
2448b502715SKrishna Yenduri uiop->uio_fmode & (FNDELAY|FNONBLOCK));
2457c478bd9Sstevel@tonic-gate break;
2467c478bd9Sstevel@tonic-gate case DEVURANDOM:
2477c478bd9Sstevel@tonic-gate error = kcf_rnd_get_pseudo_bytes(random_bytes, len);
2487c478bd9Sstevel@tonic-gate break;
2497c478bd9Sstevel@tonic-gate default:
2507c478bd9Sstevel@tonic-gate return (ENXIO);
2517c478bd9Sstevel@tonic-gate }
2527c478bd9Sstevel@tonic-gate
2537c478bd9Sstevel@tonic-gate if (error == 0) {
2547c478bd9Sstevel@tonic-gate /*
2557c478bd9Sstevel@tonic-gate * /dev/[u]random is not a seekable device. To prevent
2567c478bd9Sstevel@tonic-gate * uio offset from growing and eventually exceeding
2577c478bd9Sstevel@tonic-gate * the maximum, reset the offset here for every call.
2587c478bd9Sstevel@tonic-gate */
2597c478bd9Sstevel@tonic-gate uiop->uio_loffset = 0;
2607c478bd9Sstevel@tonic-gate error = uiomove(random_bytes, len, UIO_READ, uiop);
2617c478bd9Sstevel@tonic-gate
2627c478bd9Sstevel@tonic-gate nbytes += len;
2637c478bd9Sstevel@tonic-gate
264f317a3a3Skrishna if (devno == DEVRANDOM && nbytes >= MAXRETBYTES)
2657c478bd9Sstevel@tonic-gate break;
2667c478bd9Sstevel@tonic-gate
2677c478bd9Sstevel@tonic-gate } else if ((error == EAGAIN) && (nbytes > 0)) {
2687c478bd9Sstevel@tonic-gate error = 0;
2697c478bd9Sstevel@tonic-gate break;
2707c478bd9Sstevel@tonic-gate }
2717c478bd9Sstevel@tonic-gate }
2727c478bd9Sstevel@tonic-gate return (error);
2737c478bd9Sstevel@tonic-gate }
2747c478bd9Sstevel@tonic-gate
2757c478bd9Sstevel@tonic-gate /*ARGSUSED*/
2767c478bd9Sstevel@tonic-gate static int
rnd_write(dev_t dev,struct uio * uiop,cred_t * credp)2777c478bd9Sstevel@tonic-gate rnd_write(dev_t dev, struct uio *uiop, cred_t *credp)
2787c478bd9Sstevel@tonic-gate {
2797c478bd9Sstevel@tonic-gate int error;
2807c478bd9Sstevel@tonic-gate uint8_t buf[WRITEBUFSIZE];
2817c478bd9Sstevel@tonic-gate size_t bytes;
2828047c9fbSmcpowers minor_t devno;
2838047c9fbSmcpowers
2848047c9fbSmcpowers devno = getminor(dev);
2857c478bd9Sstevel@tonic-gate
2867c478bd9Sstevel@tonic-gate while (uiop->uio_resid > 0) {
2877c478bd9Sstevel@tonic-gate bytes = min(sizeof (buf), uiop->uio_resid);
2887c478bd9Sstevel@tonic-gate
2897c478bd9Sstevel@tonic-gate /* See comments in rnd_read() */
2907c478bd9Sstevel@tonic-gate uiop->uio_loffset = 0;
2917c478bd9Sstevel@tonic-gate if ((error = uiomove(buf, bytes, UIO_WRITE, uiop)) != 0)
2927c478bd9Sstevel@tonic-gate return (error);
2937c478bd9Sstevel@tonic-gate
2948047c9fbSmcpowers switch (devno) {
2958047c9fbSmcpowers case DEVRANDOM:
2968047c9fbSmcpowers if ((error = random_add_entropy(buf, bytes, 0)) != 0)
2978047c9fbSmcpowers return (error);
2988047c9fbSmcpowers break;
2998047c9fbSmcpowers case DEVURANDOM:
3008047c9fbSmcpowers if ((error = random_add_pseudo_entropy(buf, bytes,
3018047c9fbSmcpowers 0)) != 0)
3028047c9fbSmcpowers return (error);
3038047c9fbSmcpowers break;
3048047c9fbSmcpowers default:
3058047c9fbSmcpowers return (ENXIO);
3068047c9fbSmcpowers }
3077c478bd9Sstevel@tonic-gate }
3087c478bd9Sstevel@tonic-gate
3097c478bd9Sstevel@tonic-gate return (0);
3107c478bd9Sstevel@tonic-gate }
3117c478bd9Sstevel@tonic-gate
3129d31afc5SKrishna Yenduri static struct pollhead urnd_pollhd;
3139d31afc5SKrishna Yenduri
3147c478bd9Sstevel@tonic-gate /*
3157c478bd9Sstevel@tonic-gate * poll(2) is supported as follows:
3169d31afc5SKrishna Yenduri * . Only POLLIN, POLLOUT, and POLLRDNORM events are supported.
3177c478bd9Sstevel@tonic-gate * . POLLOUT always succeeds.
3187c478bd9Sstevel@tonic-gate * . POLLIN and POLLRDNORM from /dev/urandom always succeeds.
3197c478bd9Sstevel@tonic-gate * . POLLIN and POLLRDNORM from /dev/random will block until a
3207c478bd9Sstevel@tonic-gate * minimum amount of entropy is available.
3217c478bd9Sstevel@tonic-gate */
3227c478bd9Sstevel@tonic-gate static int
rnd_chpoll(dev_t dev,short events,int anyyet,short * reventsp,struct pollhead ** phpp)3237c478bd9Sstevel@tonic-gate rnd_chpoll(dev_t dev, short events, int anyyet, short *reventsp,
3249d31afc5SKrishna Yenduri struct pollhead **phpp)
3257c478bd9Sstevel@tonic-gate {
3267c478bd9Sstevel@tonic-gate switch (getminor(dev)) {
3277c478bd9Sstevel@tonic-gate case DEVURANDOM:
3287c478bd9Sstevel@tonic-gate *reventsp = events & (POLLOUT | POLLIN | POLLRDNORM);
3297c478bd9Sstevel@tonic-gate
3309d31afc5SKrishna Yenduri /*
3319d31afc5SKrishna Yenduri * A non NULL pollhead pointer should be returned in case
3329d31afc5SKrishna Yenduri * user polls for 0 events.
3339d31afc5SKrishna Yenduri */
334*80d5689fSPatrick Mooney if ((*reventsp == 0 && !anyyet) || (events & POLLET))
3359d31afc5SKrishna Yenduri *phpp = &urnd_pollhd;
3367c478bd9Sstevel@tonic-gate
3377c478bd9Sstevel@tonic-gate break;
3387c478bd9Sstevel@tonic-gate case DEVRANDOM:
3399d31afc5SKrishna Yenduri kcf_rnd_chpoll(events, anyyet, reventsp, phpp);
3407c478bd9Sstevel@tonic-gate break;
3417c478bd9Sstevel@tonic-gate default:
3427c478bd9Sstevel@tonic-gate return (ENXIO);
3437c478bd9Sstevel@tonic-gate }
3447c478bd9Sstevel@tonic-gate
3457c478bd9Sstevel@tonic-gate return (0);
3467c478bd9Sstevel@tonic-gate }
347