| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_rndpool.c,v 1.11 2015/04/13 23:24:33 riastradh Exp $ */ | | 1 | /* $NetBSD: kern_rndpool.c,v 1.12 2015/04/13 23:25:14 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 1997 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 1997 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Michael Graff <explorer@flame.org>. This code uses ideas and | | 8 | * by Michael Graff <explorer@flame.org>. This code uses ideas and |
9 | * algorithms from the Linux driver written by Ted Ts'o. | | 9 | * algorithms from the Linux driver written by Ted Ts'o. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -21,46 +21,44 @@ | | | @@ -21,46 +21,44 @@ |
21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 21 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 22 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 23 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 24 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
30 | * POSSIBILITY OF SUCH DAMAGE. | | 30 | * POSSIBILITY OF SUCH DAMAGE. |
31 | */ | | 31 | */ |
32 | | | 32 | |
33 | #include <sys/cdefs.h> | | 33 | #include <sys/cdefs.h> |
34 | __KERNEL_RCSID(0, "$NetBSD: kern_rndpool.c,v 1.11 2015/04/13 23:24:33 riastradh Exp $"); | | 34 | __KERNEL_RCSID(0, "$NetBSD: kern_rndpool.c,v 1.12 2015/04/13 23:25:14 riastradh Exp $"); |
35 | | | 35 | |
36 | #include <sys/param.h> | | 36 | #include <sys/param.h> |
37 | #include <sys/systm.h> | | 37 | #include <sys/systm.h> |
38 | #include <sys/sha1.h> | | 38 | #include <sys/sha1.h> |
39 | | | 39 | |
40 | #include <sys/rndpool.h> | | 40 | #include <sys/rndpool.h> |
41 | #include <dev/rnd_private.h> | | 41 | #include <dev/rnd_private.h> |
42 | | | 42 | |
43 | /* | | 43 | /* |
44 | * The random pool "taps" | | 44 | * The random pool "taps" |
45 | */ | | 45 | */ |
46 | #define TAP1 99 | | 46 | #define TAP1 99 |
47 | #define TAP2 59 | | 47 | #define TAP2 59 |
48 | #define TAP3 31 | | 48 | #define TAP3 31 |
49 | #define TAP4 9 | | 49 | #define TAP4 9 |
50 | #define TAP5 7 | | 50 | #define TAP5 7 |
51 | | | 51 | |
52 | static inline void rndpool_add_one_word(rndpool_t *, u_int32_t); | | | |
53 | | | | |
54 | void | | 52 | void |
55 | rndpool_init(rndpool_t *rp) | | 53 | rndpool_init(rndpool_t *rp) |
56 | { | | 54 | { |
57 | | | 55 | |
58 | rp->cursor = 0; | | 56 | rp->cursor = 0; |
59 | rp->rotate = 1; | | 57 | rp->rotate = 1; |
60 | | | 58 | |
61 | memset(&rp->stats, 0, sizeof(rp->stats)); | | 59 | memset(&rp->stats, 0, sizeof(rp->stats)); |
62 | | | 60 | |
63 | rp->stats.curentropy = 0; | | 61 | rp->stats.curentropy = 0; |
64 | rp->stats.poolsize = RND_POOLWORDS; | | 62 | rp->stats.poolsize = RND_POOLWORDS; |
65 | rp->stats.threshold = RND_ENTROPY_THRESHOLD; | | 63 | rp->stats.threshold = RND_ENTROPY_THRESHOLD; |
66 | rp->stats.maxentropy = RND_POOLBITS; | | 64 | rp->stats.maxentropy = RND_POOLBITS; |