mbed Phone Platform

Dependencies:   ulaw mbed ConfigFile

Committer:
okini3939
Date:
Sun Dec 26 15:49:07 2010 +0000
Revision:
1:0f82c574096f

        

Who changed what in which revision?

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