12Oct2012MbedLab

Dependents:   Lab3_VoiceMeter

Fork of EthernetNetIf by Donatien Garnier

Committer:
psawant9
Date:
Fri Oct 12 16:02:00 2012 +0000
Revision:
6:22ce63eddd2b
Parent:
0:422060928e37
Done

Who changed what in which revision?

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