Dependencies:   mbed

Dependents:   TCP

Committer:
slowness
Date:
Tue Sep 06 18:05:46 2011 +0000
Revision:
0:58c3d014a4e7

        

Who changed what in which revision?

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