Dependencies:   FatFileSystem mbed WeatherMeters SDFileSystem

Committer:
dcoban
Date:
Tue Apr 03 18:43:13 2012 +0000
Revision:
0:1a61c61d0845

        

Who changed what in which revision?

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