Library for Bert van Dam's book "ARM MICROCONTROLLERS" For all chapters with internet.

Dependencies:   mbed

Committer:
ICTFBI
Date:
Fri Oct 16 14:28:26 2015 +0000
Revision:
0:4edb816d21e1
Pre-update 16-10-15

Who changed what in which revision?

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