Suga koubou
/
Geiger_Pachube
Geiger counter http://geigermaps.jp/Create/Tutorials/mbed_geiger/ja
EthernetnetIf/LPC1768/lwip/netif/ppp/randm.h@0:5b2e60110d9b, 2011-04-15 (annotated)
- Committer:
- okini3939
- Date:
- Fri Apr 15 16:51:30 2011 +0000
- Revision:
- 0:5b2e60110d9b
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
okini3939 | 0:5b2e60110d9b | 1 | /***************************************************************************** |
okini3939 | 0:5b2e60110d9b | 2 | * randm.h - Random number generator header file. |
okini3939 | 0:5b2e60110d9b | 3 | * |
okini3939 | 0:5b2e60110d9b | 4 | * Copyright (c) 2003 by Marc Boucher, Services Informatiques (MBSI) inc. |
okini3939 | 0:5b2e60110d9b | 5 | * Copyright (c) 1998 Global Election Systems Inc. |
okini3939 | 0:5b2e60110d9b | 6 | * |
okini3939 | 0:5b2e60110d9b | 7 | * The authors hereby grant permission to use, copy, modify, distribute, |
okini3939 | 0:5b2e60110d9b | 8 | * and license this software and its documentation for any purpose, provided |
okini3939 | 0:5b2e60110d9b | 9 | * that existing copyright notices are retained in all copies and that this |
okini3939 | 0:5b2e60110d9b | 10 | * notice and the following disclaimer are included verbatim in any |
okini3939 | 0:5b2e60110d9b | 11 | * distributions. No written agreement, license, or royalty fee is required |
okini3939 | 0:5b2e60110d9b | 12 | * for any of the authorized uses. |
okini3939 | 0:5b2e60110d9b | 13 | * |
okini3939 | 0:5b2e60110d9b | 14 | * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS *AS IS* AND ANY EXPRESS OR |
okini3939 | 0:5b2e60110d9b | 15 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
okini3939 | 0:5b2e60110d9b | 16 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
okini3939 | 0:5b2e60110d9b | 17 | * IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
okini3939 | 0:5b2e60110d9b | 18 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
okini3939 | 0:5b2e60110d9b | 19 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
okini3939 | 0:5b2e60110d9b | 20 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
okini3939 | 0:5b2e60110d9b | 21 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
okini3939 | 0:5b2e60110d9b | 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
okini3939 | 0:5b2e60110d9b | 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
okini3939 | 0:5b2e60110d9b | 24 | * |
okini3939 | 0:5b2e60110d9b | 25 | ****************************************************************************** |
okini3939 | 0:5b2e60110d9b | 26 | * REVISION HISTORY |
okini3939 | 0:5b2e60110d9b | 27 | * |
okini3939 | 0:5b2e60110d9b | 28 | * 03-01-01 Marc Boucher <marc@mbsi.ca> |
okini3939 | 0:5b2e60110d9b | 29 | * Ported to lwIP. |
okini3939 | 0:5b2e60110d9b | 30 | * 98-05-29 Guy Lancaster <glanca@gesn.com>, Global Election Systems Inc. |
okini3939 | 0:5b2e60110d9b | 31 | * Extracted from avos. |
okini3939 | 0:5b2e60110d9b | 32 | *****************************************************************************/ |
okini3939 | 0:5b2e60110d9b | 33 | |
okini3939 | 0:5b2e60110d9b | 34 | #ifndef RANDM_H |
okini3939 | 0:5b2e60110d9b | 35 | #define RANDM_H |
okini3939 | 0:5b2e60110d9b | 36 | |
okini3939 | 0:5b2e60110d9b | 37 | /*********************** |
okini3939 | 0:5b2e60110d9b | 38 | *** PUBLIC FUNCTIONS *** |
okini3939 | 0:5b2e60110d9b | 39 | ***********************/ |
okini3939 | 0:5b2e60110d9b | 40 | /* |
okini3939 | 0:5b2e60110d9b | 41 | * Initialize the random number generator. |
okini3939 | 0:5b2e60110d9b | 42 | */ |
okini3939 | 0:5b2e60110d9b | 43 | void avRandomInit(void); |
okini3939 | 0:5b2e60110d9b | 44 | |
okini3939 | 0:5b2e60110d9b | 45 | /* |
okini3939 | 0:5b2e60110d9b | 46 | * Churn the randomness pool on a random event. Call this early and often |
okini3939 | 0:5b2e60110d9b | 47 | * on random and semi-random system events to build randomness in time for |
okini3939 | 0:5b2e60110d9b | 48 | * usage. For randomly timed events, pass a null pointer and a zero length |
okini3939 | 0:5b2e60110d9b | 49 | * and this will use the system timer and other sources to add randomness. |
okini3939 | 0:5b2e60110d9b | 50 | * If new random data is available, pass a pointer to that and it will be |
okini3939 | 0:5b2e60110d9b | 51 | * included. |
okini3939 | 0:5b2e60110d9b | 52 | */ |
okini3939 | 0:5b2e60110d9b | 53 | void avChurnRand(char *randData, u32_t randLen); |
okini3939 | 0:5b2e60110d9b | 54 | |
okini3939 | 0:5b2e60110d9b | 55 | /* |
okini3939 | 0:5b2e60110d9b | 56 | * Randomize our random seed value. To be called for truely random events |
okini3939 | 0:5b2e60110d9b | 57 | * such as user operations and network traffic. |
okini3939 | 0:5b2e60110d9b | 58 | */ |
okini3939 | 0:5b2e60110d9b | 59 | #if MD5_SUPPORT |
okini3939 | 0:5b2e60110d9b | 60 | #define avRandomize() avChurnRand(NULL, 0) |
okini3939 | 0:5b2e60110d9b | 61 | #else /* MD5_SUPPORT */ |
okini3939 | 0:5b2e60110d9b | 62 | void avRandomize(void); |
okini3939 | 0:5b2e60110d9b | 63 | #endif /* MD5_SUPPORT */ |
okini3939 | 0:5b2e60110d9b | 64 | |
okini3939 | 0:5b2e60110d9b | 65 | /* |
okini3939 | 0:5b2e60110d9b | 66 | * Use the random pool to generate random data. This degrades to pseudo |
okini3939 | 0:5b2e60110d9b | 67 | * random when used faster than randomness is supplied using churnRand(). |
okini3939 | 0:5b2e60110d9b | 68 | * Thus it's important to make sure that the results of this are not |
okini3939 | 0:5b2e60110d9b | 69 | * published directly because one could predict the next result to at |
okini3939 | 0:5b2e60110d9b | 70 | * least some degree. Also, it's important to get a good seed before |
okini3939 | 0:5b2e60110d9b | 71 | * the first use. |
okini3939 | 0:5b2e60110d9b | 72 | */ |
okini3939 | 0:5b2e60110d9b | 73 | void avGenRand(char *buf, u32_t bufLen); |
okini3939 | 0:5b2e60110d9b | 74 | |
okini3939 | 0:5b2e60110d9b | 75 | /* |
okini3939 | 0:5b2e60110d9b | 76 | * Return a new random number. |
okini3939 | 0:5b2e60110d9b | 77 | */ |
okini3939 | 0:5b2e60110d9b | 78 | u32_t avRandom(void); |
okini3939 | 0:5b2e60110d9b | 79 | |
okini3939 | 0:5b2e60110d9b | 80 | |
okini3939 | 0:5b2e60110d9b | 81 | #endif /* RANDM_H */ |