xref: /freebsd/share/man/man9/random_harvest.9 (revision 87c1627502a5dde91e5284118eec8682b60f27a2)
1.\"
2.\" Copyright (c) 2002 Mark R V Murray
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
21.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
22.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.\" $FreeBSD$
27.\"
28.Dd February 6, 2002
29.Dt RANDOM_HARVEST 9
30.Os
31.Sh NAME
32.Nm random_harvest
33.Nd gather entropy from the kernel for the entropy device
34.Sh SYNOPSIS
35.In sys/types.h
36.In sys/random.h
37.Ft void
38.Fo random_harvest
39.Fa "void *entropy"
40.Fa "u_int size"
41.Fa "u_int bits"
42.Fa "u_int frac"
43.Fa "enum esource source"
44.Fc
45.Sh DESCRIPTION
46The
47.Fn random_harvest
48function is used by device drivers
49and other kernel processes to pass data
50that is considered (at least partially) stochastic
51to the entropy device.
52.Pp
53The caller should pass a pointer (to no more than 16 bytes) of
54the
55.Dq random
56data in
57.Fa entropy .
58The argument
59.Fa size
60contains the number of bytes pointed to.
61The caller should
62.Em "very conservatively"
63estimate the number of random bits
64in the sample,
65and pass this in
66.Fa bits
67or
68.Fa frac .
69If the estimated number of bits per sample is an integer, then
70.Fa bits
71is used, and
72.Fa frac
73is 0.
74Otherwise,
75for low-entropy samples,
76.Dq fractional
77entropy can be supplied in
78.Fa frac .
79(This is considered to be
80.Fa frac /
811024 bits of entropy.)
82The
83.Fa source
84is chosen from
85.Dv RANDOM_WRITE , RANDOM_KEYBOARD , RANDOM_MOUSE , RANDOM_NET
86and
87.Dv RANDOM_INTERRUPT ,
88and is used to indicate the source of the entropy.
89.Pp
90Interrupt harvesting has been simplified
91for the kernel programmer.
92If a device driver registers an interrupt handler
93with
94.Xr BUS_SETUP_INTR 9
95or
96.Xr bus_setup_intr 9 ,
97then it is only necessary to
98include the
99.Dv INTR_ENTROPY
100bit in the
101.Fa flags
102argument to have that interrupt source
103be used for entropy harvesting.
104.Sh SEE ALSO
105.Xr random 4 ,
106.Xr BUS_SETUP_INTR 9
107.Sh AUTHORS
108The
109.Fx
110.Xr random 4
111entropy device and supporting documentation was written by
112.An Mark R V Murray .
113