| @@ -1,98 +1,98 @@ | | | @@ -1,98 +1,98 @@ |
1 | /* $NetBSD: rnd_private.h,v 1.8 2015/04/13 22:43:41 riastradh Exp $ */ | | 1 | /* $NetBSD: rnd_private.h,v 1.9 2015/04/14 13:03:37 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 |
15 | * notice, this list of conditions and the following disclaimer. | | 15 | * notice, this list of conditions and the following disclaimer. |
16 | * 2. Redistributions in binary form must reproduce the above copyright | | 16 | * 2. Redistributions in binary form must reproduce the above copyright |
17 | * notice, this list of conditions and the following disclaimer in the | | 17 | * notice, this list of conditions and the following disclaimer in the |
18 | * documentation and/or other materials provided with the distribution. | | 18 | * documentation and/or other materials provided with the distribution. |
19 | * | | 19 | * |
20 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 20 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
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 | #ifndef _DEV_RNDPRIVATE_H | | 33 | #ifndef _DEV_RNDPRIVATE_H |
34 | #define _DEV_RNDPRIVATE_H | | 34 | #define _DEV_RNDPRIVATE_H |
35 | | | 35 | |
36 | #include <sys/types.h> | | 36 | #include <sys/types.h> |
37 | #include <sys/mutex.h> | | 37 | #include <sys/mutex.h> |
38 | #include <sys/queue.h> | | 38 | #include <sys/queue.h> |
39 | #include <sys/rndio.h> | | 39 | #include <sys/rndio.h> |
40 | #include <sys/rndsource.h> | | | |
41 | #include <sys/rndpool.h> | | 40 | #include <sys/rndpool.h> |
| | | 41 | #include <sys/rndsource.h> |
42 | | | 42 | |
43 | /* | | 43 | /* |
44 | * Number of bytes returned per hash. This value is used in both | | 44 | * Number of bytes returned per hash. This value is used in both |
45 | * rnd.c and rndpool.c to decide when enough entropy exists to do a | | 45 | * rnd.c and rndpool.c to decide when enough entropy exists to do a |
46 | * hash to extract it. | | 46 | * hash to extract it. |
47 | */ | | 47 | */ |
48 | #define RND_ENTROPY_THRESHOLD 10 | | 48 | #define RND_ENTROPY_THRESHOLD 10 |
49 | | | 49 | |
50 | /* | | 50 | /* |
51 | * Used by rnd_extract_data() and rndpool_extract_data() to describe how | | 51 | * Used by rnd_extract_data() and rndpool_extract_data() to describe how |
52 | * "good" the data has to be. | | 52 | * "good" the data has to be. |
53 | */ | | 53 | */ |
54 | #define RND_EXTRACT_ANY 0 /* extract anything, even if no entropy */ | | 54 | #define RND_EXTRACT_ANY 0 /* extract anything, even if no entropy */ |
55 | #define RND_EXTRACT_GOOD 1 /* return as many good bytes | | 55 | #define RND_EXTRACT_GOOD 1 /* return as many good bytes |
56 | (short read ok) */ | | 56 | (short read ok) */ |
57 | | | 57 | |
58 | bool rnd_extract(void *, size_t); | | 58 | bool rnd_extract(void *, size_t); |
59 | bool rnd_tryextract(void *, size_t); | | 59 | bool rnd_tryextract(void *, size_t); |
60 | void rnd_getmore(size_t); | | 60 | void rnd_getmore(size_t); |
61 | void rnd_wakeup_readers(void); | | 61 | void rnd_wakeup_readers(void); |
62 | | | 62 | |
63 | /* | | 63 | /* |
64 | * Flag indicating rnd_init has run. | | 64 | * Flag indicating rnd_init has run. |
65 | */ | | 65 | */ |
66 | extern int rnd_ready; | | 66 | extern int rnd_ready; |
67 | | | 67 | |
68 | /* | | 68 | /* |
69 | * Bootloader-supplied entropy. Use only in tests against NULL to | | 69 | * Bootloader-supplied entropy. Use only in tests against NULL to |
70 | * determine whether the bootloader supplied entropy. | | 70 | * determine whether the bootloader supplied entropy. |
71 | */ | | 71 | */ |
72 | extern rndsave_t *boot_rsp; | | 72 | extern rndsave_t *boot_rsp; |
73 | | | 73 | |
74 | /* | | 74 | /* |
75 | * List of rndsources. | | 75 | * List of rndsources. |
76 | */ | | 76 | */ |
77 | LIST_HEAD(rndsource_head, krndsource); | | 77 | LIST_HEAD(rndsource_head, krndsource); |
78 | | | 78 | |
79 | /* | | 79 | /* |
80 | * Global entropy pool state. Access to everything here is serialized | | 80 | * Global entropy pool state. Access to everything here is serialized |
81 | * by rndpool_mtx. | | 81 | * by rndpool_mtx. |
82 | */ | | 82 | */ |
83 | extern kmutex_t rndpool_mtx; | | 83 | extern kmutex_t rndpool_mtx; |
84 | extern rndpool_t rnd_pool; | | 84 | extern rndpool_t rnd_pool; |
85 | extern struct rndsource_head rnd_sources; | | 85 | extern struct rndsource_head rnd_sources; |
86 | | | 86 | |
87 | /* | | 87 | /* |
88 | * Debugging flags. | | 88 | * Debugging flags. |
89 | */ | | 89 | */ |
90 | #ifdef RND_DEBUG | | 90 | #ifdef RND_DEBUG |
91 | extern int rnd_debug; | | 91 | extern int rnd_debug; |
92 | #define RND_DEBUG_WRITE 0x0001 | | 92 | #define RND_DEBUG_WRITE 0x0001 |
93 | #define RND_DEBUG_READ 0x0002 | | 93 | #define RND_DEBUG_READ 0x0002 |
94 | #define RND_DEBUG_IOCTL 0x0004 | | 94 | #define RND_DEBUG_IOCTL 0x0004 |
95 | #define RND_DEBUG_SNOOZE 0x0008 | | 95 | #define RND_DEBUG_SNOOZE 0x0008 |
96 | #endif | | 96 | #endif |
97 | | | 97 | |
98 | #endif /* _DEV_RNDPRIVATE_H */ | | 98 | #endif /* _DEV_RNDPRIVATE_H */ |