summaryrefslogtreecommitdiffstats
path: root/sys/dev/random/yarrow.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix a buffer overrun in /dev/random which, due to the nature of themarkm2002-12-121-3/+4
| | | | | | | | | kernel memory allocator, is harmless. This could be a problem for other systems, though. I've modified Darren's patch a little. Original patch by: Darren Schack, Isilon Systems, Inc <darrens@isilon.com> Also analysed by: SGI, and in particular Divy Le Ray of SGI OK'ed by: re(rwatson)
* Remove #ifdef'ed Giant mutex wrappers round debugging statements.markm2002-09-211-8/+0
|
* Upgrade the random device to use a "real" hash instead of buildingmarkm2002-07-151-4/+3
| | | | | | | | | | one out of a block cipher. This has 2 advantages: 1) The code is _much_ simpler 2) We aren't committing our security to one algorithm (much as we may think we trust AES). While I'm here, make an explicit reseed do a slow reseed instead of a fast; this is in line with what the original paper suggested.
* Change callers of mtx_init() to pass in an appropriate lock type name. Injhb2002-04-041-1/+1
| | | | | | | most cases NULL is passed, but in some cases such as network driver locks (which use the MTX_NETWORK_LOCK macro) and UMA zone locks, a name is used. Tested on: i386, alpha, sparc64
* Massive lint-inspired cleanup.markm2002-03-031-18/+18
| | | | | | | Remove unneeded includes. Deal with unused function arguments. Resolve a boatload of signed/unsigned imcompatabilities. Etc.
* Staticise the random_state array.msmith2002-01-101-3/+3
| | | | Reviewed by: markm
* Catch up to header include changes:jhb2001-03-281-0/+1
| | | | | - <sys/mutex.h> now requires <sys/systm.h> - <sys/mutex.h> and <sys/sx.h> now require <sys/lock.h>
* Fix nasty corruption problem where a 64bit variable was being usedmarkm2001-03-281-8/+6
| | | | | | (overflowed) to catch a 256bit result. Hard work done by: jhb
* Very large makeover of the /dev/random driver.markm2001-03-101-274/+107
| | | | | | | | | | | | | | | | | | | | | | | | o Separate the kernel stuff from the Yarrow algorithm. Yarrow is now well contained in one source file and one header. o Replace the Blowfish-based crypto routines with Rijndael-based ones. (Rijndael is the new AES algorithm). The huge improvement in Rijndael's key-agility over Blowfish means that this is an extremely dramatic improvement in speed, and makes a heck of a difference in its (lack of) CPU load. o Clean up the sysctl's. At BDE's prompting, I have gone back to static sysctls. o Bug fixes. The streamlining of the crypto stuff enabled me to find and fix some bugs. DES also found a bug in the reseed routine which is fixed. o Change the way reseeds clear "used" entropy. Previously, only the source(s) that caused a reseed were cleared. Now all sources in the relevant pool(s) are cleared. o Code tidy-up. Mostly to make it (nearly) 80-column compliant.
* Take down a comment that is no longer true.markm2001-03-031-4/+0
| | | | /dev/random is ready for prime time!
* Make a big improvement to entropy-harvesting speed by not having anymarkm2001-02-111-66/+37
| | | | locks (only atomic assigns) in the harvest ringbuffer.
* Change and clean the mutex lock interface.bmilekic2001-02-091-36/+36
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mtx_enter(lock, type) becomes: mtx_lock(lock) for sleep locks (MTX_DEF-initialized locks) mtx_lock_spin(lock) for spin locks (MTX_SPIN-initialized) similarily, for releasing a lock, we now have: mtx_unlock(lock) for MTX_DEF and mtx_unlock_spin(lock) for MTX_SPIN. We change the caller interface for the two different types of locks because the semantics are entirely different for each case, and this makes it explicitly clear and, at the same time, it rids us of the extra `type' argument. The enter->lock and exit->unlock change has been made with the idea that we're "locking data" and not "entering locked code" in mind. Further, remove all additional "flags" previously passed to the lock acquire/release routines with the exception of two: MTX_QUIET and MTX_NOSWITCH The functionality of these flags is preserved and they can be passed to the lock/unlock routines by calling the corresponding wrappers: mtx_{lock, unlock}_flags(lock, flag(s)) and mtx_{lock, unlock}_spin_flags(lock, flag(s)) for MTX_DEF and MTX_SPIN locks, respectively. Re-inline some lock acq/rel code; in the sleep lock case, we only inline the _obtain_lock()s in order to ensure that the inlined code fits into a cache line. In the spin lock case, we inline recursion and actually only perform a function call if we need to spin. This change has been made with the idea that we generally tend to avoid spin locks and that also the spin locks that we do have and are heavily used (i.e. sched_lock) do recurse, and therefore in an effort to reduce function call overhead for some architectures (such as alpha), we inline recursion for this case. Create a new malloc type for the witness code and retire from using the M_DEV type. The new type is called M_WITNESS and is only declared if WITNESS is enabled. Begin cleaning up some machdep/mutex.h code - specifically updated the "optimized" inlined code in alpha/mutex.h and wrote MTX_LOCK_SPIN and MTX_UNLOCK_SPIN asm macros for the i386/mutex.h as we presently need those. Finally, caught up to the interface changes in all sys code. Contributors: jake, jhb, jasone (in no particular order)
* Fix typos: initalise -> initialise.asmodai2001-02-081-5/+5
| | | | Initalise is not an english word.
* Remove NOBLOCKRANDOM as a compile-time option. Instead, providemarkm2001-01-141-0/+5
| | | | | | | | | | | | | | | | exactly the same functionality via a sysctl, making this feature a run-time option. The default is 1(ON), which means that /dev/random device will NOT block at startup. setting kern.random.sys.seeded to 0(OFF) will cause /dev/random to block until the next reseed, at which stage the sysctl will be changed back to 1(ON). While I'm here, clean up the sysctls, and make them dynamic. Reviewed by: des Tested on Alpha by: obrien
* select() DKI is now in <sys/selinfo.h>.wollman2001-01-091-1/+1
|
* Major speedup to /dev/random and the kernel thread that reseeds it.markm2000-12-021-92/+102
| | | | | | | | | | | | | | There is no more TAILQ fifo to harvest the entropy; instead, there is a circular buffer of constant size (changeable by macro) that pretty dramatically improves the speed and fixes potential slowdowns- by-locking. Also gone are a slew of malloc(9) and free(9) calls; all harvesting buffers are static. All-in-all, this is a good performance improvement. Thanks-to: msmith for the circular buffer concept-code.
* Greatly improve the boot-up unblocking time of the entropy device.markm2000-11-251-3/+7
|
* Stop explicitly using nanotime(9) and use the new get_cyclecounter(9)markm2000-11-251-19/+21
| | | | | | | | | call instead. This makes a pretty dramatic difference to the amount of work that the harvester needs to do - it is much friendlier on the system. (80386 and 80486 class machines will notice little, as the new get_cyclecounter() call is a wrapper round nanotime(9) for them).
* Remove unneeded #include <sys/proc.h> lines.phk2000-10-291-1/+0
|
* Catch up to moving headers:jhb2000-10-201-1/+1
| | | | | - machine/ipl.h -> sys/ipl.h - machine/mutex.h -> sys/mutex.h
* After some complaints about the dir names, the random device ismarkm2000-10-141-31/+34
| | | | | | | | | | | | | | | | | | | | now in dirs called sys/*/random/ instead of sys/*/randomdev/*. Introduce blocking, but only at startup; the random device will block until the first reseed happens to prevent clients from using untrustworthy output. Provide a read_random() call for the rest of the kernel so that the entropy device does not need to be present. This means that things like IPX no longer need to have "device random" hardcoded into thir kernel config. The downside is that read_random() will provide very poor output until the entropy device is loaded and reseeded. It is recommended that developers do NOT use the read_random() call; instead, they should use arc4random() which internally uses read_random(). Clean up the mutex and locking code a bit; this makes it possible to unload the module again.
* Remove unneeded includes.markm2000-09-211-2/+0
| | | | Submitted by: phk
* Remove the mtx_t, witness_t, and witness_blessed_t types. Instead, justjhb2000-09-141-2/+2
| | | | | | use struct mtx, struct witness, and struct witness_blessed. Requested by: bde
* The "struct proc" argument to read_random was ill-conceived, and amarkm2000-09-121-1/+1
| | | | | | | | hangover from previous experimentation. Remove it. This will clean up gratuitous needs for forward references and other namespace pollution. Moaned about by: bde Brought to my attention by: bp
* Move the prototypes for random_set_wakeup* from yarrow.c to yarrow.h so thatjhb2000-09-111-2/+0
| | | | | | both yarrow.c and harvest.c can use them. Approved by: markm
* - Use RFHIGHPID when creating the kthread to get a more sensible pid.jhb2000-09-111-2/+3
| | | | | - Don't fake walking a tailq. Instead, use a while loop that pulls items off the head of the queue while the queue is not empty.
* Large upgrade to the entropy device; mainly inspired by feedbackmarkm2000-09-101-161/+283
| | | | | | | | | | | | | | | | from many folk. o The reseed process is now a kthread. With SMPng, kthreads are pre-emptive, so the annoying jerkiness of the mouse is gone. o The data structures are protected by mutexes now, not splfoo()/splx(). o The cryptographic routines are broken out into their own subroutines. this facilitates review, and possible replacement if that is ever found necessary. Thanks to: kris, green, peter, jasone, grog, jhb Forgotten to thank: You know who you are; no offense intended.
* o Fix a horrible bug where small reads (< 8 bytes) would return themarkm2000-07-251-13/+30
| | | | | | | | wrong bytes. o Improve the public interface; use void* instead of char* or u_int64_t to pass arbitrary data around. Submitted by: kris ("horrible bug")
* Clean this up with some BDE-inspired fixes.markm2000-07-231-18/+23
| | | | | | | | | | | o Make the comments KNF-compliant. o Use nanotime instead of getnanotime; the manpage lies about the kern.timecounter.method - it has been removed. o Fix the ENTROPYSOURCE const permanently. o Make variable names more consistent. o Make function prototypes more consistent. Some more needs to be done; to follow.
* Add randomness write functionality. This does absolutely nothing formarkm2000-07-171-0/+19
| | | | | | | | | | | | | entropy estimation, but causes an immediate reseed after the input (read in sizeof(u_int64_t) chunks) is "harvested". This will be used in the reboot "reseeder", coming in another commit. This can be used very effectively at any time you think your randomness is compromised; something like # (ps -gauxwww; netstat -an; dmesg; vmstat -c10 1) > /dev/random will give the attacker something to think about.
* Storing to a pointer is (effectively) atomic; no need to protect thismarkm2000-07-111-2/+2
| | | | | | | with splhigh(). However, the entropy-harvesting routine needs pretty serious irq-protection, as it is called out of irq handlers etc. Clues given by: bde
* I think I need to move the newly static variables to the random_statemarkm2000-07-111-6/+5
| | | | | | structure; remind myself in the cooments. Also regroup all the Yarrow variables at the top of the variable list; they are "special". (no functional change).
* One should never allocate 4-kilobyte structs and such on the interruptgreen2000-07-111-2/+6
| | | | | | | | | | stack. It's bad for your machine's health. Make the two huge structs in reseed() static to prevent crashes. This is the bug that people have been running into and panic()ing on for the past few days. Reviewed by: phk
* Provide more splsofttq() protection for the reseed task (running out ofmarkm2000-07-101-1/+14
| | | | taskqueue_swi).
* Make sure that tasks (running out of taskqueue_swi at splsofttq)markm2000-07-091-0/+5
| | | | are not interfered with by the harvester.
* Yarrow tweaks; separate the fast and slow reseed tasks so that they don'tmarkm2000-07-091-10/+13
| | | | | stomp on each other; provide constant names (as enums) for the harvester to use (makes it more self-documenting).
* Add entropy gathering code. This will work whether the module ismarkm2000-07-071-80/+208
| | | | compiled in or loaded.
* style(9) fixes from BDE.markm2000-06-261-1/+1
| | | | We shouldn't use '#include ""', rather '#include<>'.
* Fix include for non-module case.markm2000-06-251-1/+1
| | | | Thanks-to: SOS
* New machine-independant /dev/random driver.markm2000-06-251-0/+213
This is work-in-progress, and the entropy-gathering routines are not yet present. As such, this should be viewed as a pretty reasonable PRNG with _ABSOLUTELY_NO_ security!! Entropy gathering will be the subject of ongoing work. This is written as a module, and as such is unloadable, but there is no refcounting done. I would like to use something like device_busy(9) to achieve this (eventually). Lots of useful ideas from: bde, phk, Jeroen van Gelderen Reviewed by: dfr
OpenPOWER on IntegriCloud