Index: head/sys/conf/files =================================================================== --- head/sys/conf/files (revision 67111) +++ head/sys/conf/files (revision 67112) @@ -1,1033 +1,1033 @@ # $FreeBSD$ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and # dependency lines other than the first are silently ignored. # aicasm optional ahc \ dependency "$S/dev/aic7xxx/aicasm/*.[chyl]" \ compile-with "${MAKE} -f $S/dev/aic7xxx/aicasm/Makefile MAKESRCPATH=$S/dev/aic7xxx/aicasm" \ no-obj no-implicit-rule \ clean "aicasm aicasm_gram.c aicasm_scan.c y.tab.h" aic7xxx_{seq,reg}.h optional ahc \ compile-with "./aicasm ${INCLUDES} -I$S/cam/scsi -I$S/dev/aic7xxx -o aic7xxx_seq.h -r aic7xxx_reg.h $S/dev/aic7xxx/aic7xxx.seq" \ no-obj no-implicit-rule before-depend \ clean "aic7xxx_seq.h aic7xxx_reg.h" \ dependency "$S/dev/aic7xxx/aic7xxx.{reg,seq} $S/cam/scsi/scsi_message.h aicasm" kern/device_if.m standard kern/bus_if.m standard kern/linker_if.m standard cam/cam.c optional scbus cam/cam_extend.c optional scbus cam/cam_periph.c optional scbus cam/cam_queue.c optional scbus cam/cam_sim.c optional scbus cam/cam_xpt.c optional scbus cam/scsi/scsi_all.c optional scbus cam/scsi/scsi_cd.c optional cd cam/scsi/scsi_ch.c optional ch cam/scsi/scsi_da.c optional da cam/scsi/scsi_pass.c optional pass cam/scsi/scsi_pt.c optional pt cam/scsi/scsi_sa.c optional sa cam/scsi/scsi_ses.c optional ses cam/scsi/scsi_targ_bh.c optional targbh cam/scsi/scsi_target.c optional targ coda/coda_fbsd.c count vcoda coda/coda_namecache.c optional vcoda coda/coda_psdev.c optional vcoda coda/coda_subr.c optional vcoda coda/coda_venus.c optional vcoda coda/coda_vfsops.c optional vcoda coda/coda_vnops.c optional vcoda crypto/blowfish/bf_cbc.c optional ipsec ipsec_esp crypto/blowfish/bf_cbc_m.c optional ipsec ipsec_esp crypto/blowfish/bf_enc.c optional ipsec ipsec_esp crypto/blowfish/bf_skey.c optional ipsec ipsec_esp crypto/cast128/cast128.c optional ipsec ipsec_esp crypto/cast128/cast128_cbc.c optional ipsec ipsec_esp crypto/des/des_3cbc.c optional ipsec ipsec_esp crypto/des/des_cbc.c optional ipsec ipsec_esp crypto/des/des_ecb.c optional ipsec ipsec_esp crypto/des/des_setkey.c optional ipsec ipsec_esp crypto/rc5/rc5.c optional ipsec ipsec_esp crypto/rc5/rc5_cbc.c optional ipsec ipsec_esp crypto/sha1.c optional ipsec ddb/db_access.c optional ddb ddb/db_break.c optional ddb ddb/db_command.c optional ddb ddb/db_examine.c optional ddb ddb/db_expr.c optional ddb ddb/db_input.c optional ddb ddb/db_kld.c optional ddb ddb/db_lex.c optional ddb ddb/db_output.c optional ddb ddb/db_print.c optional ddb ddb/db_ps.c optional ddb ddb/db_run.c optional ddb ddb/db_sym.c optional ddb ddb/db_sysctl.c optional ddb ddb/db_trap.c optional ddb ddb/db_variables.c optional ddb ddb/db_watch.c optional ddb ddb/db_write_cmd.c optional ddb dev/aac/aac.c optional aac #dev/aac/aac_debug.c optional aac dev/aac/aac_disk.c optional aac dev/aac/aac_pci.c optional aac pci dev/acpi/acpi.c optional acpi dev/acpi/acpi_io.c optional acpi dev/acpi/acpi_event.c optional acpi dev/acpi/acpi_powerres.c optional acpi dev/acpi/aml/aml_amlmem.c optional acpi dev/acpi/aml/aml_common.c optional acpi dev/acpi/aml/aml_evalobj.c optional acpi dev/acpi/aml/aml_memman.c optional acpi dev/acpi/aml/aml_name.c optional acpi dev/acpi/aml/aml_obj.c optional acpi dev/acpi/aml/aml_parse.c optional acpi dev/acpi/aml/aml_store.c optional acpi dev/acpi/aml/aml_region.c optional acpi dev/advansys/adv_eisa.c optional adv eisa dev/advansys/adv_pci.c optional adv pci dev/advansys/advansys.c optional adv dev/advansys/advlib.c optional adv dev/advansys/advmcode.c optional adv dev/advansys/adw_pci.c optional adw pci dev/advansys/adwcam.c optional adw dev/advansys/adwlib.c optional adw dev/advansys/adwmcode.c optional adw dev/aha/aha.c count aha dev/aha/aha_isa.c optional aha isa dev/aha/aha_mca.c optional aha mca dev/ahb/ahb.c optional ahb eisa dev/aic/aic.c optional aic dev/aic/aic_pccard.c optional aic card dev/aic7xxx/aic7770.c optional ahc eisa dev/aic7xxx/ahc_eisa.c optional ahc eisa #dev/aic7xxx/ahc_isa.c optional ahc isa dev/aic7xxx/ahc_pci.c optional ahc pci dev/aic7xxx/aic7xxx.c optional ahc dev/aic7xxx/aic7xxx_93cx6.c optional ahc dev/aic7xxx/aic7xxx_freebsd.c optional ahc dev/aic7xxx/aic7xxx_pci.c optional ahc pci dev/amr/amr.c optional amr dev/amr/amr_disk.c optional amr dev/amr/amr_pci.c optional amr dev/an/if_an.c optional an dev/an/if_an_isa.c optional an isa dev/an/if_an_pccard.c optional an card dev/an/if_an_pci.c optional an pci dev/asr/asr.c optional asr pci dev/ata/ata-all.c count ata dev/ata/ata-disk.c count atadisk dev/ata/ata-raid.c count atadisk dev/ata/ata-dma.c optional ata dev/ata/atapi-all.c optional atapicd dev/ata/atapi-all.c optional atapifd dev/ata/atapi-all.c optional atapist dev/ata/atapi-cd.c count atapicd dev/ata/atapi-fd.c count atapifd dev/ata/atapi-tape.c count atapist dev/awi/am79c930.c optional awi dev/awi/awi.c optional awi dev/awi/awi_wep.c optional awi dev/awi/awi_wicfg.c optional awi dev/awi/if_awi_pccard.c optional awi card dev/bktr/bktr_audio.c optional bktr pci dev/bktr/bktr_card.c optional bktr pci dev/bktr/bktr_core.c count bktr pci dev/bktr/bktr_i2c.c optional bktr pci smbus dev/bktr/bktr_os.c optional bktr pci dev/bktr/bktr_tuner.c optional bktr pci dev/buslogic/bt.c optional bt dev/buslogic/bt_eisa.c optional bt eisa dev/buslogic/bt_isa.c optional bt isa dev/buslogic/bt_mca.c optional bt mca dev/buslogic/bt_pci.c optional bt pci dev/cardbus/cardbus.c optional cardbus dev/ccd/ccd.c count ccd dev/cs/if_cs.c optional cs #dev/dpt/dpt_control.c optional dpt dev/dpt/dpt_eisa.c optional dpt eisa dev/dpt/dpt_pci.c optional dpt pci dev/dpt/dpt_scsi.c optional dpt dev/ed/if_ed.c optional ed dev/ed/if_ed_pccard.c optional ed card dev/ed/if_ed_pci.c optional ed pci dev/en/midway.c count en dev/ep/if_ep.c optional ep dev/ep/if_ep_eisa.c optional ep eisa dev/ep/if_ep_isa.c optional ep isa dev/ep/if_ep_mca.c optional ep mca dev/ep/if_ep_pccard.c optional ep card dev/ex/if_ex.c optional ex dev/ex/if_ex_isa.c optional ex isa dev/ex/if_ex_pccard.c optional ex card dev/fe/if_fe.c optional fe dev/fe/if_fe_pccard.c optional fe card dev/hea/eni.c optional hea dev/hea/eni_buffer.c optional hea dev/hea/eni_globals.c optional hea dev/hea/eni_if.c optional hea dev/hea/eni_init.c optional hea dev/hea/eni_intr.c optional hea dev/hea/eni_receive.c optional hea dev/hea/eni_transmit.c optional hea dev/hea/eni_vcm.c optional hea dev/hfa/fore_buffer.c optional hfa dev/hfa/fore_command.c optional hfa dev/hfa/fore_globals.c optional hfa dev/hfa/fore_if.c optional hfa dev/hfa/fore_init.c optional hfa dev/hfa/fore_intr.c optional hfa dev/hfa/fore_load.c optional hfa dev/hfa/fore_output.c optional hfa dev/hfa/fore_receive.c optional hfa dev/hfa/fore_stats.c optional hfa dev/hfa/fore_timer.c optional hfa dev/hfa/fore_transmit.c optional hfa dev/hfa/fore_vcm.c optional hfa dev/ichsmb/ichsmb.c optional ichsmb dev/ichsmb/ichsmb_pci.c optional ichsmb pci dev/ida/ida.c optional ida dev/ida/ida_disk.c optional ida dev/ida/ida_eisa.c optional ida eisa dev/ida/ida_pci.c optional ida pci dev/ie/if_ie.c count ie isa dev/iicbus/iicbb_if.m optional iicbb dev/iicbus/iicbus_if.m optional iicbus dev/iicbus/if_ic.c optional ic dev/iicbus/iic.c optional iic dev/iicbus/iicbb.c optional iicbb dev/iicbus/iicbus.c optional iicbus dev/iicbus/iiconf.c optional iicbus dev/iicbus/iicsmb.c optional iicsmb \ dependency "iicbus_if.h" dev/isp/isp.c optional isp dev/isp/isp_freebsd.c optional isp dev/isp/isp_target.c optional isp dev/ispfw/ispfw.c optional ispfw dev/lmc/if_lmc.c optional lmc dev/lnc/if_lnc.c count lnc dev/lnc/if_lnc_isa.c optional lnc isa dev/lnc/if_lnc_pc98.c optional lnc isa dev/lnc/if_lnc_pci.c optional lnc pci dev/mca/mca_bus.c optional mca dev/md/md.c optional md dev/mii/amphy.c optional miibus dev/mii/brgphy.c optional miibus dev/mii/dcphy.c optional miibus dev/mii/exphy.c optional miibus dev/mii/mii.c optional miibus dev/mii/mii_physubr.c optional miibus dev/mii/mlphy.c optional miibus dev/mii/nsphy.c optional miibus dev/mii/pnphy.c optional miibus dev/mii/pnaphy.c optional miibus dev/mii/rlphy.c optional miibus dev/mii/tlphy.c optional miibus dev/mii/ukphy.c optional miibus dev/mii/ukphy_subr.c optional miibus dev/mii/xmphy.c optional miibus dev/mii/miibus_if.m optional miibus dev/mlx/mlx.c optional mlx dev/mlx/mlx_disk.c optional mlx dev/mlx/mlx_pci.c optional mlx dev/mly/mly.c optional mly dev/mly/mly_cam.c optional mly dev/mly/mly_pci.c optional mly dev/musycc/musycc.c optional musycc dev/null/null.c standard dev/pccard/card_if.m optional card dev/pccard/card_if.m optional pccard dev/pccard/pccard.c optional pccard dev/pccard/pccard_cis.c optional pccard dev/pccard/pccard_cis_quirks.c optional pccard dev/pccard/power_if.m optional pccard dev/pcic/i82365.c optional pcic pccard dev/pcic/i82365_isa.c optional pcic pccard dev/pdq/if_fea.c optional fea eisa dev/pdq/if_fpa.c count fpa pci dev/pdq/pdq.c optional fea eisa dev/pdq/pdq.c optional fpa pci dev/pdq/pdq_ifsubr.c optional fea eisa dev/pdq/pdq_ifsubr.c optional fpa pci dev/ppbus/ppbus_if.m optional ppbus dev/ppbus/if_plip.c optional plip dev/ppbus/immio.c optional vpo dev/ppbus/lpbb.c optional lpbb dev/ppbus/lpt.c optional lpt dev/ppbus/pcfclock.c optional pcfclock dev/ppbus/ppb_1284.c optional ppbus dev/ppbus/ppb_base.c optional ppbus dev/ppbus/ppb_msq.c optional ppbus dev/ppbus/ppbconf.c optional ppbus dev/ppbus/ppi.c optional ppi dev/ppbus/pps.c optional pps dev/ppbus/vpo.c optional vpo dev/ppbus/vpoio.c optional vpo -dev/randomdev/harvest.c standard -dev/randomdev/randomdev.c optional random -dev/randomdev/yarrow.c optional random -dev/randomdev/hash.c optional random +dev/random/harvest.c standard +dev/random/randomdev.c optional random +dev/random/yarrow.c optional random +dev/random/hash.c optional random crypto/blowfish/bf_cbc.c optional random crypto/blowfish/bf_enc.c optional random crypto/blowfish/bf_skey.c optional random dev/rp/rp.c optional rp dev/rp/rp_isa.c optional rp isa dev/rp/rp_pci.c optional rp pci dev/si/si.c optional si dev/si/si2_z280.c optional si dev/si/si3_t225.c optional si dev/si/si_eisa.c optional si eisa dev/si/si_isa.c optional si isa dev/si/si_pci.c optional si pci dev/smbus/smbus_if.m optional smbus dev/smbus/smb.c optional smb dev/smbus/smbconf.c optional smbus dev/smbus/smbus.c count smbus dev/sn/if_sn.c optional sn dev/sn/if_sn_isa.c optional sn isa dev/sn/if_sn_pccard.c optional sn card dev/sound/isa/ad1816.c optional pcm isa dev/sound/isa/emu8000.c optional midi isa dev/sound/isa/es1888.c optional pcm isa dev/sound/isa/ess.c optional pcm isa dev/sound/isa/gusc.c optional gusc isa dev/sound/isa/gusc.c optional pcm isa dev/sound/isa/gusmidi.c optional midi isa dev/sound/isa/mpu.c optional midi isa dev/sound/isa/mss.c optional pcm isa dev/sound/isa/opl.c optional midi isa dev/sound/isa/sb.c optional pcm isa dev/sound/isa/sbc.c optional pcm isa dev/sound/isa/sbc.c optional sbc isa dev/sound/isa/uartsio.c optional midi isa dev/sound/midi/midi.c optional midi dev/sound/midi/midibuf.c optional midi dev/sound/midi/midisynth.c optional midi dev/sound/midi/sequencer.c optional seq midi #dev/sound/pci/aureal.c optional pcm pci dev/sound/pci/csa.c optional csa pci dev/sound/pci/csa.c optional pcm pci dev/sound/pci/csamidi.c optional midi csa dev/sound/pci/csapcm.c optional pcm pci dev/sound/pci/ds1.c optional pcm pci dev/sound/pci/emu10k1.c optional pcm pci dev/sound/pci/es137x.c optional pcm pci dev/sound/pci/fm801.c optional pcm pci dev/sound/pci/maestro.c optional pcm pci dev/sound/pci/neomagic.c optional pcm pci dev/sound/pci/solo.c optional pcm pci dev/sound/pci/t4dwave.c optional pcm pci dev/sound/pci/via82c686.c optional pcm pci dev/sound/pcm/ac97.c optional pcm dev/sound/pcm/channel.c optional pcm dev/sound/pcm/dsp.c optional pcm dev/sound/pcm/fake.c optional pcm dev/sound/pcm/feeder.c optional pcm dev/sound/pcm/feeder_fmt.c optional pcm #dev/sound/pcm/feeder_rate.c optional pcm dev/sound/pcm/mixer.c optional pcm dev/sound/pcm/sound.c optional pcm #dev/sound/usb/upcm.c optional pcm usb dev/streams/streams.c optional streams dev/sym/sym_hipd.c optional sym \ dependency "$S/dev/sym/sym_{conf,defs}.h" dev/tdfx/tdfx_pci.c optional tdfx dev/twe/twe.c optional twe dev/twe/twe_disk.c optional twe # # USB support dev/usb/usb_if.m optional usb dev/usb/hid.c optional usb dev/usb/if_aue.c optional aue dev/usb/if_cue.c optional cue dev/usb/if_kue.c optional kue dev/usb/ohci.c optional ohci dev/usb/udbp.c optional udbp dev/usb/ugen.c optional ugen dev/usb/uhci.c optional uhci dev/usb/uhid.c optional uhid dev/usb/uhub.c optional usb dev/usb/ukbd.c optional ukbd dev/usb/ulpt.c optional ulpt dev/usb/umass.c optional umass dev/usb/umodem.c optional umodem dev/usb/ums.c optional ums dev/usb/urio.c optional urio dev/usb/usb.c optional usb dev/usb/usb_ethersubr.c optional usb #dev/usb/usb_mem.c optional usb dev/usb/usb_quirks.c optional usb dev/usb/usb_subr.c optional usb dev/usb/usbdi.c optional usb dev/usb/usbdi_util.c optional usb dev/vinum/vinum.c optional vinum dev/vinum/vinumconfig.c optional vinum dev/vinum/vinumdaemon.c optional vinum dev/vinum/vinuminterrupt.c optional vinum dev/vinum/vinumio.c optional vinum dev/vinum/vinumioctl.c optional vinum dev/vinum/vinumlock.c optional vinum dev/vinum/vinummemory.c optional vinum dev/vinum/vinumparser.c optional vinum dev/vinum/vinumraid5.c optional vinum dev/vinum/vinumrequest.c optional vinum dev/vinum/vinumrevive.c optional vinum dev/vinum/vinumstate.c optional vinum dev/vinum/vinumutil.c optional vinum dev/vn/vn.c optional vn dev/vx/if_vx.c count vx dev/vx/if_vx_eisa.c optional vx eisa dev/vx/if_vx_pci.c optional vx pci dev/xe/if_xe.c optional xe card fs/devfs/devfs_vnops.c optional devfs fs/devfs/devfs_vfsops.c optional devfs fs/devfs/devfs_devs.c optional devfs gnu/ext2fs/ext2_alloc.c optional ext2fs gnu/ext2fs/ext2_balloc.c optional ext2fs gnu/ext2fs/ext2_inode.c optional ext2fs gnu/ext2fs/ext2_inode_cnv.c optional ext2fs gnu/ext2fs/ext2_linux_balloc.c optional ext2fs gnu/ext2fs/ext2_linux_ialloc.c optional ext2fs gnu/ext2fs/ext2_lookup.c optional ext2fs gnu/ext2fs/ext2_subr.c optional ext2fs gnu/ext2fs/ext2_vfsops.c optional ext2fs gnu/ext2fs/ext2_vnops.c optional ext2fs # # isdn4bsd device drivers # i4b/driver/i4b_trace.c count i4btrc i4b/driver/i4b_rbch.c count i4brbch i4b/driver/i4b_tel.c count i4btel i4b/driver/i4b_ipr.c count i4bipr net/slcompress.c optional i4bipr i4b/driver/i4b_ctl.c count i4bctl i4b/driver/i4b_ing.c count i4bing i4b/driver/i4b_isppp.c count i4bisppp i4b/driver/i4b_ispppsubr.c optional i4bisppp net/slcompress.c optional i4bisppp # # isdn4bsd support # i4b/layer2/i4b_mbuf.c optional i4btrc # # isdn4bsd Q.921 handler # i4b/layer2/i4b_l2.c count i4bq921 i4b/layer2/i4b_l2fsm.c optional i4bq921 i4b/layer2/i4b_uframe.c optional i4bq921 i4b/layer2/i4b_tei.c optional i4bq921 i4b/layer2/i4b_sframe.c optional i4bq921 i4b/layer2/i4b_iframe.c optional i4bq921 i4b/layer2/i4b_l2timer.c optional i4bq921 i4b/layer2/i4b_util.c optional i4bq921 i4b/layer2/i4b_lme.c optional i4bq921 # # isdn4bsd Q.931 handler # i4b/layer3/i4b_q931.c count i4bq931 i4b/layer3/i4b_l3fsm.c optional i4bq931 i4b/layer3/i4b_l3timer.c optional i4bq931 i4b/layer3/i4b_l2if.c optional i4bq931 i4b/layer3/i4b_l4if.c optional i4bq931 i4b/layer3/i4b_q932fac.c optional i4bq931 # # isdn4bsd control device driver, interface to isdnd # i4b/layer4/i4b_i4bdrv.c count i4b i4b/layer4/i4b_l4.c optional i4b i4b/layer4/i4b_l4mgmt.c optional i4b i4b/layer4/i4b_l4timer.c optional i4b # isa/isa_if.m optional isa isa/isa_common.c count isa isa/isahint.c optional isa isa/joy.c optional joy isa/pnp.c optional isa isa/pnpparse.c optional isa isofs/cd9660/cd9660_bmap.c optional cd9660 isofs/cd9660/cd9660_lookup.c optional cd9660 isofs/cd9660/cd9660_node.c optional cd9660 isofs/cd9660/cd9660_rrip.c optional cd9660 isofs/cd9660/cd9660_util.c optional cd9660 isofs/cd9660/cd9660_vfsops.c optional cd9660 isofs/cd9660/cd9660_vnops.c optional cd9660 kern/imgact_aout.c standard kern/imgact_elf.c standard kern/imgact_gzip.c optional gzip kern/imgact_shell.c standard kern/inflate.c optional gzip kern/init_main.c standard kern/init_sysent.c standard kern/kern_acct.c standard kern/kern_acl.c standard kern/kern_cap.c standard kern/kern_clock.c standard kern/kern_conf.c standard kern/kern_descrip.c standard kern/kern_environment.c standard kern/kern_event.c standard kern/kern_exec.c standard kern/kern_exit.c standard kern/kern_fork.c standard kern/kern_idle.c standard kern/kern_intr.c standard kern/kern_jail.c standard kern/kern_kthread.c standard kern/kern_ktr.c optional ktr kern/kern_ktrace.c standard kern/kern_linker.c standard kern/kern_lock.c standard kern/kern_lockf.c standard kern/kern_malloc.c standard kern/kern_mib.c standard kern/kern_module.c standard kern/kern_mutex.c standard kern/kern_ntptime.c standard kern/kern_physio.c standard kern/kern_proc.c standard kern/kern_prot.c standard kern/kern_resource.c standard kern/kern_shutdown.c standard kern/kern_sig.c standard kern/kern_subr.c standard kern/kern_switch.c standard kern/kern_synch.c standard kern/kern_syscalls.c standard kern/kern_sysctl.c standard kern/kern_tc.c standard kern/kern_threads.c standard kern/kern_time.c standard kern/kern_timeout.c standard kern/kern_xxx.c standard kern/link_aout.c standard kern/link_elf.c standard kern/md5c.c standard kern/subr_autoconf.c standard kern/subr_blist.c standard kern/subr_bus.c standard kern/subr_devstat.c standard kern/subr_disk.c standard kern/subr_disklabel.c standard kern/subr_diskslice.c standard kern/subr_eventhandler.c standard kern/subr_kobj.c standard kern/subr_log.c standard kern/subr_module.c standard kern/subr_prf.c standard kern/subr_prof.c standard kern/subr_rman.c standard kern/subr_scanf.c standard kern/subr_taskqueue.c standard kern/subr_xxx.c standard kern/sys_generic.c standard kern/sys_pipe.c standard kern/sys_process.c standard kern/sys_socket.c standard kern/sysv_ipc.c standard kern/sysv_msg.c optional sysvmsg kern/sysv_sem.c optional sysvsem kern/sysv_shm.c optional sysvshm kern/tty.c standard kern/tty_compat.c standard kern/tty_conf.c standard kern/tty_cons.c standard kern/tty_pty.c optional pty kern/tty_snoop.c count snp kern/tty_subr.c standard kern/tty_tty.c standard kern/uipc_accf.c standard kern/uipc_domain.c standard kern/uipc_mbuf.c standard kern/uipc_mbuf2.c standard kern/uipc_proto.c standard kern/uipc_socket.c standard kern/uipc_socket2.c standard kern/uipc_syscalls.c standard kern/uipc_usrreq.c standard kern/vfs_aio.c standard kern/vfs_bio.c standard kern/vfs_cache.c standard kern/vfs_cluster.c standard kern/vfs_conf.c standard kern/vfs_default.c standard kern/vfs_init.c standard kern/vfs_lookup.c standard kern/vfs_subr.c standard kern/vfs_syscalls.c standard kern/vfs_vnops.c standard # # These files in libkern/ are those needed by all architectures. Some # of the files in libkern/ are only needed on some architectures, e.g., # libkern/divdi3.c is needed by i386 but not alpha. Also, some of these # routines may be optimized for a particular platform. In either case, # the file should be moved to /conf/files. from here. # libkern/arc4random.c standard libkern/bcd.c standard libkern/index.c standard libkern/inet_ntoa.c standard libkern/mcount.c optional profiling-routine libkern/qsort.c standard libkern/random.c standard libkern/rindex.c standard libkern/scanc.c standard libkern/skpc.c standard libkern/strcat.c standard libkern/strcmp.c standard libkern/strcpy.c standard libkern/strlen.c standard libkern/strncmp.c standard libkern/strncpy.c standard libkern/strtol.c standard libkern/strtoq.c standard libkern/strtoul.c standard libkern/strtouq.c standard miscfs/deadfs/dead_vnops.c standard miscfs/fdesc/fdesc_vfsops.c optional fdesc miscfs/fdesc/fdesc_vnops.c optional fdesc miscfs/fifofs/fifo_vnops.c standard miscfs/kernfs/kernfs_vfsops.c optional kernfs miscfs/kernfs/kernfs_vnops.c optional kernfs miscfs/nullfs/null_subr.c optional nullfs miscfs/nullfs/null_vfsops.c optional nullfs miscfs/nullfs/null_vnops.c optional nullfs miscfs/portal/portal_vfsops.c optional portal miscfs/portal/portal_vnops.c optional portal miscfs/procfs/procfs_ctl.c optional procfs miscfs/procfs/procfs_dbregs.c standard miscfs/procfs/procfs_fpregs.c standard miscfs/procfs/procfs_map.c optional procfs miscfs/procfs/procfs_mem.c standard miscfs/procfs/procfs_note.c optional procfs miscfs/procfs/procfs_regs.c standard miscfs/procfs/procfs_rlimit.c optional procfs miscfs/procfs/procfs_status.c optional procfs miscfs/procfs/procfs_subr.c optional procfs miscfs/procfs/procfs_type.c optional procfs miscfs/procfs/procfs_vfsops.c optional procfs miscfs/procfs/procfs_vnops.c optional procfs miscfs/specfs/spec_vnops.c standard miscfs/umapfs/umap_subr.c optional umapfs miscfs/umapfs/umap_vfsops.c optional umapfs miscfs/umapfs/umap_vnops.c optional umapfs miscfs/union/union_subr.c optional union miscfs/union/union_vfsops.c optional union miscfs/union/union_vnops.c optional union msdosfs/msdosfs_conv.c optional msdosfs msdosfs/msdosfs_denode.c optional msdosfs msdosfs/msdosfs_fat.c optional msdosfs msdosfs/msdosfs_lookup.c optional msdosfs msdosfs/msdosfs_vfsops.c optional msdosfs msdosfs/msdosfs_vnops.c optional msdosfs net/bpf.c standard net/bpf_filter.c count bpf net/bridge.c optional bridge net/bsd_comp.c optional ppp_bsdcomp #net/hostcache.c standard net/if.c standard net/if_atmsubr.c optional atm net/if_disc.c optional disc net/if_ef.c optional ef net/if_ethersubr.c optional ether net/if_faith.c count faith net/if_fddisubr.c optional fddi net/if_gif.c count gif net/if_iso88025subr.c optional token net/if_loop.c count loop net/if_media.c standard net/if_mib.c standard net/if_ppp.c count ppp net/if_sl.c optional sl net/if_spppsubr.c optional sppp net/if_stf.c count stf net/if_tun.c optional tun net/if_tap.c optional tap net/if_vlan.c count vlan net/intrq.c standard net/net_osdep.c standard net/ppp_deflate.c optional ppp_deflate net/ppp_tty.c optional ppp net/pfil.c optional pfil_hooks net/pfil.c optional ipfilter net/radix.c standard net/raw_cb.c standard net/raw_usrreq.c standard net/route.c standard net/rtsock.c standard net/slcompress.c optional ppp net/slcompress.c optional sl net/zlib.c optional ppp_deflate net/zlib.c optional ipsec netatalk/aarp.c optional netatalk netatalk/at_control.c optional netatalk netatalk/at_proto.c optional netatalk netatalk/at_rmx.c optional netatalkdebug netatalk/ddp_input.c optional netatalk netatalk/ddp_output.c optional netatalk netatalk/ddp_usrreq.c optional netatalk netatm/atm_aal5.c optional atm_core netatm/atm_cm.c optional atm_core netatm/atm_device.c optional atm_core netatm/atm_if.c optional atm_core netatm/atm_proto.c optional atm_core netatm/atm_signal.c optional atm_core netatm/atm_socket.c optional atm_core netatm/atm_subr.c optional atm_core netatm/atm_usrreq.c optional atm_core netatm/ipatm/ipatm_event.c optional atm_ip atm_core netatm/ipatm/ipatm_if.c optional atm_ip atm_core netatm/ipatm/ipatm_input.c optional atm_ip atm_core netatm/ipatm/ipatm_load.c optional atm_ip atm_core netatm/ipatm/ipatm_output.c optional atm_ip atm_core netatm/ipatm/ipatm_usrreq.c optional atm_ip atm_core netatm/ipatm/ipatm_vcm.c optional atm_ip atm_core netatm/sigpvc/sigpvc_if.c optional atm_sigpvc atm_core netatm/sigpvc/sigpvc_subr.c optional atm_sigpvc atm_core netatm/spans/spans_arp.c optional atm_spans atm_core \ dependency "spans_xdr.h" netatm/spans/spans_cls.c optional atm_spans atm_core netatm/spans/spans_if.c optional atm_spans atm_core netatm/spans/spans_kxdr.c optional atm_spans atm_core netatm/spans/spans_msg.c optional atm_spans atm_core netatm/spans/spans_print.c optional atm_spans atm_core netatm/spans/spans_proto.c optional atm_spans atm_core netatm/spans/spans_subr.c optional atm_spans atm_core netatm/spans/spans_util.c optional atm_spans atm_core spans_xdr.h optional atm_spans atm_core \ before-depend \ dependency "$S/netatm/spans/spans_xdr.x" \ compile-with "rpcgen -h -C $S/netatm/spans/spans_xdr.x > spans_xdr.h" \ clean "spans_xdr.h" \ no-obj no-implicit-rule spans_xdr.c optional atm_spans atm_core \ before-depend \ dependency "$S/netatm/spans/spans_xdr.x" \ compile-with "rpcgen -c -C $S/netatm/spans/spans_xdr.x > spans_xdr.c" \ clean "spans_xdr.c" \ no-obj no-implicit-rule local spans_xdr.o optional atm_spans atm_core \ dependency "$S/netatm/spans/spans_xdr.x" \ compile-with "${NORMAL_C}" \ no-implicit-rule local netatm/uni/q2110_sigaa.c optional atm_uni atm_core netatm/uni/q2110_sigcpcs.c optional atm_uni atm_core netatm/uni/q2110_subr.c optional atm_uni atm_core netatm/uni/qsaal1_sigaa.c optional atm_uni atm_core netatm/uni/qsaal1_sigcpcs.c optional atm_uni atm_core netatm/uni/qsaal1_subr.c optional atm_uni atm_core netatm/uni/sscf_uni.c optional atm_uni atm_core netatm/uni/sscf_uni_lower.c optional atm_uni atm_core netatm/uni/sscf_uni_upper.c optional atm_uni atm_core netatm/uni/sscop.c optional atm_uni atm_core netatm/uni/sscop_lower.c optional atm_uni atm_core netatm/uni/sscop_pdu.c optional atm_uni atm_core netatm/uni/sscop_sigaa.c optional atm_uni atm_core netatm/uni/sscop_sigcpcs.c optional atm_uni atm_core netatm/uni/sscop_subr.c optional atm_uni atm_core netatm/uni/sscop_timer.c optional atm_uni atm_core netatm/uni/sscop_upper.c optional atm_uni atm_core netatm/uni/uni_load.c optional atm_uni atm_core netatm/uni/uniarp.c optional atm_uni atm_core netatm/uni/uniarp_cache.c optional atm_uni atm_core netatm/uni/uniarp_input.c optional atm_uni atm_core netatm/uni/uniarp_output.c optional atm_uni atm_core netatm/uni/uniarp_timer.c optional atm_uni atm_core netatm/uni/uniarp_vcm.c optional atm_uni atm_core netatm/uni/uniip.c optional atm_uni atm_core netatm/uni/unisig_decode.c optional atm_uni atm_core netatm/uni/unisig_encode.c optional atm_uni atm_core netatm/uni/unisig_if.c optional atm_uni atm_core netatm/uni/unisig_mbuf.c optional atm_uni atm_core netatm/uni/unisig_msg.c optional atm_uni atm_core netatm/uni/unisig_print.c optional atm_uni atm_core netatm/uni/unisig_proto.c optional atm_uni atm_core netatm/uni/unisig_sigmgr_state.c optional atm_uni atm_core netatm/uni/unisig_subr.c optional atm_uni atm_core netatm/uni/unisig_util.c optional atm_uni atm_core netatm/uni/unisig_vc_state.c optional atm_uni atm_core netgraph/ng_UI.c optional netgraph_UI netgraph/ng_async.c optional netgraph_async netgraph/ng_base.c optional netgraph netgraph/ng_bpf.c optional netgraph_bpf net/bpf_filter.c optional netgraph_bpf netgraph/ng_bridge.c optional netgraph_bridge netgraph/ng_cisco.c optional netgraph_cisco netgraph/ng_echo.c optional netgraph_echo netgraph/ng_ether.c optional netgraph_ether netgraph/ng_frame_relay.c optional netgraph_frame_relay netgraph/ng_hole.c optional netgraph_hole netgraph/ng_iface.c optional netgraph_iface netgraph/ng_ksocket.c optional netgraph_ksocket netgraph/ng_lmi.c optional netgraph_lmi netgraph/ng_mppc.c optional netgraph_mppc_compression # The next two files (plus the header file net/mppc.h) are proprietary and # must be obtained elsewhere in order to enable NETGRAPH_MPPC_COMPRESSION net/mppcc.c optional netgraph_mppc_compression net/mppcd.c optional netgraph_mppc_compression netgraph/ng_mppc.c optional netgraph_mppc_encryption crypto/rc4/rc4.c optional awi crypto/rc4/rc4.c optional netgraph_mppc_encryption crypto/sha1.c optional netgraph_mppc_encryption netgraph/ng_parse.c optional netgraph netgraph/ng_ppp.c optional netgraph_ppp netgraph/ng_pppoe.c optional netgraph_pppoe netgraph/ng_pptpgre.c optional netgraph_pptpgre netgraph/ng_rfc1490.c optional netgraph_rfc1490 netgraph/ng_socket.c optional netgraph_socket netgraph/ng_tee.c optional netgraph_tee netgraph/ng_tty.c optional netgraph_tty netgraph/ng_vjc.c optional netgraph_vjc net/slcompress.c optional netgraph_vjc netinet/accf_data.c optional accept_filter_data netinet/accf_http.c optional accept_filter_http netinet/fil.c optional ipfilter inet netinet/if_atm.c optional atm netinet/if_ether.c optional ether netinet/igmp.c optional inet netinet/in.c optional inet netinet/in_gif.c optional gif inet #netinet/in_hostcache.c optional inet netinet/in_pcb.c optional inet netinet/in_proto.c optional inet netinet/in_rmx.c optional inet netinet/ip_auth.c optional ipfilter inet netinet/ip_divert.c optional ipdivert netinet/ip_dummynet.c optional dummynet netinet/ip_ecn.c optional inet netinet/ip_ecn.c optional inet6 netinet/ip_encap.c optional inet netinet/ip_encap.c optional inet6 netinet/ip_fil.c optional ipfilter inet netinet/ip_flow.c optional inet netinet/ip_frag.c optional ipfilter inet netinet/ip_fw.c optional ipfirewall netinet/ip_icmp.c optional inet netinet/ip_input.c optional inet netinet/ip_log.c optional ipfilter inet netinet/ip_mroute.c optional inet netinet/ip_nat.c optional ipfilter inet netinet/ip_output.c optional inet netinet/ip_proxy.c optional ipfilter inet netinet/ip_state.c optional ipfilter inet netinet/mlfk_ipl.c optional ipfilter inet netinet/raw_ip.c optional inet netinet/tcp_debug.c optional tcpdebug netinet/tcp_input.c optional inet netinet/tcp_output.c optional inet netinet/tcp_subr.c optional inet netinet/tcp_timer.c optional inet netinet/tcp_usrreq.c optional inet netinet/udp_usrreq.c optional inet netinet6/ah_core.c optional ipsec netinet6/ah_input.c optional ipsec netinet6/ah_output.c optional ipsec netinet6/dest6.c optional inet6 netinet6/esp_core.c optional ipsec ipsec_esp netinet6/esp_input.c optional ipsec ipsec_esp netinet6/esp_output.c optional ipsec ipsec_esp netinet6/frag6.c optional inet6 netinet6/icmp6.c optional inet6 netinet6/in6.c optional inet6 netinet6/in6_cksum.c optional inet6 netinet6/in6_gif.c optional gif inet6 netinet6/in6_ifattach.c optional inet6 netinet6/in6_pcb.c optional inet6 netinet6/in6_prefix.c optional inet6 netinet6/in6_proto.c optional inet6 netinet6/in6_rmx.c optional inet6 netinet6/in6_src.c optional inet6 netinet6/ip6_forward.c optional inet6 netinet6/ip6_fw.c optional inet6 ipv6firewall netinet6/ip6_input.c optional inet6 netinet6/ip6_mroute.c optional inet6 netinet6/ip6_output.c optional inet6 netinet6/ipcomp_core.c optional ipsec netinet6/ipcomp_input.c optional ipsec netinet6/ipcomp_output.c optional ipsec netinet6/ipsec.c optional ipsec netinet6/mld6.c optional inet6 netinet6/nd6.c optional inet6 netinet6/nd6_nbr.c optional inet6 netinet6/nd6_rtr.c optional inet6 netinet6/raw_ip6.c optional inet6 netinet6/route6.c optional inet6 netinet6/scope6.c optional inet6 netinet6/udp6_output.c optional inet6 netinet6/udp6_usrreq.c optional inet6 netipx/ipx.c optional ipx netipx/ipx_cksum.c optional ipx netipx/ipx_input.c optional ipx netipx/ipx_ip.c optional ipx netipx/ipx_outputfl.c optional ipx netipx/ipx_pcb.c optional ipx netipx/ipx_proto.c optional ipx netipx/ipx_tun.c optional ipx netipx/ipx_usrreq.c optional ipx netipx/spx_debug.c optional ipx netipx/spx_usrreq.c optional ipx netkey/key.c optional ipsec netkey/keydb.c optional ipsec netkey/key_debug.c optional ipsec netkey/keysock.c optional ipsec netnatm/natm.c optional natm netnatm/natm_pcb.c optional natm netnatm/natm_proto.c optional natm netncp/ncp_conn.c optional ncp netncp/ncp_crypt.c optional ncp netncp/ncp_login.c optional ncp netncp/ncp_mod.c optional ncp netncp/ncp_ncp.c optional ncp netncp/ncp_nls.c optional ncp netncp/ncp_rq.c optional ncp netncp/ncp_sock.c optional ncp netncp/ncp_subr.c optional ncp netns/idp_usrreq.c optional ns netns/ns.c optional ns netns/ns_error.c optional ns netns/ns_input.c optional ns netns/ns_ip.c optional ns netns/ns_output.c optional ns netns/ns_pcb.c optional ns netns/ns_proto.c optional ns netns/spp_debug.c optional ns netns/spp_usrreq.c optional ns nfs/bootp_subr.c optional bootp nfs/krpc_subr.c optional bootp nfs/nfs_bio.c optional nfs nfs/nfs_node.c optional nfs nfs/nfs_nqlease.c optional nfs nfs/nfs_serv.c optional nfs nfs/nfs_socket.c optional nfs nfs/nfs_srvcache.c optional nfs nfs/nfs_subs.c optional nfs nfs/nfs_syscalls.c optional nfs nfs/nfs_vfsops.c optional nfs nfs/nfs_vnops.c optional nfs ntfs/ntfs_compr.c optional ntfs ntfs/ntfs_ihash.c optional ntfs ntfs/ntfs_subr.c optional ntfs ntfs/ntfs_vfsops.c optional ntfs ntfs/ntfs_vnops.c optional ntfs nwfs/nwfs_io.c optional nwfs nwfs/nwfs_ioctl.c optional nwfs nwfs/nwfs_node.c optional nwfs nwfs/nwfs_subr.c optional nwfs nwfs/nwfs_vfsops.c optional nwfs nwfs/nwfs_vnops.c optional nwfs pccard/pccard.c count card pccard/pccard_beep.c optional card pccard/pccard_nbk.c optional card pccard/pcic.c optional pcic card pci/agp.c optional agp pci/agp_if.m optional agp pci/agp_intel.c optional agp pci/agp_via.c optional agp pci/agp_sis.c optional agp pci/agp_ali.c optional agp pci/agp_amd.c optional agp pci/agp_i810.c optional agp pci/alpm.c count alpm pci/amd.c optional amd pci/cy_pci.c optional cy pci pci/if_ar_p.c count ar pci pci/if_dc.c optional dc pci/if_de.c optional de pci/if_en_pci.c optional en pci pci/if_fxp.c optional fxp pci/if_mn.c optional mn pci/if_pcn.c optional pcn pci/if_rl.c optional rl pci/if_sf.c optional sf pci/if_sis.c optional sis pci/if_sk.c optional sk pci/if_sr_p.c optional sr pci pci/if_ste.c optional ste pci/if_ti.c optional ti pci/if_tl.c optional tl pci/if_tx.c optional tx pci/if_vr.c optional vr pci/if_wb.c optional wb pci/if_wx.c optional wx pci/if_xl.c optional xl pci/intpm.c optional intpm pci/isp_pci.c optional isp pci/meteor.c count meteor pci pci/ncr.c optional ncr pci/ohci_pci.c optional ohci pci/pccbb.c optional pccbb cardbus pci/pci.c count pci pci/pci_compat.c optional pci compat_oldpci \ warning "Old PCI driver compatability shims present." pci/pcic_p.c optional pcic pci pci/pcisupport.c optional pci pci/pci_if.m optional pci pci/pcib_if.m optional pci pci/simos.c optional simos pci/uhci_pci.c optional uhci pci/xrpu.c optional xrpu posix4/ksched.c optional _kposix_priority_scheduling posix4/p1003_1b.c standard posix4/posix4_mib.c standard ufs/ffs/ffs_alloc.c optional ffs ufs/ffs/ffs_alloc.c optional ifs ufs/ffs/ffs_alloc.c optional mfs ufs/ffs/ffs_balloc.c optional ffs ufs/ffs/ffs_balloc.c optional ifs ufs/ffs/ffs_balloc.c optional mfs ufs/ffs/ffs_inode.c optional ffs ufs/ffs/ffs_inode.c optional ifs ufs/ffs/ffs_inode.c optional mfs ufs/ffs/ffs_snapshot.c optional ffs ufs/ffs/ffs_snapshot.c optional ifs ufs/ffs/ffs_snapshot.c optional mfs ufs/ffs/ffs_softdep.c optional softupdates ufs/ffs/ffs_softdep_stub.c standard ufs/ffs/ffs_subr.c optional ffs ufs/ffs/ffs_subr.c optional ifs ufs/ffs/ffs_subr.c optional mfs ufs/ffs/ffs_tables.c optional ffs ufs/ffs/ffs_tables.c optional ifs ufs/ffs/ffs_tables.c optional mfs ufs/ffs/ffs_vfsops.c optional ffs ufs/ffs/ffs_vfsops.c optional ifs ufs/ffs/ffs_vfsops.c optional mfs ufs/ffs/ffs_vnops.c optional ffs ufs/ffs/ffs_vnops.c optional ifs ufs/ffs/ffs_vnops.c optional mfs ufs/mfs/mfs_vfsops.c optional mfs ufs/mfs/mfs_vnops.c optional mfs ufs/ufs/ufs_bmap.c standard ufs/ufs/ufs_extattr.c standard ufs/ufs/ufs_ihash.c standard ufs/ufs/ufs_inode.c standard ufs/ufs/ufs_lookup.c standard ufs/ifs/ifs_lookup.c optional ifs ufs/ifs/ifs_vfsops.c optional ifs ufs/ifs/ifs_vnops.c optional ifs ufs/ifs/ifs_subr.c optional ifs ufs/ufs/ufs_quota.c standard ufs/ufs/ufs_vfsops.c standard ufs/ufs/ufs_vnops.c standard vm/default_pager.c standard vm/device_pager.c standard vm/phys_pager.c standard vm/swap_pager.c standard vm/vm_fault.c standard vm/vm_glue.c standard vm/vm_init.c standard vm/vm_kern.c standard vm/vm_map.c standard vm/vm_meter.c standard vm/vm_mmap.c standard vm/vm_object.c standard vm/vm_page.c standard vm/vm_pageout.c standard vm/vm_pager.c standard vm/vm_swap.c standard vm/vm_unix.c standard vm/vm_zone.c standard vm/vnode_pager.c standard Index: head/sys/dev/randomdev/randomdev.c =================================================================== --- head/sys/dev/randomdev/randomdev.c (revision 67111) +++ head/sys/dev/randomdev/randomdev.c (nonexistent) @@ -1,175 +0,0 @@ -/*- - * Copyright (c) 2000 Mark R V Murray - * All rights reserved. - * - * 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 - * in this position and unchanged. - * 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 AUTHOR ``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 AUTHOR 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. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -static d_open_t random_open; -static d_read_t random_read; -static d_write_t random_write; -static d_ioctl_t random_ioctl; - -#define CDEV_MAJOR 2 -#define RANDOM_MINOR 3 -#define URANDOM_MINOR 4 - -static struct cdevsw random_cdevsw = { - /* open */ random_open, - /* close */ (d_close_t *)nullop, - /* read */ random_read, - /* write */ random_write, - /* ioctl */ random_ioctl, - /* poll */ nopoll, - /* mmap */ nommap, - /* strategy */ nostrategy, - /* name */ "random", - /* maj */ CDEV_MAJOR, - /* dump */ nodump, - /* psize */ nopsize, - /* flags */ 0, - /* bmaj */ -1 -}; - -/* For use with make_dev(9)/destroy_dev(9). */ -static dev_t random_dev; -static dev_t urandom_dev; /* XXX Temporary */ - -SYSCTL_NODE(_kern, OID_AUTO, random, CTLFLAG_RW, 0, "Random Number Generator"); -SYSCTL_NODE(_kern_random, OID_AUTO, yarrow, CTLFLAG_RW, 0, "Yarrow Parameters"); -SYSCTL_INT(_kern_random_yarrow, OID_AUTO, gengateinterval, CTLFLAG_RW, - &random_state.gengateinterval, 10, "Generator Gate Interval"); -SYSCTL_INT(_kern_random_yarrow, OID_AUTO, bins, CTLFLAG_RW, - &random_state.bins, 10, "Execution time tuner"); -SYSCTL_INT(_kern_random_yarrow, OID_AUTO, fastthresh, CTLFLAG_RW, - &random_state.pool[0].thresh, 100, "Fast pool reseed threshhold"); -SYSCTL_INT(_kern_random_yarrow, OID_AUTO, slowthresh, CTLFLAG_RW, - &random_state.pool[1].thresh, 160, "Slow pool reseed threshhold"); -SYSCTL_INT(_kern_random_yarrow, OID_AUTO, slowoverthresh, CTLFLAG_RW, - &random_state.slowoverthresh, 2, "Slow pool over-threshhold reseed"); - -static int -random_open(dev_t dev, int flags, int fmt, struct proc *p) -{ - if ((flags & FWRITE) && (securelevel > 0 || suser(p))) - return EPERM; - else - return 0; -} - -static int -random_read(dev_t dev, struct uio *uio, int flag) -{ - u_int c, ret; - int error = 0; - void *random_buf; - - c = min(uio->uio_resid, PAGE_SIZE); - random_buf = (void *)malloc(c, M_TEMP, M_WAITOK); - while (uio->uio_resid > 0 && error == 0) { - ret = read_random(random_buf, c); - error = uiomove(random_buf, ret, uio); - } - free(random_buf, M_TEMP); - return error; -} - -static int -random_write(dev_t dev, struct uio *uio, int flag) -{ - u_int c; - int error = 0; - void *random_buf; - - random_buf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK); - while (uio->uio_resid > 0) { - c = min(uio->uio_resid, PAGE_SIZE); - error = uiomove(random_buf, c, uio); - if (error) - break; - write_random(random_buf, c); - } - free(random_buf, M_TEMP); - return error; -} - -static int -random_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) -{ - return ENOTTY; -} - -static int -random_modevent(module_t mod, int type, void *data) -{ - int error; - - switch(type) { - case MOD_LOAD: - error = random_init(); - if (error != 0) - return error; - if (bootverbose) - printf("random: \n"); - random_dev = make_dev(&random_cdevsw, RANDOM_MINOR, UID_ROOT, - GID_WHEEL, 0666, "random"); - urandom_dev = make_dev(&random_cdevsw, URANDOM_MINOR, UID_ROOT, - GID_WHEEL, 0666, "urandom"); /* XXX Temporary */ - return 0; - - case MOD_UNLOAD: - random_deinit(); - destroy_dev(random_dev); - destroy_dev(urandom_dev); /* XXX Temporary */ - return 0; - - case MOD_SHUTDOWN: - return 0; - - default: - return EOPNOTSUPP; - } -} - -DEV_MODULE(random, random_modevent, NULL); Property changes on: head/sys/dev/randomdev/randomdev.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/sys/dev/randomdev/hash.c =================================================================== --- head/sys/dev/randomdev/hash.c (revision 67111) +++ head/sys/dev/randomdev/hash.c (nonexistent) @@ -1,119 +0,0 @@ -/*- - * Copyright (c) 2000 Mark R V Murray - * All rights reserved. - * - * 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 - * in this position and unchanged. - * 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 AUTHOR ``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 AUTHOR 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. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -/* initialise the hash by copying in some supplied data */ -void -yarrow_hash_init(struct yarrowhash *context, void *data, size_t size) -{ - size_t count; - - count = size > KEYSIZE ? KEYSIZE : size; - memset(context->hash, 0xff, KEYSIZE); - memcpy(context->hash, data, count); -} - -/* Do a Davies-Meyer hash using a block cipher. - * H_0 = I - * H_i = E_M_i(H_i-1) ^ H_i-1 - */ -void -yarrow_hash_iterate(struct yarrowhash *context, void *data, size_t size) -{ - u_char keybuffer[KEYSIZE], temp[KEYSIZE]; - size_t count; - int iteration, last, i; - - iteration = 0; - last = 0; - for (;;) { - if (size <= KEYSIZE) - last = 1; - count = size > KEYSIZE ? KEYSIZE : size; - memcpy(keybuffer, &((u_char *)data)[iteration], count); - memset(&keybuffer[KEYSIZE - count], 0xff, count); - BF_set_key(&context->hashkey, count, - &((u_char *)data)[iteration]); - BF_cbc_encrypt(context->hash, temp, KEYSIZE, &context->hashkey, - context->ivec, BF_ENCRYPT); - for (i = 0; i < KEYSIZE; i++) - context->hash[i] ^= temp[i]; - if (last) - break; - iteration += KEYSIZE; - size -= KEYSIZE; - } -} - -/* Conclude by returning a pointer to the data */ -void -yarrow_hash_finish(struct yarrowhash *context, void *buf) -{ - memcpy(buf, context->hash, sizeof(context->hash)); -} - -/* Initialise the encryption routine by setting up the key schedule */ -void -yarrow_encrypt_init(struct yarrowkey *context, void *data, size_t size) -{ - size_t count; - - count = size > KEYSIZE ? KEYSIZE : size; - BF_set_key(&context->key, size, data); -} - -/* Encrypt the supplied data using the key schedule preset in the context */ -void -yarrow_encrypt(struct yarrowkey *context, void *d_in, void *d_out, size_t size) -{ - size_t count; - int iteration, last; - - last = 0; - for (iteration = 0;; iteration += KEYSIZE) { - if (size <= KEYSIZE) - last = 1; - count = size > KEYSIZE ? KEYSIZE : size; - BF_cbc_encrypt(&((u_char *)d_in)[iteration], - &((u_char *)d_out)[iteration], count, &context->key, - context->ivec, BF_ENCRYPT); - if (last) - break; - size -= KEYSIZE; - } -} Property changes on: head/sys/dev/randomdev/hash.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/sys/dev/randomdev/harvest.c =================================================================== --- head/sys/dev/randomdev/harvest.c (revision 67111) +++ head/sys/dev/randomdev/harvest.c (nonexistent) @@ -1,91 +0,0 @@ -/*- - * Copyright (c) 2000 Mark R V Murray - * All rights reserved. - * - * 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 - * in this position and unchanged. - * 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 AUTHOR ``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 AUTHOR 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. - * - * $FreeBSD$ - */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/* hold the address of the routine which is actually called if - * the ramdomdev is loaded - */ -static void (*reap)(struct timespec *, void *, u_int, u_int, u_int, u_int) = NULL; - -/* Initialise the harvester at load time */ -void -random_init_harvester(void (*reaper)(struct timespec *, void *, u_int, u_int, u_int, u_int)) -{ - reap = reaper; -} - -/* Deinitialise the harvester at unload time */ -void -random_deinit_harvester(void) -{ - reap = NULL; -} - -/* Entropy harvesting routine. This is supposed to be fast; do - * not do anything slow in here! - * Implemented as in indirect call to allow non-inclusion of - * the entropy device. - */ -void -random_harvest(void *entropy, u_int count, u_int bits, u_int frac, u_int origin) -{ - struct timespec timebuf; - - if (reap) { - nanotime(&timebuf); - (*reap)(&timebuf, entropy, count, bits, frac, origin); - } -} - -/* Helper routines to enable kthread_exit() to work while the module is - * being (or has been) unloaded. - */ -void -random_set_wakeup(int *var, int value) -{ - *var = value; - wakeup(var); -} - -void -random_set_wakeup_exit(int *var, int value, int exitval) -{ - random_set_wakeup(var, value); - kthread_exit(exitval); -} Property changes on: head/sys/dev/randomdev/harvest.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/sys/dev/randomdev/hash.h =================================================================== --- head/sys/dev/randomdev/hash.h (revision 67111) +++ head/sys/dev/randomdev/hash.h (nonexistent) @@ -1,46 +0,0 @@ -/*- - * Copyright (c) 2000 Mark R V Murray - * All rights reserved. - * - * 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 - * in this position and unchanged. - * 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 AUTHOR ``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 AUTHOR 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. - * - * $FreeBSD$ - */ - -#define KEYSIZE 32 /* 32 bytes == 256 bits */ - -struct yarrowhash { /* Big! Make static! */ - BF_KEY hashkey; /* Data cycles through here */ - u_char ivec[8]; /* Blowfish Internal */ - u_char hash[KEYSIZE]; /* Repeatedly encrypted */ -}; - -struct yarrowkey { /* Big! Make static! */ - BF_KEY key; /* Key schedule */ - u_char ivec[8]; /* Blowfish Internal */ -}; - -void yarrow_hash_init(struct yarrowhash *, void *, size_t); -void yarrow_hash_iterate(struct yarrowhash *, void *, size_t); -void yarrow_hash_finish(struct yarrowhash *, void *); -void yarrow_encrypt_init(struct yarrowkey *, void *, size_t); -void yarrow_encrypt(struct yarrowkey *context, void *, void *, size_t); Property changes on: head/sys/dev/randomdev/hash.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/sys/dev/randomdev/yarrow.c =================================================================== --- head/sys/dev/randomdev/yarrow.c (revision 67111) +++ head/sys/dev/randomdev/yarrow.c (nonexistent) @@ -1,525 +0,0 @@ -/*- - * Copyright (c) 2000 Mark R V Murray - * All rights reserved. - * - * 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 - * in this position and unchanged. - * 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 AUTHOR ``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 AUTHOR 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. - * - * $FreeBSD$ - */ - -/* NOTE NOTE NOTE - This is not finished! It will supply numbers, but - * it is not yet cryptographically secure!! - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -/* #define DEBUG */ -/* #define DEBUG1 */ /* Very noisy - prints plenty harvesting stats */ - -static void generator_gate(void); -static void reseed(int); -static void random_harvest_internal(struct timespec *, void *, u_int, u_int, u_int, enum esource); - -static void random_kthread(void *); - -/* Structure holding the entropy state */ -struct random_state random_state; - -/* Queue holding harvested entropy */ -TAILQ_HEAD(harvestqueue, harvest) harvestqueue, - initqueue = TAILQ_HEAD_INITIALIZER(harvestqueue); - -/* These are used to queue harvested packets of entropy. The entropy - * buffer size of 16 is pretty arbitrary. - */ -struct harvest { - struct timespec time; /* nanotime for clock jitter */ - u_char entropy[16]; /* the harvested entropy */ - u_int size, bits, frac; /* stats about the entropy */ - enum esource source; /* stats about the entropy */ - u_int pool; /* which pool this goes into */ - TAILQ_ENTRY(harvest) harvest; /* link to next */ -}; - -/* The reseed thread mutex */ -static struct mtx random_reseed_mtx; - -/* The entropy harvest mutex */ -static struct mtx random_harvest_mtx; - -/* <0 until the kthread starts, 0 for running */ -static int random_kthread_status = -1; - -/* <0 to end the kthread, 0 to let it run */ -static int random_kthread_control = 0; - -static struct proc *random_kthread_proc; - -static void -random_kthread(void *status) -{ - int pl, src, overthreshhold[2]; - struct harvest *event; - struct source *source; -#ifdef DEBUG1 - int queuecount; -#endif - -#ifdef DEBUG - printf("At %s, line %d: mtx_owned(&Giant) == %d\n", __FILE__, __LINE__, mtx_owned(&Giant)); - printf("At %s, line %d: mtx_owned(&sched_lock) == %d\n", __FILE__, __LINE__, mtx_owned(&sched_lock)); -#endif - random_set_wakeup((int *)status, 0); - - for (pl = 0; pl < 2; pl++) - yarrow_hash_init(&random_state.pool[pl].hash, NULL, 0); - - for (;;) { - - if (TAILQ_EMPTY(&harvestqueue)) { - - /* Sleep for a second to give the system a chance */ - mtx_enter(&Giant, MTX_DEF); - tsleep(&harvestqueue, PUSER, "rndslp", hz); - mtx_exit(&Giant, MTX_DEF); - - } - else { - - /* Suck the harvested entropy out of the queue and hash - * it into the fast and slow pools. - */ -#ifdef DEBUG1 - queuecount = 0; -#endif - while (!TAILQ_EMPTY(&harvestqueue)) { -#ifdef DEBUG1 - queuecount++; -#endif - mtx_enter(&random_harvest_mtx, MTX_DEF); - - event = TAILQ_FIRST(&harvestqueue); - TAILQ_REMOVE(&harvestqueue, event, harvest); - - mtx_exit(&random_harvest_mtx, MTX_DEF); - - source = &random_state.pool[event->pool].source[event->source]; - yarrow_hash_iterate(&random_state.pool[event->pool].hash, - event->entropy, sizeof(event->entropy)); - yarrow_hash_iterate(&random_state.pool[event->pool].hash, - &event->time, sizeof(event->time)); - source->frac += event->frac; - source->bits += event->bits + source->frac/1024; - source->frac %= 1024; - free(event, M_TEMP); - - /* XXX abuse tsleep() to get at mi_switch() */ - /* tsleep(&harvestqueue, PUSER, "rndprc", 1); */ - - } -#ifdef DEBUG1 - printf("Harvested %d events\n", queuecount); -#endif - - /* Count the over-threshold sources in each pool */ - for (pl = 0; pl < 2; pl++) { - overthreshhold[pl] = 0; - for (src = 0; src < ENTROPYSOURCE; src++) { - if (random_state.pool[pl].source[src].bits - > random_state.pool[pl].thresh) - overthreshhold[pl]++; - } - } - - /* if any fast source over threshhold, reseed */ - if (overthreshhold[FAST]) - reseed(FAST); - - /* if enough slow sources are over threshhold, reseed */ - if (overthreshhold[SLOW] >= random_state.slowoverthresh) - reseed(SLOW); - - } - - /* Is the thread scheduled for a shutdown? */ - if (random_kthread_control < 0) { - if (!TAILQ_EMPTY(&harvestqueue)) { -#ifdef DEBUG - printf("Random cleaning extraneous events\n"); -#endif - mtx_enter(&random_harvest_mtx, MTX_DEF); - TAILQ_FOREACH(event, &harvestqueue, harvest) { - TAILQ_REMOVE(&harvestqueue, event, harvest); - free(event, M_TEMP); - } - mtx_exit(&random_harvest_mtx, MTX_DEF); - } -#ifdef DEBUG - printf("Random kthread setting terminate\n"); -#endif - random_set_wakeup_exit((int *)status, -1, 0); - break; - } - - } - -} - -int -random_init(void) -{ - int error; - -#ifdef DEBUG - printf("Random initialise\n"); -#endif - - random_state.gengateinterval = 10; - random_state.bins = 10; - random_state.pool[0].thresh = 100; - random_state.pool[1].thresh = 160; - random_state.slowoverthresh = 2; - random_state.which = FAST; - - harvestqueue = initqueue; - - /* Initialise the mutexes */ - mtx_init(&random_reseed_mtx, "random reseed", MTX_DEF); - mtx_init(&random_harvest_mtx, "random harvest", MTX_DEF); - - /* Start the hash/reseed thread */ - error = kthread_create(random_kthread, &random_kthread_status, - &random_kthread_proc, RFHIGHPID, "random"); - if (error != 0) - return error; - - /* Register the randomness harvesting routine */ - random_init_harvester(random_harvest_internal); - -#ifdef DEBUG - printf("Random initalise finish\n"); -#endif - - return 0; -} - -void -random_deinit(void) -{ -#ifdef DEBUG - printf("Random deinitalise\n"); -#endif - - /* Deregister the randomness harvesting routine */ - random_deinit_harvester(); - -#ifdef DEBUG - printf("Random deinitalise waiting for thread to terminate\n"); -#endif - - /* Command the hash/reseed thread to end and wait for it to finish */ - random_kthread_control = -1; - while (random_kthread_status != -1) - tsleep(&random_kthread_status, PUSER, "rndend", hz); - -#ifdef DEBUG - printf("Random deinitalise removing mutexes\n"); -#endif - - /* Remove the mutexes */ - mtx_destroy(&random_reseed_mtx); - mtx_destroy(&random_harvest_mtx); - -#ifdef DEBUG - printf("Random deinitalise finish\n"); -#endif -} - -static void -reseed(int fastslow) -{ - /* Interrupt-context stack is a limited resource; make large - * structures static. - */ - static u_char v[TIMEBIN][KEYSIZE]; /* v[i] */ - static struct yarrowhash context; - u_char hash[KEYSIZE]; /* h' */ - u_char temp[KEYSIZE]; - int i, j; - -#ifdef DEBUG - printf("Reseed type %d\n", fastslow); -#endif - - /* The reseed task must not be jumped on */ - mtx_enter(&random_reseed_mtx, MTX_DEF); - - /* 1. Hash the accumulated entropy into v[0] */ - - yarrow_hash_init(&context, NULL, 0); - /* Feed the slow pool hash in if slow */ - if (fastslow == SLOW) - yarrow_hash_iterate(&context, - &random_state.pool[SLOW].hash, sizeof(struct yarrowhash)); - - yarrow_hash_iterate(&context, - &random_state.pool[FAST].hash, sizeof(struct yarrowhash)); - - /* 2. Compute hash values for all v. _Supposed_ to be computationally - * intensive. - */ - - if (random_state.bins > TIMEBIN) - random_state.bins = TIMEBIN; - for (i = 1; i < random_state.bins; i++) { - yarrow_hash_init(&context, NULL, 0); - /* v[i] #= h(v[i-1]) */ - yarrow_hash_iterate(&context, v[i - 1], KEYSIZE); - /* v[i] #= h(v[0]) */ - yarrow_hash_iterate(&context, v[0], KEYSIZE); - /* v[i] #= h(i) */ - yarrow_hash_iterate(&context, &i, sizeof(int)); - /* Return the hashval */ - yarrow_hash_finish(&context, v[i]); - } - - /* 3. Compute a new key; h' is the identity function here; - * it is not being ignored! - */ - - yarrow_hash_init(&context, NULL, 0); - yarrow_hash_iterate(&context, &random_state.key, KEYSIZE); - for (i = 1; i < random_state.bins; i++) - yarrow_hash_iterate(&context, &v[i], KEYSIZE); - yarrow_hash_finish(&context, temp); - yarrow_encrypt_init(&random_state.key, temp, KEYSIZE); - - /* 4. Recompute the counter */ - - random_state.counter = 0; - yarrow_encrypt(&random_state.key, &random_state.counter, temp, - sizeof(random_state.counter)); - memcpy(&random_state.counter, temp, random_state.counter); - - /* 5. Reset entropy estimate accumulators to zero */ - - for (i = 0; i <= fastslow; i++) { - for (j = 0; j < ENTROPYSOURCE; j++) { - if (random_state.pool[i].source[j].bits > - random_state.pool[i].thresh) { - random_state.pool[i].source[j].bits = 0; - random_state.pool[i].source[j].frac = 0; - } - } - } - - /* 6. Wipe memory of intermediate values */ - - memset((void *)v, 0, sizeof(v)); - memset((void *)temp, 0, sizeof(temp)); - memset((void *)hash, 0, sizeof(hash)); - - /* 7. Dump to seed file */ - /* XXX Not done here yet */ - - /* Release the reseed mutex */ - mtx_exit(&random_reseed_mtx, MTX_DEF); - -#ifdef DEBUG - printf("Reseed finish\n"); -#endif - -} - -u_int -read_random(void *buf, u_int count) -{ - static u_int64_t genval; - static int cur = 0; - static int gate = 1; - u_int i; - u_int retval; - - /* The reseed task must not be jumped on */ - mtx_enter(&random_reseed_mtx, MTX_DEF); - - if (gate) { - generator_gate(); - random_state.outputblocks = 0; - gate = 0; - } - if (count >= sizeof(random_state.counter)) { - retval = 0; - for (i = 0; i < count; i += sizeof(random_state.counter)) { - random_state.counter++; - yarrow_encrypt(&random_state.key, &random_state.counter, - &genval, sizeof(random_state.counter)); - memcpy((char *)buf + i, &genval, - sizeof(random_state.counter)); - if (++random_state.outputblocks >= random_state.gengateinterval) { - generator_gate(); - random_state.outputblocks = 0; - } - retval += sizeof(random_state.counter); - } - } - else { - if (!cur) { - random_state.counter++; - yarrow_encrypt(&random_state.key, &random_state.counter, - &genval, sizeof(random_state.counter)); - memcpy(buf, &genval, count); - cur = sizeof(random_state.counter) - count; - if (++random_state.outputblocks >= random_state.gengateinterval) { - generator_gate(); - random_state.outputblocks = 0; - } - retval = count; - } - else { - retval = cur < count ? cur : count; - memcpy(buf, - (char *)&genval + - (sizeof(random_state.counter) - cur), - retval); - cur -= retval; - } - } - mtx_exit(&random_reseed_mtx, MTX_DEF); - return retval; -} - -void -write_random(void *buf, u_int count) -{ - u_int i; - struct timespec timebuf; - - /* arbitrarily break the input up into 8-byte chunks */ - for (i = 0; i < count; i += 8) { - nanotime(&timebuf); - random_harvest_internal(&timebuf, (char *)buf + i, 8, 0, 0, - RANDOM_WRITE); - } - - /* Maybe the loop iterated at least once */ - if (i > count) - i -= 8; - - /* Get the last bytes even if the input length is not a multiple of 8 */ - count %= 8; - if (count) { - nanotime(&timebuf); - random_harvest_internal(&timebuf, (char *)buf + i, count, 0, 0, - RANDOM_WRITE); - } - - /* Explicit reseed */ - reseed(FAST); -} - -static void -generator_gate(void) -{ - int i; - u_char temp[KEYSIZE]; - -#ifdef DEBUG - printf("Generator gate\n"); -#endif - - for (i = 0; i < KEYSIZE; i += sizeof(random_state.counter)) { - random_state.counter++; - yarrow_encrypt(&random_state.key, &random_state.counter, - &(temp[i]), sizeof(random_state.counter)); - } - - yarrow_encrypt_init(&random_state.key, temp, KEYSIZE); - memset((void *)temp, 0, KEYSIZE); - -#ifdef DEBUG - printf("Generator gate finish\n"); -#endif -} - -/* Entropy harvesting routine. This is supposed to be fast; do - * not do anything slow in here! - */ - -static void -random_harvest_internal(struct timespec *timep, void *entropy, u_int count, - u_int bits, u_int frac, enum esource origin) -{ - struct harvest *event; - u_int64_t entropy_buf; - -#if 0 -#ifdef DEBUG - printf("Random harvest\n"); -#endif -#endif - event = malloc(sizeof(struct harvest), M_TEMP, M_NOWAIT); - - if (origin < ENTROPYSOURCE && event != NULL) { - - /* nanotime provides clock jitter */ - event->time = *timep; - - /* the harvested entropy */ - count = count > sizeof(entropy_buf) - ? sizeof(entropy_buf) - : count; - memcpy(event->entropy, entropy, count); - - event->size = count; - event->bits = bits; - event->frac = frac; - event->source = origin; - - /* protect the queue from simultaneous updates */ - mtx_enter(&random_harvest_mtx, MTX_DEF); - - /* toggle the pool for next insertion */ - event->pool = random_state.which; - random_state.which = !random_state.which; - - TAILQ_INSERT_TAIL(&harvestqueue, event, harvest); - - mtx_exit(&random_harvest_mtx, MTX_DEF); - } -} Property changes on: head/sys/dev/randomdev/yarrow.c ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/sys/dev/randomdev/yarrow.h =================================================================== --- head/sys/dev/randomdev/yarrow.h (revision 67111) +++ head/sys/dev/randomdev/yarrow.h (nonexistent) @@ -1,75 +0,0 @@ -/*- - * Copyright (c) 2000 Mark R V Murray - * All rights reserved. - * - * 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 - * in this position and unchanged. - * 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 AUTHOR ``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 AUTHOR 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. - * - * $FreeBSD$ - */ - -/* #define ENTROPYSOURCE nn entropy sources (actually classes) - * The entropy classes will as follows: - * 0 - Direct write - * 1 - Keyboard - * 2 - Mouse - */ - -#define ENTROPYBIN 256 /* buckets to harvest entropy events */ -#define TIMEBIN 16 /* max value for Pt/t */ - -#define FAST 0 -#define SLOW 1 - -int random_init(void); -void random_deinit(void); -void random_init_harvester(void (*)(struct timespec *, void *, u_int, u_int, u_int, enum esource)); -void random_deinit_harvester(void); -void random_set_wakeup(int *, int); -void random_set_wakeup_exit(int *, int, int); - -void write_random(void *, u_int); - -/* This is the beastie that needs protecting. It contains all of the - * state that we are excited about. - * This is a biiig structure. It may move over to a malloc(9)ed - * replacement. - */ -struct random_state { - u_int64_t counter; /* C */ - struct yarrowkey key; /* K */ - int gengateinterval; /* Pg */ - int bins; /* Pt/t */ - int outputblocks; /* count output blocks for gates */ - u_int slowoverthresh; /* slow pool overthreshhold reseed count */ - struct pool { - struct source { - u_int bits; /* estimated bits of entropy */ - u_int frac; /* fractional bits of entropy - (given as 1024/n) */ - } source[ENTROPYSOURCE]; - u_int thresh; /* pool reseed threshhold */ - struct yarrowhash hash; /* accumulated entropy */ - } pool[2]; /* pool[0] is fast, pool[1] is slow */ - int which; /* toggle - shows the current insertion pool */ -}; - -extern struct random_state random_state; Property changes on: head/sys/dev/randomdev/yarrow.h ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/sys/dev/random/harvest.c =================================================================== --- head/sys/dev/random/harvest.c (revision 67111) +++ head/sys/dev/random/harvest.c (revision 67112) @@ -1,91 +1,134 @@ /*- * Copyright (c) 2000 Mark R V Murray * All rights reserved. * * 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 * in this position and unchanged. * 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 AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #include #include #include #include #include +#include +#include #include #include +#include #include -#include -#include +#include +#include +static u_int read_random_phony(void *, u_int); + /* hold the address of the routine which is actually called if * the ramdomdev is loaded */ -static void (*reap)(struct timespec *, void *, u_int, u_int, u_int, u_int) = NULL; +static void (*reap_func)(struct timespec *, void *, u_int, u_int, u_int, u_int) = NULL; +static u_int (*read_func)(void *, u_int) = read_random_phony; /* Initialise the harvester at load time */ void -random_init_harvester(void (*reaper)(struct timespec *, void *, u_int, u_int, u_int, u_int)) +random_init_harvester(void (*reaper)(struct timespec *, void *, u_int, u_int, u_int, u_int), u_int (*reader)(void *, u_int)) { - reap = reaper; + reap_func = reaper; + read_func = reader; } /* Deinitialise the harvester at unload time */ void random_deinit_harvester(void) { - reap = NULL; + reap_func = NULL; + read_func = read_random_phony; } /* Entropy harvesting routine. This is supposed to be fast; do * not do anything slow in here! * Implemented as in indirect call to allow non-inclusion of * the entropy device. */ void random_harvest(void *entropy, u_int count, u_int bits, u_int frac, u_int origin) { struct timespec timebuf; - if (reap) { + if (reap_func) { nanotime(&timebuf); - (*reap)(&timebuf, entropy, count, bits, frac, origin); + (*reap_func)(&timebuf, entropy, count, bits, frac, origin); } } -/* Helper routines to enable kthread_exit() to work while the module is - * being (or has been) unloaded. +/* Userland-visible version of read_random */ +u_int +read_random(void *buf, u_int count) +{ + return (*read_func)(buf, count); +} + +/* If the entropy device is not loaded, make a token effort to + * provide _some_ kind of randomness. This should only be used + * inside other RNG's, like arc4random(9). */ -void -random_set_wakeup(int *var, int value) +static u_int +read_random_phony(void *buf, u_int count) { - *var = value; - wakeup(var); + struct timespec timebuf; + u_long randval; + int size, i; + static int initialised = 0; + + /* Try to give random(9) a half decent initialisation + * DO not make the mistake of thinking this is secure!! + */ + if (!initialised) { + nanotime(&timebuf); + srandom((u_long)(timebuf.tv_sec ^ timebuf.tv_nsec)); + } + + /* Fill buf[] with random(9) output */ + for (i = 0; i < count; i+= sizeof(u_long)) { + randval = random(); + size = (count - i) < sizeof(u_long) ? (count - i) : sizeof(u_long); + memcpy(&((char *)buf)[i], &randval, size); + } + + return count; } +/* Helper routine to enable kthread_exit() to work while the module is + * being (or has been) unloaded. + * This routine is in this file because it is always linked into the kernel, + * and will thus never be unloaded. This is critical for unloadable modules + * that have threads. + */ void -random_set_wakeup_exit(int *var, int value, int exitval) +random_set_wakeup_exit(void *control) { - random_set_wakeup(var, value); - kthread_exit(exitval); + wakeup(control); + mtx_enter(&Giant, MTX_DEF); + kthread_exit(0); + /* NOTREACHED */ } Index: head/sys/dev/random/hash.c =================================================================== --- head/sys/dev/random/hash.c (revision 67111) +++ head/sys/dev/random/hash.c (revision 67112) @@ -1,119 +1,119 @@ /*- * Copyright (c) 2000 Mark R V Murray * All rights reserved. * * 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 * in this position and unchanged. * 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 AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include -#include +#include /* initialise the hash by copying in some supplied data */ void yarrow_hash_init(struct yarrowhash *context, void *data, size_t size) { size_t count; count = size > KEYSIZE ? KEYSIZE : size; memset(context->hash, 0xff, KEYSIZE); memcpy(context->hash, data, count); } /* Do a Davies-Meyer hash using a block cipher. * H_0 = I * H_i = E_M_i(H_i-1) ^ H_i-1 */ void yarrow_hash_iterate(struct yarrowhash *context, void *data, size_t size) { u_char keybuffer[KEYSIZE], temp[KEYSIZE]; size_t count; int iteration, last, i; iteration = 0; last = 0; for (;;) { if (size <= KEYSIZE) last = 1; count = size > KEYSIZE ? KEYSIZE : size; memcpy(keybuffer, &((u_char *)data)[iteration], count); memset(&keybuffer[KEYSIZE - count], 0xff, count); BF_set_key(&context->hashkey, count, &((u_char *)data)[iteration]); BF_cbc_encrypt(context->hash, temp, KEYSIZE, &context->hashkey, context->ivec, BF_ENCRYPT); for (i = 0; i < KEYSIZE; i++) context->hash[i] ^= temp[i]; if (last) break; iteration += KEYSIZE; size -= KEYSIZE; } } /* Conclude by returning a pointer to the data */ void yarrow_hash_finish(struct yarrowhash *context, void *buf) { memcpy(buf, context->hash, sizeof(context->hash)); } /* Initialise the encryption routine by setting up the key schedule */ void yarrow_encrypt_init(struct yarrowkey *context, void *data, size_t size) { size_t count; count = size > KEYSIZE ? KEYSIZE : size; BF_set_key(&context->key, size, data); } /* Encrypt the supplied data using the key schedule preset in the context */ void yarrow_encrypt(struct yarrowkey *context, void *d_in, void *d_out, size_t size) { size_t count; int iteration, last; last = 0; for (iteration = 0;; iteration += KEYSIZE) { if (size <= KEYSIZE) last = 1; count = size > KEYSIZE ? KEYSIZE : size; BF_cbc_encrypt(&((u_char *)d_in)[iteration], &((u_char *)d_out)[iteration], count, &context->key, context->ivec, BF_ENCRYPT); if (last) break; size -= KEYSIZE; } } Index: head/sys/dev/random/randomdev.c =================================================================== --- head/sys/dev/random/randomdev.c (revision 67111) +++ head/sys/dev/random/randomdev.c (revision 67112) @@ -1,175 +1,203 @@ /*- * Copyright (c) 2000 Mark R V Murray * All rights reserved. * * 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 * in this position and unchanged. * 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 AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ #include #include #include #include #include #include #include #include #include #include +#include #include +#include #include +#include #include #include #include #include -#include -#include +#include +#include static d_open_t random_open; static d_read_t random_read; static d_write_t random_write; static d_ioctl_t random_ioctl; +static d_poll_t random_poll; #define CDEV_MAJOR 2 #define RANDOM_MINOR 3 #define URANDOM_MINOR 4 static struct cdevsw random_cdevsw = { /* open */ random_open, /* close */ (d_close_t *)nullop, /* read */ random_read, /* write */ random_write, /* ioctl */ random_ioctl, - /* poll */ nopoll, + /* poll */ random_poll, /* mmap */ nommap, /* strategy */ nostrategy, /* name */ "random", /* maj */ CDEV_MAJOR, /* dump */ nodump, /* psize */ nopsize, /* flags */ 0, /* bmaj */ -1 }; /* For use with make_dev(9)/destroy_dev(9). */ static dev_t random_dev; static dev_t urandom_dev; /* XXX Temporary */ SYSCTL_NODE(_kern, OID_AUTO, random, CTLFLAG_RW, 0, "Random Number Generator"); SYSCTL_NODE(_kern_random, OID_AUTO, yarrow, CTLFLAG_RW, 0, "Yarrow Parameters"); SYSCTL_INT(_kern_random_yarrow, OID_AUTO, gengateinterval, CTLFLAG_RW, &random_state.gengateinterval, 10, "Generator Gate Interval"); SYSCTL_INT(_kern_random_yarrow, OID_AUTO, bins, CTLFLAG_RW, &random_state.bins, 10, "Execution time tuner"); SYSCTL_INT(_kern_random_yarrow, OID_AUTO, fastthresh, CTLFLAG_RW, &random_state.pool[0].thresh, 100, "Fast pool reseed threshhold"); SYSCTL_INT(_kern_random_yarrow, OID_AUTO, slowthresh, CTLFLAG_RW, &random_state.pool[1].thresh, 160, "Slow pool reseed threshhold"); SYSCTL_INT(_kern_random_yarrow, OID_AUTO, slowoverthresh, CTLFLAG_RW, &random_state.slowoverthresh, 2, "Slow pool over-threshhold reseed"); static int random_open(dev_t dev, int flags, int fmt, struct proc *p) { if ((flags & FWRITE) && (securelevel > 0 || suser(p))) return EPERM; else return 0; } static int random_read(dev_t dev, struct uio *uio, int flag) { u_int c, ret; int error = 0; void *random_buf; - c = min(uio->uio_resid, PAGE_SIZE); - random_buf = (void *)malloc(c, M_TEMP, M_WAITOK); - while (uio->uio_resid > 0 && error == 0) { - ret = read_random(random_buf, c); - error = uiomove(random_buf, ret, uio); + if (flag & IO_NDELAY && !random_state.seeded) { + error = EWOULDBLOCK; } - free(random_buf, M_TEMP); + else { + if (random_state.seeded) { + c = min(uio->uio_resid, PAGE_SIZE); + random_buf = (void *)malloc(c, M_TEMP, M_WAITOK); + while (uio->uio_resid > 0 && error == 0) { + ret = read_random_real(random_buf, c); + error = uiomove(random_buf, ret, uio); + } + free(random_buf, M_TEMP); + } + else + error = tsleep(&random_state, 0, "rndblk", 0); + } return error; } static int random_write(dev_t dev, struct uio *uio, int flag) { u_int c; int error = 0; void *random_buf; random_buf = (void *)malloc(PAGE_SIZE, M_TEMP, M_WAITOK); while (uio->uio_resid > 0) { c = min(uio->uio_resid, PAGE_SIZE); error = uiomove(random_buf, c, uio); if (error) break; write_random(random_buf, c); } free(random_buf, M_TEMP); return error; } static int random_ioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct proc *p) { return ENOTTY; +} + +static int +random_poll(dev_t dev, int events, struct proc *p) +{ + int revents; + + revents = 0; + if (events & (POLLIN | POLLRDNORM)) { + if (random_state.seeded) + revents = events & (POLLIN | POLLRDNORM); + else + selrecord(p, &random_state.rsel); + } + return revents; } static int random_modevent(module_t mod, int type, void *data) { int error; switch(type) { case MOD_LOAD: error = random_init(); if (error != 0) return error; if (bootverbose) printf("random: \n"); random_dev = make_dev(&random_cdevsw, RANDOM_MINOR, UID_ROOT, GID_WHEEL, 0666, "random"); urandom_dev = make_dev(&random_cdevsw, URANDOM_MINOR, UID_ROOT, GID_WHEEL, 0666, "urandom"); /* XXX Temporary */ return 0; case MOD_UNLOAD: random_deinit(); destroy_dev(random_dev); destroy_dev(urandom_dev); /* XXX Temporary */ return 0; case MOD_SHUTDOWN: return 0; default: return EOPNOTSUPP; } } DEV_MODULE(random, random_modevent, NULL); Index: head/sys/dev/random/yarrow.c =================================================================== --- head/sys/dev/random/yarrow.c (revision 67111) +++ head/sys/dev/random/yarrow.c (revision 67112) @@ -1,525 +1,528 @@ /*- * Copyright (c) 2000 Mark R V Murray * All rights reserved. * * 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 * in this position and unchanged. * 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 AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ /* NOTE NOTE NOTE - This is not finished! It will supply numbers, but * it is not yet cryptographically secure!! */ #include #include #include #include #include #include #include #include +#include #include #include #include #include #include #include -#include -#include +#include +#include /* #define DEBUG */ /* #define DEBUG1 */ /* Very noisy - prints plenty harvesting stats */ static void generator_gate(void); static void reseed(int); static void random_harvest_internal(struct timespec *, void *, u_int, u_int, u_int, enum esource); static void random_kthread(void *); /* Structure holding the entropy state */ struct random_state random_state; /* Queue holding harvested entropy */ TAILQ_HEAD(harvestqueue, harvest) harvestqueue, initqueue = TAILQ_HEAD_INITIALIZER(harvestqueue); /* These are used to queue harvested packets of entropy. The entropy - * buffer size of 16 is pretty arbitrary. + * buffer size is pretty arbitrary. */ struct harvest { struct timespec time; /* nanotime for clock jitter */ - u_char entropy[16]; /* the harvested entropy */ + u_char entropy[HARVESTSIZE]; /* the harvested entropy */ u_int size, bits, frac; /* stats about the entropy */ enum esource source; /* stats about the entropy */ u_int pool; /* which pool this goes into */ TAILQ_ENTRY(harvest) harvest; /* link to next */ }; /* The reseed thread mutex */ static struct mtx random_reseed_mtx; -/* The entropy harvest mutex */ +/* The entropy harvest mutex, as well as the mutex associated + * with the msleep() call during deinit + */ static struct mtx random_harvest_mtx; -/* <0 until the kthread starts, 0 for running */ -static int random_kthread_status = -1; - /* <0 to end the kthread, 0 to let it run */ static int random_kthread_control = 0; static struct proc *random_kthread_proc; static void -random_kthread(void *status) +random_kthread(void *arg /* NOTUSED */) { int pl, src, overthreshhold[2]; struct harvest *event; struct source *source; #ifdef DEBUG1 int queuecount; #endif #ifdef DEBUG - printf("At %s, line %d: mtx_owned(&Giant) == %d\n", __FILE__, __LINE__, mtx_owned(&Giant)); - printf("At %s, line %d: mtx_owned(&sched_lock) == %d\n", __FILE__, __LINE__, mtx_owned(&sched_lock)); + printf("At %s, line %d: mtx_owned(&Giant) == %d, mtx_owned(&sched_lock) == %d\n", __FILE__, __LINE__, mtx_owned(&Giant), mtx_owned(&sched_lock)); #endif - random_set_wakeup((int *)status, 0); for (pl = 0; pl < 2; pl++) yarrow_hash_init(&random_state.pool[pl].hash, NULL, 0); for (;;) { if (TAILQ_EMPTY(&harvestqueue)) { /* Sleep for a second to give the system a chance */ mtx_enter(&Giant, MTX_DEF); tsleep(&harvestqueue, PUSER, "rndslp", hz); mtx_exit(&Giant, MTX_DEF); } else { /* Suck the harvested entropy out of the queue and hash * it into the fast and slow pools. */ #ifdef DEBUG1 queuecount = 0; #endif while (!TAILQ_EMPTY(&harvestqueue)) { #ifdef DEBUG1 queuecount++; #endif mtx_enter(&random_harvest_mtx, MTX_DEF); event = TAILQ_FIRST(&harvestqueue); TAILQ_REMOVE(&harvestqueue, event, harvest); mtx_exit(&random_harvest_mtx, MTX_DEF); source = &random_state.pool[event->pool].source[event->source]; yarrow_hash_iterate(&random_state.pool[event->pool].hash, event->entropy, sizeof(event->entropy)); yarrow_hash_iterate(&random_state.pool[event->pool].hash, &event->time, sizeof(event->time)); source->frac += event->frac; source->bits += event->bits + source->frac/1024; source->frac %= 1024; free(event, M_TEMP); - /* XXX abuse tsleep() to get at mi_switch() */ - /* tsleep(&harvestqueue, PUSER, "rndprc", 1); */ - } #ifdef DEBUG1 printf("Harvested %d events\n", queuecount); #endif /* Count the over-threshold sources in each pool */ for (pl = 0; pl < 2; pl++) { overthreshhold[pl] = 0; for (src = 0; src < ENTROPYSOURCE; src++) { if (random_state.pool[pl].source[src].bits > random_state.pool[pl].thresh) overthreshhold[pl]++; } } /* if any fast source over threshhold, reseed */ if (overthreshhold[FAST]) reseed(FAST); /* if enough slow sources are over threshhold, reseed */ if (overthreshhold[SLOW] >= random_state.slowoverthresh) reseed(SLOW); } /* Is the thread scheduled for a shutdown? */ - if (random_kthread_control < 0) { + if (random_kthread_control != 0) { if (!TAILQ_EMPTY(&harvestqueue)) { #ifdef DEBUG printf("Random cleaning extraneous events\n"); #endif mtx_enter(&random_harvest_mtx, MTX_DEF); TAILQ_FOREACH(event, &harvestqueue, harvest) { TAILQ_REMOVE(&harvestqueue, event, harvest); free(event, M_TEMP); } mtx_exit(&random_harvest_mtx, MTX_DEF); } #ifdef DEBUG printf("Random kthread setting terminate\n"); #endif - random_set_wakeup_exit((int *)status, -1, 0); + random_set_wakeup_exit(&random_kthread_control); + /* NOTREACHED */ break; } } } int random_init(void) { int error; #ifdef DEBUG printf("Random initialise\n"); #endif random_state.gengateinterval = 10; random_state.bins = 10; random_state.pool[0].thresh = 100; random_state.pool[1].thresh = 160; random_state.slowoverthresh = 2; random_state.which = FAST; harvestqueue = initqueue; /* Initialise the mutexes */ mtx_init(&random_reseed_mtx, "random reseed", MTX_DEF); mtx_init(&random_harvest_mtx, "random harvest", MTX_DEF); /* Start the hash/reseed thread */ - error = kthread_create(random_kthread, &random_kthread_status, + error = kthread_create(random_kthread, NULL, &random_kthread_proc, RFHIGHPID, "random"); if (error != 0) return error; /* Register the randomness harvesting routine */ - random_init_harvester(random_harvest_internal); + random_init_harvester(random_harvest_internal, read_random_real); #ifdef DEBUG printf("Random initalise finish\n"); #endif return 0; } void random_deinit(void) { #ifdef DEBUG printf("Random deinitalise\n"); #endif /* Deregister the randomness harvesting routine */ random_deinit_harvester(); #ifdef DEBUG printf("Random deinitalise waiting for thread to terminate\n"); #endif /* Command the hash/reseed thread to end and wait for it to finish */ + mtx_enter(&random_harvest_mtx, MTX_DEF); random_kthread_control = -1; - while (random_kthread_status != -1) - tsleep(&random_kthread_status, PUSER, "rndend", hz); + msleep((void *)&random_kthread_control, &random_harvest_mtx, PUSER, + "rndend", 0); + mtx_exit(&random_harvest_mtx, MTX_DEF); #ifdef DEBUG printf("Random deinitalise removing mutexes\n"); #endif /* Remove the mutexes */ mtx_destroy(&random_reseed_mtx); mtx_destroy(&random_harvest_mtx); #ifdef DEBUG printf("Random deinitalise finish\n"); #endif } static void reseed(int fastslow) { /* Interrupt-context stack is a limited resource; make large * structures static. */ static u_char v[TIMEBIN][KEYSIZE]; /* v[i] */ static struct yarrowhash context; u_char hash[KEYSIZE]; /* h' */ u_char temp[KEYSIZE]; int i, j; #ifdef DEBUG printf("Reseed type %d\n", fastslow); #endif /* The reseed task must not be jumped on */ mtx_enter(&random_reseed_mtx, MTX_DEF); /* 1. Hash the accumulated entropy into v[0] */ yarrow_hash_init(&context, NULL, 0); /* Feed the slow pool hash in if slow */ if (fastslow == SLOW) yarrow_hash_iterate(&context, &random_state.pool[SLOW].hash, sizeof(struct yarrowhash)); yarrow_hash_iterate(&context, &random_state.pool[FAST].hash, sizeof(struct yarrowhash)); /* 2. Compute hash values for all v. _Supposed_ to be computationally * intensive. */ if (random_state.bins > TIMEBIN) random_state.bins = TIMEBIN; for (i = 1; i < random_state.bins; i++) { yarrow_hash_init(&context, NULL, 0); /* v[i] #= h(v[i-1]) */ yarrow_hash_iterate(&context, v[i - 1], KEYSIZE); /* v[i] #= h(v[0]) */ yarrow_hash_iterate(&context, v[0], KEYSIZE); /* v[i] #= h(i) */ yarrow_hash_iterate(&context, &i, sizeof(int)); /* Return the hashval */ yarrow_hash_finish(&context, v[i]); } /* 3. Compute a new key; h' is the identity function here; * it is not being ignored! */ yarrow_hash_init(&context, NULL, 0); yarrow_hash_iterate(&context, &random_state.key, KEYSIZE); for (i = 1; i < random_state.bins; i++) yarrow_hash_iterate(&context, &v[i], KEYSIZE); yarrow_hash_finish(&context, temp); yarrow_encrypt_init(&random_state.key, temp, KEYSIZE); /* 4. Recompute the counter */ random_state.counter = 0; yarrow_encrypt(&random_state.key, &random_state.counter, temp, sizeof(random_state.counter)); memcpy(&random_state.counter, temp, random_state.counter); /* 5. Reset entropy estimate accumulators to zero */ for (i = 0; i <= fastslow; i++) { for (j = 0; j < ENTROPYSOURCE; j++) { if (random_state.pool[i].source[j].bits > random_state.pool[i].thresh) { random_state.pool[i].source[j].bits = 0; random_state.pool[i].source[j].frac = 0; } } } /* 6. Wipe memory of intermediate values */ memset((void *)v, 0, sizeof(v)); memset((void *)temp, 0, sizeof(temp)); memset((void *)hash, 0, sizeof(hash)); /* 7. Dump to seed file */ /* XXX Not done here yet */ /* Release the reseed mutex */ mtx_exit(&random_reseed_mtx, MTX_DEF); #ifdef DEBUG printf("Reseed finish\n"); #endif + if (!random_state.seeded) { + random_state.seeded = 1; + selwakeup(&random_state.rsel); + wakeup(&random_state); + } + } u_int -read_random(void *buf, u_int count) +read_random_real(void *buf, u_int count) { static u_int64_t genval; static int cur = 0; static int gate = 1; u_int i; u_int retval; /* The reseed task must not be jumped on */ mtx_enter(&random_reseed_mtx, MTX_DEF); if (gate) { generator_gate(); random_state.outputblocks = 0; gate = 0; } if (count >= sizeof(random_state.counter)) { retval = 0; for (i = 0; i < count; i += sizeof(random_state.counter)) { random_state.counter++; yarrow_encrypt(&random_state.key, &random_state.counter, &genval, sizeof(random_state.counter)); memcpy((char *)buf + i, &genval, sizeof(random_state.counter)); if (++random_state.outputblocks >= random_state.gengateinterval) { generator_gate(); random_state.outputblocks = 0; } retval += sizeof(random_state.counter); } } else { if (!cur) { random_state.counter++; yarrow_encrypt(&random_state.key, &random_state.counter, &genval, sizeof(random_state.counter)); memcpy(buf, &genval, count); cur = sizeof(random_state.counter) - count; if (++random_state.outputblocks >= random_state.gengateinterval) { generator_gate(); random_state.outputblocks = 0; } retval = count; } else { retval = cur < count ? cur : count; memcpy(buf, (char *)&genval + (sizeof(random_state.counter) - cur), retval); cur -= retval; } } mtx_exit(&random_reseed_mtx, MTX_DEF); return retval; } void write_random(void *buf, u_int count) { u_int i; struct timespec timebuf; - /* arbitrarily break the input up into 8-byte chunks */ - for (i = 0; i < count; i += 8) { + /* arbitrarily break the input up into HARVESTSIZE chunks */ + for (i = 0; i < count; i += HARVESTSIZE) { nanotime(&timebuf); - random_harvest_internal(&timebuf, (char *)buf + i, 8, 0, 0, + random_harvest_internal(&timebuf, (char *)buf + i, HARVESTSIZE, 0, 0, RANDOM_WRITE); } /* Maybe the loop iterated at least once */ if (i > count) - i -= 8; + i -= HARVESTSIZE; - /* Get the last bytes even if the input length is not a multiple of 8 */ - count %= 8; + /* Get the last bytes even if the input length is not a multiple of HARVESTSIZE */ + count %= HARVESTSIZE; if (count) { nanotime(&timebuf); random_harvest_internal(&timebuf, (char *)buf + i, count, 0, 0, RANDOM_WRITE); } /* Explicit reseed */ reseed(FAST); } static void generator_gate(void) { int i; u_char temp[KEYSIZE]; #ifdef DEBUG printf("Generator gate\n"); #endif for (i = 0; i < KEYSIZE; i += sizeof(random_state.counter)) { random_state.counter++; yarrow_encrypt(&random_state.key, &random_state.counter, &(temp[i]), sizeof(random_state.counter)); } yarrow_encrypt_init(&random_state.key, temp, KEYSIZE); memset((void *)temp, 0, KEYSIZE); #ifdef DEBUG printf("Generator gate finish\n"); #endif } /* Entropy harvesting routine. This is supposed to be fast; do * not do anything slow in here! */ static void random_harvest_internal(struct timespec *timep, void *entropy, u_int count, u_int bits, u_int frac, enum esource origin) { struct harvest *event; - u_int64_t entropy_buf; #if 0 #ifdef DEBUG printf("Random harvest\n"); #endif #endif event = malloc(sizeof(struct harvest), M_TEMP, M_NOWAIT); if (origin < ENTROPYSOURCE && event != NULL) { /* nanotime provides clock jitter */ event->time = *timep; /* the harvested entropy */ - count = count > sizeof(entropy_buf) - ? sizeof(entropy_buf) + count = count > sizeof(event->entropy) + ? sizeof(event->entropy) : count; memcpy(event->entropy, entropy, count); event->size = count; event->bits = bits; event->frac = frac; event->source = origin; /* protect the queue from simultaneous updates */ mtx_enter(&random_harvest_mtx, MTX_DEF); /* toggle the pool for next insertion */ event->pool = random_state.which; random_state.which = !random_state.which; TAILQ_INSERT_TAIL(&harvestqueue, event, harvest); mtx_exit(&random_harvest_mtx, MTX_DEF); } } Index: head/sys/dev/random/yarrow.h =================================================================== --- head/sys/dev/random/yarrow.h (revision 67111) +++ head/sys/dev/random/yarrow.h (revision 67112) @@ -1,75 +1,79 @@ /*- * Copyright (c) 2000 Mark R V Murray * All rights reserved. * * 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 * in this position and unchanged. * 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 AUTHOR ``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 AUTHOR 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. * * $FreeBSD$ */ /* #define ENTROPYSOURCE nn entropy sources (actually classes) * The entropy classes will as follows: * 0 - Direct write * 1 - Keyboard * 2 - Mouse */ #define ENTROPYBIN 256 /* buckets to harvest entropy events */ #define TIMEBIN 16 /* max value for Pt/t */ +#define HARVESTSIZE 16 /* max size of each harvested entropy unit */ + #define FAST 0 #define SLOW 1 int random_init(void); void random_deinit(void); -void random_init_harvester(void (*)(struct timespec *, void *, u_int, u_int, u_int, enum esource)); +void random_init_harvester(void (*)(struct timespec *, void *, u_int, u_int, u_int, enum esource), u_int (*)(void *, u_int)); void random_deinit_harvester(void); -void random_set_wakeup(int *, int); -void random_set_wakeup_exit(int *, int, int); +void random_set_wakeup_exit(void *); +u_int read_random_real(void *, u_int); void write_random(void *, u_int); /* This is the beastie that needs protecting. It contains all of the * state that we are excited about. * This is a biiig structure. It may move over to a malloc(9)ed * replacement. */ struct random_state { u_int64_t counter; /* C */ struct yarrowkey key; /* K */ int gengateinterval; /* Pg */ int bins; /* Pt/t */ int outputblocks; /* count output blocks for gates */ u_int slowoverthresh; /* slow pool overthreshhold reseed count */ struct pool { struct source { u_int bits; /* estimated bits of entropy */ u_int frac; /* fractional bits of entropy (given as 1024/n) */ } source[ENTROPYSOURCE]; u_int thresh; /* pool reseed threshhold */ struct yarrowhash hash; /* accumulated entropy */ } pool[2]; /* pool[0] is fast, pool[1] is slow */ int which; /* toggle - shows the current insertion pool */ + int seeded; /* 0 until first reseed, then 1 */ + struct selinfo rsel; /* For poll(2) */ }; extern struct random_state random_state; Index: head/sys/modules/randomdev/Makefile =================================================================== --- head/sys/modules/randomdev/Makefile (revision 67111) +++ head/sys/modules/randomdev/Makefile (nonexistent) @@ -1,11 +0,0 @@ -# $FreeBSD$ - -.PATH: ${.CURDIR}/../../dev/randomdev -.PATH: ${.CURDIR}/../../crypto/blowfish -KMOD = random -SRCS = bus_if.h device_if.h randomdev.c yarrow.c hash.c -SRCS += bf_cbc.c bf_skey.c bf_enc.c -CFLAGS += -I${.CURDIR}/../.. -NOMAN = yes - -.include Property changes on: head/sys/modules/randomdev/Makefile ___________________________________________________________________ Deleted: svn:keywords ## -1 +0,0 ## -FreeBSD=%H \ No newline at end of property Index: head/sys/modules/Makefile =================================================================== --- head/sys/modules/Makefile (revision 67111) +++ head/sys/modules/Makefile (revision 67112) @@ -1,32 +1,32 @@ # $FreeBSD$ # XXX present but broken: ip_mroute_mod .if exists(${.CURDIR}/../crypto) && !defined(NOCRYPT) -_randomdev= randomdev +_random= random .endif SUBDIR= 3dfx accf_data accf_http agp aha amr an aue \ cam ccd cd9660 coda cue dc ed fdesc fxp if_disc if_ef \ if_ppp if_sl if_tap if_tun ip6fw ipfilter ipfw ispfw joy kernfs kue \ md mfs mii mlx msdos ncp netgraph nfs ntfs nullfs \ - nwfs pcn portal procfs ${_randomdev} \ + nwfs pcn portal procfs ${_random} \ rl rp sf sis sk sn sound ste syscons ti tl twe tx \ udbp ugen uhid ukbd ulpt umapfs umass umodem ums union urio usb \ vinum vn vpo vr wb wx xl # XXX some of these can move to the general case when de-i386'ed .if ${MACHINE_ARCH} == "i386" SUBDIR+=aac asr bktr coff fpu gnufpu ibcs2 linprocfs linux mly splash streams \ svr4 vesa wi .endif .if ${MACHINE} == "pc98" SUBDIR+=snc .endif .if ${MACHINE_ARCH} == "alpha" SUBDIR+=osf1 .endif .include Index: head/sys/modules/random/Makefile =================================================================== --- head/sys/modules/random/Makefile (revision 67111) +++ head/sys/modules/random/Makefile (revision 67112) @@ -1,11 +1,12 @@ # $FreeBSD$ -.PATH: ${.CURDIR}/../../dev/randomdev +.PATH: ${.CURDIR}/../../dev/random .PATH: ${.CURDIR}/../../crypto/blowfish KMOD = random SRCS = bus_if.h device_if.h randomdev.c yarrow.c hash.c SRCS += bf_cbc.c bf_skey.c bf_enc.c +SRCS += vnode_if.h CFLAGS += -I${.CURDIR}/../.. NOMAN = yes .include