Measure system

Dependencies:   EthernetNetIf mbed RF12B

Committer:
benecsj
Date:
Thu Mar 10 19:56:45 2011 +0000
Revision:
1:b26ab2467b1a

        

Who changed what in which revision?

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