diff options
author | David Walter Seikel | 2016-03-28 22:28:34 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-03-28 22:28:34 +1000 |
commit | 7028cbe09c688437910a25623098762bf0fa592d (patch) | |
tree | 10b5af58277d9880380c2251f109325542c4e6eb /src/others/irrlicht-1.8.1/source/Irrlicht/aesGladman/prng.h | |
parent | Move lemon to the src/others directory. (diff) | |
download | SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.zip SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.gz SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.bz2 SledjHamr-7028cbe09c688437910a25623098762bf0fa592d.tar.xz |
Move Irrlicht to src/others.
Diffstat (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/aesGladman/prng.h')
-rw-r--r-- | src/others/irrlicht-1.8.1/source/Irrlicht/aesGladman/prng.h | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/aesGladman/prng.h b/src/others/irrlicht-1.8.1/source/Irrlicht/aesGladman/prng.h new file mode 100644 index 0000000..a81ed8e --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/aesGladman/prng.h | |||
@@ -0,0 +1,74 @@ | |||
1 | /* | ||
2 | --------------------------------------------------------------------------- | ||
3 | Copyright (c) 2002, Dr Brian Gladman < >, Worcester, UK. | ||
4 | All rights reserved. | ||
5 | |||
6 | LICENSE TERMS | ||
7 | |||
8 | The free distribution and use of this software in both source and binary | ||
9 | form is allowed (with or without changes) provided that: | ||
10 | |||
11 | 1. distributions of this source code include the above copyright | ||
12 | notice, this list of conditions and the following disclaimer; | ||
13 | |||
14 | 2. distributions in binary form include the above copyright | ||
15 | notice, this list of conditions and the following disclaimer | ||
16 | in the documentation and/or other associated materials; | ||
17 | |||
18 | 3. the copyright holder's name is not used to endorse products | ||
19 | built using this software without specific written permission. | ||
20 | |||
21 | ALTERNATIVELY, provided that this notice is retained in full, this product | ||
22 | may be distributed under the terms of the GNU General Public License (GPL), | ||
23 | in which case the provisions of the GPL apply INSTEAD OF those given above. | ||
24 | |||
25 | DISCLAIMER | ||
26 | |||
27 | This software is provided 'as is' with no explicit or implied warranties | ||
28 | in respect of its properties, including, but not limited to, correctness | ||
29 | and/or fitness for purpose. | ||
30 | --------------------------------------------------------------------------- | ||
31 | Issue Date: 24/01/2003 | ||
32 | |||
33 | This is the header file for an implementation of a random data pool based on | ||
34 | the use of an external entropy function (inspired by Peter Gutmann's work). | ||
35 | */ | ||
36 | |||
37 | #ifndef _PRNG_H | ||
38 | #define _PRNG_H | ||
39 | |||
40 | #include "sha1.h" | ||
41 | |||
42 | #define PRNG_POOL_LEN 256 /* minimum random pool size */ | ||
43 | #define PRNG_MIN_MIX 20 /* min initial pool mixing iterations */ | ||
44 | |||
45 | /* ensure that pool length is a multiple of the SHA1 digest size */ | ||
46 | |||
47 | #define PRNG_POOL_SIZE (SHA1_DIGEST_SIZE * (1 + (PRNG_POOL_LEN - 1) / SHA1_DIGEST_SIZE)) | ||
48 | |||
49 | /* A function for providing entropy is a parameter in the prng_init() */ | ||
50 | /* call. This function has the following form and returns a maximum */ | ||
51 | /* of 'len' bytes of pseudo random data in the buffer 'buf'. It can */ | ||
52 | /* return less than 'len' bytes but will be repeatedly called for more */ | ||
53 | /* data in this case. */ | ||
54 | |||
55 | typedef int (*prng_entropy_fn)(unsigned char buf[], unsigned int len); | ||
56 | |||
57 | typedef struct | ||
58 | { unsigned char rbuf[PRNG_POOL_SIZE]; /* the random pool */ | ||
59 | unsigned char obuf[PRNG_POOL_SIZE]; /* pool output buffer */ | ||
60 | unsigned int pos; /* output buffer position */ | ||
61 | prng_entropy_fn entropy; /* entropy function pointer */ | ||
62 | } prng_ctx; | ||
63 | |||
64 | /* initialise the random stream generator */ | ||
65 | void prng_init(prng_entropy_fn fun, prng_ctx ctx[1]); | ||
66 | |||
67 | /* obtain random bytes from the generator */ | ||
68 | void prng_rand(unsigned char data[], unsigned int data_len, prng_ctx ctx[1]); | ||
69 | |||
70 | /* close the random stream generator */ | ||
71 | void prng_end(prng_ctx ctx[1]); | ||
72 | |||
73 | #endif | ||
74 | |||