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