Deleted Added
full compact
harvest.c (62969) harvest.c (63771)
1/*-
2 * Copyright (c) 2000 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 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 2000 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 unchanged lines hidden (view full) ---

18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/dev/random/harvest.c 62969 2000-07-11 19:37:25Z markm $
26 * $FreeBSD: head/sys/dev/random/harvest.c 63771 2000-07-23 11:08:16Z markm $
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/types.h>
32#include <sys/queue.h>
33#include <sys/linker.h>
34#include <sys/libkern.h>
35#include <sys/mbuf.h>
36#include <sys/random.h>
37#include <sys/time.h>
38#include <crypto/blowfish/blowfish.h>
39
40#include <dev/randomdev/yarrow.h>
41
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/types.h>
32#include <sys/queue.h>
33#include <sys/linker.h>
34#include <sys/libkern.h>
35#include <sys/mbuf.h>
36#include <sys/random.h>
37#include <sys/time.h>
38#include <crypto/blowfish/blowfish.h>
39
40#include <dev/randomdev/yarrow.h>
41
42/* hold the address of the routine which is actually called if */
43/* the ramdomdev is loaded */
42/* hold the address of the routine which is actually called if
43 * the ramdomdev is loaded
44 */
44static void (*reap)(struct timespec *, u_int64_t, u_int, u_int, u_int) = NULL;
45
46/* Initialise the harvester at load time */
47void
48random_init_harvester(void (*reaper)(struct timespec *, u_int64_t, u_int, u_int, u_int))
49{
50 reap = reaper;
51}
52
53/* Deinitialise the harvester at unload time */
54void
55random_deinit_harvester(void)
56{
57 reap = NULL;
58}
59
45static void (*reap)(struct timespec *, u_int64_t, u_int, u_int, u_int) = NULL;
46
47/* Initialise the harvester at load time */
48void
49random_init_harvester(void (*reaper)(struct timespec *, u_int64_t, u_int, u_int, u_int))
50{
51 reap = reaper;
52}
53
54/* Deinitialise the harvester at unload time */
55void
56random_deinit_harvester(void)
57{
58 reap = NULL;
59}
60
60/* Entropy harvesting routine. This is supposed to be fast; do */
61/* not do anything slow in here! */
62/* Implemented as in indirect call to allow non-inclusion of */
63/* the entropy device. */
61/* Entropy harvesting routine. This is supposed to be fast; do
62 * not do anything slow in here!
63 * Implemented as in indirect call to allow non-inclusion of
64 * the entropy device.
65 */
64void
66void
65random_harvest(u_int64_t entropy, u_int bits, u_int frac, u_int source)
67random_harvest(u_int64_t entropy, u_int bits, u_int frac, u_int origin)
66{
68{
67 struct timespec nanotime;
69 struct timespec timebuf;
68
69 if (reap) {
70
71 if (reap) {
70 getnanotime(&nanotime);
71 (*reap)(&nanotime, entropy, bits, frac, source);
72 nanotime(&timebuf);
73 (*reap)(&timebuf, entropy, bits, frac, origin);
72 }
73}
74 }
75}