12.07.2015 Views

INTRO (9) NetBSD Kernel Developer's Manual INTRO (9) NAME ...

INTRO (9) NetBSD Kernel Developer's Manual INTRO (9) NAME ...

INTRO (9) NetBSD Kernel Developer's Manual INTRO (9) NAME ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

RND (9) <strong>NetBSD</strong> <strong>Kernel</strong> Developer’s <strong>Manual</strong> RND (9)<strong>NAME</strong>RND, rnd_attach_source, rnd_detach_source, rnd_add_data, rnd_add_uint32 —functionsto make adevice available for entropy collectionSYNOPSIS#include voidrnd_attach_source(rndsource_element_t ∗rnd_source , char ∗devname ,uint32_t source_type , uint32_t flags);voidrnd_detach_source(rndsource_element_t ∗rnd_source);voidrnd_add_data(rndsource_element_t ∗rnd_source , void ∗data , uint32_t len ,uint32_t entropy);voidrnd_add_uint32(rndsource_element_t ∗rnd_source , uint32_t datum);DESCRIPTIONThese RND functions make adevice available for entropy collection for /dev/random.Ideally the first argument rnd_source of these functions gets included in the devices’ entity struct, but anymeans to permanently (static) attach one such argument to one incarnation of the device is ok. Do not sharernd_source structures between two devices.rnd_attach_source(rndsource_element_t ∗rnd_source , char ∗devname , uint32_tsource_type , uint32_t flags)This function announces the availability of a device for entropy collection. It must be calledbefore the source struct pointed to by rnd_source is used in any ofthe following functions.devname is the name of the device. It is used to print a message (if the kernel is compiled with‘‘options RND_VERBOSE’’) and also for status information printed with rndctl(8).source_type is RND_TYPE_NET for network devices, RND_TYPE_DISK for physical disks,RND_TYPE_TAPE for a tape drive, and RND_TYPE_TTY for a tty. RND_TYPE_UNKNOWN isnot to be used as a type. It is used internally to the rnd system.flags are the logical OR of RND_FLAG_NO_COLLECT (don’t collect or estimate)RND_FLAG_NO_ESTIMATE (don’t estimate) to control the default setting for collection andestimation. Note that devices of type RND_TYPE_NET default to RND_FLAG_NO_ESTIMATE.rnd_detach_source(rndsource_element_t ∗rnd_source)This function disconnects the device from entropy collection.rnd_add_uint32(rndsource_element_t ∗rnd_source , uint32_t datum)This function adds the value of datum to the entropy pool. No entropy isassumed to be collectedfrom this value, it merely helps stir the entropy pool. All entropy isgathered from jitter betweenthe timing of events.Note that using a constant for datum does not weaken security, but it does not help. Try tousesomething that can change, such as an interrupt status register which might have a bit set forreceive ready or transmit ready, orother device status information.To allow the system to gather the timing information accurately, this call should be placed withinthe actual hardware interrupt service routine. Care must be taken to ensure that the interrupt was<strong>NetBSD</strong> 3.0 October 20, 1997 1

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!