Dependents:   RTnoV3 RTnoV3_LED RTnoV3_Template RTnoV3_ADC ... more

Committer:
sherckuith
Date:
Sat Dec 31 11:25:27 2011 +0000
Revision:
0:479ce5546098
Ethernet

Who changed what in which revision?

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