Onenet

Dependents:   K64F_eCompass_OneNET_JW

Committer:
robert_jw
Date:
Mon Jun 20 01:40:20 2016 +0000
Revision:
0:b2805b6888dc
ADS

Who changed what in which revision?

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