Adam Green / EthernetInterface
Committer:
AdamGreen
Date:
Sat Sep 07 21:38:42 2013 +0000
Revision:
0:3b00827bb0b7
Sync to latest network stack source from github.

Who changed what in which revision?

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