]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man9/random_harvest.9
Remove $FreeBSD$: two-line nroff pattern
[FreeBSD/FreeBSD.git] / share / man / man9 / random_harvest.9
1 .\"
2 .\" Copyright (c) 2002-2015 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 .Dd August 26, 2018
27 .Dt RANDOM_HARVEST 9
28 .Os
29 .Sh NAME
30 .Nm random_harvest
31 .Nd gather entropy from the kernel for the entropy device
32 .Sh SYNOPSIS
33 .In sys/types.h
34 .In sys/random.h
35 .Ft void
36 .Fo random_harvest_direct
37 .Fa "void *entropy"
38 .Fa "u_int size"
39 .Fa "enum esource source"
40 .Fc
41 .Ft void
42 .Fo random_harvest_fast
43 .Fa "void *entropy"
44 .Fa "u_int size"
45 .Fa "enum esource source"
46 .Fc
47 .Ft void
48 .Fo random_harvest_queue
49 .Fa "void *entropy"
50 .Fa "u_int size"
51 .Fa "enum esource source"
52 .Fc
53 .Sh DESCRIPTION
54 The
55 .Fn random_harvest_*
56 functions are used by device drivers
57 and other kernel processes to pass data
58 that is considered (at least partially) stochastic
59 to the entropy device.
60 .Pp
61 The caller should pass
62 a pointer pointing to the
63 .Dq random
64 data in
65 .Fa entropy .
66 The argument
67 .Fa size
68 contains the number of bytes pointed to.
69 The
70 .Fa source
71 is chosen from one of
72 the values enumerated in
73 .Pa sys/dev/random.h .
74 and is used to indicate the source of the entropy.
75 .Pp
76 The
77 .Fo random_harvest_direct
78 .Fc
79 variant is used
80 for early harvesting
81 before any multitasking
82 is enabled.
83 .Pp
84 The
85 .Fn random_harvest_fast
86 variant is used
87 by sources that
88 should not take
89 a performance hit
90 from harvesting,
91 as they are high-rate
92 sources.
93 Some entropy is sacrificed,
94 but the high rate of supply
95 will compensate for this.
96 .Pp
97 The
98 .Fn random_harvest_queue
99 variant is used
100 for general harvesting
101 and is the default
102 choice for most entropy sources
103 such as interrupts
104 or console events.
105 .Pp
106 Interrupt harvesting has been
107 in part simplified
108 for the kernel programmer.
109 If a device driver registers an interrupt handler
110 with
111 .Xr BUS_SETUP_INTR 9
112 or
113 .Xr bus_setup_intr 9 ,
114 then it is only necessary to
115 include the
116 .Dv INTR_ENTROPY
117 bit in the
118 .Fa flags
119 argument to have that interrupt source
120 be used for entropy harvesting.
121 This should be done wherever practicable.
122 .Sh SEE ALSO
123 .Xr random 4 ,
124 .Xr BUS_SETUP_INTR 9
125 .Sh AUTHORS
126 The
127 .Fx
128 .Xr random 4
129 entropy device and supporting documentation was written by
130 .An Mark R V Murray .