http://mbed.org/users/okini3939/notebook/logger/

Dependencies:   mbed

Committer:
okini3939
Date:
Sat Apr 16 15:15:48 2011 +0000
Revision:
0:a3c892f39cc1

        

Who changed what in which revision?

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